2013-12-18 20:28:06 +01:00
|
|
|
#include "Defines.hlsli"
|
|
|
|
#include "LightCalc.hlsli"
|
|
|
|
#include "PosManipulation.hlsli"
|
2014-01-08 07:01:59 +01:00
|
|
|
#include "SSAO.hlsli"
|
2013-12-18 20:28:06 +01:00
|
|
|
//todo
|
|
|
|
//LightCulling
|
2014-01-08 07:01:59 +01:00
|
|
|
//Calc Diff + Spec Done
|
|
|
|
//Calc Ambience Done
|
2013-12-18 20:28:06 +01:00
|
|
|
//Write Glow
|
|
|
|
|
|
|
|
|
|
|
|
[numthreads(16, 16, 1)]
|
2014-01-08 07:01:59 +01:00
|
|
|
void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-01-08 07:01:59 +01:00
|
|
|
float2 UV = DTid / Pixels;
|
|
|
|
UV.x = UV.x * 2 - 1;
|
|
|
|
UV.y = 1 - 2 * UV.y;
|
|
|
|
float3 ViewPos = ToVpos(DTid.xy, UV);
|
2013-12-18 20:28:06 +01:00
|
|
|
DiffSpec Shaded;
|
|
|
|
Shaded.Diffuse = float4(0,0,0,0);
|
|
|
|
Shaded.Specular = float4(0,0,0,0);
|
2014-01-08 07:01:59 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
for(int i = 0; i < Lights; ++i)
|
|
|
|
{
|
|
|
|
DiffSpec light = LightCalc(Points[i], ViewPos, DTid.xy);
|
2014-01-08 07:01:59 +01:00
|
|
|
Shaded.Diffuse += light.Diffuse;
|
|
|
|
Shaded.Specular += light.Specular;
|
|
|
|
}
|
|
|
|
|
2014-01-30 15:12:53 +01:00
|
|
|
//Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1);
|
|
|
|
Diffuse[DTid.xy] = float4(DiffuseGlow[DTid.xy].xyz,1);
|
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
Specular[DTid.xy] = float4(Shaded.Specular, 1);
|
|
|
|
|
|
|
|
|
|
|
|
if((DTid.x + DTid.y) %4 == 0 )
|
|
|
|
{
|
|
|
|
float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy);
|
|
|
|
Ambient[DTid.xy/4] = AmbValue;
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
2014-01-08 07:01:59 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|