|
|
|
|
Reply From: |
skysphr |
Convert the process material to a shader material. Modify the following:
uniform float initial_linear_velocity;
uniform float emission_angle; // <<<<<<<<< Add this
uniform float initial_angle;
-
Inside the vertex function, somewhere below if (RESTART || restart) {
, change the assignment of CUSTOM.x from base_angle * degree_to_rad
to (base_angle + emission_angle) * degree_to_rad
-
In the else bracket following the previous if, find where it says CUSTOM.x = base_angle * degree_to_rad;
and change it to CUSTOM.x += base_angle * degree_to_rad;
After the changes are done, you can send the shader an angle parameter by calling $Particles2D.process_material.set_shader_param("emission_angle", your_angle_in_degrees)
I hope this helps
Hm… I have only just started using Godot and, truth be told, I haven’t got the slightest clue what you are talking about. I tried changing the process material from particle material to shader material, but that only resulted in no visible particles at all.
So the first thing I’d need to figure out is how to make anything show up at all.
Also, I couldn’t find any of the code you wrote anywhere. Where would that be?
Irolan | 2021-09-21 20:42
You can convert a particle material to a shader material from the drop down menu:
This will make the particle logic editable. Upon conversion, the bottom panel should open the shader code editor.
skysphr | 2021-09-22 13:55
I found it, and it works! Thank you skysphr!
Incredible how much effort this takes, considering how simple it seems.
Also figured out how make the particles fade over time:
Add another variable uniform float alpha_fade, change line COLOR = hue_rot_mat * color_value; to COLOR = (hue_rot_mat * color_value) - vec4(0, 0, 0, CUSTOM.y * alpha_fade);
I would have NEVER guessed that CUSTOM.x, CUSTOM.y and so on are just random names and do not refer to axis.
Irolan | 2021-09-23 18:53
Yeah particle shaders and shaders in general are not quite the most documented feature around Pretty sure you could have done the alpha fade out without editing the shader though: Go to color, add a gradient texture, set the leftmost color to white, set the rightmost color to transparent.
skysphr | 2021-09-24 10:48
Nope. I would’ve done that if it were possible, but the color value is indeed just that. Can’t turn it into a gradient.
Irolan | 2021-09-24 10:57
Sorry, I meant color ramp:
skysphr | 2021-09-24 13:35
Hm… I can’t find it. It may just be me being blind, but the Particle2D’s inspector is so convoluted I have severe trouble finding the settings I need. I see there is a “Scale” above the “Color” in your screenshot. I clicked through everything I could find, I have no idea where that might be. The only “Scale” I find is under “Transform” and there’s no “Color” there.
I know I can do this if I use a ParticlesMaterial, but nowhere in the ShaderMaterial can I find any way to introduce a GradientTexture, aside from when I add a CanvasItemMaterial under “Material”. However, whatever I do there doesn’t seem to do anything.
Well, honestly, I’m done with this. I spent a week’s worth of evenings trying to figure this out, it works now, quite well actually (in no small part thanks to you), so I’m not going to try and touch it again.
I hear the particle system in Godot 4 is going to see some significant improvement over Godot 3, so here’s hoping for that. Because right now I don’t feel like touching these again.
Irolan | 2021-09-24 15:16
Well yeah it only exists there before you convert the material to a shader material. Afterwards, you’re in control of everything that particles do. However, using a simple multiplication in the shader the way you did is probably much more optimized for the GPU.
skysphr | 2021-09-24 16:41