Godot Particle Shader CUSTOM - storing more than 4 pieces of data?

229 Views Asked by At

I'm wondering if there is any way I can store more than 4 pieces of custom data between frames of a particle shader. In my shader, each particle is given a random xyz position and xyz rotation. I want these to be remembered because I want to sometimes revert the position and rotation to these in process(). This is 6 pieces of data that I will need to store. I am aware of CUSTOM which persists between frames, but this is a vec4, so it can't store 6 pieces of data.

Is there some way I can store 6 pieces (or an arbitrary amount) of data between frames?

I'm very new to particle shaders and everything 3D so any ideas or a way to do this better would be great! Thank you

1

There are 1 best solutions below

0
Manon On

You could use a matrix datatype instead of a vector one. They can go up to 4*4 matrices, so way bigger than your need.

You define them like this:

mat2 m2 = mat2(vec2(1.0, 0.0), vec2(0.0, 1.0));
mat3 m3 = mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
mat4 identity = mat4(1.0);

This snippet is extracted from godot4 documentation here