I'm trying to model a star in Unity, and it, sort of works, but it's not ideal. Currently, I'm using a large sphere with a self-illuminating material containing a star texture applied to it's surface, and a spotlight to create the effect of starlight, like this:
While it works, it doesn't look the greatest. I'm looking for an effect more along the lines of how Kerbal Space Program models a star:
How can I achieve this effect?
Answer
- Use an animated texture.* There are some good ones in the store for < $10.
- Add a Halo. You can use the particle system, or just a transparent glow texture on a billboard in front of the sun with a script to re-position the texture when the camera moves. This hides the aliased edges of the sphere model, allowing you to use a lower poly model, and looks nice.
- Rotate the sun, slowly.
- Use particle system for eruptions.
- Use a custom shader to make the edges match well with the halo(multiply normal with camera vector to find edges).
The animated gif shows a static texture first, followed by a number of additions, in order:
- Animated Texture
- Brighten the edges of the sphere based on normals
- Add camera-facing transparent billboard with white/yellow halo
- Particles, moving from the center to the outside, then fading
- Add 2 transparent "ray" billboards, facing the camera and rotating along the camera axis in opposite directions.
With the animated texture, be sure to use mipmaps, or it will look horrible at some distances. Slow framerates in the texture (10 fps) are fine when looking at a sun from far away, but when you get close, you may also want to use a higher framerate. If you don't have a high framerate texture or can't waste the video memory for one, you can use a custom shader to interpolate every other pixel based on the previous and next image.
By changing use of Hue/Saturation/Value inside the shader, you can get results like these, without ever having to modify the texture:
I started with a cheap model from the store so I didn't have to do the animated texture. On the other hand it means I can't share the current prefab, because the texture is purchased.
*Alternatively, you can look into mapping 2D noise on a sphere and use 3D noise for the time dimension, or use 4D noise if you don't want to do the mapping and can spare the performance.
No comments:
Post a Comment