Simple Improvements to LI: Shadows Image Based Lighting László Szécsi.

8
Simple Improvements to Simple Improvements to LI: LI: Shadows Shadows Image Based Lighting Image Based Lighting László Szécsi László Szécsi
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    216
  • download

    2

Transcript of Simple Improvements to LI: Shadows Image Based Lighting László Szécsi.

Simple Improvements to Simple Improvements to LI:LI:ShadowsShadowsImage Based LightingImage Based Lighting

László SzécsiLászló Szécsi

Image based Image based lightinglighting

Image based lighting Image based lighting (IBL)(IBL)

CPU program

Vertex shader

Pixelshader

PositionNormal

Transforms

Transf. posReflection direction

Environment map id

RasterizationInterpolation

Env.Maptexels

Interpolated Reflection direction

Env.map lookup

IBLIBL: vertex/fragment : vertex/fragment shadersshadersvoid 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); }

Reflection of ideal Reflection of ideal mirrors: Fresnel mirrors: Fresnel functionfunction

F|| = F =cos ’ - (n+k j ) coscos’+ (n+k j ) cos

2cos - (n+k j ) cos’

cos+ (n+k j ) cos’

n =sin’sin

Snellius-Descarteslaw of refractionn = Relative speed of the wave

2

SimplificationSimplification

FF||+ F

2= if light is not polarized

F F0 + (1-F0) (1-cos’)5

F0 =

(n -1)2 + k2

(n+1)2 + k2Schlick93, Lazányi05

Fresnel Fragment Fresnel Fragment shadershader

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 );}

Diffuse/Glossy Diffuse/Glossy reflections of IBLreflections of IBL

cos’