ok, now we're a step closer...
I didn't realize that I need to create the light shader within the c++ source. That's clear now.
The thread I've posted in my last post was just a help to understand the declaration and definition of parameters and functions. it has nothing to do with the light itself.
NOW, i have managed to create everything and to attach the shader to the light and the light (for this test an area sphere) is visible in the scene but doesn't illuminate anything. Pretty weird. Here is the code:
Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Parameters
miColor l_color_eva = *mi_eval_color(¶ms->color);
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Declaration
miTag cache_decl = mi_api_name_lookup( mi_mem_strdup("light_shader") );
if(!cache_decl) //maybe already cached
{
miParameter *out_color = mi_api_parameter_decl(miTYPE_COLOR,mi_mem_strdup("out_color"),NULL);
miParameter *l_color = mi_api_parameter_decl(miTYPE_COLOR,mi_mem_strdup("l_color"),NULL);
miFunction_decl *func_decl = mi_api_funcdecl_begin(out_color,mi_mem_strdup("light_shader"),l_color);
func_decl->version = 1;
miTag func_decl_tag = mi_api_funcdecl_end();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Definition
miTag func_def;
if(mi_api_function_call(mi_mem_strdup("light_shader")))
{
mi_api_parameter_name(mi_mem_strdup("l_color"));
mi_api_parameter_value(miTYPE_COLOR,&l_color_eva,NULL,NULL);
func_def = mi_api_function_call_end(miNULLTAG);
if(func_def){
//mi_api_shader_add(mi_mem_strdup("lshader"), func_def);
mi_warning("defining output shader");
}
else
{
mi_warning("problems defining output shader");
return miFALSE;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// LIGHT
miVector org;
org.x = 0;
org.y = 0;
org.z = 0;
miLight *oLight = mi_api_light_begin(mi_mem_strdup("test"));
oLight->type = miLIGHT_ORIGIN;
oLight->origin = org;
oLight->visible = miTRUE;
oLight->area = miLIGHT_SPHERE;
oLight->primitive.sphere.radius = 1;
//mi_api_function_append(oLight->shader,func_def);
miTag lshader = oLight->shader;
oLight->shader = func_def;
oLight->shader = mi_api_function_append(oLight->shader, lshader);
return(mi_geoshader_add_result(result,mi_api_light_end()));
return( miTRUE );
}
The shader itself is just a color output! But I think this should be enough information to the light so it can shine.
One other thing is the output that mr gives at render time:
Code:
' INFO : API 0.3 debug: entering scope "_0@35:464::"
' INFO : LIB 0.3 debug: registry lookup: "light_shader" -> "light_shader"
' INFO : PHEN 0.3 debug: add shader 0x477 with decl 0x465
' WARNING : PHEN 0.3 warn : defining output shader
' INFO : API 0.3 debug: begin light test
' INFO : API 0.3 debug: leaving scope "_0@35:464::"
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x47b, DAG level 6
' INFO : SCEN 0.3 vdebg: TCB: No instances for a given path to '_0@35:464::test'
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x46a, DAG level 2
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x473, DAG level 4
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x472, DAG level 6
' INFO : SCEN 0.3 vdebg: TCB: No instances for a given path to 'grid/Polygon Mesh(0)'
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x41b, DAG level 2
' INFO : SCEN 0.3 debug: calling traversal function 07A20F00 for instance 0x41f, DAG level 4
' INFO : SCEN 0.3 vdebg: TCB: No instances for a given path to 'Point/Light'
' INFO : PHEN 0.3 debug: calling exit shaders
' INFO : API 0.3 vdebg: "_0@2c:44f::1" has wrong scope, current scope is ""
' INFO : API 0.3 vdebg: "_0@2c:44f::0" has wrong scope, current scope is ""
' INFO : API 0.3 vdebg: "_0@2c:44f::test" has wrong scope, current scope is ""
' INFO : PHEN 0.3 debug: delete shader 0x4c6
' INFO : PHEN 0.3 debug: add shader 0x4c6 with decl 0x465
' INFO : PHEN 0.3 debug: delete shader 0x4c6
' INFO : SCEN 0.3 info : 1 geometry leaf instance (1 scheduled, 0 cached, 0 shared)
' INFO : SCEN 0.3 info : 2 light leaf instances
What does this mean? Can someone explain to me what exactly is meant by this output.
Thanks in advance...