Jump to content
  • Advertisement
Sign in to follow this  
Naruto-kun

Blending Surfaces (without using vertices)

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

Hi guys

 

Is there a way to blend or "layer" multiple IDirect3DSurface9 images on top of eachother using alpha blending and if so, how would i go about it? I would like to avoid having to create vertex buffers and applying textures to them as such since this is a 2D not a 3D operation.

 

Thanks

JB

Share this post


Link to post
Share on other sites
Advertisement

I guess you must do exactly what you don't want to do. Create a vertex buffer defining a full screen quad and a pixel shader defining the blending operation you want to perform.

 

What is the usage of the final result?

 

Cheers!

Share this post


Link to post
Share on other sites

I don't see "2D not 3D" as a valid reason to not use vertex buffers and textures here.  There's absolutely nothing about 2D that precludes their use.  Perhaps you're drawing using StretchRect calls instead of DrawPrimitive?  If so, then maybe you should look at the ID3DXSprite interface for an alternative, or else use vertex buffers and textures with the D3DFVF_XYZRHW option in an FVF (or D3DDECLUSAGE_POSITIONT in a declaration) to specify 2D coords without needing to worry about transforms (you can also use DrawPrimitiveUP to totally avoid vertex buffers if you wish - generally not recommended but good enough for simple programs where absolute performance isn't a requirement).

 

StretchRect itself can't do alpha blending; it merely transfers the contents of one surface to another.  You can't use a surface in a shader; you need to use textures.  So if you're using surfaces and StretchRect then you need to get away from that.

Share this post


Link to post
Share on other sites

The reason i want to avoid vertex buffers is because this blended surface is going to become part of a single texture and all this has to happen offscreen before i apply the texture to the scene. However since you say i can use textures with pixel shaders, you say it is possible to blend multiple textures with a pixel shader into 1 texture surface? Are there any examples of this?

Edited by Naruto-kun

Share this post


Link to post
Share on other sites

The reason i want to avoid vertex buffers is because this blended surface is going to become part of a single texture and all this has to happen offscreen before i apply the texture to the scene.

 

You can draw to an offscreen surface, but any kind of drawing under D3D9 requires vertex buffers or at least using Draw...UP commands where you can leave the vertex buffer management for the API. 

 

Cheers!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!