Questions about the light

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
Storm54
Gnoblar
Posts: 5
Joined: Sat Jun 08, 2013 7:08 am
Location: Russia

Questions about the light

Post by Storm54 »

Hello! I continue to dig with a light and there was a couple of questions:
1. Can I install the "power" of a source of light? In the API has not found the right method. At the moment, the source illuminates everything walls, despite the fact that they are located far away.
2. Light manages to pass through walls. Because of this, it turns out that it illuminates even totally enclosed spaces. How to fix it?

Using per-pixel lighting from the article: http://www.ogre3d.org/tikiwiki/tiki-ind ... 20Lighting

Tried to search the forum, but did not find the description of a similar problem.
Thanks.
PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: Questions about the light

Post by PhilipLB »

You are searching for the attenuation. :)
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.
Storm54
Gnoblar
Posts: 5
Joined: Sat Jun 08, 2013 7:08 am
Location: Russia

Re: Questions about the light

Post by Storm54 »

However, the damping does not work with the application of this material :(
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Questions about the light

Post by Kojack »

The shader you are using from the wiki has no support for attenuation. When using shaders, the entire lighting system must be written in the shader, ogre has no control over it (all it can do is make the values like attenuation available, it can't perform the actual calculation).
You'll need a more complex lighting shader like http://www.ogre3d.org/tikiwiki/tiki-ind ... he+Monster

To make lights not go through walls, you'll need to enable shadows.
PhilipLB
Google Summer of Code Student
Google Summer of Code Student
Posts: 550
Joined: Thu Jun 04, 2009 5:07 pm
Location: Berlin
x 108

Re: Questions about the light

Post by PhilipLB »

Yes, it's not included in the shader there, but that's easy. You use the parameter "light_attenuation" from here:
http://www.ogre3d.org/docs/manual/manua ... d_005fauto

Set it in your pixelshader .program:

Code: Select all

param_named_auto lightAttenuation0 light_attenuation 0
Get it in your shader (CG example):

Code: Select all

uniform float4 lightAttenuation0,
And use it:

Code: Select all

float attenuation = 1;
if (lightPosition.w != 0) {
    float distance = length(lightPosition.xyz - position);
    attenuation = 1.0 / (lightAttenuation.y + lightAttenuation.z * distance  + lightAttenuation.w * distance * distance);
}
lightColor = attenuation * otherLightStuff;
Those snippets are taken from the volume terrain example shaders.
Google Summer of Code 2012 Student
Topic: "Volume Rendering with LOD aimed at terrain"
Project links: Project thread, WIKI page, Code fork for the project
Mentor: Mattan Furst


Volume GFX, accepting donations.
Post Reply