• Advertisement
Sign in to follow this  

HLSL Billboard not working

This topic is 1907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can´t seem to get my billboard HLSL code to work in my vertex shader.
My result is that my Quad is not showing at all...

My code for Billboarding is:

I don´t understand why it is all blank?
[source lang="cpp"]float4x4 matWorldView = mul(worldMatrix, viewMatrix);
float3 vPositionVS = position + float3(matWorldView._41, matWorldView._42, matWorldView._43);
output.position = mul(float4(vPositionVS, 1.0f), projMatrix);[/source]

and my complete vertex shader looks like this :

OBS! My worldMatrix is Identity if that mathers.

[source lang="cpp"]VOut VShader(float4 position : POSITION, float4 normal : NORMAL, float2 texcoord : TEXCOORD, float4 color: COLOR)
{
VOut output;

//This is the billboard code.
float4x4 matWorldView = mul(worldMatrix, viewMatrix);
float3 vPositionVS = position + float3(matWorldView._41, matWorldView._42, matWorldView._43);
output.position = mul(float4(vPositionVS, 1.0f), projMatrix);

//I just commented this code out for the billboard code
//output.position = mul(final, position);

//The rest is just lighting.
// set the ambient light
output.color = ambientcol;
output.color.rgb = color.rgb;
// calculate the diffuse light and add it to the ambient light
float4 norm = normalize(normal);
float diffusebrightness = saturate(dot(norm, lightvec));
output.color += lightcol * diffusebrightness;
//be sure to take alpha last as other formulas might destroy this.
output.color.a = color.a;

output.texcoord = texcoord; // set the texture coordinates, unmodified

return output;
}[/source] Edited by KurtO

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement