Hi guys
Im curious, do HLSL floats have different numerical ranges to C++ floats? As far as I recall, C++ floats can have a range of 1.2E-38 to 3.4E38.
I am getting a odd response from a geometry shader here. Here is the vertex XYZ values after being multiplied by the world matrix on the C++ side:
62909.550781f, 43.891846f, 129223.367188f
and here is the code in the geometry shader:
float4 vert = mul(sprite[0].pos, g_world);
float4 center = float4(vert.xz*0.000043192f, 0, 1);
//top right
if(abs(center.x) < 1.0f && abs(center.y) < 1.0f)
{
v.p = center+float4(0.007702941f, 0.002502837f, 0, 0);
triStream.Append(v);
//bottom right
v.p = center+float4(0.004760679f, -0.006552513f, 0, 0);
triStream.Append(v);
//top
v.p = center+float4(0, 0.008099352f, 0, 0);
triStream.Append(v);
//bottom left
v.p = center+float4(-0.004760679f, -0.006552513f, 0, 0);
triStream.Append(v);
//top left
v.p = center+float4(-0.007702941f, 0.002502837f, 0, 0);
triStream.Append(v);
triStream.RestartStrip();
}
If we take the Z value of 129223.367188 (which is getting shifted to the Y value for the display) and multiply by 0.000043192f, I should get a value of 5.5814 etc which would put the vertex well outside of the viewport limit of +-1.0f. However, despite the limiting if statement in the above code which prevents a triangle from being sent out if it is greater than 1.0f, the vertex still gets drawn around 0.5f-0.6f on the display.
Any ideas as to why? Transposing the world matrix has no effect. This just makes no sense.