diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-01-25 15:25:33 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-01-25 19:14:20 +0300 |
commit | c813a1b3583e9a3bf17c75e16995ebadb046361a (patch) | |
tree | 8f5405c7f0a05aef8d43342764fc0a42ef577a54 /source/blender/draw/intern/shaders | |
parent | eab066cbf2da1fdb8162d9ed814a9491f9acf02d (diff) |
Cycles: add Point Info node
With (center) position, radius and random value outputs.
Eevee does not yet support rendering point clouds, but an untested
implementation of this node was added for when it does.
Ref T92573
Diffstat (limited to 'source/blender/draw/intern/shaders')
-rw-r--r-- | source/blender/draw/intern/shaders/common_pointcloud_lib.glsl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl index 2da16d3f6a9..dd725ad327f 100644 --- a/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl +++ b/source/blender/draw/intern/shaders/common_pointcloud_lib.glsl @@ -22,13 +22,22 @@ mat3 pointcloud_get_facing_matrix(vec3 p) return facing_mat; } +/* Returns world center position and radius. */ +void pointcloud_get_pos_and_radius(out vec3 outpos, out float outradius) +{ + outpos = point_object_to_world(pos.xyz); + outradius = dot(abs(mat3(ModelMatrix) * pos.www), vec3(1.0 / 3.0)); +} + /* Return world position and normal. */ void pointcloud_get_pos_and_nor(out vec3 outpos, out vec3 outnor) { - vec3 p = point_object_to_world(pos.xyz); + vec3 p; + float radius; + pointcloud_get_pos_and_radius(p, radius); + mat3 facing_mat = pointcloud_get_facing_matrix(p); - float radius = dot(abs(mat3(ModelMatrix) * pos.www), vec3(1.0 / 3.0)); /* TODO(fclem): remove multiplication here. Here only for keeping the size correct for now. */ radius *= 0.01; outpos = p + (facing_mat * pos_inst) * radius; |