From 38940662e540743a6a8da287390a02a9f3f76f6d Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Tue, 14 Jul 2015 18:48:54 +0200 Subject: 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 --- .../nodes/shader/nodes/node_shader_particle_info.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source/blender/nodes') 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 05f7301776f..6cc8de322af 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -26,6 +26,7 @@ */ #include "../node_shader_util.h" +#include "RE_shader_ext.h" static bNodeSocketTemplate outputs[] = { { SOCK_FLOAT, 0, "Index" }, @@ -40,6 +41,22 @@ static bNodeSocketTemplate outputs[] = { { SOCK_VECTOR, 0, "Angular Velocity" }, { -1, 0, "" } }; +static void node_shader_exec_particle_info(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out) +{ + ShadeInput *shi = ((ShaderCallData *)data)->shi; + + RE_instance_get_particle_info(shi->obi, out[0]->vec, out[1]->vec, out[2]->vec, out[3]->vec, out[4]->vec, out[5]->vec, out[6]->vec); +} + +static int gpu_shader_particle_info(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + + return GPU_stack_link(mat, "particle_info", in, out, + GPU_builtin(GPU_PARTICLE_SCALAR_PROPS), + GPU_builtin(GPU_PARTICLE_LOCATION), + GPU_builtin(GPU_PARTICLE_VELOCITY), + GPU_builtin(GPU_PARTICLE_ANG_VELOCITY)); +} /* node type definition */ void register_node_type_sh_particle_info(void) @@ -47,8 +64,10 @@ void register_node_type_sh_particle_info(void) static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_compatibility(&ntype, NODE_NEW_SHADING | NODE_OLD_SHADING); node_type_socket_templates(&ntype, NULL, outputs); + node_type_exec(&ntype, NULL, NULL, node_shader_exec_particle_info); + node_type_gpu(&ntype, gpu_shader_particle_info); nodeRegisterType(&ntype); } -- cgit v1.2.3