Jump to content
Sign in to follow this  
mark

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

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
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!!

Share this post


Link to post
Share on other sites

voila :)

the geometry is just a sphere with noise, and the shader needs some work, but im happy with it and learnt a lot doing this. thanks again edward ;)

mango1e.jpg

Share this post


Link to post
Share on other sites

No prob, mark. Nice pic. So it looks like you've implemented a lot more of the mango shader now?

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×