Jump to content
  • Advertisement
Sign in to follow this  
nex7

would someone mind pointing out where im going wrong? (hlsl billboarding)

This topic is 3713 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


VS_OUTPUT VertexShader(VS_INPUT input)
{

	VS_OUTPUT Out;
    
    
	float4x4 vp = mul(View,Projection);
    
    float3 center = mul(input.Position,World);  
    
    float3 eyeVector = normalize(CameraPos.xyz - input.Position);
    
    float3 right = normalize(cross(eyeVector,worldUp));
    
    float3 finalPos = center;
    
    finalPos += right;
    
    finalPos += worldUp;
    
    float4 finalPos4 = float4(finalPos,1);    
    
    Out.Position = mul(finalPos4,vp);
    
    Out.TexCoord = input.TexCoord;
    
    Out.Color = input.Color;    
   
    return Out;
    
  
}


I'm just not seeing any billboard type movement at all. thanks in advance! [Edited by - nex7 on May 16, 2008 11:10:09 AM]

Share this post


Link to post
Share on other sites
Advertisement
How are you differentiating the corners of the billboard? Seems like they're all being set to
center + right + worldUp

Share this post


Link to post
Share on other sites
People always seem to get caught up in this "up vector, right vector" nonsense when billboarding.


VS_OUTPUT VertexShader(VS_INPUT input)
{
VS_OUTPUT Out;

float3 positionWS = input.Position + float3(World._41, World._42, World._43);
float3 positionVS = positionWS - CameraPos.xyz; // Or you could use "+ float3(View._41, View._42, View.43)"

Out.Position = mul(positionVS, Projection);
Out.TexCoord = input.TexCoord;
Out.Color = input.Color;

return Out;
}



Share this post


Link to post
Share on other sites
Thanks for the replies!

Quote:
Original post by gzboli
How are you differentiating the corners of the billboard? Seems like they're all being set to
center + right + worldUp



All of the corner verts have a position when they enter the shader..i send in prepositioned verts around the origin...


Quote:
Original post by MJP
People always seem to get caught up in this "up vector, right vector" nonsense when billboarding.


with your shader I don't see anything on screen :(

Share this post


Link to post
Share on other sites
OH never mind i got it....Thanks MJP

error was in the last multiply

Out.Position = mul(positionVS, Projection);

needed to be

Out.Position = mul(float4(positionVS,1.0f), Projection);


VS_OUTPUT VertexShader(VS_INPUT input)
{
VS_OUTPUT Out;

float3 positionWS = input.Position + float3(World._41, World._42, World._43);
float3 positionVS = positionWS - CameraPos.xyz; // Or you could use "+ float3(View._41, View._42, View.43)"

Out.Position = mul(float4(positionVS,1.0f), Projection);
Out.TexCoord = input.TexCoord;
Out.Color = input.Color;

return Out;
}





thanks again for your help

Share this post


Link to post
Share on other sites
This method also has the unfortunate side effect of attaching the billboard to the camera instead of just leaving it in the world and rotating to the camera...ill work on that next.

Share this post


Link to post
Share on other sites
Quote:
Original post by nex7
This method also has the unfortunate side effect of attaching the billboard to the camera instead of just leaving it in the world and rotating to the camera...ill work on that next.


What do you mean by "attaching the billboard to the camera"? All this should do is move the quad to its world position, and never rotate it so that its always facing front. Are the quads moving when the camera moves?

Share this post


Link to post
Share on other sites
The quads are moving when the camera rotates...


if i look up....the quads will kind of rotate up with the camera

Share this post


Link to post
Share on other sites
Ahh right, I'm an idiot. Don't use CameraPos, try this instead:


float3 positionVS = positionWS + float3(View._41, View._42, View.43);

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!