Jump to content
  • Advertisement
Sign in to follow this  
Waverider

OpenGL DirectX multitexture pipeline - a little help please

This topic is 4138 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've been spending that last few days getting familiar with the multitexture pipelines of OpenGL and DirectX. For what I wanted to try, it seemed OpenGL was able to handle it much easier, and I just want to make sure I'm not making DirectX more complicated than it needs to be (it already is, but still...) What I'm doing is replicating the terrain splatting in this article: http://www.gamedev.net/reference/articles/article2238.asp. I'm not really replicating the entire problem, I just want to get the first result (grass with a dirt pattern on it). All I did was grab the dirt picture, alpha map and grass picture off the page. I want to take the grass and add the dirt to it using the alpha map. I've been successful in both OpenGL and DirectX and got identical results, but look at the differences between the two: OpenGL: Please note that the textures I place at each step are independent of the operations I perform at each step (OpenGL allows you to access any texture in the pipeline at any step). Texture 0: grass. GL_DECAL, pass it on Texture 1: alpha map. Perform GL_INTERPOLATE using alpha map's alpha and the two textures' colors Texture 2: dirt. Modulate with the vertices on the polygon to apply lighting. DirectX: (DirectX is more limited in that you can only access the most recent result and the texture at the current step) Texture 0: grass. Retrieve color value. Ignore alpha. Texture 1: alpha map. Retrieve color value from result and alpha from this texture. Texture 2: dirt texture. Perform a BLENDCURRENTALPHA using the colors from the result and current texture Texture 3: nothing - just a placeholder to allow another operation. Modulate result with polygon's vertices for lighting. Does this look right? Is there an easier way to do this (in fewer steps?). Does DirectX provide a way to access any texture in the pipeline from any step? And yes, I know about the pixel shaders. Why didn't I just use that? Because I'm not there yet! Thanks for any help or insight. [Edited by - Waverider on March 21, 2007 3:44:46 PM]

Share this post


Link to post
Share on other sites
Advertisement
The Direct3D seems right. The OpenGL I don't understand. While I admit I'm not an OpenGL expert, from what I've seen of multitexturing, there's still only one texture per stage in OpenGL, and therefore the second stage, "Perform GL_INTERPOLATE using alpha map's alpha and the two textures' colors", makes sense only if the "two textures" are the grass and alpha textures. In that case you could do the same thing with Direct3D.

Share this post


Link to post
Share on other sites
There is only one texture per stage in OpenGL, but you can refer to any texture in the current pipeline when you specify arguments. When I use GL_INTERPOLATE, I'm allowed to specify elements from GL_TEXTURE_0, 1 and 2, with no required reference to GL_PREVIOUS (DirectX's equivalent of D3DTA_CURRENT). So in my OpenGL code, I'm doing the full combine in one step, and the textures can actually be submitted in any order I want as long as I set up the arguments correctly.

Anyway, thanks. There are still little qwirks I'm finding as I study more (it seems that in DirectX, color operations are limited to color elements and can't include any Alpha unless the Op type specifies. OpenGL doesn't have this limitation either). If DirectX wasn't so limited in the options at each step, I could probably pull off the combine with a single LERP operation, and then modulate with the vertex colors.

Share this post


Link to post
Share on other sites
There are modifiers available to arguments. ie: if your COLORARG1 was D3DTA_TEXTURE | D3DTA_ALPHAREPLICATE it would use the alpha, not the texture color. There is also a D3DTA_COMPLEMENT flag which does (1-value).

The texture stages pretty much offer the exact same support as pixel shader 1.1, except for "blue replicate", which isn't available except as a shader.

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!