OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: -Point Light Attenuation
View page
Source of version: 6
(current)
{INCLUDE(page="ogrelex ext tpl")/} --- A point light's attenuation defines how bright it is with respect to its distance from objects. You can set a light's attenuation by using Ogre's __Light::setAttenuation__ function. The function takes four Real parameters: ''Range'', ''Constant'', ''Linear'', and ''Quadratic''. The ''Range'' parameter has nothing to do with the brightness. If an objects distance is greater than the ''range'', the light has no effect on the object. If the object is in range, the light's effect is calculated with the following formulas: * Luminosity = 1 / Attenuation * Attenuation = ''Constant'' + ''Linear'' * Distance + ''Quadratic'' * Distance~np~^~/np~2 Picking the values by trial and error is time consuming and unintuitive. I have calculated some values for the parameters that work well for specified ranges. Using these numbers, the light has 100% intensity at 0 distance, and trails off to near black at a distance equal to the Range. Keep in mind that most of the light falls in the first 20% of the range. ^ __''Range Constant Linear Quadratic''__ 3250, 1.0, 0.0014, 0.000007 600, 1.0, 0.007, 0.0002 325, 1.0, 0.014, 0.0007 200, 1.0, 0.022, 0.0019 160, 1.0, 0.027, 0.0028 100, 1.0, 0.045, 0.0075 65, 1.0, 0.07, 0.017 50, 1.0, 0.09, 0.032 32, 1.0, 0.14, 0.07 20, 1.0, 0.22, 0.20 13, 1.0, 0.35, 0.44 7, 1.0, 0.7, 1.8 ^ {img src="img/wiki_up/Attenuation_Graph.jpg" alt="Attenuation_Graph.jpg"} For example, if you wish to have a light that gradually dims until it has no effect at distance 100: {CODE(wrap="1", colors="c++")} Light *light; //create pointer to light object light = mSceneMgr->createLight("Light #1"); //set the pointer to a newly created light light->setType(Light::LT_POINT); // make this light a point light light->setDiffuseColour(1.0, .5, 0.0); //color the light orange light->setSpecularColour(1.0, 1.0, 0.0); //yellow highlights light->setAttenuation(100, 1.0, 0.045, 0.0075);{CODE} Once you have chosen a ''Range'' and corresponding values, you can tweak the ''Constant'' and ''Linear'' values. Decreasing the ''Constant'' parameter toward 0.0 brightens the light, while increasing it dims the light. Increasing the ''Linear'' parameter causes the light to fade more quickly with distance. I don't suggest changing the ''Quadratic'' value or decreasing the ''Linear'' values, as doing so will require you to recalculate the ''Range''. Negative numbers are not allowed. Finally, Decreasing the ''Range'' value may give your application a performance boost, but decreasing it too much will cause the object to noticeably change brightness when it moves out of range of the point light. !!See also * ((-Light|Light)) * ((Light Attenuation Shortcut)) - code snippet --- {INCLUDE(page="ogrelex ext tpl")/} --- Alias: (alias(Point_Light_Attenuation))
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
97 online users