Sun lamps and sky texture

I’m having several issues with lamps, but as @lubos stated that this first version was going to be buggy I will wait for the next version before starting to think on issues. So for now, just discussing some thoughts.

I used blender a lot in the past for modeling, but I always exported the models to use them with other engines. So I’m quite new to rendering inside blender.

I was wondering why all the examples are using points lights. I see sun lamps as a more natural approach as the examples are using a sky texture as background. When I started to construct the scene, It was a surprise for me that there was not an automatic way of using the sun lamp direction vector as an input for the sky texture (this is only blender related). I also had problems finding a fast solution for this on the internet so I solved the problem using drivers and I think it’s interesting to share the method. I did all the calculations manually, so even if it seems to work… something could be wrong.

When creating the world nodes, create a driver in the vector parameter of the sky texture node. Use the rotation transform of the sun lamp as the targets. On the driver editor, add three variables for each component (x, y, z) of the shader node tree. Each of these vars will need to extract one of the rotation components (path data of them: x = rotation_euler[0], y = rotation_euler[1] and z = rotation_euler[2]). Finally use these variables in the following scripted expressions to set the values of the shader node tree vector components:

x = cos(z) * sin(y) * cos(x) + sin(z) * sin(x)
y = sin(z) * sin(y) * cos(x) - cos(z) * sin(x)
z = cos(y) * cos(x)

And… The sky texture should react to the sun lamp rotation!

As this explanation about configuring the driver seems cumbersome, please, find the .blend file here:
https://dl.dropboxusercontent.com/u/7549551/SunLight.blend.zip

One consideration about using sun lamps for now:

  • The position is important. Although this should not be the case, armory seems to use the position for something and this compromises the shadows. So “clip start”, “clip end” and “field of view” of the sun lamp seem to be applied from the sun lamp position.
1 Like

Nice tip, thanks! I’m sure it’ll come in handy

Wow, there is some really cool stuff popping up.

I just opened that blend file and it works in Armory out of the box, still find that mind blowing.:slight_smile: Also the drivers are super useful. Once Armory itself supports drivers, this should also work in real-time, for example if the lamp is animated on the timeline.

Would you mind adding the blend to the https://github.com/armory3d/armory_addons? Of course with credits kept in-tact.

About the lamps, it is still a mess indeed. For sun lamps, clip start/end need to get removed. Right now it’s still used to capture shadows, and it’s super annoying to mess with those params.

Nice!

Yes, there is no problem in adding the blend file to the addons repository. Do you want me to do a pull request or do you prefer to upload it yourself? I would prefer you to do it :slight_smile: , so you can choose the conventions for the directory structure and file naming (feel free to modify the name of the file or set different default elements inside the .blend). If, on the other hand, this is not so important I can do a pull request, if you want.

Blend is up, will come handy in the future. :slight_smile: