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:

enter image description here

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:

enter image description here

How can I achieve this effect?

  • 1
    \$\begingroup\$ I don't know about Unity, but looks like you need to draw in an "additive" blend mode. \$\endgroup\$ Commented Jul 25, 2015 at 20:21
  • 1
    \$\begingroup\$ You could always go this direction: shadertoy.com/view/XdBSDh \$\endgroup\$
    – Alan Wolfe
    Commented Jul 25, 2015 at 20:55
  • 4
    \$\begingroup\$ You need to be much more specific and show that you have done your research. There is a plethora of information out there for star rendering. Typically, you will use a 2d camera-facing billboard to render the corona over top of your generic star. Nobody can teach you everything involved to make a realistic looking star on a SE answer. Here is a good tutorial from the Seed of Andromeda game. seedofandromeda.com/blogs/51-procedural-star-rendering . Another, rougher tutorial on reddit, but good info none-the-less seedofandromeda.com/blogs/51-procedural-star-rendering \$\endgroup\$ Commented Jul 25, 2015 at 20:56
  • \$\begingroup\$ In Unity, change the Shader of the Material to Additive (that's under the Particle submenu I think, because Additive blend mode is mostly useful on particles). \$\endgroup\$
    – jhocking
    Commented Jul 25, 2015 at 21:15
  • 1
    \$\begingroup\$ @Shane Two yrs later but better late than never I guess. Cheers.. reddit.com/r/gamedev/comments/33xuyj/procedural_star_rendering \$\endgroup\$ Commented Jun 9, 2017 at 22:54

3 Answers 3

  • 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:

  1. Animated Texture
  2. Brighten the edges of the sphere based on normals
  3. Add camera-facing transparent billboard with white/yellow halo
  4. Particles, moving from the center to the outside, then fading
  5. Add 2 transparent "ray" billboards, facing the camera and rotating along the camera axis in opposite directions.

Building a Sun

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:

enter image description here enter image description here enter image description here enter image description here [enter image description here enter image description here

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.

  • 4
    \$\begingroup\$ If you aim for it being realistic: the edges of a star actually are not brighter but less bright than the centre of the disk. \$\endgroup\$ Commented Dec 14, 2015 at 17:20
  • 2
    \$\begingroup\$ @planetmaker Absolutely. But a cool looking effect is easier to achieve with a white or white-ish halo and details in the center. It can be done the other way, but I think it's quite a bit trickier Anyway, looking into a realistic sun permanently blinds us, so we don't want a realistic sun:) \$\endgroup\$
    – Peter
    Commented Dec 14, 2015 at 17:49

Other then the particale system and halo effects Vadim mentioned you could create your own shader effect. There is some introduction to shaders for Unity and the possibilities are endless.

  • \$\begingroup\$ I don't know if you found or created that shader, but it is absolutely gorgeous. \$\endgroup\$ Commented Dec 14, 2015 at 17:38
  • \$\begingroup\$ No I have not created the shader, unfortunately my knowledge about shaders is pretty basic. But I agree, it's gorgeous ;). \$\endgroup\$
    – Madmenyo
    Commented Dec 14, 2015 at 18:48

Try using a Particle System and a halo effect. You could also add a light to the star and have a bloom effect on your camera.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .