Can shading language iterate with information of a previous vertex

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cchipont

I’m trying to persist the vertex vec3 info to the next and I’m wondering if this is possible in shading language in godot 3.1. What type of var should it be, a uniform?

:bust_in_silhouette: Reply From: omggomb

If you want to pass information from one vertex to another during a single pass of a shader, that’s not possible since a shader is executed for each vertex in parallel.

If you want to have data you calculated in on pass available in the following pass you could take a look at particle materials. These are the only ones that can persist data between execution steps: https://docs.godotengine.org/en/3.1/tutorials/shading/shading_reference/particle_shader.html

Also you can’t write to uniforms and they are constant for a single pass, meaning during a single pass the value of the uniform will not change, no matter which vertex is being processed. If you’re looking to pass data between a vertex and a fragment shader in a single execution step, take a look at varyings. Both uniforms and varyings are a general concept of glsl shaders, so any tutorial for glsl will do.

If you only want to read different data for each vertex, you’ll need to use textures and encode the data into these.

A shader pass is basically the shader being run once for every vertex.