DirectX9 / HLSL Shader Model 3 - Passing Doubles between Shaders
Posted
by
P. Avery
on Game Development
See other posts from Game Development
or by P. Avery
Published on 2013-10-31T19:54:39Z
Indexed on
2013/10/31
22:19 UTC
Read the original article
Hit count: 564
I need higher precision on a few values within my vertex and pixel shaders...I'm currently using floats, so I would like to use doubles...I've read that HLSL Model 4 has two functions to convert a double into two unsigned integers and back again( asuint() and asdouble() ). These functions are only supported on HLSL 4 and I am using DirectX 9 which will only compile HLSL Model 3 and below...
How can I pass a double between shaders? here is implementation for HLSL 4:
struct VS_INPUT
{
float2 v;
};
struct PS_INPUT
{
uint a;
uint b;
uint c;
uint d;
};
PS_INPUT VertexShader( VS_INPUT Input )
{
PS_INPUT Output = ( PS_INPUT )0;
double2 vPos = mul( Input.v, mWorld ).xy;
asuint( vPos.x, Output.a, Output.b );
asuint( vPos.y, Output.c, Output.d );
return Output;
}
float4 PixelShader( PS_INPUT Input )
{
double2 vPos;
vPos.x = asdouble( Input.a, Input.b );
vPos.y = asdouble( Input.c, Input.d );
...
return 1;
}
© Game Development or respective owner