c++ - How to implement a lambert shader using Arnold API? (for beginners) -


how implement lambert shader using arnold api? (for beginners)

this example implement constant shader. don't know how implement lambert shader using arnold api (integrate light , samples).

#include <ai.h> #include <cstring>  ai_shader_node_export_methods(lambertmethods);  enum lambertparameters {p_albedo};  node_parameters {     aiparameterrgb("albedo", 1.0f, 1.0f, 1.0f); }  node_loader {     if (i > 0) return false;     node->methods = lambertmethods;     node->output_type = ai_type_rgb;     node->name = "lambert";     node->node_type = ai_node_shader;     strcpy(node->version, ai_version);     return true; }  node_initialize {}  node_update {}  shader_evaluate {     atcolor albedo = aishaderevalparamrgb(p_albedo);     sg->out.rgb = albedo; }  node_finish {} 

loop on lights in scene.

shader_evaluate {     atcolor albedo = aishaderevalparamrgb(p_albedo);     atcolor diffuse = ai_rgb_black;     ailightsprepare(sg);     while (ailightsgetsample(sg)) {         if (ailightgetaffectdiffuse(sg->lp)) {             float ldotn = aiv3dot(sg->ld, sg->n)             diffuse += albedo * sg->li * sg->we * ai_oneoverpi * max(0, ldotn);         }     }     sg->out.rgb = diffuse; } 

source: understanding gi basic shader


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -