Sign in to follow this  

alphablending on different hardware

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

[font="arial, verdana, tahoma, sans-serif"][size="2"]Hi all. I've been developing a game that uses billboarded planes textured with partially-transparent Texture2Ds. This works great on my dev machine but when one of the other devs on the project tried to run the game on his laptop the textured planes don't seem to render correctly. They basically flicker into existence every few seconds but otherwise aren't showing at all. The other shapes in the game use opaque textures and render fine on both machines so we're pretty sure that the problem has to do with alpha blending. Beyond that, I'm uncertain how to proceed. [/size][/font][font="arial, verdana, tahoma, sans-serif"][size="2"]Per [url="http://blogs.msdn.com/b/shawnhar/archive/2009/02/18/depth-sorting-alpha-blended-objects.aspx"]Shawn Hargreaves' advice[/url], I'm rendering all of the opaque shapes first, then sorting the alpha shapes by distance to the camera and rendering those. The planes are being drawn via Game.GraphicsDevice.DrawIndexedPrimitives using a very simple shader. If anyone can help I will gladly provide additional information on request. Could this be something to do with hardware differences? Thank you.[/size][/font]

Share this post


Link to post
Share on other sites
I am also on this project...and just as lost. Here follows our shader code. =)
[code]


float4x4 World;
float4x4 View;
float4x4 Projection;
Texture2D DiffuseTexture;

sampler2D DiffuseSampler = sampler_state { Texture = <DiffuseTexture>; };

struct VertexPositionTexture {
float4 Position : POSITION0;
float2 UV : TEXCOORD0;
};

VertexPositionTexture TexturedVertexShader(VertexPositionTexture input) {
VertexPositionTexture output;

output.Position = mul(input.Position, World);
output.Position = mul(output.Position, View);
output.Position = mul(output.Position, Projection);
output.UV = input.UV;

return output;
}

float4 TexturedPixelShader(VertexPositionTexture input) : COLOR0 {
return tex2D(DiffuseSampler, input.UV);
}

technique DefaultEffect {
Pass {
VertexShader = compile vs_2_0 TexturedVertexShader();
PixelShader = compile ps_2_0 TexturedPixelShader();
}
}

[/code]

EDIT: I posted the wrong version of the shader; corrected.

Share this post


Link to post
Share on other sites
If you say that your objects are flickering in and out of existence on different hardware, then perhaps your application has to fall back to using a depth buffer with less precision than on your dev machine and it is causing z-fighting when you draw your billboards.

Share this post


Link to post
Share on other sites
[quote name='DragonGeo2' timestamp='1297902529' post='4775186']
If you say that your objects are flickering in and out of existence on different hardware, then perhaps your application has to fall back to using a depth buffer with less precision than on your dev machine and it is causing z-fighting when you draw your billboards.
[/quote]

Interesting. Thanks for the response! Do you know if this problem could still occur if there was nothing else drawn behind the billboards? I can see how the billboards might get placed behind another object if there were a depth buffering issue, but in this case there aren't any other objects that would be drawn in front of them. Could a depth buffering issue cause them to disappear completely despite that fact?

Share this post


Link to post
Share on other sites

This topic is 2491 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.

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