Sign in to follow this  

Order of blending triangles? Need grouping of triangles in D3D 9

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

I have unusual task with Direct3D 8 or 9. For example, we have a simple scene with three triangles with textures with ALPHA Channels (Triangle1 is a higher object, Triangle3 is a lower one). ============ Triangle1| Triangle2| Triangle3 ============ Direct3D draws triangles step-by-step from bottom to top. But we need possibility when Direct3D draws Triangle1 and Triangle2 *TOGETHER*, and only AFTER THIS draws them onto Triangle3. Because Triangle1 and Triangle2 is a one virtual object in our case and we need that Direct3D blends them, and draw result over Triangle3. I couldn't find any variant how to set group of triangles and do it in one pass. We have only one slow and dangerous variant, when render to texture *in two pass*. Also stencil buffer is not suitable because it has onle 1-bit per pixel. I know this task looks strange, but we absolutely need in this possiblity for our 2D over 3D game like engine! Please advice. I'll describe more detaily: ================ Triangle1 (texture with alpha channel) Triangle2 (texture with alpha channel) Triangle3 (texture with alpha channel) Triangle4 (texture with alpha channel) Triangle5 Triangle6 ================= It necessary to blend triangles 1-5, and moreover draw result with 50% of intensity over Triantle6. [Edited by - Malder1 on June 22, 2005 3:11:41 PM]

Share this post


Link to post
Share on other sites
The only way I can think of is to assign a texture coordinate to triangle 5 and 6 where the alpha value is 1.0 (completely visible).
But if you need to have a different texture assigned to triangle 5 and 6 then I believe you'll have to stick with the multi-pass method.
Either way you'd have to render the completely visible polygons first, and only then render the alpha blended polygons so they can get blended with the visible polygon instead of the background.

Share this post


Link to post
Share on other sites
Thank you for the response!

Do you recommend to render in two pass to texture or to device?
If render to texture it limits to texture's limiation (e.g. 2048x2048). Is it a good way to render scene into one huge texture?

Share this post


Link to post
Share on other sites
You should render directly to the default render target unless you are planning to do post-processing effects, if that is the case then render to a texture that is the same size as the backbuffer.
Having a render target that is bigger than the backbuffer will only reduce your performance and waste memory.

Share this post


Link to post
Share on other sites
Ok, thank you!

Only maybe it's earlier to say about performance, but according to first tests it seems that displaying of two triangles with texture (1024x768) on the entire screen (with two pass, first rendering to texture and then rendering to the screen) gives only 290 FPS on AthlonXP 1600+ with GeForce 4 Ti 4200 and only 50 FPS on Pentium4 3 GHz with integrated Intel graphics card.

Share this post


Link to post
Share on other sites
Keep in mind that tests using only a few polygons are in most cases (always?) inconclusive.
Altough the performance on that Intel card seems a bit too slow...

As I told you before, rendering those polygons to the texture will only be useful if you are planing on doing post-processing. If you want to do that then only render to the texture what you really need to, and then blend the texture onto the backbuffer.

example:

RenderNormalEntities();
device->SetRenderTarget( myTexture );
RenderPostProcessingEntities(); // render the entities/meshes that need post-processing
device->SetRenderTarget( defaultRenderTarget );
AddTextureIntoBackbuffer( myTexture );


Also, most post-processing stuff doesn't need to be the same size of the backbuffer, so, to gain some speed you could make the render target texture half the size of the backbuffer, or even 4 times smaller. This of course reduces quality, but it is most of the times "not noticable".

I'm not very experienced in this kind of stuff, so if anyone can explain this better than me, please do so.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I grateful for your detailed explanations!

Share this post


Link to post
Share on other sites

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