75 lines
1.4 KiB
Plaintext
75 lines
1.4 KiB
Plaintext
float4x4 viewProj : register(c31);
|
|
float2 quadddx : register(c30);
|
|
|
|
struct QuadInput
|
|
{
|
|
float4 p:position;
|
|
float2 t:texcoord0;
|
|
};
|
|
|
|
struct QuadOutput
|
|
{
|
|
float4 p:position;
|
|
float2 t:texcoord0;
|
|
float4 q:texcoord1;
|
|
};
|
|
|
|
struct IndexedQuadInput
|
|
{
|
|
float4 p:position;
|
|
float2 n:normal;
|
|
float4 i:texcoord0;
|
|
float k:texcoord1;
|
|
};
|
|
|
|
struct IndexedQuadOutput
|
|
{
|
|
float4 q:position;
|
|
float3 n:normal;
|
|
float4 p:texcoord0;
|
|
float4 k:texcoord1;
|
|
float2 t:texcoord2;
|
|
float size:texcoord3;
|
|
};
|
|
|
|
void calc(IndexedQuadInput i, out IndexedQuadOutput o, float sizeFactor)
|
|
{
|
|
float3 eyeVector = viewProj._m02_m12_m22;
|
|
float3 side;
|
|
float3 up;
|
|
|
|
side = normalize(cross(eyeVector, float3(0,1,0)));
|
|
up = normalize(cross(side,eyeVector));
|
|
|
|
float3 finalPos = i.i.xyz;
|
|
float size = i.i.w * sizeFactor;
|
|
finalPos += (i.p.x) * side * size * (1 - i.k * 0.5);
|
|
finalPos += (i.p.y) * up * size * (1 + i.k * 5);
|
|
|
|
float4 finalPos4 = float4(finalPos, 1);
|
|
|
|
o.q = mul(finalPos4, viewProj);
|
|
|
|
o.t = i.n;
|
|
o.n.xy = i.n;
|
|
o.n.z = 0.0;
|
|
o.p = finalPos4;
|
|
o.k.xyz = i.p.xyz;
|
|
o.k.a = i.k;
|
|
o.size = size;
|
|
}
|
|
|
|
void vsDeferred(IndexedQuadInput i, out IndexedQuadOutput o) { calc(i, o, 1.0); }
|
|
|
|
void vsDepth(IndexedQuadInput i, out IndexedQuadOutput o) { calc(i, o, 0.9); }
|
|
|
|
QuadOutput vsCompose(QuadInput i)
|
|
{
|
|
QuadOutput o;
|
|
o.p = i.p;
|
|
o.q = i.p;
|
|
o.t = i.t;
|
|
o.t *= 1.0 + quadddx;
|
|
|
|
return o;
|
|
} |