Custom light type and overloading scene rendering
-
- Posts: 57
- Joined: Sat Oct 11, 2014 11:07 pm
Custom light type and overloading scene rendering
The engine I am developing has a non-traditional light type which is a cross between a directional an a point light. Basically it is a "point" or object that is assumed to be much larger than the objects it is lighting. If there is a way to make an entire object be a light source that would be best. However, I do not know an efficient way of doing this which leaves me to accomplish this kind of lighting by using a directional light whose direction is calculated and changed based on the position of each object drawn. This means the engine must update all lights of this type in the scene for every object that is rendered. What is the best way to solve this issue? Should I subclass the engine and copy the code that does scene rendering (adding an update call) or use another approach (such as forcing each node to call this update as it is rendered)? Basically it is the entire scene rendering method that would need to be dealt with if the former is possible.
Re: Custom light type and overloading scene rendering
You mean an area light? There are various shader solutions for those. Best use a shader in any case.
-
- Posts: 57
- Joined: Sat Oct 11, 2014 11:07 pm
Re: Custom light type and overloading scene rendering
I have never heard of an "area" light. A good example of the kind of lighting I mean is the sun lighting planets, moons, etc... None of the light types light the planet properly except the directional light. However, the directional light needs to point a different direction for each planet.
The problem with shaders is that I have no idea where to begin solving this specific type of problem with a shader. I have looked into them before and have a basic understanding of them but none of the tutorial's I have read offer any insights into this kind of situation. I have never been able to figure out how to have them interact with specific light sources in the scene. In other words, how does a shader interact with the objects in the irrlicht engine? This all MUST be done dynamically. The lights and their effects cannot be hard-coded. I need to be able to create one or more of these "type" of lights dynamically at certain positions and have them act as an "oversized" light.
The problem with shaders is that I have no idea where to begin solving this specific type of problem with a shader. I have looked into them before and have a basic understanding of them but none of the tutorial's I have read offer any insights into this kind of situation. I have never been able to figure out how to have them interact with specific light sources in the scene. In other words, how does a shader interact with the objects in the irrlicht engine? This all MUST be done dynamically. The lights and their effects cannot be hard-coded. I need to be able to create one or more of these "type" of lights dynamically at certain positions and have them act as an "oversized" light.
-
- Posts: 57
- Joined: Sat Oct 11, 2014 11:07 pm
Re: Custom light type and overloading scene rendering
I did some searching for area lights and I haven't found much so far, other than examples that show what they are. I did find someone who asked about using a mesh as a light source in unity. This would be even better if I could somehow do this in Irrlicht. I have no idea where to start learning how to do this though.
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Custom light type and overloading scene rendering
I understand what you mean. Unfortunately, I don't think this is possible in Irrlicht yet. You can sort of simulate it by making many lights in an area, separated by short distances. But this requires deferred rendering since irrlicht only supports 8 lights at a time (hard-coded limit). Somebody has already done this and shared the code. Maybe IrrRenderer will suit your needs: http://irrlicht.sourceforge.net/forum/v ... =6&t=49713
Re: Custom light type and overloading scene rendering
In your shader callback, you would determine the light's attributes for that object, and pass them to the shader. The callback is called for each drawcall during rendering, so you can pass a different light to each planet.
Area lights are usually used for soft shadows, as point lights create hard-edged ones. So it's just a different directional one per object needed here, not an area light.
Area lights are usually used for soft shadows, as point lights create hard-edged ones. So it's just a different directional one per object needed here, not an area light.
-
- Posts: 57
- Joined: Sat Oct 11, 2014 11:07 pm
Re: Custom light type and overloading scene rendering
How does Irrlicht turn control over to a shader? How does Irrlicht send data to the shader that it needs to do its task? While I believe that I would ultimately using a pixel shader, I would need to send the size constraints for both the light mesh and the mesh being drawn as well as the distance between them. I would also need to project where on the light source a line tangent to the surface of the object intersects the surface of the light. It would also speed things up in the calculation (for symmetrical objects) if I could deal with a localized array in the shader code.
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Custom light type and overloading scene rendering
First, in case you don't know how to work with shaders in irrlicht, have a look at IGPUProgrammingServices.h and IShaderConstantSetCallBack.hprimem0ver wrote:How does Irrlicht turn control over to a shader? How does Irrlicht send data to the shader that it needs to do its task? While I believe that I would ultimately using a pixel shader, I would need to send the size constraints for both the light mesh and the mesh being drawn as well as the distance between them. I would also need to project where on the light source a line tangent to the surface of the object intersects the surface of the light. It would also speed things up in the calculation (for symmetrical objects) if I could deal with a localized array in the shader code.
The driver's IGPUProgramming services can be obtained from IVideoDriver::getGPUProgrammingServices. With it, you can add high level shaders.
-
- Posts: 57
- Joined: Sat Oct 11, 2014 11:07 pm
Re: Custom light type and overloading scene rendering
Ok, thanks for the info. I will take a look at those.
Re: Custom light type and overloading scene rendering
Might be better to simply look at Example 10 - Shaders.