diff options
author | Alexander Romanov <a.romanov@blend4web.com> | 2015-07-14 19:48:54 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-07-14 19:52:29 +0300 |
commit | 38940662e540743a6a8da287390a02a9f3f76f6d (patch) | |
tree | f29f438c5365e2ea2699853ef9510ee676273dc7 /source/blender/render | |
parent | 107e34407d0ae4120cc7a12fdb208986a0b47d8e (diff) |
Particle Info node support for GLSL mode and the internal render.
With this patch "Particle Info" node from Cycles works in GLSL and BI
Alexander (Blend4Web Team)
Reviewers: psy-fi
Note: moved particle info to object render instance instead of
shadeinput during review - Antony.
Differential Revision: https://developer.blender.org/D1313
Diffstat (limited to 'source/blender/render')
4 files changed, 60 insertions, 4 deletions
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 7c76f0362f4..c53fb7d1153 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -178,7 +178,7 @@ typedef struct ShadeInput { int layflag, passflag, combinedflag; struct Group *light_override; struct Material *mat_override; - + #ifdef RE_RAYCOUNTER RayCounter raycounter; #endif @@ -206,6 +206,7 @@ int multitex_nodes(struct Tex *tex, float texvec[3], float dxt[3], float dyt[3], const short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex, struct ImagePool *pool); float RE_lamp_get_data(struct ShadeInput *shi, struct Object *lamp_obj, float col[4], float lv[3], float *dist, float shadow[4]); +void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]); /* shaded view and bake */ struct Render; diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index e12a1575992..3569cb2c168 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -367,6 +367,14 @@ typedef struct ObjectInstanceRen { struct RayObject *raytree; int transform_primitives; + /* Particle info */ + float part_index; + float part_age; + float part_lifetime; + float part_size; + float part_co[3]; + float part_vel[3]; + float part_avel[3]; } ObjectInstanceRen; /* ------------------------------------------------------------------------- */ diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 42c654b2c43..d271592af5f 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -69,7 +69,8 @@ #include "DNA_material_types.h" #include "DNA_meshdata_types.h" -#include "DNA_texture_types.h" +#include "DNA_texture_types.h" +#include "DNA_particle_types.h" #include "BKE_customdata.h" #include "BKE_DerivedMesh.h" @@ -1375,6 +1376,38 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, obi->psysindex= psysindex; obi->lay= lay; + /* Fill particle info */ + if (obi->psysindex >= 0) { + int psysindex = 0; + int index; + ParticleSystem *psys; + if (obi->par) { + for (psys = obi->par->particlesystem.first; psys; psys = psys->next) { + if (psysindex == obi->psysindex) + break; + ++psysindex; + } + if (psys) { + if (obi->index < psys->totpart) + index = obi->index; + else { + index = psys->child[obi->index - psys->totpart].parent; + } + if (index >= 0) { + ParticleData* p = &psys->particles[index]; + obi->part_index = index; + obi->part_size = p->size; + obi->part_age = RE_GetStats(re)->cfra - p->time; + obi->part_lifetime = p->lifetime; + + copy_v3_v3(obi->part_co, p->state.co); + copy_v3_v3(obi->part_vel, p->state.vel); + copy_v3_v3(obi->part_avel, p->state.ave); + } + } + } + } + if (mat) { copy_m4_m4(obi->mat, mat); copy_m3_m4(mat3, mat); @@ -1388,6 +1421,18 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, return obi; } +void RE_instance_get_particle_info(struct ObjectInstanceRen *obi, float *index, float *age, float *lifetime, float co[3], float *size, float vel[3], float angvel[3]) +{ + *index = obi->part_index; + *age = obi->part_age; + *lifetime = obi->part_lifetime; + copy_v3_v3(co, obi->part_co); + *size = obi->part_size; + copy_v3_v3(vel, obi->part_vel); + copy_v3_v3(angvel, obi->part_avel); +} + + void RE_makeRenderInstances(Render *re) { ObjectInstanceRen *obi, *oldobi; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 5a5e67e1e43..08304533b95 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -39,6 +39,7 @@ #include "DNA_lamp_types.h" #include "DNA_meshdata_types.h" #include "DNA_material_types.h" +#include "DNA_particle_types.h" #include "BKE_scene.h" @@ -155,9 +156,10 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) memset(&shi->raycounter, 0, sizeof(shi->raycounter)); #endif - if (shi->mat->nodetree && shi->mat->use_nodes) + if (shi->mat->nodetree && shi->mat->use_nodes) { compat = ntreeShaderExecTree(shi->mat->nodetree, shi, shr); - + } + /* also run this when node shaders fail, due to incompatible shader nodes */ if (compat == false) { /* copy all relevant material vars, note, keep this synced with render_types.h */ |