Jump to content
  • Advertisement
Sign in to follow this  
digitaldisciple

alphablending on different hardware

This topic is 2774 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"]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. [/font][font="arial, verdana, tahoma, sans-serif"]Per Shawn Hargreaves' advice, 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.[/font]

Share this post


Link to post
Share on other sites
Advertisement
I am also on this project...and just as lost. Here follows our shader 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();
}
}



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

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.


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
Have you tried using the DX control panel to switch over to the debug runtimes and made sure you're not triggering any DX errors?

Share this post


Link to post
Share on other sites

Have you tried using the DX control panel to switch over to the debug runtimes and made sure you're not triggering any DX errors?


That is a clever idea. We will do this. =)

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!