Frustum culling now works correctly for all resolutions

This commit is contained in:
Tleety
2016-01-15 15:38:14 +01:00
parent 14bc850fab
commit 3de853ac8b
9 changed files with 101 additions and 65 deletions
+56 -48
View File
@@ -1,49 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
<Components>
<c:Transform>
<Position X="0" Y="0" Z="0"/>
<Orientation X="0" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Transform>
<Position X="0" Y="0" Z="0"/>
<Scale X="100" Y="1" Z="100"/>
</c:Transform>
<c:Model>
<Resource>Models/Core/UnitPlane.obj</Resource>
</c:Model>
</Components>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="1" Y="1" Z="0"/>
<Orientation X="0" Y="0.78539" Z="0"/>
</c:Transform>
<c:Model>
<Resource>An error</Resource>
</c:Model>
</Components>
<Children>
<Entity>
<Components>
<c:Transform>
<Position X="2" Y="0" Z="0"/>
<Orientation X="0" Y="0.78539" Z="0"/>
</c:Transform>
<c:Model>
<Resource>An error</Resource>
</c:Model>
</Components>
<Children>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Components>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.obj</Resource>
</c:Model>
<c:Transform>
<Scale X="100" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>An error</Resource>
</c:Model>
<c:Transform>
<Position X="1" Y="1" Z="0"/>
<Orientation X="0" Y="0.785390019" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>An error</Resource>
</c:Model>
<c:Transform>
<Position X="2" Y="0" Z="0"/>
<Orientation X="0" Y="0.785390019" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity>
<Components>
<c:Camera/>
<c:Transform>
<Position X="5.85247707" Y="3.8454349" Z="-1.14486957"/>
<Orientation X="2.51327395" Y="1.23916209" Z="-3.1415925"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+2 -2
View File
@@ -9,10 +9,10 @@
#define MAX_LIGHTS_PER_TILE 200
#define NUM_TILES 3600
#define TILE_SIZE 16
uniform mat4 V;
uniform vec2 ScreenDimensions;
struct Plane {
vec3 Normal;
@@ -105,7 +105,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 * 80));
GroupIndex = int(gl_WorkGroupID.x + (gl_WorkGroupID.y * int(ScreenDimensions.x/TILE_SIZE)));
if(gl_LocalInvocationIndex == 0)
{
GroupLightCount = 0;
+2 -2
View File
@@ -4,7 +4,7 @@ uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec4 Color;
uniform vec2 ScreenDimensions;
uniform sampler2D texture0;
#define TILE_SIZE 16
@@ -99,7 +99,7 @@ void main()
LightResult totalLighting;
totalLighting.Diffuse = scene_ambient;
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * 80));
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
int start = int(LightGrids.Data[currentTile].Start);
int amount = int(LightGrids.Data[currentTile].Amount);
+1 -2
View File
@@ -1,7 +1,6 @@
#version 430
#define TILE_SIZE 16
#define NUM_TILES 3600
uniform mat4 P;
uniform vec2 ScreenDimensions;
@@ -70,7 +69,7 @@ void main ()
if ( gl_GlobalInvocationID.x < ScreenDimensions.x / TILE_SIZE && gl_GlobalInvocationID.y < ScreenDimensions.y / TILE_SIZE ) { // inside the screen
Frustums.Data[gl_GlobalInvocationID.x + gl_GlobalInvocationID.y*80] = f;
Frustums.Data[gl_GlobalInvocationID.x + gl_GlobalInvocationID.y*int(ScreenDimensions.x/TILE_SIZE)] = f;
}
}