Using a shader on the whole GPUParticles2D system rather than the individual particles

Godot Version

4.2

Question

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? :slight_smile:

interesting shader you are working with, but i fail to understand what do you mean by skew whole gpu particle2d

i tried 2 of the shader you tested with at my end
image
image
based on the blue rectangle it should be skewing the gpuparticle2d

if possible, provide what it should look like

No skew:

Wrong skew with shader (the particle is skewed before other operations, like angular velocity):

Desired effect (everything is skewed as a whole after other operations, like angular velocity):

the last one is basically the first one but skewed with node2d’s skew?

Yes, the last one is the first one with skew. Those examples aren’t done with GPUParticle2D. I just did those to show what I mean.

Bumpsie