GLSL: Stupid question about emulating fixed pipeline

Started by
1 comment, last by shodanjr_gr 16 years, 1 month ago
Im getting into GLSL, and i want to write a pair of shaders for emulating the fixed pipeline functionality. Im kinda stuck at the point when the texture coordinates are transformed inside the vertex shader. gl_TexCoord = gl_TextureMatrix * gl_MultiTextureCoordi; This is supposed to happen for every set of texture coordinates up to gl_MaxTextureCoords, right? (which i would assume varies from app to app). How am i supposed to iterate the set of gl_MultiTextureCoords from 0 to gl_MaxTextureCoords, if they arent in an array? I guess this is more of a C/C++ question than a GLSL question, but it might be that i am missing something really obvious. Thanks in advance! PS: Is there a mirror for the ShaderGen framework? 3dLabs seems to have made it disappear from their website.
Advertisement
You should only be manipulating the data that you actually need. So if your primary shader has two textures, then only manipulate the first two texture coordinates and make sure they are initialized properly in the app.

You shouldn't try to make one size fits all shaders, just make the few exclusively different shaders that you will actually need.

So the array isn't accesed via a variable and a loop. It's accessed with constants.

gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTextureCoord0;
gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTextureCoord1;

Most of your shaders will expect the texture matrix to be identity, so typically this computation can be excluded.
Quote:Original post by bzroom
You should only be manipulating the data that you actually need. So if your primary shader has two textures, then only manipulate the first two texture coordinates and make sure they are initialized properly in the app.

You shouldn't try to make one size fits all shaders, just make the few exclusively different shaders that you will actually need.


Thanks for the speedy reply :)

I understand your reasoning, and that's what i will be doing in shaders related to my actual work. But im trying to get as generic as possible in emulating fixed functionality.

Is it just not possible to do it? Or is it just considered bad coding?

This topic is closed to new replies.

Advertisement