"Vympel" disse: Duvido que você ache uma explicação melhor do que a encontrada no manual do mental ray queja vem no MAX:!: tá afimde traduzir para gente? quemse abilita? :) " Print Thread Subject A full explination of DGS shaders Posted by ickyptang (Posting A Bit) Posted on 09/05/03 03:14 PM I have been reading on here that many people want to use Mental Ray's DGS shader, but don't understand quite how it works... I've also had requests to write up an explination of sorts for it, so thats exactly what I am doing : ) I'll go over each individual DGS attribute, but first I need to do some reality-explaining. It might seem like I am "talking down" to you, but I am merely trying to give simple explinations of what reality does so you can understand what DGS does to try and exactly simulate it... so... just bear with me til the end of the explination before you jump to any conclusions ; ) I warn you, this is going to be REALLY LONG... but, then again, I suppose all of my posts are : P Before I start, I just want to make clear that this post is an in-depth explination of DGS materials, not really a tutorial of step-by-step how to create and use a DGS material within Maya. I have had requests to do such a post and will do one shortly. Basically, I want to include pictures in that post, and I don't currently have access to my site so that I can include pictures... long story. So lets get started. As I have said in previous posts, in reality EVERYTHING is reflective. Thats the basis of sight: light striking a surface, being reflected, and then striking our eyes. So if this is the case, why do certain objects appear as a solid color? The laws of physics dictate that light traveling in a straight line will reflect at an exact angle to the angle at which it strikes the surface, in the opposite direction. If light strikes a surface at a 45 degree angle from the right, it will reflect at 45 degrees to the left... 90 degrees to a surface (perpenidicular) it will reflect exactly back towards the source... etc. Thus, if everything is reflective, it might be reasonable to assume that everything should just appear as a mirror (of course if EVERYTHING was a mirror, there wouldn't be much to reflect, but I digress ; ) While its true that light does reflect in a straight line, its also true that surfaces in reality are rarely, if ever, completely smooth. Most surfaces have tiny imperfections. Microscopic "bumps," invisible to the naked eye, that affect how light is reflected. These microscopic bumps, or "microfacets," reflect light at different angles. So, even if light strikes a flat surface from exact perpendicular angle to the surface, chances are the reflection will not remain perpendicular to that surface. It will strike a microfacet and be shot off at a slight angle. The light is scattered and this causes blurred reflections. So, why do some objects appear as solid colors? First let me explain a solid white object, then we will go to colors. A white light strikes a white wall. This wall has enough microfacets to scatter all the light that strikes it, and blur it to such a degree that no visible "reflection" is seen. While it is still reflecting the light and the environment around it, it is SO blurred that no specific reflections can be made out, and thus it appears as a "flat white." When light is blurred to such a degree that no actual reflection can be seen, it is usually referred to as a "diffuse" reflection. So now color. Well, its commonly known that objects have a certain colors which they tend to reflect more than others. For example, red objects reflect more colors in the red side of the light spectrum than they would, say, in the green side. So, objects have colors because when light is reflected off of them, certain colors are reflecting more than others. When a colored surface has enough microfacets to scatter enough light to a "diffuse" degree, we see a flat color. Now theres the issue of specular highlights. First I need to dispell a commonly held belief in the CG community: in reality, there is no such thing as a specular highlight as we know it. There is no such thing as a magic white spot that appears in conjunction to a light source. In reality, all highlights (and I mean ALL highlights) are the results of reflections. Most highlights that we see are the reflection of light sources, but they can also be just a reflection of a bright area... like a bright white object or something. So, if this is true, and all highlgihts are the results of reflections, how come there are black objects with highlights? If light is reflected off an object, one would think that it should not be black, as black indicates that all light is being absorbed by an object, with none reflected. Well, to put it simply, it doesn't take much reflection to produce a highlight. Something can reflect to such a small degree that no true color can be easily made out, nor can any crisp reflection be seen. However, if there is something bright enough to produce a highlight (like a light source), it will appear in any object thats reflection is not blurred to such a degree to be diffuse. You can test this, if you want, by holding your finger up to any object with a highlight and moving it around. If you look in the right place you will see your finger reflected in the object, even if it is very faint or very blurred. Generally, if you hold your finger beneath the highlight, you will see it reflected in the dark area. Now what about transparency? As we all know, transparency is caused by light passing through an object. Why, then, do traditional shaders let us us make something 100% transparent and still have a highlight? Since I said that all highlights are caused by a reflection, how can something let 100% light pass through and still have a highlight? Simply put, it can't. There are virtually no objects in reality that are 100% transparent. Air is probably the closest contender to that, but I dunno that I'd call that an object ; ) Similary, it is physically impossible to have an object both 100% transparent and have reflectivity at the same time. If all light is passing through the object, there is no light left to reflect. Traditionally, you might create, say, a glass shader by having a blinn at 100% transparency, a white diffuse, a white specular highlight, and a 10% reflection. This is wrong in so many ways : ) While it might look good and like glass enough to fake it, it is completely and totally false in reality-terms. First off, you have 100% light passing through. Then you have a 10% reflection... already we are dealing with 110% of the light striking the surface. 100% passes through, 10% reflects. Now lets look at the white highlight. With traditional shaders, white highlights are an indication that 100% of the light striking the surface is being returned to the viewer. Thus, we now have 210% light... 100% passing trough, 110% reflecting. Ok, then theres the white diffuse... as I said above, diffuse is still a form of reflection. White diffuse means that no light is being absorbed, it is all reflected, just in a very scattered manner. So thats another 100% being reflected off. We now have 310% since we have 100% passing through, and 210% reflecting. Have you ever tried to do some Global Illumination or Final Gathering with traditional shaders and have gotten insanely bright results? Thats why... we are getting 310% of light coming from a 100% light source!!! ; ) In reality, to get the same glass effect, you'd have a 90% transparent surface with 10% being reflected back... thats all. The 10% reflection would take care of the reflection of the environment and the highlight by itself. There is no diffuse reflection/transmission, or else the glass would take on a "frosted" look. So, having all these seperate elements to generate the look of a shader is a long way to fake reality. In reality, there are only 2 things indicating the look of a surface: reflection and transmission. The fake may look fine and pass scrutiny, but for us reality purists, its no good ; ) Now to DGS. DGS stands for "Diffuse, Glossy, Specular." As can be expected from the name, DGS splits reflection into 3 types: Diffuse, Glossy, and Specular. In reality, there are no real "types" of reflection, just different reflections due to the amount that the reflected light is scattered. DGS splits it into 3 for ease of use. Before I go into how each parameter works individually, let me explain how to define a value for them. The value is derived entirely via the color channel. There is no seperate value defining the "strength" of the effect, its all based on the color. Thus, if you have a pure white specular reflection (1, 1, 1 in the RGB or 0, 0, 1 in the HSV) it is equivalent to a 100% reflection. If you have, say, a pure blue defined (0, 0, 1 in RGB or 240, 1, 1 in HSV) it tells the shader to reflect 100% of the blue light and absorb all the red and green information. This would be similar to setting a blue reflected color using a blinn or phong. Furthermore, if you have a 50% gray set (.5, .5, .5 in RGB or 0, 0,.5 in HSV) you will get a 50% reflection. Ok, now, lets go into the individual attributes of the DGS. We'll work "backwards" (as far as the name DGS is concerned) and start with Specular. Specular is a "mirror" reflection. In other words, its reflection that is not scattered at all. Specular reflection assumes that the surface is completely and totally smooth, and returns a reflection at an exact opposite angle to where the light strikes the surface. Simple. Glossy is slightly more complex. "Glossy" is the term used to refer to scattered reflections. DGS works on a microfacet principle, meaning that if you set a glossy reflection, it treats the surface as if it was covered in microfacets, and thus returns a blurred reflection. Not surprisingly, you can get a similar results by putting an INCREDIBLY dense bump map on a surface... DGS, and other glossy shaders for that matter, are just far more efficient than using a bump-map method. I will go into exactly how to control the "density" of the microfacets (using the shiny parameters) shortly. (as a side note, you get grainy results using blurred reflections if the sampling quality of your render is too low... -2 0 is the lowest effective/recommended sampling quality and 2 4 is the highest... 2 4 will make things nice and crisp, but it takes FOREVER... you have been warned ; ) Last we come to Diffuse. Judging from my explination above of diffuse reflections, you would think that if you make your shader glossy enough (and thus scatter the light to a significant enough degree) you will get a diffuse reflection... and you'd be right : ) However, DGS seperates reflection into the glossy and diffuse to offer greater control over the look of your surface. Also, its WAY faster to simply use the diffuse channel then to try to make an exceptionally blurred glossy... Simply put, though, you set the diffuse color as your base color. A red wall will have a red diffuse... a wooden surface would have a wood-pattern in the diffuse channel. So on and so forth. Basically, under most circumstances, this is where your texture maps go. Ok, going back to glossy, let me explain how it works. I have said you can control the amount of scattering or blur, and this is done by the Shiny parameters. Shiny works in the opposite manner of how you might expect: the lower the value the MORE glossy or blurred your reflections are. This works very much like the Cosine Power parameter of a Phong shader. Higher values are more focused (less blurry) whereas lower values are more spread (more blurry). Set the value high enough (like, say, to 1000) and your reflection will appear, more or less, like a specular reflection. The lower the number (say to 1 or lower) and the reflection will appear quite diffuse. Simple, no? There are two other shiny parameters, however: Shiny_U and Shiny_V. These control, as one might expect, the amount of blur along the U and V axis. This is used to get more blur along one direction of your surface, an effect more commonly known as "anistropic" highlights. You can use these to simulate a brushed metal look. They work the same way as the regular Shiny, with higher values being more focused, and lower values being more blurred. If there is a number in either Shiny_U or Shiny_V the regular Shiny parameter gets ignored. Also, if there is specular color defined WITHOUT a glossy color defined, all Shiny parameters are ignored. Ok, last but not least, the transparency parameters. The first one, Transp, controls, simply enough, how transparent your object is. So what if you want a transparent object with some reflection, like the afformentioned glass example? Well, if you remember, I said that there is no physical way for an object to be both 100% transparent and have reflection, and in reality a glass window might have, say, 90% transparency with 10% reflection. DGS works on the same principle. In order to get glass that is both transparent and reflective you'd set your specular to white and have your Transp at .9 Simply put, thats telling the shader that 90% of the light is transmitted, and 10% is being reflected in a specular manner. If you wanted blue glass, you'd have your specular set to blue and have your Transp set to 1, and if you want blue glass with reflectivity, you'd have specular at blue and Transp at something less than 1... simple. If you want frosted glass, you'd set your GLOSSY to whatever color, set a Shiny value for the amount of blur, and then work your Transparency from there. It all makes a lot of sense once you understand what its doing. Finally, the last parameter is "Ior." This is your Index of Refraction, and works exactly like Index of Refraction in any other shader. Just as a note, though, 1, not 0, means no refraction. DGS defaults at 0, so you need to change that to 1 if you want to do non-refractive transparencies. Before I finish off this ridiculously long explination, let me make the point that one can (and often does) use both the diffuse and other parameters together. For example, a wood surface with highlights would be achived by having the wood texture in the diffuse channel, and whatever color value (usually some degree of white, like a .1 gray or so) set for either the specular (for sharp highlights) or the glossy, with the appropriate shiny value(s) set for blrured highlights. And thats that. DGS in a nutshell. I hope you found this informative and didn't fall asleep TOO many times while reading it ; ) Hopefully I'll have a full tutorial of how to use DGS within Maya within the next few weeks. Have fun DGS-ing! : ) -Steve " TEXTO OBTIDO NO FORUM MAYA RENDERING DO www.cgtalk.com
Total de mensagens publicadas pelos membros da comunidade: 717341.
Total de membros registrados: 143142
Últimos membros registrados: PuriBreez345, dasfsfasdfs, zanfabh, TestolibCapsules35, TestolibKapslar3455, Whispers, dtabach, Vanotium34.
Usuário(s) on-line na última hora: 557
Legenda: Administrador, Especial, Moderador, Parceiro .