PDA

View Full Version : PhongE source code?


Shaderhacker
08-05-2004, 01:01 AM
All:

I'm trying to implement the PhongE shader that is in Maya's Hypershade. I need to know how to factor in the roughness and highlight_size variables into the conventional phong lighting equation. I figured out the whiteness parameter but need some help with how the roughness and highlight_size would play.

Here's my guess:

(R * V)^ (roughness * highlight_size)

I know this isn't correct because both roughness and highlight_size range between 0-1.

-M

Nicool
08-05-2004, 08:27 PM
You may know it better than me, but let's have a look at renderman (bmrt for instance) sl shader source codes. You may find the function for a phongE. Just a thought :sad:

Shaderhacker
08-06-2004, 05:37 PM
You may know it better than me, but let's have a look at renderman (bmrt for instance) sl shader source codes. You may find the function for a phongE. Just a thought :sad:
Where would I find such SL source codes?

-M

Nicool
08-08-2004, 04:31 PM
Hi !

You can downlaod a renderman complient renderer package (such as BRMT, 3dlight, Acqsis...) in order to look at the shaders sources (do not look at the uncompiled versions of open soruces projects, but right in the renderer directories). Search for *.sl

Otherwise, you can find online a lot of renderman shaders sources. Here are some *.slim http://www.highend3d.com/renderman/shaders/ SLIMs are renderman shader with interface infos so as to be used in a render tree. Search in the source the for the sl shader component (leaving all interface features).

And a lot of contacts and sl shaders sources here : http://www.renderman.org/RMR/index.html

Feel free to ask me for more infos :thumbsup:

Shaderhacker
08-09-2004, 09:50 PM
Thanks for the help but the Renderman shaders on Highend3d.com don't really simulate what this PhongE shader does in Maya. Hmm...I wish I could get that info from someone at Alias Wavefront.


-M

playmesumch00ns
08-10-2004, 10:33 AM
The PhongE's most likely Schlick's fast method (god knows why they called it PhongE)

The code's the same as phong, except you replace the
exp( R.V, n );
bit with
(R.V)/(n-n*(R.V)-(R.V));

obviously you'll want to precalculate R.V....

Shaderhacker
08-10-2004, 05:51 PM
Actually there has to be more to it than those variables. I'm trying to figure out these variables that Maya uses to control the Phong.


Roughness - (0:1) we obviously know this is the factor which acts as the exponent. Probably used in a 1 / roughness, but I'm not sure how they are able to take it to zero (which should give an error).

Highlight Size - (0:1) again an attribute that seems to control the outer rim of the highlight. I am curious as to how this fits into the phong equation. Perhaps a multiplier of the exponent roughness?

Whiteness - (Color) I know what this does. I can use a interpolation function between white and the color of the material to get this value and then multiply it by the specular color.

So, that leaves the roughness and highlight size. With roughness, I just want to know how they have it going to zero if they are using 1 / roughness as the exponent.

-M

playmesumch00ns
08-11-2004, 08:08 AM
I think you answered your own question there.

Do you have to match it exactly for some reason? I'm pretty sure that's what they're using, so it's just a case of tweaking the numbers.

Shaderhacker
08-13-2004, 05:01 PM
I think you answered your own question there.

Do you have to match it exactly for some reason? I'm pretty sure that's what they're using, so it's just a case of tweaking the numbers.Not really. 2 multipliers isn't what's really being done in the PhongE shader. If you adjust both parameters, you can see a difference. If they were directly multiplied together, you would just get a scaling of the highlight. There seems to be an inner and outer rim to the phong light where the roughness and highlight size control it.

I'll test this to be sure.

-M

Shaderhacker
08-25-2004, 01:49 AM
Well, after some digging around in books, I found the solution to the PhongE shader in Maya. I've implemented it and tested it already and it looks very similar to Maya's shader. The problem was finding out how to adjust the sharpness of the highlight. As it stands, the parameter "roughness" adjusts the size of the highlight, but not the sharpness or the falloff of the highlight. Going through my old Advanced Renderman book, gave the solution.:) If anyone is curious, it's on page 231. It uses a smoothstep function to control the falloff. Very impressive actually.;)

-M

jeremybirn
08-25-2004, 02:38 AM
On the highlight size vs. roughness issue, be sure to test your shader with a roughness of about 2 to see if it matches the almost cartoonish output that Maya's PhongE gives.

On the whiteness vs. specular color issue, also note that whiteness influences specular highlight colors but not reflections, whereas specular color also tints the reflections. (I know that may sound backwards, but that's the way it is when you test it.)

-jeremy

Shaderhacker
08-25-2004, 05:38 PM
On the highlight size vs. roughness issue, be sure to test your shader with a roughness of about 2 to see if it matches the almost cartoonish output that Maya's PhongE gives.

On the whiteness vs. specular color issue, also note that whiteness influences specular highlight colors but not reflections, whereas specular color also tints the reflections. (I know that may sound backwards, but that's the way it is when you test it.)

-jeremy
Jeremy,

Impressive. The highlight size is actually the "roughness" factor in the Phong lighting model and the roughness attribute is actually the "sharpness" in the glossy shader in Renderman. This is clearly backwards!

I have the whiteness affecting the specular color. I use a different method for affecting reflectivity.

So, in short:

roughness (in Maya) = sharpness (in my shader)
highlight size (in Maya) = roughness (in my shader)

-M

CGTalk Moderation
01-18-2006, 09:00 PM
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.