Jump to content

Car Shader


priel

Recommended Posts

I'm fairly certain that there *is* a color shift implicit in fresnel (related to wavelengths). The overall result is that reflections at grazing angles have the colour of the source (the thing being reflected), whereas normal reflections (along the surface normal) are tinted by the surface color. See "Computer Graphics" by Foley & van Dam -- the details are explained somewhere in there I think.

well, yes... but if I add (screen, whatever) reflection fraction (properly weighted by fresnel) to diffuse fraction, do I get " tinted reflection? (tinted by underlaying surface most along normals less at grazing angles). That what I ment to say. These white rolloffs - seam to be just b/w fresnel added to surface. That was my supposition.

thanks anyway for comments ;)

Sy.

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

well, yes... but if I add (screen, whatever) reflection fraction (properly weighted by fresnel) to diffuse fraction, do I get " tinted reflection?

No, it doesn't happen automatically; you have to do the color shift by hand (you have to blend the color-shifted source before you "add, screen, whatever"). A simple approach is to mix between tinted and un-tinted based on the two Fresnel reflectivities: the one at current incidence (say, theta) and the one at normal incidence. Here's some untested pseudocode of what I mean:

float  Fth	= ...;   // Fresnel kr at theta (current incidence)
float  F0	 = ...;   // Fresnel kr at zero (normal incidence)
vector Cenv   = ...;   // the source color to be reflected
vector Calb   = ...;   // the surface color or albedo
float  Kshift = ...;   // how much color shifting to do (a dimmer)
vector out	= Cenv;  // final result
// then...
if(Kshift>0) {
   // normalize shift to the [F0,1] range
   float Ksh = mix(0, max(Fth-F0,0.0)/clamp(1.0-F0,0,1), Kshift);
   // mix based on the calculated shift weight
   out = Fth*mix(Cenv*Calb,Cenv,Ksh);
} else {
   out = Cenv*Fth;
}

Is that kind'a what you were talking about?

Link to comment
Share on other sites

Mario,

thank you a lot for explnation.

I think I've finished my humble car shader - I used Stu's shader for the base + added a couple of features, like env.map, bump layer, flake layer and such. Nothing fancy ofcource, I'll try to upload the source and some nifty teapot renders the next week. (this GPRS sucks.)

Link to comment
Share on other sites

... but got render artifact which generated by aanoise.

If someone know how to solve this problem, I would buy you a beer. ;)

... post-1266-1161254280_thumb.jpg

It can be something difficult the guys have suggested but I assume the problem may be likely caused by math operations that you use to process your noise

Link to comment
Share on other sites

A couple of quick comments:

1. Those little white squares look very much like NaN's ("not a number") to me; and I really doubt that aanoise is generating them. Run the vex profiler and enable the check for NaN's with "mantra -V P"; see if it reports any.

2. If there are NaN's, then start stripping the shader layer by layer -- look for potential division-by-zero, exponentials with wild parameters, uninitialized variables, roots of negative numbers (though these may be checked internally), etc. Repeat until all NaN's are gone, but leave the profiler up because some of these may only show up at certain angles -- and if that is the case, then I would very much suspect your reflectance code (BRDF), or any other angle-dependent portion of the shader.

It can be something difficult the guys have suggested but I assume the problem may be likely caused by math operations that you use to process your noise

post-1266-1161413605_thumb.jpg

post-1266-1161413634_thumb.jpg

Link to comment
Share on other sites

Hi Mario and MADjestic, you guys are absolutely right. It wasn't caused by aanoise, it caused by an unexpected big number color value which i didn't notice at all.

Problem is solved. I owe u guys a beer. Send via Fedex or DHL?( :P just kidding.)

Here is the render and vopnet. It isn't an accurate car shader. gotta test render with some hdri map. Still far away from what i expected. Gotta make those flakes look glittering, u guys have any idea?

post-1266-1161413605_thumb.jpgpost-1266-1161413634_thumb.jpg

Oh yea, gotta animate the camera and render out an image sequence to check for anti-aliasing.

Thanks, I have learned along with your reply.

I like the way your flakes look, Jordan

However I see that you use global P for your AANoise position - this way the noise will flow when your car or camera moves - I would recommend pass the P through Rest Position VOP or add Shading Layer parameter VOP to noise position - this way the noise will stick to the object space.

By the way - can you tell me the params of your AANoise? (frequency and type - or anything you've changed), colormix4, 5, 6 and Edgefalloff2? Unless you want to keep this in secret ofcourse.

cheers

Link to comment
Share on other sites

Gotta make those flakes look glittering, u guys have any idea?

I used dot product of normalized Normal and Eye vectors to effect some noise params - this way the noise is modified as soon as relative camera-surface postiton changes.

P.S. Maybe it worths trying to rewrite the aanoise to make it 4D - c'mon guys, it's the 21st century!

Link to comment
Share on other sites

However I see that you use global P for your AANoise position - this way the noise will flow when your car or camera moves - I would recommend pass the P through Rest Position VOP or add Shading Layer parameter VOP to noise position - this way the noise will stick to the object space.

Good tips, much appreciated :)

By the way - can you tell me the params of your AANoise? (frequency and type - or anything you've changed), colormix4, 5, 6 and Edgefalloff2? Unless you want to keep this in secret ofcourse.

Here is the screengrab of my AANoise params. I noticed that if i want to get a smoother reflection and fine-noise for the flakes, I have to crank up the micropoly smoothing(shading quality which found in the render tab, value may be vary based on your model and your noise-size.)

post-1266-1161489734_thumb.jpg

Regarding to color mix4, 5, 6 i did a cheap trick which is not physically correct at all. I color-mixed the aanoise and piped it to the input of specular as a specular map to fake glittering. And the flakes itself have specularity that's what the lighting3 node meant for. And also mixed the color of flakes specular because in real life we noticed that the flakes not only glitter at one color. The Edgefalloff2 meant to mask out the flakes which would affect the noise not spreading all over the car and only visible at certain position like position "I" and also it only glitter when that's a specular highlight.

But, I still striving for a more accurate look which would get my hand busy in vop for the next few days. Reading some renderman book and use my best guess to find some related function in VOP.

I am completely a newby in shader writing. Your help is always welcome ;)

Link to comment
Share on other sites

post-1266-1161490684_thumb.jpg

The image I attached above is to show the comparison between my render and real-life photography.

It seems like the fresnel term that i applied doesn't work out the way it meant to be.

I suspose more light is reflected at the grazing angle but u can tell that the reflection is pretty dull at grazing angle that appeared in my render.

Once again, Your solution is always welcome :) :) :)

Link to comment
Share on other sites

post-1266-1161490684_thumb.jpg

The image I attached above is to show the comparison between my render and real-life photography.

It seems like the fresnel term that i applied doesn't work out the way it meant to be.

I suspose more light is reflected at the grazing angle but u can tell that the reflection is pretty dull at grazing angle that appeared in my render.

Once again, Your solution is always welcome :) :) :)

Thanks for your reply, Jordan

Concerning the pics

Link to comment
Share on other sites

  • 2 weeks later...
I've notice the lightsource from the hdri reflection map tend to be more crisp compare to use a low dynamic range reflection map when reflected on the model. How to cut down the intensity of crispiness when using hdri as reflection map???

By "more crisp", do you mean sharper? Would blurring the HDRI map help?

Link to comment
Share on other sites

I can't find cook-torrence in the lightingmodel vop rolloff.

If is possible, i wish i could complete the car paint shader in VOP.

Hi Jordan,

I believe the default "VEX Specular" model in the Lighting Model VOP (simply "specular()" in VEX) is the Cook-Torrence specular model.

The crispiness comes from the highlights being not clamped at 1 - which is a very good thing really. Reflecting clamped light sources that appear in reflection maps would give you less correct results.

I must be honest and admit I cant tell from your render if the car paint is meant to be metallic or matte (with just a glossy reflection). It looks like it's solid matte black from your render.

If you're going for a metallic paint, you might need to soften the reflection. Are you raytracing the HDR dome? Or using an environment map? As Edward says, you could try specifying to your environment function to slightly blur the environment to try to emulate another type of highlight. Or pre-blur your HDRI - and if you want to you can play with HDRShop's specular convolution function.

In fact, you might find yourself casting a crisp AND a blurred reflection into the car to get the paint and clearcoat finish together.

Just a couple of ideas,

Jason

Link to comment
Share on other sites

I believe the default "VEX Specular" model in the Lighting Model VOP (simply "specular()" in VEX) is the Cook-Torrence specular model.

First of all, thanks for your declaration.

I must be honest and admit I cant tell from your render if the car paint is meant to be metallic or matte (with just a glossy reflection). It looks like it's solid matte black from your render.

oops, sorry i didn't turn on the light. I was trying to render with Full irradiance, but it was extremely slow although I have the irradiance caching turn on and render in supersampling 2x2 gi sampling quality 64.

If you're going for a metallic paint, you might need to soften the reflection. Are you raytracing the HDR dome? Or using an environment map?

Yes, i am raytracing the HDR dome. The HDR map has been converted to *.rat for supersampling purpose, I have attached a filterstep to blur the map, I still received sharp highlight, is that simply because of the color of the highlights not being clamped at 1?

In fact, you might find yourself casting a crisp AND a blurred reflection into the car to get the paint and clearcoat finish together.

Good idea :) , Since i m gonna cast a crisp and a blurred reflection, both of the specular reflection is from the hdri map. Should i turn off "contribute to specular" from the light tab?? i would give it a try to create a diffuse only light. ( if i m not doing hdri lighting ) using a standard light like spotlight and pointlight would cast a sharp specular on the model(sourcy lighting) which is looks unrealistic when you compare your render to real-life example. In real-life, the way the car look often determine by its surrounding(the light source).

And finally i got one more question to ask. We have 3 different attenuation in our houdini light which is half intensity distance, physically correct and no attenuation. I guess we determine the "decay" by adjusting the "Atten Distance"? or if we are using cone light, it is determine by the cone rolloff(the penumbra)?

If my guess is correct, the value on the Atten Distance slider is way too abstract, I have to do a couple of test renders by sliding it right to left to see the result.

As I notice, some other packages has different type of light decay for example like linear(inverse),

quadratic(inverse square) and cubic. Are they similar to the half intensity distance, physicallly correct in houdini?

And also when we apply an area light, If we resize the area-shape by using the params in the transform tab, does it affect the light( as we know the bigger the area shape, the softer the shadow is)? I know we can adjust the size in the illumination tab, but what if i want a rectangular shape instead of a perfect square which come out straight from the grid.

Sometimes for the sake of determine the shape of the area light source when doing indoor lighting, I would use an ASAD light (the shadow cast by ASAD light looks similar to area shadow) but you will see shadow overlapping at large object. :( unless u crank up your point instances, which is slow as hell as u crank up the sampling of area light.

thanks.

Link to comment
Share on other sites

Still in WIP, but now i am working on the flakes on/off switch.

As we know that those flakes only visible in certain range like

when the car is next to you.

So U can toggle on/off the flakes based on its distance to camera.

Here I post my carpaint-wip.

Feel free to download and refine.

Car_paint_v.1.rar

This image below, i rendered with the carpaint shader i just did.

Image based lighting

One infinite light- diffuse only.

HDR reflection map.

post-1266-1163157577_thumb.jpg

Here is the screenshot of the shop's params.

post-1266-1163157649_thumb.jpg

The complete shader will be come shortly.

Descriptive comments will be added in the final otl.

Link to comment
Share on other sites

Hi there,

This is my humble 2 pennies as a contribution to this thread.

This shader is a hybrid system between modified stu’s shader, a piece from Jordan’s code (describing the reflection) and my own deems. It uses 2 models for reflection (a simpler one and a more complex one, that lets using environment maps, colors and such), allows adding bump noise to add some non-linearity to the inner surface. The math from the paper, that Jordan has generously mentioned, is used to generate specs(flakes) – at least the way I understood/implemented math – it uses pseudo-random flakes normals, based on flakes’ uv’s and flakes’ distribution model, driven by ‘m’ attribute (different for various car-paints - see the paper for more info).

http://www.mpi-sb.mpg.de/~guenther/carpaint/carpaint.pdf

Hope this will be of some help to somebody.

car_paint_small.0001.tiff

very cool, madjestic! getting to see the result of this community.

One man can't build rome.

If u need any hdri image and car model for test, send me a private message.

and one more question for you madjestic.

i just quit my job recently and freelancing at home for the purpose of

learning programming(shading language and computer graphic) and math at home.

No money to go college/university.

Any advice??????

i was struggling to digest the math in that paper.......

so far, i am doing some highschool math exercise like matrix multiplication, vector algebra, coordinate transformation, trigonometry and etc....

Any recommendation for coding exspecially for those ppl like me doesn't have a coding background.

The self-pace learning curve is steep especiallly without a guide from a knowlegable person.

Sometimes, i didn't even make any progress in a week time.... because of the code and math.. but the theory know some....

and let's together complete the shader. ;) gotta go thru your setup when i am free.

Link to comment
Share on other sites

Hi there,

It uses 2 models for reflection (a simpler one and a more complex one, that lets using environment maps, colors and such),

car_paint_small.0001.tiff

good idea. this is what did for my chrome-shader too.

Is good to use both raytrace and environment maps.

U may interested, Raytracing for the movie "Cars"

raytrace good for inter-reflection, environment maps good for the approximation of distant enviroment.

Here is my car-render again. another test for my shader... still wip...

Day12-725766.jpg

Next gonna zoom the car real-close to check the flakes and how it glitter.. I think the glitter got to be done in compositing........ any idea guys?

This studios Eden Lab does nice CG car render. worth to check it out... after watching their reel, i feel i still far away........... from a good carpaint shader. :)

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...