[osg-users] problem setting texture min/mag filter

antiro black antiro42 at gmail.com
Tue Feb 20 01:38:44 PST 2018


Hi,

As far as I can tell it does not seem to be rendering related, the shader is really sampling data from the texture that was never in the original image. A summary of my experiments:

Input is an image which is half red (255,0,0) and half black (0,0,0) and it is set as a texture for the shader. min/mag filter is set to nearest.

1: Shader sampling this texture and coloring a bigger output texture with whatever it samples -> result: half red, half black output but the halves are separated by a dark red line (as if locations sampled in between the red and black pixels have returned an _unweighted_ average of the two colors)

2: Same shader, but input texture uses min/mag filter of linear -> result half red/half black output but now separated by a gradient (the expected _weighted_ linear interplation when sampling in between black/red pixels)

3: min/mag filter back at nearest now. To verify that it is not a rendering artifact I changed the shader to output red/black when the input is red/black but purple if the input is something else -> result: the output now has a purple line separating the red/black halves, so clearly I am sampling data that is not in the original image.

It is my understanding that a nearest filter should result in the value of the _single_ nearest pixel being returned when sampling a location in a texture, but my experiments seem to point at an unweighted average of the neighboring pixels values?

Thank you!

Cheers,
antiro

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72966#72966







More information about the osg-users mailing list