Download presentation
Presentation is loading. Please wait.
1
Simple Improvements to LI: Shadows Image Based Lighting László Szécsi
2
Image based lighting
3
Image based lighting (IBL) CPU program Vertex shader Pixel shader Position Normal Transforms Transf. pos Reflection direction Environment map id Rasterization Interpolation Env.Map texels Interpolated Reflection direction Env.map lookup
4
IBL: vertex/fragment shaders void VertexShader( in float4 position : POSITION, in float4 normal : NORMAL, uniform float4x4 MVP : state.matrix.mvp, uniform float4x4 MV : state.matrix.modelview[0], uniform float4x4 MVIT : state.matrix.modelview.invtrans[0], out float4 hPosition : POSITION, out float3 reflectdir : TEXCOORD1 ) { hPosition = mul(MVP, position); float3 view = normalize( - mul(MV, position).xyz ); float3 normcam = normalize( mul(MVIT, normal).xyz ); refrectdir = reflect(view, normcam); } float4 FragmentShader( in float3 reflectdir : TEXCOORD1, uniform samplerCUBE envMap ) : COLOR { return texCUBE(envMap, reflectdir); }
5
Reflection of ideal mirrors: Fresnel function F || = F=F= cos ’ - (n+k j ) cos cos ’+ (n+k j ) cos 2 cos - (n+k j ) cos ’ cos + (n+k j ) cos ’ ’’ n =n = sin ’ sin Snellius-Descartes law of refraction n = Relative speed of the wave 2
6
Simplification F F || + F 2 = if light is not polarized F F0 + (1-F0) (1-cos ’) 5 F0 = (n -1) 2 + k 2 (n+1) 2 + k 2 Schlick93, Lazányi05
7
Fresnel Fragment shader float4 FragmentShader( in float3 reflectdir : TEXCOORD1, in float3 normal : TEXCOORD2, uniform float3 F0, uniform samplerCUBE envMap ) : COLOR { // Fresnel reflection reflectdir = normalize( reflectdir ); normal = normalize( normal ); float3 F = F0 + pow(1-dot(normal, reflectdir), 5) * (1-F0); float3 I = texCUBE(envMap, reflectdir); return float4( F * I, 1 ); }
8
Diffuse/Glossy reflections of IBL cos ’
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.