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;
}
would someone mind pointing out where im going wrong? (hlsl billboarding)
How are you differentiating the corners of the billboard? Seems like they're all being set to
center + right + worldUp
center + right + worldUp
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;}
Thanks for the replies!
All of the corner verts have a position when they enter the shader..i send in prepositioned verts around the origin...
with your shader I don't see anything on screen :(
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 :(
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);
thanks again for your help
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
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.
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?
The quads are moving when the camera rotates...
if i look up....the quads will kind of rotate up with the camera
if i look up....the quads will kind of rotate up with the camera
Ahh right, I'm an idiot. Don't use CameraPos, try this instead:
float3 positionVS = positionWS + float3(View._41, View._42, View.43);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement