-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshader.hlsl
84 lines (67 loc) · 1.95 KB
/
shader.hlsl
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//--------------------------------------------------------------------------------------
// File: Tutorial02.fx
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 pos :SV_POSITION;
float3 worldPos:TEXCOORD0;
float3 normal :TEXCOORD1;
float4 color: COLOR0;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float4 Color: COLOR0;
};
cbuffer cbNeverChanges : register(b0)
{
matrix World;
matrix View;
matrix Projection;
float4 lightdir;
float4 eye;
};
cbuffer cbVariable: register(b1)
{
matrix local;
float4 kd;
float4 ks;
float ns;
}
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS(VS_INPUT input)
{
VS_OUTPUT o;
o.pos = mul(input.Pos, local);
o.pos = mul(o.pos, World);
o.worldPos = (float3) o.pos;
o.pos = mul(o.pos, View);
o.pos = mul(o.pos, Projection);
o.normal = mul(input.Norm, local);
o.normal = mul(o.normal, World);
o.normal = normalize(o.normal);
o.color = input.Color;
return o;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS(VS_OUTPUT input) : SV_Target
{
//float4 finalColor = 0;
//finalColor += saturate(dot((float3)lightdir, input.normal)) * input.color;
//float3 V = normalize(eye - input.worldPos);
// float3 H = normalize((float3)lightdir + V);
// float spec = pow(max(dot(input.normal, H), 0), ns);
//float4 specolor = ks * spec;
// finalColor += saturate(specolor);
//finalColor = saturate(finalColor);
//finalColor.a = 1;
//return finalColor;
return input.color;
}