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

Multitexturing

Started by L. Spiro Apr 14, 2009 at 6:03 PM 4 replies 700+ views
Original Post
L. Spiro
L. Spiro
SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_CURRENT ) tells it to use the current color of the incoming fragment for texture stage 0. What if I have a texture in slot 3 and I want to take the color (or alpha) from there instead (while in texture stage 0)? // Assuming texture unit 0 is active, this would be the code in OpenGL. ::glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE3 ); // I want to do this in DirectX, but there seems not to be an equivalent to GL_TEXTURE3. No shaders. Thank you, L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
L. Spiro
L. Spiro
So? Is it impossible without shaders?


L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
ET3D
ET3D
You can't. Each stage reads its own texture. Why not use shaders?
L. Spiro
L. Spiro
To support older hardware.
To make it easy to port to other systems such as iPhone/iPod touch, which have no shaders (the engine supports both OpenGL and DirectX, hence why I need this feature).

OpenGL supports reading texture values from other texture stages. But unfortunately if DirectX does not, then I can not do it in OpenGL either.
The engine can only support features that both API’s provide.


L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Zoner
Zoner
I had a nice long post that I lost before submitting, so I'll be quick.

Years ago I worked on a rendering engine that had to deal with scaling from pre T&L hardware up to shader 1.1 hardware. I had 52 base materials in the engine. Factoring in hardware compatibilty permutations, it ended up being 133 to work on all hardware well.

Fixed function texture stage setups have a lot of rules to live by.

1) Test the texture stage setup on ALL hardware you plan to run on. You must assume they do not work at all on hardware you haven't tested. If you are lucky the driver can tell you it failed to call DrawPrimitive or DrawIndexedPrimitive successfully. If you weren't lucky it will look wrong or be missing at runtime.

2) If you make the assumption that every single texture stage state requires a texture be bound, you will save a lot of time. If you want to try and break this rule see rule #1. NVIDIA is pretty much the only company with cards that could break this rule back then.

3) If you want to make even more texture stage setups work without testing them, assume that arg1 must be 'texture' for all operations. Matrox required this, and it wasn't very pleasant to deal with this restriction.

4) Pre T&L boards (TNT, TNT2, Voodoos, Matrox anything pre-G550 (Parhelia)) cannot reference specular texture arguments in the texture stage setups at all. They just don't have an interpolator for them.

5) If you know you will be running on NVIDIA hardware, you can use their texture stage state hack to enable 2 register combiners. Not all of them, but better than not having them at all. NVIDIA specific, but handy. Finding docs on this might be difficult now, but it should still work.

6) A surprising amount of drivers lie about hardware T&L and vertex shading support. The easiest way to filter them out is to also check pixel shader support. If its missing, its emulated. Its far better to handle it yourself or even lete D3D software deal with it than the driver.
http://www.gearboxsoftware.com/
ET3D
ET3D
I don't know what kind of engine you're trying to write, but if you plan to do anything graphically impressive, you'd have to have a shader code path.

Also, if you're talking about GL_TEXTURE3, then you're talking about fixed function with 4 textures. This already rules out all fixed function ATI and NVIDIA cards. What you're trying to do might not even work on shader model 1.1-1.3 cards (NVIDIA GeForce 3,4). In short, you're left with cards with shader model 1.4 and higher, anyway.

I've also got to ask, why support D3D9 at all? If you already plan an OpenGL path, that should work for PC cards and other platforms.

Topic Locked

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

Sign in to reply to this topic.