1 / 32

Real Time Rendering

Real Time Rendering. Lighting and Reflectance Model. Light interaction. Interaction It depends on the physical characteristics of the light, the physical composition and characteristics fo the matter. When light makes contact with material, three types of interactions may occur.

maya
Download Presentation

Real Time Rendering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Real Time Rendering Lighting and Reflectance Model

  2. Light interaction. • Interaction • It depends on the physical characteristics of the light, the physical composition and characteristics fo the matter. • When light makes contact with material, three types of interactions may occur. • Light reflection, light absorption, light transmitted.

  3. Light interaction. • Interaction. • Form. • Conservation of energy. • Majority of incident light. • Reflected light and Absorbed light. • Light is reflected towards the observer from all visible surface regines. • BRDF describes how much light is reflected when light makes with a certain material.

  4. BRDF? • It is function that describes how light is reflected from a surface. • It is used to describe material properties. • Input value • Incoming and outgoing azimuth and elevation angles. • Wave length of the incoming light. • Presented with RGB color.

  5. BRDF? • General functional notation. • Position-invariant BRDF in functional notation. λ : used to indicate that the BRDF depends on the wavelength under Consideration. θi, φi : represent the incoming light direction in spherical coordinates. θo, φo : represent the outgoing reflected direction in spherical coordinates u , v : represent the surface position parameterized in texture space.

  6. BRDF? • Definition of BRDF • It is defined as the ratio of the quantity of reflected light in direction wo, to the amount of light that reaches the surface form direction wi. • wo is incoming light direction, wi is outgoing light direction.

  7. BRDF? • Definition of BRDF • It is defined as the ratio of the quantity of reflected light in direction wo, to the amount of light that reaches the surface form direction wi. • Lo : quantity of light reflected from the surface in direction wo. • Ei : amount of light arriving from direction wi.

  8. BRDF? • Definition of BRDF. • Incoming light projected onto the surface element. (similar to lambertian lighting)

  9. BRDF? • Given a BRDF and an incoming radiance distribution (at Hemisphere) • The reflectance equation determines the outgoing radiance for a given viewing direction relative to the surface. • Single point light source

  10. BRDF? • Important properties • Input and output angle can be switched. • Function value will be the same. • BRDF must be normalized. • Total outgoing energy must be less than or equal to incoming energy. • not include the scattering of light within the surface. • BSSRDF function describes this penomenas.

  11. Phong Light Equation. • Phong Light • BRDF

  12. Implementing BRDFs-Factorization • Idea • Map the incoming and outgoing directions to pixels on the texture. • BRDF function is separated in as few significant term as possible. • Direction vector can be interpolated linearly across the texture. • Convert a BRDF into a set of pairs of two-dimensional texture. • One texture is accessed by incoming direction. • The other is accessed by outgoing direction.

  13. Implementing BRDFs-Factorization

  14. Implementing BRDFs in Shaders. • Lambertian Model • Shader code PixelOut main(V2FI IN) { IN.LightVector=normalize(IN.LightVector); PixelOut Out; float4 DiffuseColor = float4(1.0f, 1.0f, 1.0f, 1.0f); Out.Color = DiffuseColor * max(dot(IN.LightVector,normalize(IN.Normal)), 0.0f); return Out; }

  15. Implementing BRDFs in Shaders. • Lambertian Model

  16. LIGHT N R=L+2S L+S=Ncosθ S=N(N×L)-L RESULT:R=2N(N×L)-L S R VIEWER L θ θ α V ( ) n = × R I K V I L S S Implementing BRDFs in Shaders. • Phong material. • Blinn-Phong material. Φ+ Ψ=(Φ- Ψ)+ θ 2 Ψ= θ H=L+V/|L+V| ( ) n = × H I K N I L S S

  17. Implementing BRDFs in Shaders. • Phong and Blinn-Phong material.

  18. Implementing BRDFs in Shaders. • Oren-Nayar Diffuse Relflection • Describe some rough surfaces such as dirt, clay, and some types of cloth exhibit a high degree of retro reflection PixelOut main(V2FI IN) { PixelOut Out; float3 N=normalize(IN.Normal); float3 L=normalize(IN.LightVector); float3 V=normalize(IN.ViewVector); float4 DiffuseColor = float4(0.7f, 0.8f, 0.7f, 1.0f); float VdotN = dot(N,V); float LdotN = dot(N,L); float Irradiance = max(LdotN,0.0f); float theta_r = acos(VdotN); float theta_i = acos(LdotN); float cos_phi_diff = dot( normalize(V-N*VdotN),normalize(L-N*LdotN)); float alpha = max(theta_i,theta_r); float beta = min(theta_i,theta_r); float roughness = 0; float A = 1.0f-0.5f*(roughness*roughness/roughness*roughness+0.3f); float B = 0.45f*(roughness*roughness/roughness*roughness+0.09f); float Oren_Nayer = (A+B*max(cos_phi_diff,0.0f)*sin(alpha)*tan(beta)); Out.Color = DiffuseColor * Oren_Nayer*Irradiance; return Out; }

  19. Implementing BRDFs in Shaders. • Oren-Nayar Diffuse Relflection

  20. Implementing BRDFs in Shaders. • Minnaert Reflection • Good for modeling the appearance of velvet. PixelOut main(V2FI IN) { PixelOut Out; float3 N=normalize(IN.Normal); float3 L=normalize(IN.LightVector); float3 V=normalize(IN.ViewVector); float4 DiffuseColor = float4(0.7f, 0.8f, 0.7f, 1.0f); float NdotL = dot(N,L); float NdotV = dot(N,V); float Irradiance = max(NdotL,0.0f); float Power = 0.75; float Minneart = pow(NdotL*NdotV,Power)*Irradiance; Out.Color = DiffuseColor * Minneart; return Out; }

  21. Implementing BRDFs in Shaders. • Minnaert Reflection

  22. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Ward Reflection Model. • Isotropic PixelOut main(V2FI IN) { PixelOut Out; float3 N=normalize(IN.Normal); float3 L=normalize(IN.LightVector); float3 V=normalize(IN.ViewVector); float roughness = 0.35f; float roughness_2 = pow(roughness,2); float4 DiffuseColor = {0.2775f, 0.2775f, 0.2775f, 1.0f}; float4 SpecularColor = {0.773911f,0.773911f,0.773911f,1.0f}; float NdotV = dot(N,V); float NdotL = dot(N,L); float3 HalfVector = normalize((L+V)/2); float Irradiance = max(NdotL,0.0f); float r = acos(dot(N,HalfVector)); float tan2 = -pow(tan(r),2); float FirstTerm = exp(tan2/roughness_2)/(6.28*roughness_2); float SecondTerm = 1/sqrt(NdotL*NdotV); float Ward_Isotropic = FirstTerm * SecondTerm; Out.Color = (DiffuseColor+SpecularColor*Ward_Isotropic)*Irradiance; return Out; } α = standard deviation of the surface slope.

  23. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Ward Isotropic reflection model

  24. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Ward Reflection Model. • Anisotropic • Computationally convenient approximation.

  25. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Ward Reflection Model. • Anisotropic PixelOut main(V2FI IN) { PixelOut OutPixel; float3 PixelToEye = normalize(IN.ViewVector); float3 NewNormal = normalize(IN.Normal); float3 HalfVector = normalize(IN.LightVector + PixelToEye); //First Term float CosTheta = dot(NewNormal, IN.LightVector); float CosDelta = dot(NewNormal, PixelToEye); float4 FirstTerm = 1.0f / sqrt(CosTheta * CosDelta); float2 Roughness = {0.9f, 0.1f}; //Second Term float4 SecondTerm = 1.0f / (12.56 * Roughness.x * Roughness.y); //Third Term float3 Direction = {0.0f, 0.0f, 1.0}; float3 X = normalize(cross(NewNormal, Direction)); float3 Y = normalize(cross(NewNormal, X)); float HdotX = dot(HalfVector, X); float HdotY = dot(HalfVector, Y); float HdotN = dot(HalfVector, NewNormal); float A = -2.0f * (pow((HdotX / Roughness.x), 2) + pow((HdotY / Roughness.y), 2)); float B = 1.0f + HdotN; float4 ThirdTerm = exp(A / B); float4 Irradiance = max(0.0f, CosTheta); float4 DiffuseColor = {0.2775f, 0.2775f, 0.2775f, 1.0f}; float4 SpecularColor = {0.773911f,0.773911f,0.773911f,1.0f}; float4 SpecularTerm = SpecularColor * FirstTerm * SecondTerm * ThirdTerm; OutPixel.Color = (DiffuseColor + SpecularTerm) * Irradiance; return OutPixel; }

  26. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Ward Anisotropic Reflection Model.

  27. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Schlick Reflection Model. PixelOut main(V2FI IN) { PixelOut Out; float3 N=normalize(IN.Normal); float3 L=normalize(IN.LightVector); float3 V=normalize(IN.ViewVector); float4 DiffuseColor = {0.75164f, 0.60648f, 0.22648f, 1.0f}; float4 SpecularColor = {0.628281f,0.555802f,0.366065f,10.0f}; float3 Reflection = normalize(2.0f * N * dot(N,L)-L); float RdotV = max(dot(Reflection.xyz,V),0.0); float SchlickTerm = RdotV / (SpecularColor.w - (SpecularColor.w * RdotV) + RdotV); float4 Diffuse = DiffuseColor * max(0.0f, dot(L,N)); float4 Specular = SpecularColor * SchlickTerm; Out.Color = Diffuse + Specular; return Out; }

  28. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Schlick Reflection Model.

  29. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Cook-Torrance Model.

  30. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Cook-Torrance Model. PS_OUTPUT OutPixel; float3 PixelToEye = normalize(In.ViewVector); float3 NewNormal = normalize(In.Normal); float3 LightVector = normalize(In.LightVector); float3 HalfVector = normalize(LightVector + PixelToEye); float NdotH = max(0.0f, dot(NewNormal, HalfVector)); float3 RoughnessParams = {0.5f, 0.5f, 0.5f}; //Start the "D" term, use Blinn Gaussian float Alpha = acos(NdotH); float C = RoughnessParams.x; float m = RoughnessParams.y; float D = C * exp(-(pow(Alpha / m, 2.0f))); //Start the "G" term float NdotV = dot(NewNormal, PixelToEye); float VdotH = dot(HalfVector, PixelToEye); float NdotL = dot(LightVector, NewNormal); float G1 = 2 * NdotH * NdotV / NdotH; float G2 = 2 * NdotH * NdotL / NdotH; float G = min(1.0f, max(0.0f, min(G1, G2))); //Start the fresnel term. Use the approximation from //http://developer.nvidia.com/docs/IO/3035/ATT/FresnelReflection.pdf float R0 = RoughnessParams.z; float F = R0 + (1.0f - R0) * pow(1.0f - NdotL, 5.0); float4 DiffuseColor = {1.0f, 1.0f, 1.0f, 1.0f}; OutPixel.Color = DiffuseColor * F * D * G / (NdotL * NdotV); return OutPixel; }

  31. Implementing BRDFs in Shaders. • Specular and Metallic Reflection Models. • Cook-Torrance Model.

  32. Implementing BRDFs in Shaders. • Video

More Related