Roberto Vicini
Roberto Vicini

Reputation: 3

Reading height values from texture in vertex shader

I have a geotiff from SRTM. I send it on GPU, in a vertex shader as a sampler2D. Thus i have it as a sampler2D uniform. All that i want is to read height data from that sampler2D (in vertex shader). I dont want use gl_Vertex.

Upvotes: 0

Views: 782

Answers (1)

Robert Rouhani
Robert Rouhani

Reputation: 14678

The feature you're looking for is called Vertex Texture Fetch.

There's an older article on the OpenGL wiki about it, but essentially you bind the texture to a texture unit, make sure the uniform sampler2D is set to the same texture unit, then call texture2D(myTex, coords) in your shader.

Your coordinates can be set up in a number of ways, but the goal is to make it simple to turn a vertex coordinate to a texture coordinate in the [0, 1] range.

Upvotes: 1

Related Questions