PDA

View Full Version : Write mentalray for maya shader problem


nicholasgsa
11-16-2010, 04:40 AM
Hello everyone :
I am a beginner, I write a simple shader ,when I rendering, I get the Error "PHEN 0.3 error 051011: shader "one_color" not found ". (WindowsXP, maya 2009 ,visual studio 8)



###################################
MI :
declare shader
color "one_color" (
color "color" default 1 1 1 )
version 1
apply material
end declare
#################################
DLL :
#include <stdio.h>
#include <math.h>
#include <shader.h>

typedef struct {
miColor color;
} one_color_t;

DLLEXPORT int one_color_version(void) {return(1);}

DLLEXPORT miBoolean one_color_init(
miState *state,
one_color_t *param,
miBoolean *init_req)
{
if (!param) {
/* shader init */
*init_req = miTRUE; /* do instance inits */
} else {
/* shader instance init */
}
return(miTRUE);
}

DLLEXPORT miBoolean one_color_exit(
miState *state,
one_color_t *param)
{
if (param) {
/* shader instance exit */
} else {
/* shader exit */
}
return(miTRUE);
}


DLLEXPORT miBoolean one_color(
miColor *result,
miState *state,
one_color_t *param)
{
/*
* get parameter values. It is inefficient to do this all at the beginning of
* the code. Move the assignments here to where the values are first used.
* You may want to use pointers for colors and vectors.
*/

miColor color = *mi_eval_color(&param->color);

/*
* set shader results. ``+='' etc. is useful for shaders in shader
* lists but other shaders may need to simply assign result variables.
*/

result->r += 0.0;
result->g += 0.0;
result->b += 0.0;
result->a += 0.0;

return(miTRUE);
}
#################################


I hope to get some advice, Sorry my bad English,Hope that we can understand what I mean. :banghead:
Thanks a loooooooooooooooooooooot :cry:

haggi
11-16-2010, 07:37 AM
The code seems to be correct. If this message occurs, you should check if your shader is loaded at all if maya is started. Maya should print the loaded shader dlls in the script editor.

I suppose your shader is not loaded at all. Try to load it directly with the mentalray shader libraray tool. If it is not loaded, there may be some missing dlls, or your shader is compliled for 32bit instead for 64bit.

nicholasgsa
11-17-2010, 05:40 AM
The code seems to be correct. If this message occurs, you should check if your shader is loaded at all if maya is started. Maya should print the loaded shader dlls in the script editor.

I suppose your shader is not loaded at all. Try to load it directly with the mentalray shader libraray tool. If it is not loaded, there may be some missing dlls, or your shader is compliled for 32bit instead for 64bit.

Thank you for you reply . :D

// parsing C:/Program Files/Autodesk/Maya2009/mentalray/include/one_color.mi
// loading C:/Program Files/Autodesk/Maya2009/mentalray/lib/one_color.dll
// generating Maya nodes...
So I think shader dll is loaded. My system is a 32BIT and maya version 2009 32bit .
I am very confused what is the reason :banghead:

nicholasgsa
11-17-2010, 05:48 AM
I guess my AEtemplate problem? If so, Please everybody can provide some AEtemplate aspects of the tutorial. :shrug:

nicholasgsa
11-18-2010, 12:23 AM
Hope Everybody can help more. :bounce:

haggi
11-18-2010, 08:11 AM
AETemplates are never the reason why a shader doesnt work at all.
It could be possible that you need extern C declaration for your code:


extern "C" DLLEXPORT miBoolean one_color(...)

nicholasgsa
11-19-2010, 01:20 AM
AETemplates are never the reason why a shader doesnt work at all.
It could be possible that you need extern C declaration for your code:


extern "C" DLLEXPORT miBoolean one_color(...)


Thank you haggi, You are so great :buttrock:
Now is not reporting a mistake in MAYA. But there is a question rendered image is black and no alpha channel. :eek:

nicholasgsa
11-19-2010, 06:32 AM
Thank you haggi, You are so great :buttrock:
Now is not reporting a mistake in MAYA. But there is a question rendered image is black and no alpha channel. :eek:


Sorry, this is a very stupid mistake. Shader is working .Thank you haggi :buttrock:

CGTalk Moderation
11-19-2010, 06:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.