parent
8e98d10f74
commit
8c376121c3
16 changed files with 46 additions and 16 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -3,10 +3,23 @@
|
|||
Texture2D textureColor : register(t1);
|
||||
SamplerState samplerColor : register(s1);
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
float4x4 lightSpace;
|
||||
float4 lightPos;
|
||||
float zNear;
|
||||
float zFar;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO 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.
|
|
@ -14,7 +14,9 @@ struct UBO
|
|||
float4x4 view;
|
||||
float4x4 model;
|
||||
float4x4 lightSpace;
|
||||
float3 lightPos;
|
||||
float4 lightPos;
|
||||
float zNear;
|
||||
float zFar;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
|
@ -45,7 +47,7 @@ VSOutput main(VSInput input)
|
|||
|
||||
float4 pos = mul(ubo.model, float4(input.Pos, 1.0));
|
||||
output.Normal = mul((float3x3)ubo.model, input.Normal);
|
||||
output.LightVec = normalize(ubo.lightPos - input.Pos);
|
||||
output.LightVec = normalize(ubo.lightPos.xyz - input.Pos);
|
||||
output.ViewVec = -pos.xyz;
|
||||
|
||||
output.ShadowCoord = mul(biasMat, mul(ubo.lightSpace, mul(ubo.model, float4(input.Pos, 1.0))));
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue