Forward+ Fixes

This commit is contained in:
viktorljung
2015-12-16 13:36:38 +01:00
parent 1431bd1a11
commit 5602b32507
5 changed files with 56 additions and 42 deletions
+13 -7
View File
@@ -23,8 +23,8 @@ layout (std430, binding = 1) buffer LightBuffer
} PointLights;
struct LightGrid {
int Amount;
int Start;
float Start;
float Amount;
vec2 Padding;
};
@@ -35,7 +35,7 @@ layout (std430, binding = 2) buffer LightGridBuffer
layout (std430, binding = 4) buffer LightIndexBuffer
{
int LightIndex[];
float LightIndex[];
};
@@ -98,11 +98,14 @@ void main()
LightResult totalLighting;
totalLighting.Diffuse = scene_ambient;
int start = int(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Start);
int amount = int(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount);
//for(int i = 0; i < 3; i++)
for(int i = LightGrids.Data[int(tilePos.x + tilePos.y*80)].Start; i < LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount; i++)
for(int i = start; i < start + amount; i++)
{
int l = LightIndex[i];
int l = int(LightIndex[i]);
LightResult result = CalcPointLight(V * PointLights.List[l].Position, PointLights.List[l].Radius, PointLights.List[l].Color, PointLights.List[l].Intensity, viewVec, position, normal);
@@ -111,12 +114,15 @@ void main()
}
fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
//fragmentColor = texel * Input.DiffuseColor * Color;
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 )
{
fragmentColor = vec4(0.5, 0, 0, 0);
} else {
//fragmentColor = vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Start/3600, 0, 0, 1);
//fragmentColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/3.0, 0, 0, 1);
}
}
+7 -2
View File
@@ -67,7 +67,12 @@ void main ()
Frustums.Data[gl_GlobalInvocationID.x + gl_GlobalInvocationID.y*80] = f;
if ( gl_GlobalInvocationID.x < ScreenDimensions.x / TILE_SIZE && gl_GlobalInvocationID.y < ScreenDimensions.y / TILE_SIZE ) { // innanför skärmen?
Frustums.Data[gl_GlobalInvocationID.x + gl_GlobalInvocationID.y*80] = f;
}
}
}
+14 -5
View File
@@ -43,8 +43,8 @@ layout (std430, binding = 1) buffer LightBuffer
} PointLights;
struct LightGrid {
int Amount;
int Start;
float Start;
float Amount;
vec2 Padding;
};
@@ -60,7 +60,7 @@ layout (std430, binding = 3) buffer LightOffsetBuffer
layout (std430, binding = 4) buffer LightIndexBuffer
{
int LightIndex[];
float LightIndex[];
};
shared int GroupLightCount;
@@ -107,7 +107,7 @@ void AppendLight(int li)
layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
void main ()
{
GroupIndex = int(gl_WorkGroupID.x + gl_WorkGroupID.y * gl_NumWorkGroups.y);
GroupIndex = int(gl_WorkGroupID.x + (gl_WorkGroupID.y * 80));
if(gl_LocalInvocationIndex == 0)
{
GroupLightCount = 0;
@@ -146,6 +146,15 @@ void main ()
LightGrid g;
g.Start = GroupLightIndexStartOffset;
g.Amount = GroupLightCount;
LightGrids.Data[GroupIndex];
g.Padding = vec2(1111, 1111);
LightGrids.Data[GroupIndex] = g;
}
memoryBarrierShared();
barrier();
for (uint i = gl_LocalInvocationIndex; i < GroupLightCount; i += TILE_SIZE * TILE_SIZE )
{
LightIndex[GroupLightIndexStartOffset + i] = GroupLightIndex[i];
}
}