Depth rendering of terrain works
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import Common;
|
||||
import VertexData;
|
||||
import MaterialParameter;
|
||||
|
||||
@@ -10,7 +11,7 @@ struct Scene
|
||||
{
|
||||
StructuredBuffer<InstanceData> instances;
|
||||
}
|
||||
|
||||
layout(set=2)
|
||||
ParameterBlock<Scene> pScene;
|
||||
|
||||
[shader("vertex")]
|
||||
|
||||
@@ -9,6 +9,7 @@ struct ViewParameter
|
||||
float4 cameraPos_WS;
|
||||
float2 screenDimensions;
|
||||
}
|
||||
layout(set = 0)
|
||||
ParameterBlock<ViewParameter> pViewParams;
|
||||
|
||||
|
||||
|
||||
@@ -8,22 +8,22 @@ struct StaticMeshVertexData : IVertexData
|
||||
{
|
||||
VertexAttributes attributes;
|
||||
MaterialParameter params;
|
||||
float4 localPos = float4(positions[index], 1);
|
||||
float4 localPos = float4(positions[3 * index + 0], positions[3 * index + 1], positions[3 * index + 2], 1);
|
||||
float4 worldPos = mul(transform, localPos);
|
||||
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||
params.worldPosition = worldPos.xyz;
|
||||
params.texCoords = texCoords[index];
|
||||
params.normal = normals[index];
|
||||
params.tangent = tangents[index];
|
||||
params.biTangent = biTangents[index];
|
||||
params.texCoords = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
|
||||
params.normal = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
|
||||
params.tangent = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
|
||||
params.biTangent = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
|
||||
attributes.parameter = params;
|
||||
attributes.clipPosition = clipPos;
|
||||
return attributes;
|
||||
}
|
||||
StructuredBuffer<float3> positions;
|
||||
StructuredBuffer<float2> texCoords;
|
||||
StructuredBuffer<float3> normals;
|
||||
StructuredBuffer<float3> tangents;
|
||||
StructuredBuffer<float3> biTangents;
|
||||
StructuredBuffer<float> positions;
|
||||
StructuredBuffer<float> texCoords;
|
||||
StructuredBuffer<float> normals;
|
||||
StructuredBuffer<float> tangents;
|
||||
StructuredBuffer<float> biTangents;
|
||||
};
|
||||
|
||||
@@ -4,4 +4,5 @@ interface IVertexData
|
||||
{
|
||||
VertexAttributes getAttributes(uint index, float4x4 transform);
|
||||
};
|
||||
layout(set = 1)
|
||||
ParameterBlock<IVertexData> pVertexData;
|
||||
+118
-322
@@ -1,114 +1,45 @@
|
||||
#version 450
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
layout(row_major) uniform;
|
||||
layout(row_major) buffer;
|
||||
|
||||
#line 11 0
|
||||
struct CullingParams_0
|
||||
#line 5 0
|
||||
struct InstanceData_0
|
||||
{
|
||||
uvec3 numThreadGroups_0;
|
||||
uint pad0_0;
|
||||
uvec3 numThreads_0;
|
||||
uint pad1_0;
|
||||
mat4x4 transformMatrix_0;
|
||||
};
|
||||
|
||||
|
||||
#line 35 1
|
||||
layout(binding = 0, set = 1)
|
||||
layout(std140) uniform _S1
|
||||
{
|
||||
uvec3 numThreadGroups_0;
|
||||
uint pad0_0;
|
||||
uvec3 numThreads_0;
|
||||
uint pad1_0;
|
||||
}gCullingParams_0;
|
||||
|
||||
#line 2113 2
|
||||
layout(binding = 1, set = 1)
|
||||
uniform texture2D gCullingParams_depthTextureVS_0;
|
||||
|
||||
|
||||
#line 11 0
|
||||
layout(std430, binding = 2, set = 1) buffer StructuredBuffer_uint_t_0 {
|
||||
uint _data[];
|
||||
} gCullingParams_oLightIndexCounter_0;
|
||||
|
||||
#line 11
|
||||
layout(std430, binding = 3, set = 1) buffer StructuredBuffer_uint_t_1 {
|
||||
uint _data[];
|
||||
} gCullingParams_tLightIndexCounter_0;
|
||||
|
||||
#line 11
|
||||
layout(std430, binding = 4, set = 1) buffer StructuredBuffer_uint_t_2 {
|
||||
uint _data[];
|
||||
} gCullingParams_oLightIndexList_0;
|
||||
|
||||
#line 11
|
||||
layout(std430, binding = 5, set = 1) buffer StructuredBuffer_uint_t_3 {
|
||||
uint _data[];
|
||||
} gCullingParams_tLightIndexList_0;
|
||||
|
||||
#line 1572 2
|
||||
layout(rg32ui)
|
||||
layout(binding = 6, set = 1)
|
||||
uniform uimage2D gCullingParams_oLightGrid_0;
|
||||
|
||||
|
||||
#line 1572
|
||||
layout(rg32ui)
|
||||
layout(binding = 7, set = 1)
|
||||
uniform uimage2D gCullingParams_tLightGrid_0;
|
||||
|
||||
|
||||
#line 26 1
|
||||
struct Plane_0
|
||||
{
|
||||
vec3 n_0;
|
||||
float d_0;
|
||||
};
|
||||
|
||||
struct Frustum_0
|
||||
{
|
||||
Plane_0 sides_0[4];
|
||||
Plane_0 basePlane_0;
|
||||
};
|
||||
|
||||
|
||||
#line 11 0
|
||||
layout(std430, binding = 8, set = 1) readonly buffer StructuredBuffer_Frustum_t_0 {
|
||||
Frustum_0 _data[];
|
||||
} gCullingParams_frustums_0;
|
||||
|
||||
#line 64 3
|
||||
struct LightEnv_0
|
||||
{
|
||||
uint numDirectionalLights_0;
|
||||
uint numPointLights_0;
|
||||
};
|
||||
|
||||
|
||||
#line 25
|
||||
layout(binding = 0, set = 2)
|
||||
layout(std140) uniform _S2
|
||||
{
|
||||
uint numDirectionalLights_0;
|
||||
uint numPointLights_0;
|
||||
}gLightEnv_0;
|
||||
|
||||
#line 22
|
||||
struct PointLight_0
|
||||
{
|
||||
vec4 position_WS_0;
|
||||
vec4 colorRange_0;
|
||||
};
|
||||
|
||||
|
||||
#line 64
|
||||
layout(std430, binding = 2, set = 2) readonly buffer StructuredBuffer_PointLight_t_0 {
|
||||
PointLight_0 _data[];
|
||||
} gLightEnv_pointLights_0;
|
||||
layout(std430, binding = 0) readonly buffer StructuredBuffer_InstanceData_t_0 {
|
||||
InstanceData_0 _data[];
|
||||
} pScene_instances_0;
|
||||
|
||||
#line 5 1
|
||||
layout(std430, binding = 0, set = 2) readonly buffer StructuredBuffer_float3_t_0 {
|
||||
vec3 _data[];
|
||||
} pVertexData_positions_0;
|
||||
|
||||
#line 5
|
||||
layout(std430, binding = 1, set = 2) readonly buffer StructuredBuffer_float2_t_0 {
|
||||
vec2 _data[];
|
||||
} pVertexData_texCoords_0;
|
||||
|
||||
#line 5
|
||||
layout(std430, binding = 2, set = 2) readonly buffer StructuredBuffer_float3_t_1 {
|
||||
vec3 _data[];
|
||||
} pVertexData_normals_0;
|
||||
|
||||
#line 5
|
||||
layout(std430, binding = 3, set = 2) readonly buffer StructuredBuffer_float3_t_2 {
|
||||
vec3 _data[];
|
||||
} pVertexData_tangents_0;
|
||||
|
||||
#line 5
|
||||
layout(std430, binding = 4, set = 2) readonly buffer StructuredBuffer_float3_t_3 {
|
||||
vec3 _data[];
|
||||
} pVertexData_biTangents_0;
|
||||
|
||||
#line 5 2
|
||||
struct ViewParameter_0
|
||||
{
|
||||
mat4x4 viewMatrix_0;
|
||||
@@ -117,266 +48,131 @@ struct ViewParameter_0
|
||||
vec2 screenDimensions_0;
|
||||
};
|
||||
|
||||
layout(binding = 0)
|
||||
layout(std140) uniform _S3
|
||||
|
||||
#line 12
|
||||
layout(binding = 0, set = 1)
|
||||
layout(std140) uniform _S1
|
||||
{
|
||||
mat4x4 viewMatrix_0;
|
||||
mat4x4 projectionMatrix_0;
|
||||
vec4 cameraPos_WS_0;
|
||||
vec2 screenDimensions_0;
|
||||
}viewParams_0;
|
||||
}pViewParams_0;
|
||||
|
||||
#line 39 0
|
||||
shared uint uMinDepth_0;
|
||||
#line 4206 3
|
||||
layout(location = 0)
|
||||
out vec3 _S2;
|
||||
|
||||
|
||||
#line 40
|
||||
shared uint uMaxDepth_0;
|
||||
#line 4206
|
||||
layout(location = 1)
|
||||
out vec3 _S3;
|
||||
|
||||
|
||||
|
||||
shared uint oLightCount_0;
|
||||
#line 4206
|
||||
layout(location = 2)
|
||||
out vec2 _S4;
|
||||
|
||||
|
||||
|
||||
shared uint tLightCount_0;
|
||||
#line 4206
|
||||
layout(location = 3)
|
||||
out vec3 _S5;
|
||||
|
||||
|
||||
#line 42
|
||||
shared Frustum_0 groupFrustum_0;
|
||||
#line 4206
|
||||
layout(location = 4)
|
||||
out vec3 _S6;
|
||||
|
||||
|
||||
#line 50
|
||||
shared uint tLightList_0[1024];
|
||||
#line 4206
|
||||
layout(location = 5)
|
||||
out vec3 _S7;
|
||||
|
||||
|
||||
#line 63
|
||||
void tAppendLight_0(uint lightIndex_0)
|
||||
#line 4206
|
||||
layout(location = 6)
|
||||
out vec3 _S8;
|
||||
|
||||
|
||||
#line 1 4
|
||||
struct MaterialParameter_0
|
||||
{
|
||||
uint index_0;
|
||||
((index_0) = atomicAdd((tLightCount_0), (1U)));
|
||||
if(index_0 < 1024U)
|
||||
{
|
||||
tLightList_0[index_0] = lightIndex_0;
|
||||
vec3 position_TS_0;
|
||||
vec3 worldPosition_0;
|
||||
vec2 texCoords_0;
|
||||
vec3 normal_0;
|
||||
vec3 tangent_0;
|
||||
vec3 biTangent_0;
|
||||
vec3 viewDir_TS_0;
|
||||
};
|
||||
|
||||
#line 67
|
||||
}
|
||||
struct VertexAttributes_0
|
||||
{
|
||||
MaterialParameter_0 parameter_0;
|
||||
vec4 clipPosition_0;
|
||||
};
|
||||
|
||||
|
||||
#line 9 1
|
||||
VertexAttributes_0 StaticMeshVertexData_getAttributes_0(uint _S9, mat4x4 _S10)
|
||||
{
|
||||
|
||||
return;
|
||||
vec4 worldPos_0 = (((vec4(pVertexData_positions_0._data[_S9], 1.0)) * (_S10)));
|
||||
|
||||
vec4 clipPos_0 = ((((((worldPos_0) * (pViewParams_0.viewMatrix_0)))) * (pViewParams_0.projectionMatrix_0)));
|
||||
|
||||
#line 10
|
||||
MaterialParameter_0 params_0;
|
||||
|
||||
#line 15
|
||||
params_0.worldPosition_0 = worldPos_0.xyz;
|
||||
params_0.texCoords_0 = pVertexData_texCoords_0._data[_S9];
|
||||
params_0.normal_0 = pVertexData_normals_0._data[_S9];
|
||||
params_0.tangent_0 = pVertexData_tangents_0._data[_S9];
|
||||
params_0.biTangent_0 = pVertexData_biTangents_0._data[_S9];
|
||||
|
||||
#line 9
|
||||
VertexAttributes_0 attributes_0;
|
||||
|
||||
#line 20
|
||||
attributes_0.parameter_0 = params_0;
|
||||
attributes_0.clipPosition_0 = clipPos_0;
|
||||
return attributes_0;
|
||||
}
|
||||
|
||||
|
||||
#line 58 3
|
||||
vec3 PointLight_getViewPos_0(PointLight_0 this_0)
|
||||
{
|
||||
return (((this_0.position_WS_0) * (viewParams_0.viewMatrix_0))).xyz;
|
||||
}
|
||||
|
||||
|
||||
#line 36
|
||||
bool PointLight_insidePlane_0(PointLight_0 this_1, Plane_0 plane_0)
|
||||
{
|
||||
return dot(plane_0.n_0, PointLight_getViewPos_0(this_1).xyz) - plane_0.d_0 < - this_1.colorRange_0.w;
|
||||
}
|
||||
|
||||
|
||||
#line 46 0
|
||||
shared uint oLightList_0[1024];
|
||||
|
||||
|
||||
#line 53
|
||||
void oAppendLight_0(uint lightIndex_1)
|
||||
{
|
||||
uint index_1;
|
||||
((index_1) = atomicAdd((oLightCount_0), (1U)));
|
||||
if(index_1 < 1024U)
|
||||
{
|
||||
oLightList_0[index_1] = lightIndex_1;
|
||||
|
||||
#line 57
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#line 45
|
||||
shared uint oLightIndexStartOffset_0;
|
||||
|
||||
|
||||
|
||||
shared uint tLightIndexStartOffset_0;
|
||||
|
||||
|
||||
#line 75
|
||||
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
||||
#line 18 0
|
||||
void main()
|
||||
{
|
||||
ivec3 _S4 = ivec3(ivec2(gl_GlobalInvocationID.xy), 0);
|
||||
|
||||
uint uDepth_0 = floatBitsToUint((texelFetch((gCullingParams_depthTextureVS_0), ((_S4)).xy, ((_S4)).z)).x);
|
||||
bool _S5 = gl_LocalInvocationIndex == 0U;
|
||||
#line 18
|
||||
VertexAttributes_0 _S11 = StaticMeshVertexData_getAttributes_0(uint(gl_VertexIndex), pScene_instances_0._data[uint(gl_InstanceIndex)].transformMatrix_0);
|
||||
|
||||
#line 81
|
||||
if(_S5)
|
||||
{
|
||||
uMinDepth_0 = 4294967295U;
|
||||
uMaxDepth_0 = 0U;
|
||||
oLightCount_0 = 0U;
|
||||
tLightCount_0 = 0U;
|
||||
groupFrustum_0 = gCullingParams_frustums_0._data[gl_WorkGroupID.x + gl_WorkGroupID.y * gCullingParams_0.numThreadGroups_0.x];
|
||||
#line 18
|
||||
_S2 = _S11.parameter_0.position_TS_0;
|
||||
|
||||
#line 81
|
||||
}
|
||||
#line 18
|
||||
_S3 = _S11.parameter_0.worldPosition_0;
|
||||
|
||||
#line 90
|
||||
barrier();
|
||||
#line 18
|
||||
_S4 = _S11.parameter_0.texCoords_0;
|
||||
|
||||
atomicMin((uMinDepth_0), (uDepth_0));
|
||||
atomicMax((uMaxDepth_0), (uDepth_0));
|
||||
#line 18
|
||||
_S5 = _S11.parameter_0.normal_0;
|
||||
|
||||
barrier();
|
||||
#line 18
|
||||
_S6 = _S11.parameter_0.tangent_0;
|
||||
|
||||
#line 104
|
||||
Plane_0 _S6 = { vec3(0.0, 0.0, -1.0), - uintBitsToFloat(uMinDepth_0) };
|
||||
#line 18
|
||||
_S7 = _S11.parameter_0.biTangent_0;
|
||||
|
||||
#line 125
|
||||
uvec2 _S7 = gl_WorkGroupID.xy;
|
||||
#line 18
|
||||
_S8 = _S11.parameter_0.viewDir_TS_0;
|
||||
|
||||
#line 125
|
||||
uint i_0 = gl_LocalInvocationIndex;
|
||||
#line 18
|
||||
gl_Position = _S11.clipPosition_0;
|
||||
|
||||
#line 125
|
||||
for(;;)
|
||||
{
|
||||
|
||||
#line 106
|
||||
if(i_0 < gLightEnv_0.numPointLights_0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line 106
|
||||
break;
|
||||
}
|
||||
PointLight_0 light_0 = gLightEnv_pointLights_0._data[i_0];
|
||||
|
||||
|
||||
|
||||
tAppendLight_0(i_0);
|
||||
if(!PointLight_insidePlane_0(light_0, _S6))
|
||||
{
|
||||
oAppendLight_0(i_0);
|
||||
|
||||
#line 113
|
||||
}
|
||||
|
||||
#line 106
|
||||
i_0 = i_0 + 1024U;
|
||||
|
||||
#line 106
|
||||
}
|
||||
|
||||
#line 120
|
||||
barrier();
|
||||
|
||||
if(_S5)
|
||||
{
|
||||
((oLightIndexStartOffset_0) = atomicAdd((gCullingParams_oLightIndexCounter_0._data[0U]), (oLightCount_0)));
|
||||
imageStore((gCullingParams_oLightGrid_0), ivec2((_S7)), uvec4(uvec2(oLightIndexStartOffset_0, oLightCount_0), uint(0), uint(0)));
|
||||
|
||||
((tLightIndexStartOffset_0) = atomicAdd((gCullingParams_tLightIndexCounter_0._data[0U]), (tLightCount_0)));
|
||||
imageStore((gCullingParams_tLightGrid_0), ivec2((_S7)), uvec4(uvec2(tLightIndexStartOffset_0, tLightCount_0), uint(0), uint(0)));
|
||||
|
||||
#line 122
|
||||
}
|
||||
|
||||
#line 130
|
||||
barrier();
|
||||
|
||||
#line 130
|
||||
uint k_0;
|
||||
|
||||
#line 130
|
||||
if(gl_LocalInvocationIndex < oLightCount_0)
|
||||
{
|
||||
|
||||
#line 130
|
||||
k_0 = gl_LocalInvocationIndex;
|
||||
|
||||
#line 130
|
||||
for(;;)
|
||||
{
|
||||
|
||||
|
||||
gCullingParams_oLightIndexList_0._data[oLightIndexStartOffset_0 + k_0] = oLightList_0[k_0];
|
||||
|
||||
#line 132
|
||||
uint j_0 = k_0 + 1024U;
|
||||
|
||||
#line 132
|
||||
if(j_0 < oLightCount_0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line 132
|
||||
break;
|
||||
}
|
||||
|
||||
#line 132
|
||||
k_0 = j_0;
|
||||
|
||||
#line 132
|
||||
}
|
||||
|
||||
#line 132
|
||||
}
|
||||
|
||||
#line 132
|
||||
if(gl_LocalInvocationIndex < tLightCount_0)
|
||||
{
|
||||
|
||||
#line 132
|
||||
k_0 = gl_LocalInvocationIndex;
|
||||
|
||||
#line 132
|
||||
for(;;)
|
||||
{
|
||||
|
||||
#line 140
|
||||
gCullingParams_tLightIndexList_0._data[tLightIndexStartOffset_0 + k_0] = tLightList_0[k_0];
|
||||
|
||||
#line 138
|
||||
uint k_1 = k_0 + 1024U;
|
||||
|
||||
#line 138
|
||||
if(k_1 < tLightCount_0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line 138
|
||||
break;
|
||||
}
|
||||
|
||||
#line 138
|
||||
k_0 = k_1;
|
||||
|
||||
#line 138
|
||||
}
|
||||
|
||||
#line 138
|
||||
}
|
||||
|
||||
#line 144
|
||||
#line 18
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user