Maya 8.5 Sun/Sky Rendering Bad


#41

I must thank everyone for all this input, I didn’t know when I started this thread that it would recieve all this great information. I have read alot, and must say didn’t understand all, but understood enough. I was wondering if for people like me who aren’t as advanced in mental ray, can someone give us a step by step on how to correct either the scene with the car I created in the beginning of the thread or how to just set a scene up to correctly render.once again thanks alot :slight_smile:


#42

That post (MZ’s explanation) needs to be properly laid out and detailed in the documentation! Thanks.


#43

After rethinking a bit iguess a script to fix old scenes would look something like this.
It takes all color attributes with no connections and applys a gamma correction.


   string $shadingGroups[]= `listSets -type 1`;
   float $gamma = 1/2.2;
   string $shadingGroup;
   for($shadingGroup in $shadingGroups){
   	if(!`objExists $shadingGroup`)
   		continue;
   	string $material = basenameEx(`connectionInfo -sfd ($shadingGroup+".surfaceShader")`);
   	if($material==""||!`attributeExists "color" $material`)
   		continue;
   	print("Setting up override for: "+$material+"
");			
   	string $plug = ($material+".color");
   	if(!`connectionInfo -isDestination $plug`){		
   		float $color[3] = `getAttr $plug`;
   		print("color: "+$color[0]+" "+$color[1]+" "+$color[2]+"
");
   		string $gammaNode = `shadingNode -asUtility gammaCorrect`;
   		addAttr -ln isGammaOverride -at bool $gammaNode;
   		setAttr -e -keyable true ($gammaNode+".isGammaOverride");
   		setAttr ($gammaNode+".isGammaOverride") 1;
   		setAttr ($gammaNode+".value") -type double3 $color[0] $color[1] $color[2];
   		setAttr ($gammaNode+".gamma")  -type double3 $gamma $gamma $gamma;
   		connectAttr -f ($gammaNode+".outValue") $plug;
   	}			
   }
   	
   

[b]

OLD POST

Conclusion[/b]

    The magic button to fix old WRONG scenes should probably look something like:

       magicCommand(){
       	for(all fileNodes as fileNode){
       		fileNode.gamma = renderGlobals.gamma;
       		fileNode.swatch.gammaCorrect = false;
       	}
       	for(all materials as material){
       		material.specular *= renderGlobals.specularMultiplier;
       		material.swatch.gammaCorrect = true;
       		material.viewport.gammaCorrect = true;
       	}
       	renderGlobals.gamma = 1/2.2;
       }
        
    here's a script that does fix gamma for textures.
  It connects a gamma node on all outColor attributes of all file nodes.
  Then it creates a gamma attribute on the file node and connects it to the gamma node.

        string $files[] = `lsType file`;
        for($file in $files){
        	if($file == "<done>")
        		break;
        	$gammaNode = `shadingNode -asUtility gammaCorrect -n ($file+"_gamma")`;
        	string $colorConnections[] = `listConnections -p true ($file+".outColor")`;
        	for($cConn in $colorConnections){
        		connectAttr -f ($gammaNode+".outValue") $cConn;
        	}
        	connectAttr -f ($file+".outColor") ($gammaNode+".value");
        	if (`attributeExists "gamma" $file`) {
        			  print "Using existing attribute
";
        	  } else {
        			  addAttr -ln gamma -at double $file;
        		setAttr -e -keyable true ($file+".gamma");
        	  }
        	
        	setAttr ($file+".gamma") (1/2.2);
        	connectAttr -f ($file+".gamma") ($gammaNode+".gammaX");
        	connectAttr -f ($file+".gamma") ($gammaNode+".gammaY");
        	connectAttr -f ($file+".gamma") ($gammaNode+".gammaZ");
        }
        
    but of course the right thing is to do it right from the beginning.
    would be nice to be able to fix texture gamma on all file nodes globally at rendertime tough.

    /Smaragden

#44

is their not one shader, or lense shader that would correct all these problems in the mental ray rendering?


#45

such a great thread! i briefly read the xsi thread, and at some point Bill spitzak posted more information about sRGB and such on his site.

http://mysite.verizon.net/spitzak/conversion/index.html

so, since im beginning to wrap my head around this let me see if my summary is accurate:

maya, max, xsi, etc… are in a 1.0 gamma space. sRGB automatically encodes a gamma of 2.2, therfore all color images out of photoshop are ‘overcorrected’ when plugged into maya. to fix this, a gamma correct node is used to ‘uncorrect’ the image, 1/2.2 = .45.

so, i guess my next question is how to best apply an overall correction at render time? if gamma correction is done to color textures, do you even need to? and, this workflow is required with the tonemapper and without?


#46

i think the easiest would be to encode the gamma correction per shader - that is at shader level… one shader fits whatever number of textures you have down the shader tree…so i wonder, how hard could it be?.. already i heard a little something like implemented in MasterZap’s shader…
so, i heard a lot of great things about ctrl.studio’s tone mapper for maya, but i haven’t dared use it `till now…and i have a feeling that many peeps around here have done the same…so, is there a set of commandments to follow with this/and all other tonemappers ?


#47

MasterZap, thx a million times for your explanations.

I too didn’t get everything, but AFAI could understand
the 2.2 sRGB gamma correction for display concerns is the evil, right?

And in order to get “physical correct” results we have to compensate for that
with tone mapping etc…

At he end of the day though, the work will be seen on the big screen,
on digital displays or on paper.

So our tone mapped gamma compensated “physically correct” images
are suposed to be rendered in 16 or 32 bit.

But as our displays don’t display correct,
we cannot judge the quality of our physically correct images at that stage.

So we take them to Photoshop - shake - etc… where appropiate color-gamma adjustments will be applied according to the delivered media, right?

Well that’s the point where I get confused. (If I didn’t miss anything)
Isn’t photorealistic 3D visualisation about faking wireframe objects to look real anyway?
Don’t things end up beeing physically incorrect anyway?


#48

so in laymans terms…

take a normal 8 bit picture downloaded from the web,

attach the mia_sky to the environment

create a gamma correct node…plug it into the color slot of the shader
plug the image into value attribute of the gamma node
change the value attributes of the gamma node to .45 .45 .45

for comparison…create the same shader without the gamma node…

render these out and viola!

i now see the differance…and it is quite amazing actually.


#49

Thanks Zap for the response.
I pretty much understand what you have said.

Colors aren’t “washed out” due to some “error”. Colors are “washed out” becaust you put in “washed out” colors… the problem is they didn’t appear washed out to you because you watched them in a gamma=1 color swatch on a gamma 2.2 monitor!

 I.e. everything you see in every un-corrected color swatch is WRONG. It's not the color it will have in the final image. 

So how do we get the corrected colour swatch ?
I can correct bitmaps using the output curve in 3dsmax9 but theres no output curve for diffuse colours.

cheers


#50

Okay you guys are pure geniuses, I tryed the gamma node, and it worked awesome, I got all correct textures. But like others are saying how do we get the correct swatch. Plus why isn’t their a gamma correct node to fix the whole scene, like one node to plug into your camera or something, can someone create or make the gamma node work so you plug it into the camera or something so the whole scene, textures and swatches are fixed at once?

If you ask me that would be one of the most important nodes ever built for Mentalray.


#51

Another thing about the new mia_material and sun/sky is, due to the way mia_material works, the reflection color is very important in the final color. You can’t adjust only the diffuse color if you wish to change the color of something, the reflectance plays into the way the diffuse looks too much, that if you leave reflection color at pure white as is usually the default, it will wash out your diffuse. The way the mia_material works, every material is supposed to have some amount of reflectance, just like in real life. Everything reflects light. Mia_material uses a brdf curve so then you can properly adjust the reflection to match the surface of things that you might consider only as diffuse, such as stone. So in a sense, for anything matte with the mia_material the reflection is almost like a second, more accurate diffuse layer. Which is why adjusting the diffuse color and the reflectance color is very important for everything. The reflectance color doesn’t adjust only the reflecting color. It adjusts the specularity and overall look of the diffuse as well.

I think if you turned the reflectance color down a bit on your materials, it’d remove the washed out look alot. Also check ‘reflection is metal’ on your car shader.


#52

Here’s a little test with 1 sphere with the default BRDF curve and the other no reflectivity at all.
The colour of both are completely different to the colour swatch colour I picked.



#53

in 8.5 sunDirection doesn´t have the lat/time… options has the ported version in 8.0, is this normal ?
I have the sun form the 8.5 bonustools loaded, no problems there…those optinos came form the sun.mll right ?
Can someone check please
MasterZap about the washed out explanation, brilliant :thumbsup:, putting a gammaCorrection node brings back the textures
regards


#54

That’s why it’s already built into mental ray. It doesnt work if you change the gamma with a lens shader though. Instead, try setting the gamma under render globals> framebuffer> primary framebuffer> gamma. You wont have the other nifty controls of the mia_exposure this way (which I couldnt check out completely yet), but at least you’ll have a ‘proper’ gamma with a little bit more convenience.

Again: this way mental ray will automatically ‘un-gamma’ all of your non-floating-point textures, i.e. regular 8/16bit textures.


#55

there´s no need to do that on a per shader base you can simply go to render globals-framebuffer-primary framebuffer-data type RGB (Float 3x32 Bit)-Gamma 0.45


#56

I tryed the gamma control under the Primary framebuffer using

data Type: RGB (Float) 3x32 Bit
Gamma: 0.45
Colorclip: Raw
and only desaturate unchecked

It worked really good, but if you use the gammacorrect shader, It actually gives a better more even lighting quality. does any body know why?,

try a simple scene using both methods…


#57

I just realized that even correcting the Gamma under Primary Framebuffer doesn’t work, it only corrects objects with textures and does nothing for objects that are just using a color swatch. Isn’t their anyway to get the whole scene to render gamma correctly?


#58

doody did you realy saw any diference using the gammaCorrect shader instead ?
i am testing a simple scene with both methods and i cant see any diference


#59

yea a very slight difference, on a square their is a difference on the lit to shaded sides using the two different methods. But both these methods are working only on objects that you use a texture on it. Even fixing the gamma under the Primary Framebuffer, I can’t firgure on how to get objects without textures to render with the gamma fixed.


#60

I can’t firgure on how to get objects without textures to render with the gamma fixed.

Wouldn’t it be correct to put in the value attr. of your gamma correct node the color of your object and then plug the output of the gamma corr. node to the diffuse of your mat. ?

That’s why it’s already built into mental ray. It doesnt work if you change the gamma with a lens shader though. Instead, try setting the gamma under render globals> framebuffer> primary framebuffer> gamma. You wont have the other nifty controls of the mia_exposure this way (which I couldnt check out completely yet), but at least you’ll have a ‘proper’ gamma with a little bit more convenience.

Again: this way mental ray will automatically ‘un-gamma’ all of your non-floating-point textures, i.e. regular 8/16bit textures.

But this means even all of your 8 bit greyscale texture (bump, reflection, specular, displacement ecc.) which you probably don’t want to be ‘un-gammed’.

Ciao :slight_smile:

Luca