Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

What does the texture() function in GLSL do?

$
0
0

Hello All

I'm currently learning GLSL, and I went through the tutorial on shaders from the OF website (great tutorial by the way). In several of the example shader programs, a texture is passed to the shader, where it comes in as a sample2DRect.

In some of the vertex shaders, this line or a similar one is present:

uniform sampler2DRect tex0;
in vec2 texcoord;
....

void main() {
    vec4 position = texture(tex0, texcoord);
    ...
}

What exactly does the texture() function do? I can see that it is taking in a sampler2DRect and vec2 as parameters and returning a vec4, but I don't understand what it really does. Is it simply combining the 2d vector with the texture?


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>