53 lines
1.1 KiB
Plaintext
53 lines
1.1 KiB
Plaintext
float4x4 matWVP : register(c0);
|
|
float4x4 matWorld : register(c12);
|
|
float4x4 matWorldI : register(c16);
|
|
float3 viewPos : register(c4);
|
|
float3 viewDir : register(c10);
|
|
float4 res : register(c5);
|
|
|
|
struct vsIn
|
|
{
|
|
float4 p : POSITION;
|
|
float3 n : NORMAL;
|
|
float4 c : COLOR;
|
|
float2 t : TEXCOORD;
|
|
};
|
|
|
|
struct vsOut
|
|
{
|
|
float4 p : POSITION;
|
|
float4 c : COLOR0;
|
|
float2 t : TEXCOORD0;
|
|
float3 n : TEXCOORD1;
|
|
float3 v : TEXCOORD2;
|
|
float4 s : TEXCOORD3;
|
|
float3 w : TEXCOORD4;
|
|
};
|
|
|
|
vsOut vs_main(vsIn i)
|
|
{
|
|
vsOut o;
|
|
|
|
// Basic transformation of untransformed vertex into clip-space
|
|
o.p= mul(i.p, matWVP);
|
|
|
|
// No scaling or translation is done, simply assign them and let the GPU interpolate
|
|
o.c = i.c;
|
|
o.t = i.t;
|
|
|
|
// Trasform to world space
|
|
o.w= mul(i.p, matWorld).xyz;
|
|
o.n= mul(i.n, transpose((float3x3)matWorldI));
|
|
//OUT.normal = mul(matWorldIT, IN.normal);
|
|
|
|
// Calculate the view vector
|
|
o.v= viewPos - o.w;
|
|
|
|
// (Pre-proj biased screen texcoords, unscaled z, w)
|
|
o.s = o.p;
|
|
o.s.xy = o.s.xy * float2(.5f, -.5f) + o.s.w * (.5f + .5f * res.zw);
|
|
o.s.z = dot(o.w - viewPos, viewDir);
|
|
|
|
return o;
|
|
};
|