PDA

View Full Version : help me , what is wrong with my codes ?


amadou
March 13th, 2006, 08:26
#include <stdio.h>
#include <math.h>
#include "shader.h"

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

DLLEXPORT miBoolean ym_Noise3(
miColor *result,
miState *state,
void *param)
{
miVector *myp ,*mypt;
miScalar myvalue;

mi_point_to_object(state,mypt, &state->point);
myvalue = mi_noise_3d(mypt);

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

return(miTRUE);
}

==============================
I want to write a procedural texture that using noise3d taking intersection point .
I compile it , link it and loade it in Maya .
I create an node of this type .
If I connect the out value to the input attribute named "diffuse" of a mib_illum_lambert node , maya crash !!!!!!!
why ? what is wrong with my shader ?
please ,help me .

Puppet
March 13th, 2006, 12:24
I suppose you should use this code:

miVector *myp;
miVector mypt;
miScalar myvalue;

mi_point_to_object(state, &mypt, &state->point);

bart
March 13th, 2006, 15:34
As Puppet notes, you have to actually allocate the space for your vector mpyt, and then create a pointer to it (&mpyt).

If you create just the pointer (mypt *), then there is no space allocated for it, before it is used. Pointers like that are usually used to point to pre-allocated data.

BTW, you might have to do the same thing for myp, wherever you eventually might use it.

amadou
March 14th, 2006, 14:54
oh , thank you very much .

I get it now . After I ask this question , I do some test . I find that if I init the pointer when I declare it , it works well .
so as you say , it have allocated the true space in memory .
am I right ?

BTW , this rule is the basic rule or it is just in writing MR shaders ?
I can't remember the details of programming pointer type .