How do you use a shader on an entire GPUParticles2D system rather than the individual particles?

13 views Asked by At

I added this canvas_item shader to the CanvasItem Material:

shader_type canvas_item;

uniform float skew_amount : hint_range(-1.0, 1.0);

void vertex() {
  // Apply skewing to vertex positions
  VERTEX.x += VERTEX.y * skew_amount;
}

But that skews each individual particle...

I also tried this:

shader_type canvas_item;

uniform float skew_amount : hint_range(-1.0, 1.0);

void vertex() {
  // Define skew matrix
  mat4 skew_matrix = mat4(
      vec4(1.0, skew_amount, 0.0, 0.0),
      vec4(0.0, 1.0, 0.0, 0.0),
      vec4(0.0, 0.0, 1.0, 0.0),
      vec4(0.0, 0.0, 0.0, 1.0)
  );

  // Transform vertex to clip space (optional)
  vec4 vertex_clip = MODEL_MATRIX * vec4(VERTEX.xy, 0.0, 1.0);

  // Apply skew using skew matrix
  vertex_clip = skew_matrix * vertex_clip;

  // Set vertex position (already transformed or not)
  VERTEX = vertex_clip.xy;
}

Which also skews each particle individually.

Finally, I tried this:

shader_type canvas_item;

uniform float skew_amount : hint_range(-1.0, 1.0);

void vertex() {
  // Transform vertex to clip space
  vec4 vertex_clip = MODEL_MATRIX * vec4(VERTEX.xy, 0.0, 1.0);

  // Apply skewing using y component
  vertex_clip.x += vertex_clip.y * skew_amount;

  // Set vertex position (already transformed)
  VERTEX = vertex_clip.xy;
}

But still the same result... Each particle got skewed individually...

So, how do I skew the entire particle system? :)

0

There are 0 answers