PDA

View Full Version : Where to interpolate



Giraffpaj
12-06-2017, 04:30 AM
Im struggling with an texture ontop of a two triangles,

recently when I only had a vertex Shader and a Fragment shader, everything worked fine, with applying the texture to the square.

but Then I added the geometry shader and the square just picks up one color.

I used a varying variable to pass the texCoord between v shader and f shader, am I supposed to use a varying var from v shader to geometry shader instead or just from geometry to f shader?

Where does the interpolation usually take place?

GClements
12-06-2017, 04:43 AM
recently when I only had a vertex Shader and a Fragment shader, everything worked fine, with applying the texture to the square.

but Then I added the geometry shader and the square just picks up one color.

I used a varying variable to pass the texCoord between v shader and f shader, am I supposed to use a varying var from v shader to geometry shader instead or just from geometry to f shader?

When using a geometry shader, there is no automatic "pass through" of variables between the vertex shader and the fragment shader. For each variable which would form part of the interface between a vertex shader and a fragment shader, a geometry shader needs corresponding input and output variables and must explicitly copy the appropriate element of the input array to the output variable for each vertex.

Use of interface blocks allows you to avoid having to choose different names for input and output variables. It also means that you can add and remove the geometry shader without having to change the other shaders.