Surface Material Physics for Shader Writers. Chas. Boyd DirectX® Graphics Architect Windows® Gaming & Graphics Technology Microsoft® Corporation. Motivation. Lighting and surface effects are clearly discernable to end-users Enables novelty for them, and differentiation for you
01 / 68Surface Material Physics for Shader Writers
1 / 17
Télécharger la présentation
Surface Material Physics for Shader Writers
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
Motivation • Lighting and surface effects are clearly discernable to end-users • Enables novelty for them, and differentiation for you • Enable a title to have a distinct “look” • See other talks on lighting models, this one focuses on surfaces
Assumptions • For all surfaces: • Other effects such as shadows will be applied in the lighting model • These are independent of the surface effects described here
Surfaces and Lighting • Key participant in visual “Look” • Interacts with lighting environment in various ways • Need to take both into account in any given situation • Design content to have surfaces that look best in the lighting environment they will be used in and vice versa
Surface-Light Interaction • Light comes in • Surface modifies it • Light leaves towards camera/eye • Surface interactions include • Absorption, reflection, self-shadowing, self-occlusion, scattering • Subsurface effects • Absorption, scattering, re-emission
Fundamentals of Surfaces • Surfaces often contain multiple constituents • Absorptive dies, reflective layers, scattering particles of various sizes • This talk proceeds from simplest to more complex surface structures
Polished Metal Surface • Process • Light comes in • Some colors are absorbed • Remaining light reflects • Atomically smooth—mirror finish • Structured highlights • image of environment are visible in them
Map-Based Technique • Apply environment map for reflection • Scale it by metal color • Accounts for some colors absorbed • That is the final color for the screen • C = envmap*base • Gamma Note: no effect
Procedural Technique • Use very high specular exponent • ~100 or higher • Accurate model for single constant color round light source • C = light*dot(N,H)^100 * base • Gamma Note: picking exponent
Use in Games • Works for gold, copper, bronze • some anodized effects • Ideal for weapons • “Gun metal blue” • Not appropriate for enameled metal • More metallic than any “metallic” auto-body enamel • Nor for oxidized e.g. verdigris • These are too rough for this model
Rougher Surfaces • Smudges, scuffs, dust, oxides • At high magnification we see:
Map-based Technique • Roughness varies per-pixel in “gloss” map e.g. alpha of base tex • Scale down environment map • c = gloss*envmap*base • Blur environment map in areas of low gloss • MIP LOD or post-process effect • MIP LOD is per-pixel in ps.2.0 • Blur is partial integral of map
Procedural Technique • Use procedural specular • spec = light*dot(N,H)**25 • but with same gloss term • c = gloss*spec*base • Decrease exponent to achieve blur
Procedural Technique • Model only Diffuse term • For directional light: • c = light * dot(N,L) * base • Or use hemisphere light • Gamma Note: • Correct using sqrt or 1-(1-x)**2 • for non-CAD applications
Layered Surface • Thin layer of smooth clear material • Over rough dye particles • Underlayer is rough because particles may be suspended • Plastics • Linoleum • Enameled metal –car finish • Varnished surface –wood
Map-Based Technique • Envt. map scaled by gloss term • spec = gloss*envmap • Added to diffuse term: • c = dot(N,L)*base + spec • Base color does not tint highlight • Gamma Note: add should be linear • Correct to linear, add, convert back • if have enough precision and time
Procedural Technique • Base color does not modulate specular, only light color does • spec = light*dot(N,H)**100 • c = dot(N,L)*base + spec*gloss • Top layer + bottom layer
Fresnel Effect • At top layer interface • Some light is reflected, • Remainder is transmitted through • Depends on surface material • And on incident angle! • Fresnel term f is proportion reflection • grazing angles: 100% reflected • normal angles: 5% reflected
Fresnel Mid 60% reflected Air Material 40% transmitted
Fresnel Normal 10% reflected Air Material 90% transmitted
Fresnel Term Approximation • Use f = 1 - cosq = (1 - E dot N) • Raise to power for better approximation • f = (1 – cosq)4 • [Schlick] used 5th power • Hack curve fit to Glassner
Fresnel Vertex Shader m4x4 oPos,v0,c8; // xform pos. to output space m4x4 r0,v0,cW // xform pos. to world space, m3x3 r1,v3,cW // xform normal to world space add r0,-r0,c14 // compute eye ray dp3 r3.x,r0.xyz,r0.xyz rsq r3.xyz,r3.x mul r0.xyz,r0.xyz,r3.xyz// normalize it dp3 r0,r0,r1; // dot eye ray with normal add r0,c1111,-r0 // complement color mul r1,r0,r0 // **2 mul r0,r1,r1 // **4 mul r0,r0,c1 // scale for fresnel add oD0,r0,c0 // bias and emit as diffuse
Fresnel Pixel Shader ps.1.1 ; def v0 // eye ray def c0 // 5% bias def c1 // 95% scale tex t0 // normal map dp3 r0,v0_bx2,t0_bx2; // dot eye ray with normal mul r1,1-r0,1-r0 // complement and square mul r0,r1,r1 // **4 mad r0,r0,c1,c0 // scale & bias
Fresnel Affects Diffuse Layer • Only light that was not reflected illuminates diffuse “dye” layer • In single light case, incident angle can be used to compute f • Then f is used to blend (lerp) between specular and diffuse • Not as useful for multi-light case • diffuse layer is illuminated by light from all directions in that case
Connexion au compte
Connectez-vous pour publier votre contenu sur SlideServe.