Factorized Push Data
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,6 +11,11 @@ cbuffer RootConstants : register(b0, space0)
|
||||
uint _Padding; // Padding for alignment
|
||||
float2 Scale; // 2D scale factor
|
||||
float2 Translate; // 2D translation
|
||||
|
||||
float3 LightDirection; // Normalized, world-space
|
||||
float LightPad;
|
||||
float3 LightColor;
|
||||
float AmbientIntensity;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
float4 main(float4 Color : TEXCOORD0) : SV_Target0
|
||||
#include "RootConstants.hlsl"
|
||||
|
||||
float4 main(float4 Color : TEXCOORD0, float3 WorldNormal : TEXCOORD1) : SV_Target0
|
||||
{
|
||||
return Color;
|
||||
float3 N = normalize(WorldNormal);
|
||||
float NdotL = saturate(dot(N, -LightDirection));
|
||||
float3 diffuse = Color.rgb * LightColor * NdotL;
|
||||
float3 ambient = Color.rgb * AmbientIntensity;
|
||||
return float4(diffuse + ambient, Color.a);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
struct Output
|
||||
{
|
||||
float4 Color : TEXCOORD0;
|
||||
float3 Normal : TEXCOORD1;
|
||||
float3 WorldNormal : TEXCOORD1;
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
@@ -20,9 +20,10 @@ Output main(uint vertexIndex : SV_VertexID)
|
||||
float3 normal = asfloat(buffer.Load3(offset + 12));
|
||||
float4 col = asfloat(buffer.Load4(offset + 24));
|
||||
|
||||
//output.Position = float4(pos, 1.0f);
|
||||
output.Position = mul(ViewProjection, mul(Model, float4(pos, 1.0f)));
|
||||
output.Color = col;
|
||||
output.Normal = normal;
|
||||
|
||||
float3 worldNormal = mul((float3x3)Model, normal);
|
||||
output.WorldNormal = worldNormal;
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user