texture1d

Texture mapping using a 1d texture with OpenGL 4.x

ぃ、小莉子 提交于 2020-01-02 07:26:12
问题 I want to use a 1d texture (color ramp) to texture a simple triangle. My fragment shader looks like this: #version 420 uniform sampler1D colorRamp; in float height; out vec4 FragColor; void main() { FragColor = texture(colorRamp, height).rgba; } My vertex shader looks like this: #version 420 layout(location = 0) in vec3 position; out float height; void main() { height = (position.y + 0.75f) / (2 * 0.75f); gl_Position = vec4( position, 1.0); } When drawing the triangle I proceed this way (I

Texture mapping using a 1d texture with OpenGL 4.x

强颜欢笑 提交于 2019-12-06 03:48:27
I want to use a 1d texture (color ramp) to texture a simple triangle. My fragment shader looks like this: #version 420 uniform sampler1D colorRamp; in float height; out vec4 FragColor; void main() { FragColor = texture(colorRamp, height).rgba; } My vertex shader looks like this: #version 420 layout(location = 0) in vec3 position; out float height; void main() { height = (position.y + 0.75f) / (2 * 0.75f); gl_Position = vec4( position, 1.0); } When drawing the triangle I proceed this way (I removed error checking form code for better readability): glUseProgram(program_); GLuint samplerLocation