Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:32:38 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:55:46 +0300
commitf6107af4cf4d907495e2e9c18e5866fd1d420650 (patch)
treeebac5a9d08145af572e5400c0697156797b73130 /source/blender
parentc8e661706fcdd88f1cf371f2e5e4eb76bf09fda3 (diff)
Cycles: change Index output of Hair and Particle Info to Random, in 0..1 range.
These are used for randomization, so it's convenient if the index is already hashed and consistent with the Object Info node.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_hash.h5
-rw-r--r--source/blender/gpu/intern/gpu_draw.c4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_hair_info.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_particle_info.c2
5 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_hash.h b/source/blender/blenlib/BLI_hash.h
index e849e5f8f61..8b797820722 100644
--- a/source/blender/blenlib/BLI_hash.h
+++ b/source/blender/blenlib/BLI_hash.h
@@ -63,4 +63,9 @@ BLI_INLINE unsigned int BLI_hash_int(unsigned int k)
return BLI_hash_int_2d(k, 0);
}
+BLI_INLINE float BLI_hash_int_01(unsigned int k)
+{
+ return (float)BLI_hash_int(k) * (1.0f/(float)0xFFFFFFFF);
+}
+
#endif // __BLI_HASH_H__
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 427e179f29a..d7e744951c4 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -41,11 +41,11 @@
#include "GPU_glew.h"
#include "BLI_blenlib.h"
+#include "BLI_hash.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
-#include "BLI_hash.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
@@ -1884,7 +1884,7 @@ static int gpu_get_particle_info(GPUParticleInfo *pi)
if (ind >= 0) {
ParticleData *p = &dob->particle_system->particles[ind];
- pi->scalprops[0] = ind;
+ pi->scalprops[0] = BLI_hash_int_01(ind);
pi->scalprops[1] = GMS.gscene->r.cfra - p->time;
pi->scalprops[2] = p->lifetime;
pi->scalprops[3] = p->size;
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index d589c8765e6..5fe14e76a90 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -190,10 +190,10 @@ void geom(
void particle_info(
vec4 sprops, vec3 loc, vec3 vel, vec3 avel,
- out float index, out float age, out float life_time, out vec3 location,
+ out float random, out float age, out float life_time, out vec3 location,
out float size, out vec3 velocity, out vec3 angular_velocity)
{
- index = sprops.x;
+ random = sprops.x;
age = sprops.y;
life_time = sprops.z;
size = sprops.w;
diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.c b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
index 5fe74976c08..6a15c59aa5b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_hair_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.c
@@ -33,7 +33,7 @@ static bNodeSocketTemplate outputs[] = {
{ SOCK_FLOAT, 0, N_("Thickness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, N_("Tangent Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
/*{ SOCK_FLOAT, 0, N_("Fade"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},*/
- { SOCK_FLOAT, 0, "Index" },
+ { SOCK_FLOAT, 0, N_("Random") },
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
index 5f0d81e98c9..721d470b467 100644
--- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c
+++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c
@@ -29,7 +29,7 @@
#include "RE_shader_ext.h"
static bNodeSocketTemplate outputs[] = {
- { SOCK_FLOAT, 0, "Index" },
+ { SOCK_FLOAT, 0, "Random" },
{ SOCK_FLOAT, 0, "Age" },
{ SOCK_FLOAT, 0, "Lifetime" },
{ SOCK_VECTOR, 0, "Location" },