Code cleanup
Skybox now rotates with the camera, fixed depth issues
This commit is contained in:
parent
68b2e0fcfe
commit
fe46cef0a7
5 changed files with 142 additions and 192 deletions
|
|
@ -6,6 +6,8 @@ layout (binding = 0) uniform UBO
|
|||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
mat4 normal;
|
||||
mat4 view;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outUVW;
|
||||
|
|
@ -13,5 +15,7 @@ layout (location = 0) out vec3 outUVW;
|
|||
void main()
|
||||
{
|
||||
outUVW = inPos;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
// Remove translation from view matrix
|
||||
mat4 viewMat = mat4(mat3(ubo.view));
|
||||
gl_Position = ubo.projection * viewMat * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright 2020 Google LLC
|
||||
// Copyright 2023 Sascha Willems
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 model;
|
||||
float4x4 normal;
|
||||
float4x4 view;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
|
@ -17,7 +20,14 @@ struct VSOutput
|
|||
VSOutput main([[vk::location(0)]] float3 Pos : POSITION0)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
|
||||
// Remove translation from view matrix
|
||||
float4x4 viewMat = ubo.view;
|
||||
viewMat[0][3] = 0.0;
|
||||
viewMat[1][3] = 0.0;
|
||||
viewMat[2][3] = 0.0;
|
||||
output.UVW = Pos;
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(Pos.xyz, 1.0)));
|
||||
output.Pos = mul(ubo.projection, mul(viewMat, mul(ubo.model, float4(Pos.xyz, 1.0))));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue