6
\$\begingroup\$

I'm drawing a 3d rendered island which has a day / night cycle and a sun that rises and sets over water.

The sea is rendered with a fragment shader derived from this Blinn-Phong tutorial.

http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-lights-ii/

The sun's position is a represented by a point at its centre which moves over time to simulate a day / night cycle. When the point is over the horizon, the sea shader uses Blinn-phong and a normal map to produce a reflection.

I don't like the way it renders at the moment for a couple of reasons. The most serious issue is light reflection is calculated from a single point at the centre of the sun's disc so that the light flicks on or off in a totally abrupt fashion as the centre of the sun crosses the horizon. See the pictures for what I mean.

The second issue also evident in the picture is the light is a pin prick in the centre of the sun and the reflection on the sea is too focussed. It should spread from the whole disc not just a point in the centre. The Sun's disc btw is just a billboard.

Before centre rises over horizon

After centre rises over horizon

What I want to happen is for the the light levels gradually increase as the sun rises and correspondingly decrease as it sets. I also want the light on the sea to spread from the whole disc rather than a pin point in the middle. This can't be a compute intensive change because the code is destined to run on mobile GPUs on android but it should still be pleasing.

I could potentially move the light point to the top of the sun to make the light appear more early and set later. However that might interfere with the light calculations in an adverse way (now the centre of the light is the top of the sun). Maybe I could start with the light point at the top and slowly move it to the centre as the sun rises (and back again as the sun sets) to counteract this problem. I could also calculate an intensity when the sun is low in the sky based on how much of the sun is showing and gradually increase the intensity to make the light stronger.

I could potentially have a cluster of light sources covering the centre, top, left, bottom and right but this increases complexity a lot and could still look weird.

Does anyone have comments on the feasibility of these ideas or have others ways I could achieve this?

\$\endgroup\$
0

2 Answers 2

2
\$\begingroup\$

Animating the intensity and position of the light as the sun sets, so that it's roughly centered in the portion of the sun above the horizon and has an intensity proportional to the area of the sun above the horizon, sounds like an idea worth trying to me.

Another thing I'd recommend trying is making the specular power on the water lower based on distance. A problem with your image is the specular highlight forms a thin line that points at the center of the sun, where it should be roughly as wide as the sun itself. Lowering the spec power in the farther-away areas should help this. You'll have to experiment with the exact equation.

\$\endgroup\$
1
  • \$\begingroup\$ Moving the light to be max(horizon, centre_of_sun) seems to do the trick with the sunrise. I'll play around with the specularity to see if I can make it less sharp \$\endgroup\$
    – locka
    Sep 24, 2013 at 12:41
-2
\$\begingroup\$

You could alternatively have the light for the sun set back like so.. Sun Movement

apologies for my terrible drawing

\$\endgroup\$
1
  • 4
    \$\begingroup\$ I think a little more explanation is in order here. \$\endgroup\$
    – House
    Sep 20, 2013 at 13:17

You must log in to answer this question.

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