Curves in shader

Godot Version

Godot v4.6.2.stable.mono

Question

I am reading the particle shader code converted from ParticleProcessMaterial attached to GPUParticles2D. If you fill AnimatedVelocity.VelocityLimit.velocity_limit_curve property before converting the material, then you will see the following code in the shader.

// NOTE: Shader automatically converted from Godot Engine 4.6.2.stable.mono's ParticleProcessMaterial.

shader_type particles;
render_mode disable_velocity;

// ...

void process() {

    // ...

    // Limit velocity.
    if (length(final_velocity) > 0.001) {
        final_velocity = normalize(final_velocity) * min(abs(length(final_velocity)), abs(texture(velocity_limit_curve, vec2(lifetime_ratio)).r));
    }

    // ...
}

I have thought that Curve in Godot can represent any curve which is possibly non-unit but textures can hold values only in the unit range 0.0 - 1.0. Am I missing something?

Textures can have different pixel formats, including floating point which can store any value.

1 Like

Thank you, I didn’t know that!
Edit: I searched a little more. Even though the doc of CurveTexture says that its curve property “Should be a unit Curve”, it seems to support HDR and FORMAT_RF or FORMAT_RGBF (did it change in the version up Godot 3 → 4?). Thus, there should be no problem to use CurveTexture or CurveXYZTexture.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.