Game Programming 09 OGRE3D Lighting/shadow in Action

Slides:



Advertisements
Similar presentations
Exploration of advanced lighting and shading techniques
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Optimized Stencil Shadow Volumes
Graphics Pipeline.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Week 9 - Friday.  What did we talk about last time?  Area lighting  Environment mapping  Blinn and Newell's method  Sphere mapping  Cubic environmental.
GAM532 DPS932 – Week 7 Introduction to shadows. Shadow Effects Light Surface No Shadows Shadows.
Computer Graphics methods
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
1 Dr. Scott Schaefer Shadows. 2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
黃聰賢. Light Position Mesh Polygon Shadow Polygon  Clear color buffer and stencil buffer  Render the scene with ambient only.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
(conventional Cartesian reference system)
Approximate Soft Shadows on Arbitrary Surfaces using Penumbra Wedges Tomas Akenine-Möller Ulf Assarsson Department of Computer Engineering, Chalmers University.
Paper by Alexander Keller
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Computer Graphics Shadows
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Computer Graphics Mirror and Shadows
Shadow Algorithms Ikrima Elhassan.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
Introducing To 3D Modeling George Atanasov Telerik Corporation
NVIDIA PROPRIETARY AND CONFIDENTIAL Occlusion (HP and NV Extensions) Ashu Rege.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
CHAPTER 11 Shadows © 2008 Cengage Learning EMEA. LEARNING OBJECTIVES In this chapter you will learn about: – –Shadow rendering algorithms – –Blinn’s shadow.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Week 10 - Wednesday.  What did we talk about last time?  Shadow volumes and shadow mapping  Ambient occlusion.
1 10/24/ :01 UML Graphics II Shadows Session 4.
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
Game Programming 08 OGRE3D Material in Action 2010 년 2 학기 디지털콘텐츠전공.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
- Laboratoire d'InfoRmatique en Image et Systèmes d'information
Game Programming 07 OGRE3D Mesh in Action 2010 년 2 학기 디지털콘텐츠전공.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
In the name of God Computer Graphics. Where We Stand So far we know how to: –Transform between spaces –Draw polygons Next –Deciding a pixel’s intensity.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
Stencil Shadows Garrett Weng. What are stencil shadows? Also known as shadow volumes Relies on use of the stencil buffer Create volumes of the shadows.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Applications and Rendering pipeline
Photorealistic Rendering vs. Interactive 3D Graphics
Chapter 10 Computer Graphics
Real-Time Rendering Shadow Volumes
Jim X. Chen George Mason University
UMBC Graphics for Games
UMBC Graphics for Games
Texture and Shadow Mapping
Computer Graphics Material Colours and Lighting
Frame Buffer Applications
Presentation transcript:

Game Programming 09 OGRE3D Lighting/shadow in Action 2010년 2학기 디지털콘텐츠전공

Rendering in Video Games Depth-Buffered Triangle Rasterization Virtual Scene Virtual Camera Various Light Sources Visual Properties Solving the Rendering Equation (Shading Equation)

Rendering in OGRE3D Depth-Buffered Triangle Rasterization Virtual Scene  createScene() Virtual Camera  createCamera()/ createViewport() Various Light Sources  createScene() Visual Properties  material Solving the Rendering Equation (OGRE3D engine)

What does make a scene look real? Material Lighting (shade + shadow)

OGRE3D Lighting Three types of lighting in OGRE3D Point (Ogre::Light::LT_POINT) Point light sources emit light from them in every direction. Spotlight (Ogre::Light::LT_SPOTLIGHT) A spotlight works exactly like a flashlight does. Directional (Ogre::Light::LT_DIRECTIONAL) Directional light simulates far-away light that hits everything in the scene from a direction.

Creating a Light Creating a Light Setting a type Setting a position SceneManager::createLight(“name”) Setting a type Ogre::Light::setType( … ) LT_POINT, LT_DIRECTIONAL, LT_SPOTLIGHT Setting a position Ogre::Light::setPosition( Ogre::Vector3(x,y,z) ) Ogre::Light* pointLight = mSceneMgr->createLight("pointLight"); pointLight->setType(Ogre::Light::LT_POINT); pointLight->setPosition(Ogre::Vector3(0, 150, 250));

Setting a Light Setting the color Setting the direction Ogre::Light::setDiffuseColour (Ogre::ColourValue(r,g,b)) Ogre::Light::setSpecularColour (Ogre::ColourValue(r,g,b)) Setting the direction Ogre::Light::setDirection( Ogre::Vector3(x,y,z)) Setting the spot light property Ogre::Light::setSpotlightRange (inner_angle, outer_angle) angle: Ogre::Degree(angle) Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight"); directionalLight->setType(Ogre::Light::LT_DIRECTIONAL); directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0)); directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0)); directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 ));

Shadow Shadows are: There are many techniques to render shadows. one of the most challenging aspects of 3D rendering still very much an active area of research. There are many techniques to render shadows. None is perfect and they all come with advantages and disadvantages

How to draw a shadow? Off-line algorithm Real-time algorithm Ray tracing shadow Real-time algorithm Projected planar shadows Shadow mapping (texture-based shadow) Stencil Shadow Volume

Ray Tracing Shadow

Projected Planar Shadows The simplest technique to create shadows from an object. Two-pass algorithm Draw the object Draw the shadow Problem: Only on a planar surface

Shadow Mapping Testing whether a pixel is visible from the light source by comparing it to a depth image of the light source's view Depth image is stored as a texture  Texture-based shadow Visualization of the depth map projected onto the scene Scene rendered from the light view Scene from the light view, depth map. Depth map test failures Scene with shadow mapping

Shadow Mapping A problem of the shadow mapping: Aliasing How to solve the problem: Increasing the resolution of the texture Projective shadow map single shadow map pixel

Stencil Shadow Volume Stencil + Shadow Volume

Stencil buffer Stencil buffer is like a mask.

Typical use of a stencil buffer Drawing a reflection effect Drawing a planar shadow 참고자료: http://developer.nvidia.com/object/Stencil_Buffer_Tutorial.html

Shadow volume concept Shadow volume is constructed from occluders Although we can create volumes for every triangle in the occluders, we only need the silhouette. Different types of volume for different types of lights

Shadow Volume concept All the objects positioned within a shadow volume are hidden from the light source and are thus in either full or partial shadow. A silhouette edge can more generally be considered as an outline or edge separating a front- and back-facing surface.

Shadow Volume concept A point light source and the shadow Volume

Stencil Shadow Volume Render the Scene without lights and keep the z-buffer. Fragments with non-zero stencil values are considered to be in shadow. The generation of the values in the stencil buffer : Render front face of shadow volume. If depth test passes, increment stencil value Render back face of shadow volume. If depth test passes, decrement stencil value Render the lit area where the stencil buffer value is 0

Stencil Shadow Volume Stencil Shadow Volume in Action Shadow volume in wireframe Rendered with the shadow Shadow volume

Stencil Shadow Pros Very accurate and robust Nearly artifact-free Faceting near the silhouette edges is the only problem Work for point lights and directional lights equally well Low memory usage

Stencil Shadow Cons Too accurate — hard edges Very fill-intensive Need a way to soften Very fill-intensive Scissor and depth bounds test help Significant CPU work required Silhouette determination Building shadow volumes Hard shadow Soft shadow

Shadow in OGRE3D Multiple implementations about shadow How to know where shadows are: Stencil Shadow Texture-based shadow How to draw the shadows Modulative shadows : darkening Additive Light Masking : brightening

Enabling shadows Disabled by default Enabling a shadow technique This should be the first thing of the scene setup. Type can be stencil shadow or texture-based shadow Create Lights. By default, they will cast shadows To turn off the shadow: Create Objects. By default, they will cast shadows mSceneMgr->setShadowTechnique(ShadowType) Calling Light::setCastsShadows(false) Calling Entity::setCastsShadows(false)

Stencil Shadow Shadow Type either: Good thing: Bad thing: Modulative Shadow SHADOWTYPE_STENCIL_MODULATIVE Additive Light Masking SHADOWTYPE_STENCIL_ADDITIVE Good thing: Self-Shadow on low-end hardware Bad thing: Hard-shadow only Slow because of a higher polygon count mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE)

Stencil Shadow Issues CPU overhead for shadow volume computation Avoid any long shadows (e.g. a very low sun position) Culling distant objects beforehand Shadow volume accuracy Don’t put any object too close to a light source Mesh edge list Edge list is necessary for constructing the shadow volume Official exporter and tools will generate it automatically If you use your own mesh, you can generate it by calling Mesh::buildEdgeList Visible silhouette edge Silhouette edge can be very marked. Especially, the mudulative method is more vulnerable with 2 or more light sources Additive lights do not suffer from this as badly because each light is masked individually

Texture-based shadow Rendering shadow casters for the point of view of the light into a texture. Then, projected onto shadow receiver. Type Name: SHADOWTYPE_TEXTURE_MODULATIVE SHADOWTYPE_TEXTURE_ADDITIVE Good things: Lower overhead Hardware acceleration Customisable (e.g. easy to make soft shadows) Bad things: Aliasing effect depending on the resolution Only supports direction lights and spotlights

Texture-based shadow Configurations Maximum number of shadow textures Shadow texture size Shadow far distance Shadow texture offset (Directional Lights) Shadow fade settings

Modulative Shadow Drawing a scene without shadows Darkening(modulating) the shadow area

Additive Shadow Drawing a scene with ambient light Adding each light one by one For this reason, rendering should be divided into several passes: Ambient pass Diffuse/specular pass Decal pass

Additive shadow Pass spliting example material TestIllumination { technique pass ambient 0.5 0.2 0.2 diffuse 1 0 0 specular 1 0.8 0.8 15 texture_unit texture grass.png }

Additive shadow Pass dividing example // Ambient pass pass { diffuse 0 0 0 specular 0 0 0 } // Diffuse / specular pass pass { scene_blend add iteration once_per_light diffuse 1 0 0 specular 1 0.8 0.8 15 } // Decal pass pass { scene_blend modulate lighting off texture_unit texture grass.png }