Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tutorials/shaders/shader_reference/spatial_shader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,16 @@ However, the value passed to the fragment shader still comes from ``VERTEX``.
For instancing, the ``INSTANCE_CUSTOM`` variable contains the instance custom data. When using particles, this information
is usually:

* **x**: Rotation angle in radians.
* **y**: Phase during lifetime (``0.0`` to ``1.0``).
* **z**: Animation frame.
* **x**: Current rotation angle in radians.
* **y**: Time the particle has been active in seconds.
* **z**: Current animation frame.
* **w**: Particle lifetime in seconds.
Comment thread
Calinou marked this conversation as resolved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. I don't know how to easily phrase it, but it contains the randomness of the lifetime.

So for example a certain particle may have 0.9 in CUSTOM.w, meaning the particle lives for 90% of the specified lifetime. So when this particle dies, CUSTOM.y will contain 0.9. Dividing Y by W gives the correct result.

I count on you all to figure out a phrasing for this, i have no idea how to make it intuitive.


To get the lifetime phase (ranging from ``0.0`` to ``1.0``), use ``CUSTOM.y / CUSTOM.w``.

Additionally, ``USERDATA1`` is defined with the following value in the built-in :ref:`class_ParticleProcessMaterial`:

* **w**: Accumulated angle from angular velocity in radians, as applied by the angular velocity texture.

This allows you to easily adjust the shader to a particle system using default particle material. When writing a custom particle
shader, this value can be used as desired.
Expand Down
Loading