"Planet Shader" for Unity 3.x?

Anyone have a “planet shader”, like the one posted on the wiki, that works with Unity 3.x? I know a couple other people have looked for such a thing but wondered if anyone made a new one or found one?

Edit: Never mind. I used Stramit’s SSE to create a new one. :wink:

This might be what you are looking for.

Nice, thanks Simon! Did you check out the shader I linked to? The UV animated clouds are a nice effect. Some pretty cool stuff on your blog, by the way.

Animated clouds… hmm good idea :slight_smile: I’ll add that when I get a chance.

I tried your shader (super clean btw) but I quite like the one built with SSE. I’ve modified it a bit (something I would never be able to do on my own without SSE) and it’s working pretty nicely.

bigkahuna, care to share yours for the community?

OldMonk

@OldMonk - It’s not really my shader, but you’re welcome to it. I followed Clamp’s tutorial using the Strumpy Shader Editor. The editor is free (although a donation is recommended) and the tutorial takes only a couple of minutes to do. I highly recommend it. Or you can cheat and download my completed graph a few posts further down in that thread. Load that graph into SSE and export a shader. Easy peasy. I’ve since modified the shader further for my particular needs, something I wouldn’t have tried to do without SSE.

I updated the shader on the wiki. With some restrictions, but it may works for you if you want to give it another try.

Thanks!

awesome thanks!

I could never get the shader on the wiki to work in U3 (didn’t try the updated one), but a few months ago I built a very similar one using the same falloff formulas. It was a very helpful starting point. I also added some fake atmospheric scattering:

Haven’t done the sun shader yet, it’s just a self lit ball so all the blooming is coming from the planet atmosphere shader. I did this because my galaxy is kinda distorted and the sun can end up filling the screen as you look at some planets so it won’t be super bright in game. I actually split things up and use a different model for the atmosphere and have separate surface and atmosphere shaders. The dodgy fake light scattering just takes the light vector and uses a basic exponential falloff, ignores normals and object thickness and doesn’t wrap around the edges of the planet at sunrise/sunset like the proper scattering models do but the result is still quite convincing and I have much more artistic control over the colours and size/intensity of the effect. I can also have really thick/large atmospheres unlike most other realistic scattering demos I’ve seen that require a fixed ratio of planet to atmosphere size and they treat the sun as a fixed point which limits the scattering radius. I needed something that would still work if the sun was being drawn larger than the whole planet behind it.

I also have cloud parallax with shadowing, but animated clouds never looked “right”, not using a simple uv rotation anyway. You need a proper animated texture, but generating it has been the hard part. I’ve been looking into fluid simulation in C4D and even other scripting environments like Processing to generate more realistic cloud animations but after several stumbles I’ve moved on to other things, will come back to it at some point.

Anyone else had any luck with proper animated clouds?

I was thinking of trying to use 2 different cloud alpha layers. One fairly detailed with some swirls that could be tiled and a second as more of a general transparency map. I then though of using a noise function along the V coord of the maps, have them split up and rotate in different directions at different speeds up and down the planet in “bands” then use the composite of those maps to paint in the clouds. It wouldn’t quite get that swirly look but it would be more convincing than just a static scrolling map. I haven’t gotten around to trying this yet, but got the idea looking at an animation of juipter’s clouds:

I also found a composite animation of earth’s clouds (was really low resolution) but it showed identical features of rotating bands like Jupiter. Form what I understand this is caused by the temperature differences as you move from the pole to the equator.

I’m building a solar system in my game Delta Velocity, and I also used strumpy’s editor to create my planet shaders. Clouds appear to move very slowly when viewed from space, so I’m not too concerned about whirling elements in the cloud layers. My solution has been to create 2 cloud textures, with even bands in one and odd bands in the other, and I rotate their UV’s at differing speeds or directions. The motion is barely perceptible, but when you stop to look the motion looks more complex than it is, especially on Jupiter.

Cameron, I’m curious, how did you achieve your atmoshperic scattering and glow? I’m using a reversed normal sphere, and a gradiant as a mask, but if you get to close (i.e. into the atmosphere) the effect is ruined.

I use a normal sphere for the atmosphere but only cull the front faces, same difference really. I then use the view direction and surface normal to do a kind of backwards rim light that’s combined with a wrapped diffuse. The wrapped diffuse allows the atmosphere to kind of hug the edges of the planet a bit more as you rotate around it, it’s not 100% realistic but I like it.

The atmosphere scattering is done by ignoring the surface normal and just doing a specular highlight based on view direction dot light direction, like I said it’s incredibly simple but when masked in a similar way to the atmosphere reverse-rim falloff it doesn’t look half bad. I actually do it twice with different coefficients and multiply the result so I can get a colour gradient, would probably be faster to use a lookup ramp texture for the color and only do the calculation once but it was just a quick and dirty “does this work?” kind of job before I moved onto other things.

The surface shader scattering is different again, was a bit tricky getting that to work. I knew kinda what I needed to do but couldn’t hold all the flips and adjustments in my head so I just did the trusty old “throw in random variables until it works” method. Even then I couldn’t get it perfect, as it gets to the edges of the sphere it’s offset from the light source a smidgen but because it’s all fuzzy and glowie you never really notice it.

Not really sure how well that method would work as a “horizon” shader while inside the atmos-sphere. You’d probably need to flip some calculations when you’re inside the sphere. For my game it’s not an issue, space turn based strategy so you never get that close to the surface.

Thanks Cameron. I was hoping you weren’t using a culled front face/ reversed normal sphere, but your idea on how to achieve surface scattering is smart, and i will use it, thanks! You also gave me an idea on how to achieve a horizion… on collision I’ll switch the normals, and change the shader, then revert on collision exit.
Does anyone know how to achieve bleeding edges in a shader, a la planetary atmosphere, without additional geometry? It would save a heap of processing power.

The one on the Wiki kinda does that, but it mostly just uses the vertex shader to make the inverted sphere on the fly:

http://www.unifycommunity.com/wiki/index.php?title=Planet

Although it’s not a surface shader so you’d need to pass in lighting info manually.

If you wanted a smooth transition using the backface sphere method my first guess would be to build/test two different shaders to get the algorithms right then combine them and lerp between the results as the camera approaches the radius of the atmosphere.

Technically when you’re inside the atmosphere everything should be blue so maybe start with a simple solid colour transition and work from there.

I’ve managed to make a a much better planet shader using faked volumetric noise to procedurally generate a texture. It then uses a ramp to colorize the planet. I’ve also used this same technique to animate the atmosphere, so you get swirling clouds which form and dissolve over time.

http://entitycrisis.blogspot.com/2011/03/planet-atmospherics.html

I know this is old, and not really Unity related :slight_smile: but the “banding” of clouds is because clouds all move at about the same speed. Since the circumference is greater near the equator, it takes the clouds in those “bands” longer revolve around the planet.

It looks like some of the bands are moving in opposite directions; they aren’t. The video is stop motion from one picture per [Jupiter] day, so all velocities will be relative to the point used to sync the frames. It looks like “red spot” was the sync reference, so anything moving slower than that will appear to move one direction, and anything faster will appear to move the other. In reality its all moving the same way, at mostly the same speeds, just with different periods.