final exam effects
play

Final exam effects Textures I Final exam effects Final exam - PDF document

Final exam effects Textures I Final exam effects Final exam effects Lighting Grads Light saber Research and implementation plan Stage lighting Textures Teams Coffee froth Implementation Donuts Coke Can


  1. Final exam effects Textures I Final exam effects Final exam effects  Lighting  Grads  Light saber  Research and implementation plan  Stage lighting  Textures  Teams  Coffee froth  Implementation  Donuts  Coke Can  RenderMan  Volumetric  Cg  Coffee smoke  Documentations  Postprocessing  Advanced Toon Shader / NPR Final exam effects Plan  Please register your preference  Textures  Mycourses quiz.  This week  Texture mapping (from files)  Bump Mapping  Environment Mapping  Simple Toon Shading  Next week  Procedural shading 1

  2. Texture Mapping Texture Mapping Define surface characteristics of  y an object using an image Basic concept: associate value texture space (u,v)  at some coordinates in texture z x with pixel at some coordinates in parameterization screen geometry geometry Coordinate spaces used in  object space (x o ,y o , z o ) texture mapping: Texture space (u, v) projection  v Object space (x o ,y o ,z o )  image Screen space (x, y)  screen space (x,y) u Texture Mapping Textures in shaders  Textures are just data  Texture coordinates available to the shader  Global variable / semantic  Actual mapping determined by underlying scene model. Textures in shaders Texture mapping in RenderMan  Tasks:  Texture coordinates range from 0-1 in texture space  Make texture data available to rendering  Grab texture data for a given point  Values of texture coords corresponding to P given in global parameters s and  Use texture coord from shading point  Indexed by some other means t .  Apply texture data as appropriate  Filtered texture lookup  Color, normal, opacity, whatever.  Free antialiasing. 2

  3. Textures in RenderMan Textures in RenderMan  Access texture values from file using  Can access color or floating point values the texture() function from file  texture (filename, q, r) -- Return  f = float texture (“foo.tex”); value(s) at texture coords (q,r)  c = color texture (“bar.tex”);  texture (filename) -- Return value(s)  Can access specific channels from file at standard texture coords (s, t).  f = texture (“foo.tex” [1]); Textures in RenderMan Texture format  texture() function provides manual  prman has a proprietary format for textures. control over filtering  txmake [args] infile outfile  Converts images into this format  See section 8.1.4 in text.  Args:  -mode [black clamp periodic]  -smode, -tmode  -short, -float  -resize up- Textures in RenderMan Textures in Cg surface paintedplastic ( float Ka = 1, Kd = .5, Ks =  Texture operations happen in fragment .5, roughness = .1; shaders color speccolor = 1; string texname = “”;)  Texture coords, attached to vertices are { color Ct = Cs; interpolated and available to fragment if (texname != “”) shader Ct *= color texture (texname);  TEXCOORD0 ,TEXCOORD1 semantic normal Nf = faceforward (normalize(N), I); vector V = -normalize (I); Ci = Ct * (Ka*ambient() + Kd*diffuse(Nf)) + speccolor * Ks * specular (Nf, V, roughness); Oi = Os; Ci *= Oi; } 3

  4. Textures in Cg Textures in Cg  Access to texture values: use  Projective texture mapping  texNNNN[proj] () functions  NNNN =  1D / 2D / 3D - using texture coords (0-1)  RECT - using texel coords (0 - texWidth, textHeight)  CUBE - for environment mapping  [proj] - projective texture map  As if projected by slide projector  Useful in shadowing Textures in Cg (vertex) Textures in Cg (fragment) struct voutput { struct toutput { float2 texCoord : TEXCOORD0; float4 color : COLOR; } } voutput mytexturepass (float2 texCoord: TEXCOORD0); toutput mytexture (float2 texCoord: TEXCOORD0, { uniform sampler2D decal); voutput OUT; { OUT.texCoord = texCoord; toutput OUT; return OUT; OUT.color = tex2D (decal, texCoord); } return OUT; } Textures in Cg Textures in Cg  The sampler2D datatype  Textures are data  Sampler objects refer to an external object  Can be used as values that Cg can sample  Individual components can be accessed via  Set in application program swizzling / masking  In OpenGL this can be a texture object  void cgGLSetTextureParameter(CGparameter param, GLuint texobj);  Questions.  Texturing parameters set in openGL will apply. 4

  5. What you can do with texture maps Texture Mapping- Bump Mapping  Adds roughness to surfaces  Color  Quick way to add detail to  Bump Mapping an object  Environment Mapping  Polygon remains physically  Toon Shading. flat, but appears bumpy Jim Blinn Texture Mapping- Bump Mapping Texture mapping – Bump Mapping  Perturbing surface normal  Texture map represents displacements from the normal  Use perturbed normal in illumination model Bump mapping in RenderMan Bump vs displacement mapping  Performed using the displacement shader:  Displacement mapping  Modifies global variables P and N  Moves actual point P+= bumpheight * normalize(N); P+= bumpheight * normalize(N); N = calculatenormal (P); N = calculatenormal (P);  Recall that displacement shaders are  Bump mapping executed before surface shaders.  Just changes normal  bumpheight can be read from a texture file, or generated procedurally, or both… N = calculatenormal (P + amp*normalize(N)); 5

  6. Bump mapping in RenderMan Bump Mapping in Renderman  Bump mapping calculations should be vector Nshad = vtransform (“shader”, N); point Pshad = transform (“shader”, P); done in “shader” space Pshad += amp * normalize (Nshad); P = transform (“shader”, “current”, Pshad); Coordinate Description N = calculatenormal (P); System  Works just as well (see Section 8.2.3 in text "shader" The coordinate system in which the shader for derivation) was defined. This is the "object" coordinate system when the shader is defined. vector Nn = normalize (N); "current" The coordinate system in which the shading P += Nn * (amp / length (vtransform(“shader”, calculations are being performed. This is Nn)); normally the "camera" or "world" coordinate system. Bump mapping in Cg Phong as a Fragment Shader  Once again, bump mapping like all void PhongVertexPass (float4 position: POSITION, float3 normal: NORMAL, texture mapping, must be done by a out float4 oPosition: POSITION, out float3 objPos: TEXCOORD0, fragment shader. out float3 oNormal: TEXCOORD1  Consider the basic Phong shader. uniform float4x4 modelViewProj) { oPosition = mul (modelViewProj, position); objPos = position.xyz; oNormal = normal; } Need texCoord at vertex to be passed to fragment shader Phong as a Fragment Shader Phong as a Fragment Shader void basicPhongFrag (float4 position: TEXCOORD0, { float3 normal : TEXCOORD1, float3 P = position.xyz; float3 N = normalize (normal); out float4 color: COLOR, uniform float3 globalAmbient, // ambient term uniform float3 lightColor, float3 ambient = Ka * globalAmbient; uniform float3 lightPos, uniform float3 eyePos, // diffuse term uniform float3 Ka, uniform float3 Kd, float3 L = normalize (lightPos - P); uniform float3 Ks, float diffuseLight = max (dot(N, L), 0); uniform float shininess) float3 diffuse = Kd * lightColor * diffuseLight; Need texCoord at vertex to be accepted by fragment shader These values will be modified by values in bump map Texture map need to be added as a parameter 6

  7. Phong as a Fragment Shader Bump Mapping // specular term  Questions? float3 V = normalize (eyePos - P); float3 R = normalize (reflect (L, N)); float specLight = pow (max(dot(R, V), 0), shininess); if (diffuseLight <= 0) specLight = 0; float3 specular = Ks * lightColor * specLight; // put it all together  Break. color.xyz = ambient + diffuse + specular; color.w = 1; } Toon Shading Toon Shading  Mimic the look of cartoons  Intentionally 2-dimensional  Use of a set solid colors (rather than a gradiant)  Hard edges [Lake, et. al. 2000] Phong Model Toon Shading  Much like diffuse shading but…  Rather than using N • L to determine shade color  Use N • L as index to a 1D texture map. ∑ ∑ k L ( V ) = k L + k L ( S • N) + k L ( R • V) e a a d i i s i i i i ambient diffuse specular Note: L n are radiance terms, include both light and material info 7

  8. Toon Shading Toon Shading  To avoid aliasing  toon shading in print:  Use large map with gradient between color  [Lake, et. al. 2000] transitions.  X-Toon [Barla, et. al. 2004] Environment mapping Environment mapping  Create an image, representing the reflection of  Not associated with a particular object but the world onto an object with an imaginary surface surrounding the  Use surrounding sphere or box, image is texture scene map indexed by direction of reflection ray  Specular Reflection – indexed by reflected ray  Poor-man’s ray tracing - cheaper  Diffuse - by surface normal  Transparency – refracted ray direction Environment Mapping Environment Mapping spherical Cube map 8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend