Page 1 of 1
HLSL Matrix
Posted: 27 Jun 2013, 10:59
by joschy
Hello,
i try to rebuild a simple shader example from AMD's RenderMonkey. I need therefor two matrixes, WORLDVIEWPROJECTION & VIEW, but it seems that only one matrix at the time is possible. See the attached pic... Or do i something wrong?
joschy
Re: HLSL Matrix
Posted: 27 Jun 2013, 11:15
by joschy
ok, i got it, but...
[// Vertex shader program output
struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float color: TEXCOORD1;
};
// Vertex Shader Program
VS_OUTPUT VS(float4 Pos: POSITION )
{
VS_OUTPUT Output;
float3 pos;
// Billboard the quads.
// The view matrix gives us our right and up vectors.
pos = 5 * Pos.z * (Pos.x * View_matrix[0]+ Pos.y * View_matrix[1]);
// Transform the vertex from 3D object space to 2D screen space.
Output.Pos = mul(float4(pos, 1), WorldViewProjection);
//Output.Pos = mul(Pos, WorldViewProjection);
Output.texCoord = Pos.xy;
Output.color = Pos.z;
return Output;
}
]
The poly should face to the view, but it doesn't. Any suggestions why? Pic from the RenderMonky screen attached.
joschy
Re: HLSL Matrix
Posted: 27 Jun 2013, 11:54
by joschy
mmmhh, it seems that these line is different calculated:
[pos = 15 * Pos.z * (Pos.x * view_matrix[0] + Pos.y * view_matrix[1]);]
Re: HLSL Matrix
Posted: 27 Jun 2013, 12:25
by joschy
I´ve reduced all the VS stuff and compare it again. RenderMonkey uses Dotproduct operations where Ventuz uses mul & mad operations, interesting..
Re: HLSL Matrix
Posted: 27 Jun 2013, 13:57
by joschy
it works, have to have the right orientation of the mesh
cheers, joschy