0 votes

Hello,

I am trying to figure out shaders lately.
I tried to alter the direction of particles stream every time it restarts. I tried to set one random number to be shared by all particles. I failed, because other than in UNIFORM, there is no place to introduce variable, where it won't be changed every frame, for every pixel, for every vertex. Like this pseudocode :

void vertex() {

uint simp_seed = uint(7);
    if RESTART : {
     VELOCITY.x  = rand_from_seed(simp_seed) }}

I want all individual particles to share one random velocity.x, but every individual particle runs its own vertex function randomizing its velocity anew. How and where should I introduce variable in shader, so I can set it unified for all instances ? Is uniform the only way ?

I run into similar problem with canvasitem shader. I wanted to set COLOR to SCREENTEXTURE when sin(TIME) was above 0.5, and at other times, set COLOR to another variable that was supposed to hold current screen color in frozen state. But because of shaders logic, COLOR,variables and screen_texture were being updated at all times, it was impossible to keep frozen COLOR like in print screen.

Godot version godot 3.2 stable
in Engine by (1,588 points)

1 Answer

+1 vote

Hi
godot does not suport transform feedback shader.

Cant you just set a uniform random number from a gd script? This would be shader-wide ... and for every particle/vertex the same.

by (3,930 points)

I know uniforms are the way to deal with it. I am just afraid this problem with random particle stream is just a trailer of more problems related to value setting unelasticity. I am very sorry to hear that there is no other way.

I actually managed to do it :)

It is possible to set value at the start of particle creation, by defining it right after the start of if (RESTART ) {
One random number can also be generated, if seed is introduced in this place.

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.