Code cleanup, refactoring and simplification
This commit is contained in:
parent
0888d1c9b0
commit
47c3bd16c4
16 changed files with 500 additions and 901 deletions
|
|
@ -6,7 +6,7 @@ layout (location = 1) in vec2 inUV;
|
|||
struct Instance
|
||||
{
|
||||
mat4 model;
|
||||
vec4 arrayIndex;
|
||||
float arrayIndex;
|
||||
};
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
|
|
@ -20,7 +20,7 @@ layout (location = 0) out vec3 outUV;
|
|||
|
||||
void main()
|
||||
{
|
||||
outUV = vec3(inUV, ubo.instance[gl_InstanceIndex].arrayIndex.x);
|
||||
outUV = vec3(inUV, ubo.instance[gl_InstanceIndex].arrayIndex);
|
||||
mat4 modelView = ubo.view * ubo.instance[gl_InstanceIndex].model;
|
||||
gl_Position = ubo.projection * modelView * vec4(inPos, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -15,5 +15,7 @@ void main()
|
|||
outUVW = inPos;
|
||||
// Convert cubemap coordinates into Vulkan coordinate space
|
||||
outUVW.xy *= -1.0;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
// Remove translation from view matrix
|
||||
mat4 viewMat = mat4(mat3(ubo.model));
|
||||
gl_Position = ubo.projection * viewMat * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -17,5 +17,7 @@ void main()
|
|||
{
|
||||
outUVW = inPos;
|
||||
outUVW.yz *= -1.0f;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
// Remove translation from view matrix
|
||||
mat4 viewMat = mat4(mat3(ubo.model));
|
||||
gl_Position = ubo.projection * viewMat * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ struct VSInput
|
|||
struct Instance
|
||||
{
|
||||
float4x4 model;
|
||||
float4 arrayIndex;
|
||||
float arrayIndex;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
|
|
@ -30,7 +30,7 @@ struct VSOutput
|
|||
VSOutput main(VSInput input, uint InstanceIndex : SV_InstanceID)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UV = float3(input.UV, ubo.instance[InstanceIndex].arrayIndex.x);
|
||||
output.UV = float3(input.UV, ubo.instance[InstanceIndex].arrayIndex);
|
||||
float4x4 modelView = mul(ubo.view, ubo.instance[InstanceIndex].model);
|
||||
output.Pos = mul(ubo.projection, mul(modelView, float4(input.Pos, 1.0)));
|
||||
return output;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -20,6 +20,11 @@ VSOutput main([[vk::location(0)]] float3 Pos : POSITION0)
|
|||
output.UVW = Pos;
|
||||
// Convert cubemap coordinates into Vulkan coordinate space
|
||||
output.UVW.xy *= -1.0;
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(Pos.xyz, 1.0)));
|
||||
// Remove translation from view matrix
|
||||
float4x4 viewMat = ubo.model;
|
||||
viewMat[0][3] = 0.0;
|
||||
viewMat[1][3] = 0.0;
|
||||
viewMat[2][3] = 0.0;
|
||||
output.Pos = mul(ubo.projection, mul(viewMat, float4(Pos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -22,6 +22,11 @@ VSOutput main([[vk::location(0)]] float3 Pos : POSITION0)
|
|||
VSOutput output = (VSOutput)0;
|
||||
output.UVW = Pos;
|
||||
output.UVW.yz *= -1.0;
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(Pos.xyz, 1.0)));
|
||||
// Remove translation from view matrix
|
||||
float4x4 viewMat = ubo.model;
|
||||
viewMat[0][3] = 0.0;
|
||||
viewMat[1][3] = 0.0;
|
||||
viewMat[2][3] = 0.0;
|
||||
output.Pos = mul(ubo.projection, mul(viewMat, float4(Pos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue