Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_particle_info.c
| Show All 34 Lines | |||||
| #if 0 /* quaternion sockets not yet supported */ | #if 0 /* quaternion sockets not yet supported */ | ||||
| { SOCK_QUATERNION, 0, "Rotation" }, | { SOCK_QUATERNION, 0, "Rotation" }, | ||||
| #endif | #endif | ||||
| { SOCK_FLOAT, 0, "Size" }, | { SOCK_FLOAT, 0, "Size" }, | ||||
| { SOCK_VECTOR, 0, "Velocity" }, | { SOCK_VECTOR, 0, "Velocity" }, | ||||
| { SOCK_VECTOR, 0, "Angular Velocity" }, | { SOCK_VECTOR, 0, "Angular Velocity" }, | ||||
| { -1, 0, "" } | { -1, 0, "" } | ||||
| }; | }; | ||||
| static void node_shader_exec_particle_info(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) | |||||
| { | |||||
| ShadeInput *shi = ((ShaderCallData *)data)->shi; | |||||
| out[0]->vec[0] = shi->part_index; | |||||
| out[1]->vec[0] = shi->part_age; | |||||
| out[2]->vec[0] = shi->part_lifetime; | |||||
| copy_v3_v3(out[3]->vec, shi->part_co); | |||||
| out[4]->vec[0] = shi->part_size; | |||||
| copy_v3_v3(out[5]->vec, shi->part_vel); | |||||
| copy_v3_v3(out[6]->vec, shi->part_avel); | |||||
| } | |||||
| static int gpu_shader_particle_info(GPUMaterial *mat, bNode *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 */ | /* node type definition */ | ||||
| void register_node_type_sh_particle_info(void) | void register_node_type_sh_particle_info(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT, 0); | 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_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); | nodeRegisterType(&ntype); | ||||
| } | } | ||||