Jump to content

cant reproduce VEX code with VOPS


Recommended Posts

Hi all,

i have happily reproduced the base colour of the renderman mango shader from a siggraph paper.

the important lines are:

	vector i = noise(0.5*sin(2*PI*s),2*t);
	vector basecolor = cspline(1,grn,ylw,org,red);
	vector nml = frontface(normalize(N), I);

	Cf = amb * ambient();
	Cf += basecolor * i * diffuse(nml);
	Cf += spec * phong(nml, -normalize(I), 1.0/rough);

and a sample render is below:

mango1a.jpg

just to clarify that i understand, i provides a smooth noise distribution across the object, and basecolor effectively provides a ramp with the supplied colours?

so i thought id try to reproduce it in VOPS, as i would rather build shaders in there, all things being equal. but it seems quite limited? no noise() or sin() functions for a start. so i used the inline VOP to generate what is generated by i in the code above.

the inline code noise(0.5*sin(2*PI*s),2*t); is not working, it becomes black when wired into the diffuse channel of the lighting model. i tried to debug and with a basic noise(s,t); the diffuse is just constant grey, no noise. i'm sure either should show the noise in greyscale on the object.

when i and basecolor are multipled then wired into the diffuse of the lighting model, again it is black.

when wired into the diffuse channel of the lighting model, the spline spline(1,grn,ylw,org,red); is just a constant orange color, presumably because the noise is not working.

very confused !!

i think i understand what the shader does in the VEX code, but i cant see why it isnt working in the VOP network. a link to a pic of the network is below if it helps:

Mango VOP network

(i have tried getting s and t from global variables, as well as shading layer as you can see here (which is what worked for the VEX code version))

any ideas? i have none left.

thanks for reading :D

Link to comment
Share on other sites

Here's whay I found trying to do this:

1. Your posted code is wrong. The first parameter to cspline should be i, not 1.

2. sin(), cos(), etc are in the Trig. VOP

3. noise() which is perlin noise is simply the Periodic Noise VOP. It appears that it doesn't provide the 2D signature but can be faked by putting it into a vector and leaving one of the components 0. I compared this to using a 2D noise() function via the inline vop and it didn't seem to make a difference.

mango.hipnc.gz

Link to comment
Share on other sites

hi edward, thanks for that!

trig VOP - doh i missed that one

will check out periodic noise :)

seems to be an error with the file you posted, i cant extract it (and it seems to be 180mb inside the archive). hope this isnt just my system..

cheers :)

Link to comment
Share on other sites

ok got it extracted !!!

i was doing it quite wrong.. i see now. a much more subtle effect on the colour gradient which is more realistic i think!

thanks a lot edward, appreciated :)

(i had to use shading layer for my S and T, otherwise it applied the shader per polygon which is interesting.. but doesnt matter - its working =)

ok now i'll fine tune the colour and move onto adding some spots!!

Link to comment
Share on other sites

yeah - base layer, spots and bruises. i'm pretty sure its correct, but have no pic of the prman version to compare.

vops seems really powerful (got a bit stuck on the if-then block but no probs =) there was nothing in the prman code i couldn't do in vops.

really this is just layers of different color, and different sized noise.. although the real test will be me doing this for another fruit and not just copying some larry gritz code!

i think the hard part will be learning the mathematics behind tuning the noise, to get hard/soft edges, different shapes etc. - i still dont know how he came up with noise(0.5*sin(2*PI*s),2*t) for example :D i suppose i vaguely understand what it does - so its a start.

anyway i'll post further pics if i have some success! cheers :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...