Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectX multitexture pipeline - a little help please

Started by Waverider Mar 21, 2007 at 3:05 PM 3 replies 2.5k views
Original Post
Waverider
Waverider
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]
It's not what you're taught, it's what you learn.
ET3D
ET3D
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.
Waverider
Waverider
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.
It's not what you're taught, it's what you learn.
Namethatnobodyelsetook
Namethatnobodyelsetook
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.
Waverider
Waverider
Ah thanks for that. I'm sure it will come in handy.
It's not what you're taught, it's what you learn.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.