forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.hlsl
More file actions
45 lines (33 loc) · 722 Bytes
/
Copy pathExample.hlsl
File metadata and controls
45 lines (33 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// HLSL model shader
// VERTEX SHADER
cbuffer Settings : register(b0)
{
float4x4 wvpMatrix;
float4x4 wMatrix;
float4 color;
};
struct InputVS
{
float3 position : POSITION;
float3 normal : NORMAL;
};
struct OutputVS
{
float4 position : SV_Position;
float3 normal : NORMAL;
};
OutputVS VS(InputVS inp)
{
OutputVS outp;
outp.position = mul(wvpMatrix, float4(inp.position, 1));
outp.normal = mul(wMatrix, float4(inp.normal, 0)).xyz;
return outp;
}
// PIXEL SHADER
float4 PS(OutputVS inp) : SV_Target
{
float3 lightDir = float3(0, 0, -1);
float NdotL = dot(lightDir, normalize(inp.normal));
float intensity = max(0.2, NdotL);
return color * float4((float3)intensity, 1);
}