/
Local Image-based Lighting Local Image-based Lighting

Local Image-based Lighting - PowerPoint Presentation

eloise
eloise . @eloise
Follow
65 views
Uploaded On 2023-10-25

Local Image-based Lighting - PPT Presentation

With Parallaxcorrected Cubemap Sébastien Lagarde Antoine Zanuttini DONTNOD Entertainment Imagebased Lighting Distant IBL Infinite cubemap Distant lighting No position Hand authored Camerabased ID: 1024561

corrected parallax local cubemap parallax corrected cubemap local float3 lighting refldirectionws box furthestplane positionws based http volume distance selectedprimitive

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Local Image-based Lighting" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1.

2. Local Image-based LightingWith Parallax-corrected CubemapSébastien Lagarde, Antoine ZanuttiniDONTNOD Entertainment

3. Image-based Lighting

4. Distant IBLInfinite cubemapDistant lightingNo positionHand authoredCamera-basedContributes to all objectsSmooth lighting transitionOfflineRuntime

5. Local IBLLocal cubemapLocal lightingPositionIn-engine generatedObject-basedContribute to nearest objectsLighting seamsParallax issueRuntimeOffline

6. Local IBLLighting seamsParallax issue

7. Our Local Image-based Lighting Approach

8. Our Local IBL ApproachMix of local cubemapsPositionLocal lightingIn-engine generatedPoint of interest -basedContribute to all objectsNo lighting seamsStill parallax issueOfflineRuntime

9. Our Local IBL ApproachNo lighting seams anymoreBut still have parallax issueAnd introduce error with distant objects

10. Parallax-corrected Cubemapin Object’s shader

11. Parallax-corrected Cubemap

12. Parallax-corrected CubemapSimple algorithm to minimize parallax issue on GPUArtists define box volumeIntersect a volume and correct the reflection vectorWe just reinvented the wheel!Kevin Bjorke, GPU GemsBartosz Czuba, Gamedev.net forums

13. Parallax-corrected CubemapWorks well on all kind of surfaces but…costlyOBB geometry proxy : ~21 instructionsFor one parallax-corrected cubemapCheaper approximation existsNVIDIA / ATI demoPseudo code D = normalize(K * (Pp - C) + R)

14. Parallax-corrected Cubemap

15. Parallax-corrected CubemapScene renderingObject’s Shader with cubemaps parallax correctionObject’shaderScene renderingMixing step with cubemaps parallax correction

16. Parallax-corrected CubemapMixing Step

17. Parallax-corrected CubemapNo pixel positionsAdd a reflection planeParallax correction is based on camera, geometry proxy and reflection planeFor current point of view

18. Parallax-corrected Cubemap // Intersection with OBB convert to unit box spacefloat3 RayWS = normalize(GetCubeDir(...)); // Current directionfloat3 RayLS = mul((float3x3)WorldToLocal, RayWS);float3 ReflCameraLS = mul(WorldToLocal, ReflCameraWS); // Can be precalc// Same code as before but for ReflCameraLS and with unit boxfloat3 Unitary = float3(1.0f, 1.0f, 1.0f);float3 FirstPlaneIntersect = (Unitary - ReflCameraLS) / RayLS;float3 SecondPlaneIntersect = (-Unitary - ReflCameraLS) / RayLS;float3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect);float Distance = min(FurthestPlane.x, min(FurthestPlane.y, FurthestPlane.z));// Use Distance in WS directly to recover intersectionfloat3 IntersectPositionWS = ReflCameraWS + RayWS * Distance;float3 ReflDirectionWS = IntersectPositionWS - CubemapPositionWS;return texCUBE(envMap, ReflDirectionWS);

19. Parallax-corrected CubemapTop-Dow view of a corridor with 3 local cubemaps

20. Parallax-corrected CubemapVideo

21. Parallax-corrected CubemapWith glossy material : Enlarge geometry proxy

22. Parallax-corrected CubemapReferenceDistortion with glossy materialOur approximation

23. Parallax-corrected CubemapImprovementRasterizing parallax corrected cubemapDraw the textured box volume from reflected camera positionNo longer restricted to box/sphere volume!Tools for artists to define any convex volume

24. Parallax-corrected Cubemap

25. Parallax-corrected Cubemap // C++Matrix Mirror = CreateMirrorMatrix(ReflectionPlaneWS);Vector ReflectedViewPositionWS = Mirror.TransformVector(ViewPositionWS);Matrix View = CalcCubeFaceViewMatrix(FaceIndex, ReflectedViewPositionWS);Matrix ViewProjection = View * Projection; // ShaderVertexMain() {float4 PositionWS = mul(LocalToWorld, InPositionOS); float4 PositionSS = mul(ViewProjectionMatrix, PositionWS);OutPosition = PositionSS; OutDirection = PositionWS.xyz - CubemapPositionWS.xyz; // Current direction}PixelMain() { OutColor = texCUBE(CubeTexture, OutDirection);}

26. Sum up : Parallax-corrected CubemapPlanar objects onlyConvex volumesScalable with number of cubemapGeneralCheap approximationPer pixel correctionSimple volume (Box/Sphere)# CubePS3 (ms)X360 (ms)10.140.2920.230.4130.310.52Measures for 128x128x6 DXT1 cubemapMeasures for 25% / 75% screen coverage# CubePS3 (ms)X360 (ms)10.24 / 0.750.19 / 0.4520.48 / 1.270.44 / 1.2130.72/ 2.260.61 / 2.27

27. Caveats

28. Caveats - Distant lighting issuesAccuracy decreases with distance from POIProvide different solutions to artistsUse ambient lighting information at objects positionMix with cubemap based on POI distanceFade cubemap contribution with distanceHelps with performance too Override cubemap by objects

29. Conclusion

30. TakeawaysNew local IBL approachCheapReplace costly real-time IBLSeveral tools in the hands of the artistsTo ease smooth lighting transitionTo get accurate lighting

31. FutureThese tools are not enoughWe developed othersDescribed in upcoming GPU pro 4 book to be released at GDC 2013

32. AcknowledgmentsFrédéric Cros (Lighting artist) for his invaluable help on testing, using and mastering our toolsDONTNOD teamNaty Hoffman for his help with the submission processThanks to all my reviewersGabriel Ware, Stephen Hill, Laury Michel, Sam Hocevar, Jérôme Banal, Nicolas Serouart, Michel Koch, Brian Karis, Colin Barré-Brisebois

33. Questions?Slides available at http://seblagarde.wordpress.com/Twitter: @SebLagardeEmail: Lagardese@hotmail.fr

34. ReferencesMcTaggart, “Half-Life 2 Valve Source Shading” http://www2.ati.com/developer/gdc/D3DTutorial10_Half-Life2_Shading.pdfBjorke, “Image based lighting”, http://http.developer.nvidia.com/GPUGems/gpugems_ch19.htmlBehc, “Box projected cubemap environment mapping” http://www.gamedev.net/topic/568829-box-projected-cubemap-environment-mapping/

35. ReferencesMad Mod Mike demo, “The Naked Truth Behind NVIDIA’s Demos”, ftp.up.ac.za/mirrors/www.nvidia.com/developer/presentations/2005/SIGGRAPH/Truth_About_NVIDIA_Demos.pdfBrennan, “Accurate Environment Mapped Reflections and Refractions by Adjusting for Object Distance”, http://developer.amd.com/media/gpu_assets/ShaderX_CubeEnvironmentMapCorrection.pdf

36. Bonus slides

37. Our Local IBL ApproachPoint of interest (POI)?Context dependentCameraPlayerAny characterDummy locationAnimated by a track

38. Our Local IBL approachInfluence volume link to local cubemapBox or sphereMust overlapGather local cubemapsBased on POI locationBased on cubemap influence volumeTake N nearest volumesTop view

39. Blending algorithmBlending weights rules100% influence at boundary of inner range0% influence at boundary of outer rangeSmaller influence more importantNo overlap of inner range

40. Blending algorithm – Pseudo code for (int i = 0; i < NumPrimitive; ++i) { if (In inner range) EarlyOut; if (In outer range) SelectedPrimitive.Add(CurrentPrimitive.GetInfluenceWeights(LocationPOI));}SelectedPrimitive.Sort();for (int i = 0; i < NumSelectedPrimitive; ++i) { SumIW += SelectedPrimitive[i]; InvSumIW += (1.0f - SelectedPrimitive[i]);}for (int i = 0; i < NumSelectedPrimitive; ++i) { BlendFactor[i] = (1.0f - (SelectedPrimitive[i] / SumIW)) / (NumSelectedPrimitive - 1); BlendFactor[i] *= ((1.0f - SelectedPrimitive[i]) / InvSumIW); SumBlendFactor += BlendFactor[i];}// Normalize BlendFactor (...)

41. Blending algorithm

42. Blending algorithmCombined on GPUMultiple shadersBy faceBy cubemap numberBlend all mipmapsFor preconcolved cubemapUse knowledge of hardware texture layout128^2 DXT1PS3 (ms)X360 (ms) 10.080.2020.090.2630.100.3440.110.41256^2 DXT1PS3 (ms)X360 (ms)10.290.4820.400.6130.540.7840.680.99

43. Parallax-corrected Cubemap float3 DirectionWS = PositionWS - CameraWS;float3 ReflDirectionWS = reflect(DirectionWS, NormalWS); // Find the ray intersection with box planefloat3 FirstPlaneIntersect = (BoxMax - PositionWS) / ReflDirectionWS;float3 SecondPlaneIntersect = (BoxMin - PositionWS) / ReflDirectionWS;// Get the furthest of these intersections along the ray (Ok because x/0 give +inf and -x/0 give –inf )float3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect);// Find the closest far intersectionfloat Distance = min(min(FurthestPlane.x, FurthestPlane.y), FurthestPlane.z);// Get the intersection positionfloat3 IntersectPositionWS = PositionWS + ReflDirectionWS * Distance;// Get corrected reflection ReflDirectionWS = IntersectPositionWS - CubemapPositionWS;return texCUBE(envMap, ReflDirectionWS);

44. Parallax-corrected cubemap

45. Parallax-corrected CubemapError analysisParallax-corrected cubemap only works for one normal

46. This slide has a 16:9 media window