- add aov parameter in [enum zsjStandardParams]
enum zsjStandardParams { ... p_aov_spec_fresnel, p_aov_refl_fresnel, ... };
- node parameter
node_parameters { ... AiParameterStr("aov_spec_fresnel", "spec_fresnel"); AiParameterStr("aov_refl_fresnel", "refl_fresnel"); ... }; }
- use a shader data struct to pass aov_name to shader
node_initialize{ ShaderData* data = new ShaderData; AiNodeSetLocalData(node,data); }; node_finish{ if (AiNodeGetLocalData(node)) { ShaderData* data = (ShaderData*) AiNodeGetLocalData(node); AiNodeSetLocalData(node, NULL); delete data; } }; node_update{ ShaderData *data = (ShaderData*)AiNodeGetLocalData(node); data->aov_spec_fresnel = params[p_aov_spec_fresnel].STR; data->aov_refl_fresnel = params[p_aov_refl_fresnel].STR; AiAOVRegister(data->aov_spec_fresnel.c_str(), AI_TYPE_RGB, AI_AOV_BLEND_OPACITY); AiAOVRegister(data->aov_refl_fresnel.c_str(), AI_TYPE_RGB, AI_AOV_BLEND_OPACITY); }; shader_evaluate{ ShaderData *data = (ShaderData*)AiNodeGetLocalData(node); ... if (sg->Rt & AI_RAY_CAMERA) { AiAOVSetRGB(sg, data->aov_spec_fresnel.c_str(), AiColor(fresnel_spec)); AiAOVSetRGB(sg, data->aov_refl_fresnel.c_str(), AiColor(fresnel_refl)); }
- edit mtd file:
[attr aov_spec_fresnel] aov.type INT 0x05 default STRING "spec_fresnel" aov.enable_composition BOOL TRUE [attr aov_refl_fresnel] aov.type INT 0x05 default STRING "refl_fresnel" aov.enable_composition BOOL TRUE
- edit template file
self.addAOVLayout(aovReorder = [‘spec_fresnel‘, ‘refl_fresnel‘])
时间: 2024-10-09 02:40:20