What PBS workflow is using ogre2? metallic or specular?
-
- Gnoblar
- Posts: 6
- Joined: Wed Mar 11, 2015 6:31 pm
- x 7
What PBS workflow is using ogre2? metallic or specular?
Hi!
I made some test in ogre 2.1, with PBS, but i cant figure out what workflow is using.
In the attached picture, are 2 balls, one directional light, and a plane. (And of course, the cubemap for reflections)
The left ball is:
Diffuse: Black
Specular: White
Roughness: White
Fresnel: 0
The right ball is:
Diffuse: White
Specular: Black
Roughness: White
Fresnel: 0
In specular workflow, I would expect that the left ball was like a mirror. In the other hand, in metallic workflow, i would expect that the right ball was like a mirror.
But, why im not getting any mirror ball? Ogre arent using specular/metalness workflow?
Reference image for specular/metalness texture workflow:
http://www.marmoset.co/wp-content/uploa ... ness02.jpg
And the links where i get the info about specular/metalness workflow:
http://www.marmoset.co/toolbag/learn/pbr-practice
http://www.alexandre-pestana.com/physic ... workflows/
And other question. What should I expect the fresnel do?
I guess fresnel go from 0 to 1, and add extra reflection in close angles (specular independent for amount of reflect, but roughness dependent for, ehm.. roughness)
I tried to make some test with fresnel, but its kinda pointless add other variable to test if idontknow what workflow are using.
Thanks!
I made some test in ogre 2.1, with PBS, but i cant figure out what workflow is using.
In the attached picture, are 2 balls, one directional light, and a plane. (And of course, the cubemap for reflections)
The left ball is:
Diffuse: Black
Specular: White
Roughness: White
Fresnel: 0
The right ball is:
Diffuse: White
Specular: Black
Roughness: White
Fresnel: 0
In specular workflow, I would expect that the left ball was like a mirror. In the other hand, in metallic workflow, i would expect that the right ball was like a mirror.
But, why im not getting any mirror ball? Ogre arent using specular/metalness workflow?
Reference image for specular/metalness texture workflow:
http://www.marmoset.co/wp-content/uploa ... ness02.jpg
And the links where i get the info about specular/metalness workflow:
http://www.marmoset.co/toolbag/learn/pbr-practice
http://www.alexandre-pestana.com/physic ... workflows/
And other question. What should I expect the fresnel do?
I guess fresnel go from 0 to 1, and add extra reflection in close angles (specular independent for amount of reflect, but roughness dependent for, ehm.. roughness)
I tried to make some test with fresnel, but its kinda pointless add other variable to test if idontknow what workflow are using.
Thanks!
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Hi!
To achieve a mirror effect you would have to set the Roughness as low as possible (i.e. 0.02) and fresnel to 0 or 1 (can't remember which one of the extremes at the moment).
Fresnel is hard to explain in detail, but in short when you're looking at very grazing angles; every surface will become a mirror. Yes, every one. Even the roughest concrete can become a mirror if looked from an angle low enough.
However, only some materials will also reflect specular light when looking towards the surface; other materials will not reflect much specularity when looked from the front.
This funny picture illustrates how you should tilt your head against a surface to get that grazing angle: http://i.imgur.com/HMOLhyt.png
If you're interested in the specifics; John Hable has an excellent post about it.
As for the "workflow": Our math is the "advanced one" in the terms that you manipulate the "low level" values from a PBS component. Therefore it is a specular workflow.
Lately it has become trend to use "metalness" values and hides the specular colours as well as the fresnel from user input; thus making it more user friendly, at the expense of eliminating the ability to represent certain rare types of materials.
Although I'm usually a fan of "low level" stuff; that's for programming. But for art I prefer friendliness. More importantly I value being able to switch between tools and retain the same look using the same or very similar parameters.
I was looking forward to DistributedViewer being released since one of Murat's partners reimplemented my code to match the look and workflow more like the other engines; but it hasn't been released yet.
When it does I will certainly take a look and see how we can migrate the 2.1 pipeline or make it switchable (since the Hlms isn't strictly tied to one BRDF)
To achieve a mirror effect you would have to set the Roughness as low as possible (i.e. 0.02) and fresnel to 0 or 1 (can't remember which one of the extremes at the moment).
Fresnel is hard to explain in detail, but in short when you're looking at very grazing angles; every surface will become a mirror. Yes, every one. Even the roughest concrete can become a mirror if looked from an angle low enough.
However, only some materials will also reflect specular light when looking towards the surface; other materials will not reflect much specularity when looked from the front.
This funny picture illustrates how you should tilt your head against a surface to get that grazing angle: http://i.imgur.com/HMOLhyt.png
If you're interested in the specifics; John Hable has an excellent post about it.
As for the "workflow": Our math is the "advanced one" in the terms that you manipulate the "low level" values from a PBS component. Therefore it is a specular workflow.
Lately it has become trend to use "metalness" values and hides the specular colours as well as the fresnel from user input; thus making it more user friendly, at the expense of eliminating the ability to represent certain rare types of materials.
Although I'm usually a fan of "low level" stuff; that's for programming. But for art I prefer friendliness. More importantly I value being able to switch between tools and retain the same look using the same or very similar parameters.
I was looking forward to DistributedViewer being released since one of Murat's partners reimplemented my code to match the look and workflow more like the other engines; but it hasn't been released yet.
When it does I will certainly take a look and see how we can migrate the 2.1 pipeline or make it switchable (since the Hlms isn't strictly tied to one BRDF)
-
- Gnoblar
- Posts: 6
- Joined: Wed Mar 11, 2015 6:31 pm
- x 7
Re: What PBS workflow is using ogre2? metallic or specular?
Wow, now i see fresnel everywhere!
Sorry for not reply earlier, I want to do it after reading what you posted about fresnel(to understand more about the topic), and suddenly i read all the documents, websites and videos about PBS availaible on the internet, and making some comparative test xD
Its a very interesting and awesome topic
And with this, I noticed several details that didnt fit with what I had read and see.
Then, with Xrgo, we made some changes to the shader to make it look (and work) like marmoset (Because marmoset use Spec workflow, looks great!, they have a great post about PBS theory, and i see in many places that they use marmoset as reference)
To consider: The curve or gradient between the angles (in fresnel) does not vary much from material to material. This explains why in several engines, the value of fresnel is fixed (or modified only in cases of very specific materials).
Therefore, in these examples, all fresnel is fixed.
First Test
The first things I noticed is that in ogre I cant get a mirror without having to modify the value of fresnel, and cant make a colored ball without having to set the roughness to 1.
The theory says that is the color of specular map , which decides if reflecting or absorbing light for color (because energy conservation), not the fresnel or roughness.
Original ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Second test
The idea behind this test is to see the influence of specular color.
Theoretically we should get a mirror ball and a christmas ball.
Mirror Ball to Black Ball
Original Ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Christmas ball to red ball
Original Ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Third Test:
Fresnel close-up test
Everything has fresnel!
So, this test is a polish ball with black specular. Only fresnel should be reflecting light.
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Red Ball
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Fourth Test:
GOLD!
Because everybody loves golden material (And its the turn for metallic materials)
Gold
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Xrgo will post and explain later the shader in this thread.
Sorry for not reply earlier, I want to do it after reading what you posted about fresnel(to understand more about the topic), and suddenly i read all the documents, websites and videos about PBS availaible on the internet, and making some comparative test xD
Its a very interesting and awesome topic
And with this, I noticed several details that didnt fit with what I had read and see.
Then, with Xrgo, we made some changes to the shader to make it look (and work) like marmoset (Because marmoset use Spec workflow, looks great!, they have a great post about PBS theory, and i see in many places that they use marmoset as reference)
To consider: The curve or gradient between the angles (in fresnel) does not vary much from material to material. This explains why in several engines, the value of fresnel is fixed (or modified only in cases of very specific materials).
Therefore, in these examples, all fresnel is fixed.
First Test
The first things I noticed is that in ogre I cant get a mirror without having to modify the value of fresnel, and cant make a colored ball without having to set the roughness to 1.
The theory says that is the color of specular map , which decides if reflecting or absorbing light for color (because energy conservation), not the fresnel or roughness.
- Top to Bottom: Roughness 0.02 to 1
- Left to Right: Specular gradient, from white to black.
- Diffuse color is red in all cases
Original ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Second test
The idea behind this test is to see the influence of specular color.
Theoretically we should get a mirror ball and a christmas ball.
Mirror Ball to Black Ball
- Left to Right: Specular gradient, from white to black
- Roughness is fixed at 0.02
- Diffuse is Black
Original Ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Christmas ball to red ball
- Left to Right: Specular gradient, from Red to black
- Roughness is fixed at 0.02
- Diffuse is Red
Original Ogre PBS
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Third Test:
Fresnel close-up test
Everything has fresnel!
So, this test is a polish ball with black specular. Only fresnel should be reflecting light.
- Black Ball
- Roughness is fixed at 0.02
- Diffuse is Black
- Specular is Black
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Red Ball
- Roughness is fixed at 0.02
- Diffuse is Red
- Specular is Black
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Fourth Test:
GOLD!
Because everybody loves golden material (And its the turn for metallic materials)
Gold
- Left to right, Roughness is 0.02 to 1
- Diffuse is Black
- Specular is #FFC455
(Click to enlarge Pictures)
Modified Ogre PBS
(Click to enlarge Pictures)
Marmoset Toolbag 2
(Click to enlarge Pictures)
Xrgo will post and explain later the shader in this thread.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: What PBS workflow is using ogre2? metallic or specular?
EDIT: now the post apeared =)
Hello, I work with PiroKun. he posted a few hours ago a very big post with lots of pictures that need Admin approval
We modified a little the pbs shader... In the meantime here is some results:
*model and textures courtesy of http://artisaverb.info/PBT.html
Hello, I work with PiroKun. he posted a few hours ago a very big post with lots of pictures that need Admin approval
We modified a little the pbs shader... In the meantime here is some results:
*model and textures courtesy of http://artisaverb.info/PBT.html
Last edited by xrgo on Wed Mar 18, 2015 10:53 pm, edited 1 time in total.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: What PBS workflow is using ogre2? metallic or specular?
Hola Victor te quedo bueno el post =D!!
Disclaimer:
This is just an implementation intented to look similar to marmoset and use the standarized specular workflow, We are not sure if it follows all the PBS rules and we havent tested performance, multiple lights, forward3D, didnt test with much textures or anything. Most of the numeric values are cooked (we just tried different values) just to look similar to marmoset. And params["gamma"] = "true";
Disclaimer2:
English is not my native language, and some things are hard to explain so excuse me if I dont make myself clear in some stuffs. Gracias!
The shader =D!! (just the glsl version)
The changes to the original implementation are the following:
In point, spots and directional, I removed the light specular color, as we studied, that don't really exists in pbs, since specularity is related to reflections, so when this lights call the “cookTorrance” method we replaced “pass.lights[@n].specular” with “vec3(0,0,0)”
When there is envprobe_map, it should be specular light, because thats the actual reflection, so specular light is the actual cubemap value “envColour”. And for diffuse light we fake global illumination contribution by the cubemap by using the envColour but blurred a lot and the projection was changed to look not “mirror like” but instead “flat” (more like this: https://www.panda3d.org/manual/images/7 ... be_map.png , but not like this http://www.opentk.com/files/cubemaptest.jpg) (not sure how to explain this sorry ). and we don't want NdotV contribution so we force an arbitrary high value (like 10000).
Anyways heres the math for that part:
And the main changes are in the cookTorrance method, these are:
FRESNEL!!! we think fresnel was considered wrong in the original shader, fresnel is suppose to be a reflection caused in grazing angles, so we did just that. And the fact is that most of other engines and workflows dont even change that value that much because fresnel factor is **almost** the same for every material, but we did noticed that fresnel decrease a little with roughness, so this is our fresnel math:
Specularity and diffuse! Specular value when full white should turn any material in a mirror, regardless of diffuse color, fresnel, etc.. only roughness will blur the reflection. So one important thing was to decrease the diffuse contribution with high specular values:
And when specular has some color, it should tint the reflection with that color, this way we can make metals, so this is how we calculate the actual reflection:
Other fact is that when specular is black, we should have none reflection at all! (EXCEPT at grazing angles, because that reflection is added by the fresnel), we should have only diffuse, and when light is very bright we should have the actual diffuse value in the lighten area, what I mean is that even if I have a light with the power of 10000s of suns and my sphere is red (1,0,0) I will get just red, not a clearer red nor white.
So the math is like this:
Some of the stuffs on the shader was maintained, but adjusted a little, for instance the “Rs” factor, I just adjusted so the bright white spot casted by a light would look more similar to marmoset. And the “G” I noticed that helped to eliminate some white pixels on the borders when the the object was very far.
The final method code is this one:
Another thing we noticed is that the roughness texture is acting like a glossiness texture, so in Textures_piece_ps.glsl we just removed th “1-” in front of the roughness texture, and now it works as the name tells you it should (black areas are 0 rough, white are full rough)... But the thing is! Sometimes we want to use textures that are on the internet and we found some gloss maps instead of the rough map, its really easy to just invert it in Gimp, but we think that maybe should exists the option to use either of those (I think it would be just a param that enables that “1-”, when sampling the texture)
Finally!
As PiroKun posted above we had a very similar result compared to marmoset, and that app uses a more standarized workflow......
So we think that this should be the workflow used by Ogre by default.
Hopefully someone... cogh cogh.. I mean Matias , would look at this and improve it so it has good performance, obey energy conservation laws, port to hlsl, and all that stuffs that we are too noob to do. And Finally integrate it as the default Pbs shader template for Ogre =D!!!! I guess the sooner the better so people dont start making textures that later wont work.
The shader File is attached to this post. Since PiroKun captured those images, I have made some little adjustments to the shader but it looks almost the same.
TL;DR: We think the default Pbs shader template is wrong and we came with a proposition to make it righ, hopefully this will be integrated to Ogre.d
Disclaimer:
This is just an implementation intented to look similar to marmoset and use the standarized specular workflow, We are not sure if it follows all the PBS rules and we havent tested performance, multiple lights, forward3D, didnt test with much textures or anything. Most of the numeric values are cooked (we just tried different values) just to look similar to marmoset. And params["gamma"] = "true";
Disclaimer2:
English is not my native language, and some things are hard to explain so excuse me if I dont make myself clear in some stuffs. Gracias!
The shader =D!! (just the glsl version)
The changes to the original implementation are the following:
In point, spots and directional, I removed the light specular color, as we studied, that don't really exists in pbs, since specularity is related to reflections, so when this lights call the “cookTorrance” method we replaced “pass.lights[@n].specular” with “vec3(0,0,0)”
When there is envprobe_map, it should be specular light, because thats the actual reflection, so specular light is the actual cubemap value “envColour”. And for diffuse light we fake global illumination contribution by the cubemap by using the envColour but blurred a lot and the projection was changed to look not “mirror like” but instead “flat” (more like this: https://www.panda3d.org/manual/images/7 ... be_map.png , but not like this http://www.opentk.com/files/cubemaptest.jpg) (not sure how to explain this sorry ). and we don't want NdotV contribution so we force an arbitrary high value (like 10000).
Anyways heres the math for that part:
Code: Select all
@property( envprobe_map )
vec3 specDir = 2.0 * dot( viewDir, nNormal ) * nNormal - viewDir;
vec3 diffDir = dot( viewDir, nNormal ) * nNormal;
vec3 envColourSpec = textureLod( texEnvProbeMap, specDir * pass.invViewMatCubemap, ROUGHNESS * 12.0 ).xyz;
vec3 envColourDiff = textureLod( texEnvProbeMap, diffDir * pass.invViewMatCubemap, 10.0 ).xyz;
@property( !hw_gamma_read )//Gamma to linear space
envColourSpec = envColourSpec * envColourSpec;@end
finalColour += cookTorrance( diffDir, viewDir, 10000, envColourDiff, envColourSpec );@end
FRESNEL!!! we think fresnel was considered wrong in the original shader, fresnel is suppose to be a reflection caused in grazing angles, so we did just that. And the fact is that most of other engines and workflows dont even change that value that much because fresnel factor is **almost** the same for every material, but we did noticed that fresnel decrease a little with roughness, so this is our fresnel math:
Code: Select all
float fresnel = pow( (1- dot(viewDir,nNormal)), ROUGHNESS*3+4.5 );
fresnel = fresnel * ( 1.0 - ROUGHNESS*0.7 );
Code: Select all
(1-(material.kS.xyz @insertpiece( MulSpecularMapValue )))*(material.kD.xyz * lightDiffuse @insertpiece( MulDiffuseMapValue ))
Code: Select all
vec3 reflection = (material.kS.xyz * lightSpecular @insertpiece( MulSpecularMapValue ) );
So the math is like this:
Code: Select all
vec3 reflection = (material.kS.xyz * lightSpecular @insertpiece( MulSpecularMapValue ) );
return (reflection + NdotL *( (1-(material.kS.xyz @insertpiece( MulSpecularMapValue )))*(material.kD.xyz * lightDiffuse @insertpiece( MulDiffuseMapValue )) ) + G*fresnel*lightSpecular + material.kS.xyz*brightSpot );
The final method code is this one:
Code: Select all
vec3 cookTorrance( vec3 lightDir, vec3 viewDir, float NdotV, vec3 lightDiffuse, vec3 lightSpecular )
{
vec3 halfWay= normalize( lightDir + viewDir );
float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 );
float NdotH = clamp( dot( nNormal, halfWay ), 0.001, 1.0 );
float VdotH = clamp( dot( viewDir, halfWay ), 0.001, 1.0 );
float sqR = max(0.004,ROUGHNESS * ROUGHNESS);
float roughPow = max( 0.004,pow(ROUGHNESS,5) );
float fresnel = pow( (1- dot(viewDir,nNormal)), ROUGHNESS*3+4.5 );
fresnel = fresnel * ( 1.0 - ROUGHNESS*0.7 );
//Roughness term (Beckmann distribution)
//Formula:
// Where alpha = NdotH and m = roughness
// R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( -tan(alpha)^2 / m^2 ) ]
// R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( ( cos(alpha)^2 - 1 ) / (m^2 cos(alpha)^2 ) ]
float NdotH_sq = NdotH * NdotH;
float roughness_a = 1.0 / ( 3.141592654 * roughPow * NdotH_sq * NdotH_sq );//( 1 / (m^2 x cos(alpha)^4 )
float roughness_b = NdotH_sq - 1.0; //( cos(alpha)^2 - 1 )
float roughness_c = roughPow * NdotH_sq; //( m^2 cos(alpha)^2 )
//Avoid Inf * 0 = NaN; we need Inf * 0 = 0
float R = min( roughness_a, 65504.0 ) * exp( 7*roughness_b / roughness_c );
//Geometric term
float shared_geo = 2.0 * NdotH / VdotH;
float geo_b = shared_geo * NdotV;
float geo_c = shared_geo * NdotL;
float G = min( 1.0, min( geo_b, geo_c ) );
//Avoid very small denominators, they go to NaN or cause aliasing artifacts
@insertpiece( FresnelType ) Rs = ( 2 * (R * G) ) / max( 20.0 * NdotV * NdotL, 0.01 );
vec3 brightSpot = Rs*lightDiffuse;
vec3 reflection = (material.kS.xyz * lightSpecular @insertpiece( MulSpecularMapValue ) );
G = min(1.0,100*G); //remove white pixels on border?
return (reflection + NdotL *( (1-(material.kS.xyz @insertpiece( MulSpecularMapValue )))*(material.kD.xyz * lightDiffuse @insertpiece( MulDiffuseMapValue )) ) + G*fresnel*lightSpecular + material.kS.xyz*brightSpot );
}
Finally!
As PiroKun posted above we had a very similar result compared to marmoset, and that app uses a more standarized workflow......
So we think that this should be the workflow used by Ogre by default.
Hopefully someone... cogh cogh.. I mean Matias , would look at this and improve it so it has good performance, obey energy conservation laws, port to hlsl, and all that stuffs that we are too noob to do. And Finally integrate it as the default Pbs shader template for Ogre =D!!!! I guess the sooner the better so people dont start making textures that later wont work.
The shader File is attached to this post. Since PiroKun captured those images, I have made some little adjustments to the shader but it looks almost the same.
TL;DR: We think the default Pbs shader template is wrong and we came with a proposition to make it righ, hopefully this will be integrated to Ogre.d
- Attachments
-
- PixelShader_ps.glsl
- (16.72 KiB) Downloaded 503 times
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
This... is.... AWESOMEEEE. Felicitaciones!
I will review the code around this week (or the next one?) to make any necessary fixes, porting etc.
Thank you a lot of for taking the time to make it look closer to Marmoset!
Don't fear. I don't think there is such title as "PBR expert". Many of us still end up wrapping our head over and over again.
I can see a one particular difference with Marmoset. Obviously Marmoset must be integrating the Env. map with the BRDF, while for now we're using a simple gaussian reduce. Gives "good enough" results but trained eyes can see the difference. (not your fault, it's mine)
I'll try to integrate these changes.
Cheers
Matias
I will review the code around this week (or the next one?) to make any necessary fixes, porting etc.
Thank you a lot of for taking the time to make it look closer to Marmoset!
Don't fear. I don't think there is such title as "PBR expert". Many of us still end up wrapping our head over and over again.
I can see a one particular difference with Marmoset. Obviously Marmoset must be integrating the Env. map with the BRDF, while for now we're using a simple gaussian reduce. Gives "good enough" results but trained eyes can see the difference. (not your fault, it's mine)
I'll try to integrate these changes.
Cheers
Matias
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: What PBS workflow is using ogre2? metallic or specular?
Yay! Cool cool cool!
- ghiboz
- Goblin
- Posts: 205
- Joined: Wed Apr 25, 2007 9:47 pm
- Location: Centallo (I)
- x 2
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
great job mates!!!
- Jayray
- Greenskin
- Posts: 115
- Joined: Sun Sep 09, 2012 5:29 pm
- Location: Strasbourg, France
- x 9
Re: What PBS workflow is using ogre2? metallic or specular?
Impressive!
My first thoughts when I saw the screenshots was: "OMG! I want that!"
I am really looking forward to having it available in Ogre 2.1
By the way, a noob question: how do you set the env map?
Do you use a static reflexion map (image file) or a dynamically generated texture?
If you use an image file, what format is it?
On previous Ogre versions, I used "cubic" textures in my materials for env maps. However, I have not figured out yet how to use them in a HLMS material. Maybe the easiest way would be to create a single image file containing the whole cube map, but I have never done it...
My first thoughts when I saw the screenshots was: "OMG! I want that!"
I am really looking forward to having it available in Ogre 2.1
By the way, a noob question: how do you set the env map?
Do you use a static reflexion map (image file) or a dynamically generated texture?
If you use an image file, what format is it?
On previous Ogre versions, I used "cubic" textures in my materials for env maps. However, I have not figured out yet how to use them in a HLMS material. Maybe the easiest way would be to create a single image file containing the whole cube map, but I have never done it...
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: What PBS workflow is using ogre2? metallic or specular?
EDIT: forgot one line on the code
To make a cube map you need something like photoshop with the dds nvidia plugin, and make a strip , just follow this tutorial:
http://www.cgtextures.com/content.php?a ... e=cubemaps
but.. DO GENERATE MIPMAPS, I believe this is used by the roughness
and here are some cool cubemaps =) http://www.humus.name/index.php?page=Textures
Its an static cube map, pbs sample shows how to use it:Jayray wrote:how do you set the env map?
Code: Select all
Ogre::HlmsTextureManager::TextureLocation texLocation = hlmsTextureManager->
createOrRetrieveTexture( "SaintPetersBasilica.dds",
Ogre::HlmsTextureManager::TEXTURE_TYPE_ENV_MAP );
datablock->setTexture( Ogre::PBSM_REFLECTION, texLocation.xIdx, texLocation.texture );
http://www.cgtextures.com/content.php?a ... e=cubemaps
but.. DO GENERATE MIPMAPS, I believe this is used by the roughness
and here are some cool cubemaps =) http://www.humus.name/index.php?page=Textures
Last edited by xrgo on Thu Mar 19, 2015 4:13 pm, edited 1 time in total.
- Jayray
- Greenskin
- Posts: 115
- Joined: Sun Sep 09, 2012 5:29 pm
- Location: Strasbourg, France
- x 9
Re: What PBS workflow is using ogre2? metallic or specular?
Nice !
Thanks a lot!
Thanks a lot!
-
- Gremlin
- Posts: 196
- Joined: Tue Jan 27, 2009 12:27 am
- x 24
Re: What PBS workflow is using ogre2? metallic or specular?
This thread is pure proof that open-source rocks
- Crystal Hammer
- Gnome
- Posts: 317
- Joined: Sat Jun 23, 2007 5:16 pm
- x 77
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Impressive. Looks great !
Btw. If I have a reflection cubemap rendered for a car every frame (or e.g. just 1 face each frame), how does one get also mipmaps generated for RTT textures? Can that be made automatically and does it need much more GPU power?
Btw. If I have a reflection cubemap rendered for a car every frame (or e.g. just 1 face each frame), how does one get also mipmaps generated for RTT textures? Can that be made automatically and does it need much more GPU power?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
I sat down today to see what happened; analyzed the math. Analyzed the books.
And of course. THE PICTURES!!!
OLD (CookTorranceSeparateDiffuse). Notice the green tint caused by the diffuse colour, even when F0 = 1 (no perfect mirror unless colour is black)
NEW (Default). Notice it is a perfect mirror when F0 = 1.
CookTorrance. At lower roughness, the light spots are smaller, with smaller tails than Default (GGX). At high roughness, it looks considerably different (more "silky")
DefaultSeparateDiffuse. Similar to CookTorranceSeparateDiffuse but with a different BRDF. Diffuse causes tint. Needs to be black to get a perfect mirror
DefaultUncorrelated. Notice the dimmer edges compared to Default; particularly at high roughness values.
- The reflection mapping code was completely broken. It was remade. It's MUCH better now.
- I added multiple BRDFs. The default one is the new one.
- Your proposed fresnel formula is incorrect. It's intuitively close, but physically incorrect. See John Hable's article. Fresnel is the result of the light reflecting, refracting and rescattering across the entire surface. This phenomena dependens on the light direction, the surface normal, and the viewing direction. Your formula doesn't account the light direction.
- The reason you had to "tweak the Rs term" to match white spot is because we were using Cook Torrance, while Marmoset is almost certainly using GGX. The new BRDF uses GGX.
- The reason Ogre didn't match at all when changing the specular colour is because Marmoset tied the specular colour to the fresnel. This has the nice property that specular colour then controls how mirror-like an object is. This isn't wrong, it just limits the amount of surfaces that can be represented by the different parameter combinations. To make the Ogre's look get closer to what Marmoset was doing, you would have to change the fresnel as well in your pictures. It is very unintuitive because to get a mirror effect you need to set the diffuse colour to black, the F0 (fresnel coefficient) to 1 and the roughness to a low value.
The "Default" and "CookTorrance" base BRDFs tie the specular with the fresnel because it's intuitive and it's what everybody else is doing. But shall somebody need more power to represent complex surfaces, you can use DefaultSeparateDiffuseFresnel (or CookTorranceSeparateDiffuseFresnel) to get the old behavior. - "DefaultUncorrelated" is there for those looking exchanging assets with Unity. It uses the height-uncorrelated version of GGX, which is what Unity uses. It is not enabled by default.
- I added two functions "importUnity" to import the values from Unity PBS materials (needs visual confirmation). From what I can see, they don't use kS and use coloured fresnel as a way to apply specular (which only limits the amount of surfaces that can be represent, also looks different)
- One of the import overloads shows how to convert from metallict to specular workflow (specular colour is obtained from from a lerp between 0.03 or so and the diffuse colour, using the metallic as weight). However, the shaders don't natively support metallic which means you can't use a "metallic texture" instead of a specular colour texture.
- If you can't match the settings to a particular renderer (i.e. Unity, Marmoset), try using the specular as coloured fresnel instead, and leave the specular as white.
- The previous BRDF Ogre was using is now named CookTorranceSeparateDiffuseFresnel
And of course. THE PICTURES!!!
OLD (CookTorranceSeparateDiffuse). Notice the green tint caused by the diffuse colour, even when F0 = 1 (no perfect mirror unless colour is black)
NEW (Default). Notice it is a perfect mirror when F0 = 1.
CookTorrance. At lower roughness, the light spots are smaller, with smaller tails than Default (GGX). At high roughness, it looks considerably different (more "silky")
DefaultSeparateDiffuse. Similar to CookTorranceSeparateDiffuse but with a different BRDF. Diffuse causes tint. Needs to be black to get a perfect mirror
DefaultUncorrelated. Notice the dimmer edges compared to Default; particularly at high roughness values.
- Jayray
- Greenskin
- Posts: 115
- Joined: Sun Sep 09, 2012 5:29 pm
- Location: Strasbourg, France
- x 9
Re: What PBS workflow is using ogre2? metallic or specular?
Niiiiiiiice!
Can't wait to try it
Can't wait to try it
- Jayray
- Greenskin
- Posts: 115
- Joined: Sun Sep 09, 2012 5:29 pm
- Location: Strasbourg, France
- x 9
Re: What PBS workflow is using ogre2? metallic or specular?
Loving it
I am now able to have really good looking diamond and glass cubes.
For glass cubes, I used "scene_blend colour_blend" to make them transparent and I use the diffuse colour to control the transparency, it works great
I am now able to have really good looking diamond and glass cubes.
For glass cubes, I used "scene_blend colour_blend" to make them transparent and I use the diffuse colour to control the transparency, it works great
- spookyboo
- Silver Sponsor
- Posts: 1141
- Joined: Tue Jul 06, 2004 5:57 am
- x 151
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Cool
Gui generator tool https://github.com/spookyboo/Magus ==> Windows binaries https://github.com/spookyboo/Magus_bin
HLMS editor https://github.com/spookyboo/HLMSEditor ==> Windows setup https://github.com/spookyboo/HLMSEditor ... e?raw=true
HLMS editor https://github.com/spookyboo/HLMSEditor ==> Windows setup https://github.com/spookyboo/HLMSEditor ... e?raw=true
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: What PBS workflow is using ogre2? metallic or specular?
awesome!! its looking way better now, I think I still have a few concerns, but let me analyze it better with Pirokun =)
Thank you very much! go ogre!!!
Thank you very much! go ogre!!!
- Crystal Hammer
- Gnome
- Posts: 317
- Joined: Sat Jun 23, 2007 5:16 pm
- x 77
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Looks beautiful
Is this also possible with dynamic reflections? I.e. would require that render to cubemap textures will have auto generated mip-maps too. Is this possible and any idea if it drops fps much? (I already asked on other topic )
Is this also possible with dynamic reflections? I.e. would require that render to cubemap textures will have auto generated mip-maps too. Is this possible and any idea if it drops fps much? (I already asked on other topic )
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
I would have to check how's the status of automatic mipmap generation. In D3D11 it's well defined but on OpenGL it has always been a nightmare.Crystal Hammer wrote:Is this also possible with dynamic reflections? I.e. would require that render to cubemap textures will have auto generated mip-maps too. Is this possible and any idea if it drops fps much? (I already asked on other topic )
May as well perform the downscale yourself if it's possible.
As for the performance drop, I doubt it will be sizeable, but it will obviously depend on the number of active cubemaps.
-
- Gnoblar
- Posts: 6
- Joined: Wed Mar 11, 2015 6:31 pm
- x 7
Re: What PBS workflow is using ogre2? metallic or specular?
Hello! this is our (Xrgo and me) point of view from a 3D artist perspective regarding this topic.
As artists, the most important thing for us here, is that the default/cooktorrance mode works exactly as the standard specular workflow. This way it would be easier to get assets that are already around for other engines that uses specular workflow, and it would encourage other people coming from other engines, or other 3D artists to join the Ogre community =)
The current implementation looks great, gives the user the option to work with SeparateDiffuseFresnel for represent complex surfaces, and Default/CookTorrance which tie the specular with fresnel, and try to work like what everybody else is doing (like Specular Workflow).
And here, we believe that there are some details that fixed, could improve the Default/CookTorrance to make it identical to the Specular Workflow:
We don't know how are the exact math of this, but roughness should decrease the final reflectivity of the material (including at grazing angles), like the examples in http://www.filmicworlds.com/2014/03/17/ ... flectance/
It would be great if Ogre had this workflows: standard specular workflow that everyone knows! (maybe metallic workflow too!) and the other one that lets you create more complex materials.
As artists, the most important thing for us here, is that the default/cooktorrance mode works exactly as the standard specular workflow. This way it would be easier to get assets that are already around for other engines that uses specular workflow, and it would encourage other people coming from other engines, or other 3D artists to join the Ogre community =)
The current implementation looks great, gives the user the option to work with SeparateDiffuseFresnel for represent complex surfaces, and Default/CookTorrance which tie the specular with fresnel, and try to work like what everybody else is doing (like Specular Workflow).
And here, we believe that there are some details that fixed, could improve the Default/CookTorrance to make it identical to the Specular Workflow:
- In the actual default we have the impression that the [specular colour + fresnel value] should be in fresnel, but fresnel just accepts a value, not a texture, so there is a problem here.
- If the idea of this is to tie the specular with fresnel, why you can still modify the specular separately? We think this parameter should be removed (Or use this intead of fresnel parameter. See the next point).
- Instead of using the word "fresnel" as the result of [specular colour + fresnel value] we should use the word "specular" so it will fit the standard specular workflow, this way would be more user friendly to people already working with pbs or people that is learning from tutorials on the web.
We don't know how are the exact math of this, but roughness should decrease the final reflectivity of the material (including at grazing angles), like the examples in http://www.filmicworlds.com/2014/03/17/ ... flectance/
It would be great if Ogre had this workflows: standard specular workflow that everyone knows! (maybe metallic workflow too!) and the other one that lets you create more complex materials.
- miki3d
- Halfling
- Posts: 56
- Joined: Wed Jul 18, 2012 1:30 pm
- Location: Italy
- x 4
Re: What PBS workflow is using ogre2? metallic or specular?
Hi all!
Here's my two cents.
As you can see on the images above, my flow is based on metalness and pbr material has a flag (or a mask) to change from dialectric to metallic, as seen on some PBR implementation (I think ue4 has something like that and marmoset explain this on site).
When metalness is 0 the material is dialectric where the diffuse comes from the texture and the IOR comes from the default for the dialetric (0.02)
When metalnessi is 1 the material is metallic where the diffuse is black and the IOR comes from the diffuse colour, so we get specular coloured when the diffuse is coloured
Here's my two cents.
As you can see on the images above, my flow is based on metalness and pbr material has a flag (or a mask) to change from dialectric to metallic, as seen on some PBR implementation (I think ue4 has something like that and marmoset explain this on site).
Code: Select all
float3 diffColor = diffuse.rgb * (1.0 - metalness);
float3 specularColor = lerp(specularLevel, diffuse.rgb, metalness);
When metalnessi is 1 the material is metallic where the diffuse is black and the IOR comes from the diffuse colour, so we get specular coloured when the diffuse is coloured
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Just to be clear. Specular and coloured fresnel yield very similar results but they're not the same. Try a maxed out green fresnel vs a maxed out green specular. The inner section of a sphere material looks the same. But as we look outwards, coloured fresnel starts losing the green colour while green specular remains green.PiroKun wrote:[*]In the actual default we have the impression that the [specular colour + fresnel value] should be in fresnel, but fresnel just accepts a value, not a texture, so there is a problem here.
Coloured fresnel was introduced as a performance optimization by other engines, and since it looked similar, it took a lot of time for people to realize it wasn't the same.
I agree that it is a problem that you can't use texture for fresnel; and this needs to be fixed (eventually...).
As for the naming though... Fresnel is the correct term. I hoped that using an import process this could be corrected and tools built upon Ogre (i.e. material editors) could change their naming conventions if they wanted to (e.g. call coloured fresnel "specular" and ignore the specular setting). May be I'm being too optimistic?
I believe what you're witnessing is the product of one of our "quick hacks". The problem is not in the shader but in the cubemap generation.Another important point (that affects both SeparateDiffuseFresnel and Default/CookTorrance )is that roughness affects the final reflection.
We don't know how are the exact math of this, but roughness should decrease the final reflectivity of the material (including at grazing angles), like the examples in http://www.filmicworlds.com/2014/03/17/ ... flectance/
Normally, generating the mipmaps for the cubemap involves a process where the BRDF is evaluated for each pixel in each mip. This accounts for roughness. This process is also slow and math heavy.
What we do instead (because I didn't have time to write it) is to use a simple down sample filter (e.g. gaussian filter, bilinear filter, or use whatever was in the file format); which is not physically correct. This is not a problem though, if you use a cubemap texture whose mipmaps have been generated by a PBR tool (I don't know if there are tools that supports generating these for exporting; technically UE4 & Unity generates them, but I don't know if they export them to DDS or something that can be easily be used somewhere else).
-
- Gnoblar
- Posts: 6
- Joined: Wed Mar 11, 2015 6:31 pm
- x 7
Re: What PBS workflow is using ogre2? metallic or specular?
Yeah, i understand its not the same. But I thought the intention with the "default/cook torrance", was to make it like what everybody else is doing. And for me, this means using only a texture to control the fresnel value and specular color, the texture for diffuse color, normal map and roughness texture. I know this limit the amount of materials that can be respresent, but i think this will be a gread advantage for everyone if this works the same way as other engines. And as you say, there is DefaultSeparateDiffuseFresnel for represent all the complex surfaces (and that is very cool too!)dark_sylinc wrote: Just to be clear. Specular and coloured fresnel yield very similar results but they're not the same. Try a maxed out green fresnel vs a maxed out green specular. The inner section of a sphere material looks the same. But as we look outwards, coloured fresnel starts losing the green colour while green specular remains green.
I'm understanding this wrong?
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: What PBS workflow is using ogre2? metallic or specular?
Gotcha. I'll add a fresnel texture to my todo list. You can ignore specular if you want to; and it then remains to be a matter of naming conventions. I may end up changing "specular" in the scripts for coloured fresnel, and "kS" for the explicit specular colour.
Btw. "Default" and "DefaultCookTorrance" are different BRDFs. Not sure if this was clear or not
Btw. "Default" and "DefaultCookTorrance" are different BRDFs. Not sure if this was clear or not