Sign in to follow this  
Kurt-olsson

HLSL Billboard not working

Recommended Posts

Kurt-olsson    254
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this