Atmospheric Scattering in OF

I’m trying to implement O’neil’s Atmospheric Scattering shaders in OF.

Has anybody done this before? I have it working inside Blender’s game engine so I thought it shouldn’t be too hard to do in OF. However I just can’t get my head around why it doesn’t work.

The code is on github.

It does run but I think there’s something going on with the texture coords. As the shaders mixes two textures it seems it’s going bezerk. This makes me think there’s something wrong with the tex coords.

I’ve copied the sphere generation code from the simple primitive sphere class.

Any insights from experienced shader devs?



1 Like

I implemented this shader in the past and it failed to work correctly until I dug around and found out that your sphere must be a certain size for the shader to work. The math only works out if your spheres (atmosphere and terrain) are the same radius as the ones in his sample code.

Along the same lines, I implemented a simple atmosphere shader a while back and later improved it a bit. Fun stuff!

Indeed funstuff… if it works :slight_smile:
I have the shader working in Blender so I’m trying to mimic everything I do in Blender in OF. From what I understand so far the size of the outer sphere has to be 2.5% bigger than the inside. So diameter 10 inside means 10.25 outside. However I’m not using the outer sphere just yet. I’m only runnning the GroundFromSpace shaders. They just mix two textures creating the night side and day side. It doesn’t work there. I just get garbled output. It’s too tempting to pursue this but it’s eating my time :frowning:

From what I read your shaders are for Ogre right?

I actually made the shader in Nvidia FXComposer and then used those shaders in Ogre. They did get complicated in the end and I’m not really proud of how difficult it is to understand them when they’re supposed to be simple!