سؤال

When using OpenGL 1.4 fixed-function multitexturing, is the output of every texture stage clamped to [0, 1] before being passed onto the next stages?

The spec says (page 153):

If the value of TEXTURE_ENV_MODE is COMBINE, the form of the texture function depends on the values of COMBINE_RGB and COMBINE_ALPHA, according to table 3.24. The RGB and ALPHA results of the texture function are then multiplied by the values of RGB_SCALE and ALPHA_SCALE, respectively. The results are clamped to [0, 1].

But in my test, that didn't happen. My texture environment for the RGB components is:

  • Stage 1: subtract GL_CONSTANT from GL_TEXTURE, where the entire texture is black, and the GL_CONSTANT color is (.5, .5, .5, 1.0)
  • Stage 2: Add GL_TEXTURE to GL_PREVIOUS, where the texture is a test rainbow.

The output gets visibly darker the brighter I make Stage 1's GL_CONSTANT color.

Is there some sort of state I can enable to get the clamping I expect?

هل كانت مفيدة؟

المحلول

Odds are good that it's a driver bug. Since fixed-function hardware doesn't exist anymore, it's all emulated in shaders. And since clamping is not default behavior in shaders, they would have to remember to clamp between combine stages. And if they forgot to test it... oops.

There's not much you can do, either way. If your implementation doesn't clamp like the spec says it should, the best you can do is file a bug report on it.

نصائح أخرى

Yes. In the spec, chapter 3.8.13, it says:

Cf and Af are the primary color components of the incoming fragment; Cs and As are the components of the texture source color, derived from the filtered texture values Rt, Gt, Bt, At, Lt, and It as shown in table 3.21; Cc and Ac are the components of the texture environment color; Cp and Ap are the components resulting from the previous texture environment (for texture environment 0, Cp and Ap are identical to Cf and Af , respectively); and Cv and Av are the primary color components computed by the texture function.

All of these color values are in the range [0;1] . The texture functions are specified in tables 3.22, 3.23, and 3.24 .

I would not know about your particular case but that answers your first (and title) question.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top