PBR material - maps issues

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

PBR material - maps issues

Post by miki3d »

Hi all!

I was playing with the pbr scene to test some materials and I get a grey look when I use a diffuse map instead of a diffuse colour, as you can see on the screenshot below.

FYI:
- I applied an hdr cubemap.
- car paint is a flat colour (diffuse 1 0 0) and it seems right.

Thanks in advance :)

Mik

Image
Last edited by miki3d on Wed May 20, 2015 5:30 pm, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material with diffuse looks wrong

Post by dark_sylinc »

I'm not sure I follow what's wrong in the picture.

The upper left tire is using a solid black diffuse (0, 0, 0).
The lower right tire is using a diffuse map which is not solid black; sampling with GIMP says it's around (0.0941, 0.0941, 0.0941).

This is not an apples to apples comparison.
Anyway, I think your problem comes from the specular component. For rubber it should be around 0.20784; which only 20.7% of the default specular 1; and the diffuse map's colour should be around 0.1608; based on physically measured values I got from googling a little.
The huge specular and the current disparity between your specular / diffuse ratio must be washing out the blackness; giving you grey as a result.
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material with diffuse looks wrong

Post by miki3d »

Hi dark_sylink! Thanks for the answer!

You're right, it was not a good comparison so I putted a completely black texture on the CartTire_0.

Both materials have the same specular/roughness/fresnel value, should not they look the same way?

Image

Tnx again :)
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBR material with diffuse looks wrong

Post by xrgo »

PiroKun
Gnoblar
Posts: 6
Joined: Wed Mar 11, 2015 6:31 pm
x 7

Re: PBR material with diffuse looks wrong

Post by PiroKun »

fresnel shouldnt be between 0 and 1? i remember seeing problems in colours, when this value go above 1. (fresnel, not IOR)

edit: meh, im wrong here, fresnel is IOR in the script, not the % of reflect.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material with diffuse looks wrong

Post by dark_sylinc »

Ugh. Yes.

What happens if you remove the normal map?.
Also if you're later adding a reflection map on code, like xrgo said in its post, there is a bug where the diffuse & specular maps are being ignored for the reflection map, which would explain your problem.
If there is something else going on (i.e. a different bug), I will need something to play with to see what's going on.
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material with diffuse looks wrong

Post by miki3d »

dark_sylinc wrote:Ugh. Yes.

What happens if you remove the normal map?.
Also if you're later adding a reflection map on code, like xrgo said in its post, there is a bug where the diffuse & specular maps are being ignored for the reflection map, which would explain your problem.
If there is something else going on (i.e. a different bug), I will need something to play with to see what's going on.
Hi dark_sylink!

We downloaded your bug fix today, I'll try it tomorrow and I let you know if everything is ok, thanks :)
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material with diffuse looks wrong

Post by miki3d »

Hi dark_sylink

The previous bug seems corrects, now I'm playing with a new one :(...

Roughness maps does not work for the cubemap, but only for le specular light, as you can see on the Box03.

PS: roughness map is a black & white checker.

Image

Tnx!
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBR material with diffuse looks wrong

Post by xrgo »

miki3d wrote:Hi dark_sylink

The previous bug seems corrects, now I'm playing with a new one :(...

Roughness maps does not work for the cubemap, but only for le specular light, as you can see on the Box03.

PS: roughness map is a black & white checker.

Image

Tnx!
that's strange I believe I tested that and it worked.
One thing I noticed is that Roughness map is actually used as a Glossness map, so there might be an inconsistency there, try forcing the roughness value to 1.0 while using the roughness map
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material with diffuse looks wrong

Post by miki3d »

Hi xrgo, tnx for the reply!

I tried with roughness=1 and now works better, as you can see here

Image

In my opinion could be better to does not take into account roughness when using roughness_map, what do you think?

I noticed that for black values on the roughness map the specular point disappears, if I'm correct someone clamps roughness value on shader to avoid this.

Need to check if roughness is inverted and seen as glossiness.

About this, If I'm correct, the ogre PBR flow is going to be Specular/Roughness but as I see around it's not common...

Other softwares (unity, marmoset, substance designer, ue4...) usually adopt these:

PBR Metallness/Roughtness (my fav...hope we also have this on ogre)
PBR Specular/Glossiness

Just to ask, why to not adopt one of this two flows?

My actual PBR shader (my implementation for ogre 1.9) is based on metalness/roughness, and for the new ogre 2.1 materials I need to know what will be the final PBR flow to convert my materials. Ok, I could make my own implementation of metallness/roughness shader but I prefer to follow the standard implementation of ogre shader as it is.

Thanks :)

Mik
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: PBR material with diffuse looks wrong

Post by al2950 »

The default roughness value is set to 0.1 for some reason, and the shaders calculate roughness by doing 'roughnessValue * roughnessTexture', which is correct and a good thing, but maybe the default should be set to 1.0 to prevent this issue.

As for the workflow the Ogre PBR 'Specular/Roughness' workflow is more powerful/flexible, but as you pointed out other engines and tools have opted to go for slightly more artists friendly workflows. I think it is good Ogre provides, by default, a more flexible PBR workflow. However it should work nicely with other workflows. To that end there are a couple of import functions, see 'HlmsPbsDatablock::importUnity', these only currently convert basic values but perhaps they could be extended to convert textures as well.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material with diffuse looks wrong

Post by dark_sylinc »

More support is planned (e.g. metallness textures for metal workflow) but it will take a while. No ETA.

As for the roughness = 1; it is desirable that the roughness of the texture to be multiplied against the roughness of the material. As with everything else, it allows you to control the strength of the texture in a global way; for example have 2 models with the same material & textures, but one is "damaged", the other one is "healthy", and the only different are the parameters such as roughness and colour.

I'll take a look at what's happening. Either the problem is that the roughness map is a glossy map, or the roughness effect on the mipmap selection gets noticed at a different rate than the effect on the light.
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material with diffuse looks wrong

Post by miki3d »

Hi dark_sylink!

What you say makes sense, can't wait for the metalness flow, till then I'll keep using spec/rough flow.

I made a test and yes, roughness map is glossiness, as you can see on the image below (roughness map white to black from left to right)

Image

Thanks for your time!

Mik
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material - maps issues

Post by miki3d »

Hi!

First of all I renamed the Subject name of this post to not open a new one relative to maps usage and issues.

I ran on a new problem playing with specular map.

I used to have material with both metallic and dialectrics parts, and specular map works on this way, but I've a problem with the dialectric part, as you can see on the screenshot below:

Image

Also played with fresnel value, as I know and tested on marmoset, when using a specular map fresnel is set to 1 but here didn't work.

Thanks :)
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material - maps issues

Post by dark_sylinc »

I don't understand what's wrong here. Everything looks the way *I* would expect. Obviously you disagree.
Could you explain again? (or show a comparison of what you'd expect)

The 1st one - Metalic side and the 2nd one look the same. So probably this is as expected.

The 1st one - Dialectric side and the 3rd one don't look the same. Probably you expect them to be. But it's not the same parameters.
The diffuse colour is the same (red), but the specular map is ( 0.2; 0.2; 0.2 ) vs the default specular of ( 1.0, 1.0, 1.0 ) and the default fresnel of 0.818 vs the modified one of 0.04.

To achieve exactly the same, you would either set the specular to white in the 1st picture, or in the 3rd one, write the following def:

Code: Select all

hlms Sphere01 pbs
{
 diffuse_map Red.tga
 roughness 0.02
 specular 0.2 0.2 0.2
}
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material - maps issues

Post by miki3d »

Yep sorry I have not taken into account default values.

I'm really trying to go deep on materials for what I need, maybe I did not understand something :)
My goal is to use maps instead of values to get mixed material, half dialectric and half metallic, imagine a texture containing a concrete wall and some metal bars.

A Test on marmoset, using the specular flow, seems correct, the main difference that I noticed with ogre is the different use of specular colour, to get similar results marmoset needs a 0.2 grey specular, and ogre a white specular.
For the ogre part, seems impossible for me to have the dialecrit part of the sphere02 identical to the dialecrit material of the sphere01 whithout an hypothetical fresnel map. But I really don't want it :D...

Maybe there's something wrong with the relation between fresnel and specular? There's any possibility to have something similar to the marmoset flow?
Has I sad beforse, I came from the metalness flow where fresnel for dialectric is almost locked to 0.04 and for metal came from the diffuse map color, and it's really easy to setup. But I can really drop it if I'll be able to get the same results with the specular flow that is also more flexible.

Here the screenshots :)

Image

Image

Thanks again!

Mik
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material - maps issues

Post by dark_sylinc »

This is going to sound silly, but can you post a picture of how it looks when all three Ogre materials have a "fresnel 1.33" setting? (even if it looks in a way completely different from what you want)
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBR material - maps issues

Post by xrgo »

Hello, try with my modified version of the shader =)... its made to look like marmoset, its using the specular texture as fresnel and the specular as white, as mentioned here: http://www.ogre3d.org/forums/viewtopic. ... 25#p516733
and calibrated the roughness and the shiny spot a little, its looking almost perfectly as marmoset

If you could post the same picture using the shader attached that would be great (either if works for you or not)
Attachments
BRDFs_piece_ps.glsl
(5.29 KiB) Downloaded 149 times
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material - maps issues

Post by dark_sylinc »

That file is probably going to work, but I still want that picture. I want to check something :)
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material - maps issues

Post by miki3d »

Here we go!

Test for dark_sylink

Everything works as expected but wait...read below the screenz...

Image

...after that test I tried to set on ogre the same specular values I applied to marmoset (grey 02, a standard spec for dialectric material, found on megascan), left the default fresnel and...pumped the diffuse light from 3 to 12

Image

Now it looks acceptable, expect for the low level of reflections on the edges, but duno if it's correct using an high value of light like this...or yes? I mean, PBR is energy conservative and permits out of range values but what are limits to have a plausible and physically correct image? Without considering, for now, LUT and HDR balancing that can help to have a nice and good result on any light condition.



Test for xrgo
With your code (just replaced the file with the existing one on the \Hlms\Pbs\GLSL folder) dialectric part seems ok, but metal part does not take any color :(...notice that I left fresnel as default

Image

Thanks guys for the support :)
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBR material - maps issues

Post by xrgo »

its working for me, but I am setting the fresnel like this:
datablock->setFresnel( Ogre::Vector3::UNIT_SCALE, true );

this means that its using the "sparate fresnel" function, try to set a white fresnel value, with separate rgb, so the shader knows it has to use all channels (since its using the specular map as fresnel, in my version)

Lastly.. if you want to make roughness looks like marmoset add this to line ~390 in the pixel shader:

Code: Select all

	float adaptedRough = 0.18 * log(100 * ROUGHNESS);
	vec3 envColourS = textureLod( texEnvProbeMap, reflDir * pass.invViewMatCubemap, adaptedRough * 12.0 ).xyz;
its just some cooked values, it looks like marmoset is still a little rough even at almost white gloss values, this kinda fixed it =)
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material - maps issues

Post by dark_sylinc »

Try "fresnel_coeff 1 1 1" on the materials when using xrgo's shaders. This will force the PBS system to use coloured fresnel.

What you need here is a fresnel map, rather than a specular map; in order to achieve what you want and make it match close to Marmoset (this is what xrgo shaders are doing, plus a few more tweaks).
We'll integrate something like this into core in the future. But for now you'll have to use xrgo's shaders.
Now it looks acceptable, expect for the low level of reflections on the edges, but duno if it's correct using an high value of light like this...or yes? I mean, PBR is energy conservative and permits out of range values but what are limits to have a plausible and physically correct image? Without considering, for now, LUT and HDR balancing that can help to have a nice and good result on any light condition.
It's worth mentioning that our PBS system is prepared for real lighting conditions using HDR. Since you're not using HDR yet, one way to fix this is by bumping the light's power (both diffuse and specular) to 3.14 or even higher values like 10 or 15.

Cheers
Matias
User avatar
miki3d
Halfling
Posts: 56
Joined: Wed Jul 18, 2012 1:30 pm
Location: Italy
x 4

Re: PBR material - maps issues

Post by miki3d »

Hi dudes!

I finally had time to make some tests and...eureka!

Image

It's the xrgo shader in action (tnx!), with the roughness tune.
We also set fresnel_coeff to 1 1 1 on the code to avoid repeating it on material scripts.
I made some cross tests with marmoset and it's identical, really good! I'm using it to tune my materials now :).

I'm not sure if I'm going to use a fresnel map in the future (if it will be implemented), and the reason is easy, it will be more difficult for artists to tune the pbr material and it needs one more map that is memory consuming.

Anyway...I'll continue to report bugs and propose trick during my tests :)...here's some:

A bug, sorry for the repost...it's about the roughtness map that is inverted, just want to know if it's on your todo list ;)
Image

tip1: when using a roughness map I also have to set roughness to 1, I think could be good to have 1 as default to avoid this (we'll change in on our code for now)

tip2: About textures amount, have you thought to put roughness map on specular alpha? It's a memory saving trick, I used to do that on my old shaders.

That's all for now, thank's a lot for everything!

Cheers

Michele
Image
Co-Founder and Design Director at VaeVictis
Current project Racecraft
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: PBR material - maps issues

Post by xrgo »

miki3d wrote: It's the xrgo shader in action (tnx!), with the roughness tune.
I made some cross tests with marmoset and it's identical, really good! I'm using it to tune my materials now :).
whoo!! cool glad its working =)
miki3d wrote: I'm not sure if I'm going to use a fresnel map in the future (if it will be implemented), and the reason is easy, it will be more difficult for artists to tune the pbr material and it needs one more map that is memory consuming.
I will be using it, but in the same way I do now, as specular, I need that everything follows standard workflows
miki3d wrote: tip1: when using a roughness map I also have to set roughness to 1, I think could be good to have 1 as default to avoid this (we'll change in on our code for now)
yes, since they multiply
miki3d wrote: tip2: About textures amount, have you thought to put roughness map on specular alpha? It's a memory saving trick, I used to do that on my old shaders.
sounds interesting >=] like!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: PBR material - maps issues

Post by dark_sylinc »

Cool! I'm glad everything's sorted out then.

The gloss vs roughness map is in my TODO list.
miki3d wrote:tip2: About textures amount, have you thought to put roughness map on specular alpha? It's a memory saving trick, I used to do that on my old shaders.
Not really. There are two main reasons not to do this:
  1. According to PBS guidelines, artists won't be spending much time with their diffuse & specular maps; having them low resolution with little detail (ie. flat colours). But the detail is in the normal & roughness maps. A 2048x2048 texture with 4 channels uses more memory than a 512x512 or 1024x1024 with 4 channels (specular) plus a 2048x2048 with one channel (roughness).
  2. Coloured specular is a really good fit for compressing with BC1 (aka DXT1); unless lossy compression on a particular asset irritates the artist. BC1 only supports 1-bit alpha; so storing the roughness in this format is not viable. You can get more bang for the buck by using BC1 for the specular colour and uncompressed monochrome or BC4-compressed for the roughness map.
Post Reply