New sunsky texture plugin

eeshlo released a python compiled texture plugin for sunsky. He did not release the source code, however, and the new version of python will not work with it, etc, etc. I am trying to write a new texture plugin.

I have stolen sunsky.cc from yafaray and as of today, I have managed to compile it independently of yafaray so I can convert it to a texture plugin for blender internal.

I need some help at this point. It would help me greatly if someone familiar with yafaray could help me with the interface for the background. I have a mostly complete class that used to inherit background_t, but I need to make some functions to get skycolor at specified x,y,z coordinates for the texture. Basically, I need a function like this:

sunsky_get_rgb(*rgb_struct, sun_x_dir, sun_y_dir, sun_z_dir, turb, x_coord, y_coord, z_coord, sun_intensity);

I of course want to eventually add lat/lon and day/time to the plugin for ease of use. Then a python script to do the sky and add a light in the correct position.

If anyone is interested, I have also managed to get sunsky compiled from Andrew’s Code (http://www.cs.cmu.edu/~ajw/software/) for Ubuntu. I had to change some includes, change some cmath functions and change some C++ methods to inline but it compiles cleanly and renders sky in tiff format.

Thanks for any help.

OK, here’s the source code. I managed to get this compiled and linked but it’s all wrong. I don’t know what I’m doing. sunsky.cc is copied from yafaray, but modified to be compiled independently. It only returns a single solid color. If someone familiar with yafaray could shed some light on what it’s supposed to do, maybe I can get this corrected.

NOTE: The inputs for the plugin don’t do anything. All the values except the coordinates are hard-coded at the moment. This is trivial to change, but I’m not adding any more complexity until I get some kind of positive result.

Files below (viewable without downloading/extracting):

http://www.calcmaster.net/blender/sunsky/

Ok, I have a basic plugin that generates sky. See the test render:

http://www.calcmaster.net/blender/sunsky/downloads/sunsky-example.jpg

You can download source code and Ubuntu 9.04 (Jaunty) binary at:

http://www.calcmaster.net/blender/sunsky/

Special thanks to subcomandante for help with coordinates. I’m pretty sure that my implementation is still wrong, but it’s something for now.

Ok, that first implementation was wrong, but who cares, I think I got it right now. And the picture should have looked like this:

http://www.calcmaster.net/blender/sunsky/

Doesn’t Blender already have a sun/sky type feature for sunlamps? I guess this would get points if it can be seen on raytraced reflections and through refracting objects.

While the internal sky/atmosphere has more features at the moment, it doesn’t create the same type of realistic sky colors that are available with the sunsky plugin, which is off of the same research paper as yafaray sunsky and Darktide sunsky. I am planning to implement integration with an actual sun as soon as possible as well as some of the other options like backscatter, etc.

Basically, the internal sky/atmosphere doesn’t produce colors as accurately as this plugin does. See this thread:

http://blenderartists.org/forum/showthread?t=8369

My plugin aims to recreate that functionality which is missing due to binary incompatibilities and lack of source code.

still need to fully understand what’s behind this, but it looks like it could be useful. will give it a try