parent
8e98d10f74
commit
8c376121c3
16 changed files with 46 additions and 16 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -6,10 +6,21 @@ layout (location = 0) in vec2 inUV;
|
|||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
mat4 lightSpace;
|
||||
vec4 lightPos;
|
||||
float zNear;
|
||||
float zFar;
|
||||
} ubo;
|
||||
|
||||
float LinearizeDepth(float depth)
|
||||
{
|
||||
float n = 1.0; // camera z near
|
||||
float f = 128.0; // camera z far
|
||||
float n = ubo.zNear;
|
||||
float f = ubo.zFar;
|
||||
float z = depth;
|
||||
return (2.0 * n) / (f + n - z * (f - n));
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,7 +11,9 @@ layout (binding = 0) uniform UBO
|
|||
mat4 view;
|
||||
mat4 model;
|
||||
mat4 lightSpace;
|
||||
vec3 lightPos;
|
||||
vec4 lightPos;
|
||||
float zNear;
|
||||
float zFar;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
|
|
@ -20,11 +22,6 @@ layout (location = 2) out vec3 outViewVec;
|
|||
layout (location = 3) out vec3 outLightVec;
|
||||
layout (location = 4) out vec4 outShadowCoord;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
const mat4 biasMat = mat4(
|
||||
0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
|
|
@ -40,7 +37,7 @@ void main()
|
|||
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(ubo.model) * inNormal;
|
||||
outLightVec = normalize(ubo.lightPos - inPos);
|
||||
outLightVec = normalize(ubo.lightPos.xyz - inPos);
|
||||
outViewVec = -pos.xyz;
|
||||
|
||||
outShadowCoord = ( biasMat * ubo.lightSpace * ubo.model ) * vec4(inPos, 1.0);
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue