380 likes | 502 Views
CSE4MOD Lighting. Paul Taylor 2009 . Textures need Lights Lights need Textures One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them -Does this need context to be awesome?-. OpenGL /DirectX Light Types. Point Spotlight Ambient
E N D
CSE4MODLighting Paul Taylor 2009
Textures need Lights Lights need Textures One Ring to rule them all, One Ring to find them,One Ring to bring them all and in the darkness bind them -Does this need context to be awesome?-
OpenGL /DirectX Light Types Point Spotlight Ambient Distant
Point home.elka.pw.edu.pl/.../general/General.html
Spot home.elka.pw.edu.pl/.../general/General.html
Ambient (Area) home.elka.pw.edu.pl/.../general/General.html
Distant (Sun / Moon) home.elka.pw.edu.pl/.../general/General.html
Specular Reflection • Specular • The more specular a surface, the move light is reflected very closely to the angle of reflection • A mirror is a near perfect Specular Surface http://www.indigorenderer.com/joomla/forum/files/specular_material_test_01_168.jpg
Diffuse Reflection(Lambertian reflection) http://torcode.com/ http://www.glenspectra.co.uk/SiteResources/Data/Templates/1product.asp?DocID=389&v1ID=
Emissive • It Glows! http://www.gennetten-concreteartist.com/d-network.html
Translucent Surfaces Too Hard Basket!!! http://www.trinity3d.com/product.php?productid=1572&cat=293&page=2 http://www.nondot.org/sabre/Projects/Raytracer/
Great so light is stupid complex! Good lighting is dependant on the reflections and behaviours of surfaces This means we can not just use simple textures that are coloured to look good We need to be able to define the behaviours of our objects We need to define the materials they are made of
Materials • For OpenGL to calculate the lighting correctly your surfaces (Polygons) need to have their material properties set. • There are five Variables you will need to consider: • Shininess Exponent • Emission (4x Floats rgba) • Specular (4x Floats rgba) • Diffuse (4x Floats rgba) // Diffuse sets the alpha trans! • Ambient (4x Floats rgba)
Lighting in 2k4 How many lights does DirectX 9 support? OpenGL 2.0?
8 Wow!
How do so many appear in game? There are 2 common ways to increase the lighting in a rendered scene: Baked in Lighting Multi-Pass Rendering
Multi-Pass • Only 8 lights can be used per render • Using the accumulation buffer we can store a frame and blend it with the next frame • By doing an additive combine we can add the lighting from both sets of lights to the scene
Baked In • This type is pre-calculated • As you have seen when you build a level • All the ‘light’ is stored in textures called light maps
Lighting in 2k4 • There are 2 light groups • Dynamic • Static
Light Properties • Colour • Brightness, Hue & Saturation ~= RGB • All range 0-255 (Brightness can exceed this limit) • Radius • The max distance a light may affect. • LightType is redundant (From the Unreal1 Era) • Lights will default to LT_Steady • The other light types are now implemented in another UT system called projectors
Directional Lights There are a few ways to create these • The Actor Browser • Light->Spotlight / Sunlight • The sunlight actor is a special case, it utilises a surface to emit light from an ‘infinite’ distance • Set the bDirectional property to true • Advanced->bDirectional
Light Effects • Lighting->LightEffect • Beware of Animated Effects they only work in UnrealEd!!! The Important ones: • LE_None – Default Constant Falloff • LE_NonIncidence – Sharper Falloff • LE_QuadraticNonIncidence – Super Sharp Falloff
Rebuild Often • As soon as you relocate a light the shadows are removed until you rebuild • Use the lights only button when you are not moving geometry around
Surface Properties (F5) • This is where you get to tweak all of your settings for texturing and light mapping • Inside the Pan/Rot/Scale Tab you will find Light Map:
Light Map Size • This is the detail level of your light map. • 1 is the most detailed • 256 the least detailed • Higher detail creates sharper shadows!!!
Static Meshes • Static Meshes are really bad at receiving shadows as they do not share the light maps used in the Unreal Engine • Surfaces are either Lit or Unlit, no graduation! • Static Meshes are good at casting shadows • So try to avoid casing shadows onto static meshes, instead let the static mesh cast a shadow onto the BSP Geometry
Terrain Behaviour • Terrain light maps are stored separate to the BSP Geometry • Stored as a birds-eye view texture.
Particles • Particles receive no light • Except for Mesh Emitters which receive very basic lighting as per static meshes
Selective Lighting If Lighting->bSpecialLit is set a light will only affect surfaces that also have bSpecialLit set to true
Improving your workflow • Scaling lights • Literal value Light += value • Percentage Light *= percentage
Making Actors Emit Light • Any Static Mesh can emit light but you need to do a few alterations: • Set bShadowCast to false so light will exit the mesh without becoming a shadow • Set bUnlit to true so the mesh will not decide that it is in shadow and turn black
Adding Coronas to Lights • This is as simple as adding a skin to your light that resembles a corona. • You’ll need to open Coronas.utx • Navigate to Display->Skins click add then click use to get the corona added to your light. • You can scale the Corona using DrawScale3D with the X and Y values
Two types of Dynamic Light • TriggerLight • These guys are set up to be triggered • Plain Old Dynamic • Poor trigger abilities
Projectors Replace Dynamic Lights for almost all uses They reduce the dependence on hardware lighting, by replacing the lighting with projected textures Projectors are both faster and better looking Projected textures interact with animated objects too!!!
Think of them as little Cameras • We take the camera, load in image into it and point it at a surface • But how do we make an animated projector?