Skip to main content
gamedev.net
🔒 Locked

mixed texture interpolation method

Started by pixelhead 0 replies 800+ views
Original Post
pixelhead
pixelhead
Hi - I don't think this is possible but I'm curious if there is a way to mix interpolation methods for a single texture lookup (wihtout custom shader). I am storing some colors in the RGB fields that needs GL_LINEAR interpolation and am storing another flag in the alpha channel that needs GL_NEAREST interpolation. I tried writing my own GLSL shader that does a GL_LINEAR texture lookup and then tries to round the alpha value. Doesn't seem to quite work though: // fVal: [0..1] float round( float fMaxRange, float fVal ) { // unnormalize value float fLabel = fMaxRange * fVal; // get decimal part of value float fFloorLabel = floor( fLabel ); float fDiff = fLabel - fFloorLabel; // round up if( fDiff > 0.5 ) fFloorLabel = fFloorLabel + 1.0; // renormalize return fFloorLabel / fMaxRange; } void main() { // lookup luminance (RGB) and label (A) vec4 vRGBA = texture3D( texture_src, vec3( gl_TexCoord[0] ) ); // do GL_NEAREST interpolation? vRGBA.a = round( 255.0, vRGBA.a ); .... } I did get my stuff to work with 2 textures but of course it's slower since it is forced to do 2 texture3D() calls. Thanks for any insight.
_the_phantom_
_the_phantom_
I don't think you've got the idea of how texture lookups work; the GL_NEAREST or GL_LINEAR dictate which data is returned from the lookup. GL_LINEAR interpolates the value from the texels surrounding the sampling point, where as GL_NEAREST forces the hardware to return a single texel which is closest to the sampling point.

There is no remapping of values, indeed they exist as floating point values in the shaders and are only remapped into the 0-255 range in the framebuffer.

Topic Locked

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

Sign in to reply to this topic.