There is a shader that sets the color of a polygon - a triangle, but I want a texture instead of a color, it turns out I need to enter my texture instead of the output color? How is this done if I have texture coordinates?

Here is a fragmentary shader:

#version 330 core in vec3 normal_modelspace; in vec3 vertex_modelspace; out vec3 color; uniform vec3 light_worldspace; void main() { vec3 n = normalize(normal_modelspace); vec3 l = normalize(light_worldspace - vertex_modelspace); float cosTheta = clamp( dot( n, l), 0,1 ); float ambient = 0.05; color = vec3(0.0,1.0,0.0) * (cosTheta + ambient); } 
  • You already asked exactly the same thing ... Stackoverflow.com/questions/785279 - Kromster
  • You need to load the texture into OpenGL, pass its ID to the shader, get a texel from the shader using the sampler and display it. Look at some lesson on texturing in OpenGL - everything will be detailed there. - Kromster
  • you have no texture coordinates in the shader, add them and everything will work out. - FatherOfFiveChildren

0