If you ever used Photon mapping mode in Kray then you probably know that it's sometimes very hard to get enough photons inside the room through the windows. This is because Photon mapping by default shoots photons from the light sources in all direction so quite a lot of photons may be wasted on the areas we don't actually see in our render.
This is why a new shader was developed - to help guide photons in places where we realy need them. So light portals are just a helper polygons that tells Kray where photons should be shoot at.
- checkmark in front of shader/modifier will not disable shader in Kray. This is current limitation of LW SDK and we'll try to fix it ASAP.
There are two new additions to the kray.p plugin: KrayLightPortal surface shader and KrayPhotonMultiplier motion modifier. If you don't see them in your list then you probably need to remove and re-add Kray plugin.
KrayLightPortal surface shader can be found in the Surface Editor on the Shaders tab. Adding shader to a surface will make those polygons act as an attractor for photons. There are a few things you have to keep in mind when creating lighportal polygons:
- polygons normals should face towards the light source (example: in windows they should face outside).
- if you block lightportal polygons with another geometry they won't work well
- lightportal polygons are visible by default. This means they will block light if they are not transparent. To make them hidden but still work correctly you must add another shader KraySurfaceOptions and uncheck Visible in it.
When you add shader to your surface you should first enable portal and assign the portal to the Light source. You do this by clicking Enable photons portal for photons or Enable caustics portal for caustics.
At the top you choose the light source you want to assign to this portal. With one shader you can only assign one light. Add another shader to assign another Light source to the portal.
You control how many photons the skyportal will use by changing Importance value. Example: Importance 40% means that 40% of photons will be shot through the portal and the other 60% will be shot the old way. This is important when you have interior scene with some exterior elements (with lightportals in windows). Then you can use for example 80% importance so 20% of photons will still hit outside while 80% will go inside.
Below you will also notice another value which cannot be changed: All light portals importance. This value will change if you add more than one Lightportal to a particular Light source and cannot be over 100%. So for example if you have two lightportals, both using the same Light source and one has importance set to 60% and the other to 80% then All lightportals importance will show 140% (will truncate) message and [[Image:when you exit shader it will automaticaly adjust both importance values so they will not exceed 100%.
KrayPhotonMultiplier modifier is a new plugin that came as a "side product" to development of light portals. We had to develop this modifier because in certain situations you need to control how much photons a light source emmits.
Often you will be presented with a problem where you get enough photons from, for example, skydome and very few from other light sources. This is because Kray computes light power based on size and luminosity of the light object. And since skydome is usually a very large object it will eat up a lot of photons, so other lights will be left with just a few of them. This can introduce serious artifacts that can be seen as a strong splotches in your renders.
You should assign this modifier to a light source that is not emmiting enough photons. You must experiment to find the right value but that's usually quite easy: just render in Photon estimate - Global unfiltered or Precomputed mode and find the right balance.
Here's an example of a render without using Photon Number Multiplier:
And here's an example of a render with Photon Number Multiplier 100000.0:
Putting LightPortals into practice
First of all we have to create Lightportal polygons. Remember that LightPortal polygons must be facing outwards (towards the light source). Here's a screen shot from the modeler about how we set up our portals. Also notice that we enclosed the whole room in a "black box". I advice you to do this for all your Photon mapping scenes.
Setting Up Layout
In layout we need to setup the surface of the LightPortal correctly. 1. Open surface editor and find Lightportal surface and go to Shaders tab
2. Add KrayLightPortal from the list
3. In KrayLightPortal properties select SUN from the list of Light at the top
4. Check Enable photons portal and leave Importance at 100%.
5. Add another KrayLightPortal shader and select Object:bath:GI from list of Lights and Enable photons portal.
6. Add KraySurfaceOptions from the shader list and in the properties uncheck Visible and Reflect caustics photons
7. Open Kray window and on Photons tab set Photonmap and Received
8. Now we can render Photon estimate - Precomputed and see if we get any photon problems.
You can see couple of too bright splotches (cells) in the left corner. It's because SUN light is not emmiting enough photons.
9. We will add KrayPhotonMultiplier modifier to Sun and set it's value to 500.
Now the render is looking better - no too bright cells can be seen anymore.
10. We can render out our final image now. I added prerender pass to get better FG and set high AA settings.
You can download final scene here: LightPortal tutorial scene download