0 votes

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?

in Engine by (18 points)

1 Answer

+2 votes

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.

by (1,083 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.