0
votes

I apologize, because this seems like a pretty straightforward problem that should be obvious, but it appears that I'm clueless.

I'm writing an engine and using Light 0 as the "sun" for the scene. I figure, ideally, the sun will be a fixed light source, not a vector, so the w/fourth index in the position vector should be 1.0f.

I setup the scene's Ortho viewpoint, then setup the light to be at the position of the character (x/y are coordinates of the plane terrain, with a positive z facing the camera and indicating "height" on the terrain -- the scene is also rotated for an isometric view on the x axis).

The character is always centered in the screen -- but I've noticed that for some reason, the light seems to shine at a position between the character and world coordinates 0,0,0. The further the character gets from world coordinates 0,0,0, the larger/wider the light is. If the character is at 0,0,0, the light is very small. If the character moves to something like 0,200,0, the light is HUGE.

I'm just trying to get my feet wet and have a "light" that follows the character (and then adjust for position, etc, later, to create a sun).

        Graphics.BeginRenderingLayer();
        {
            Video.MapRenderingMode();

            Graphics.BeginLightingLayer( Graphics.AmbientR, Graphics.AmbientG, Graphics.AmbientB, Graphics.DiffuseR, Graphics.DiffuseG, Graphics.DiffuseB, pCenter.X, pCenter.Y, pCenter.Z );
            {
                Graphics.BeginRenderingLayer();
                {
                    Graphics.CenterCamera( pCenter.X, pCenter.Y, pCenter.Z );
                    RenderMap( pWorld, pCenter, pCoordinate );
                }
                Graphics.EndRenderingLayer();

                Graphics.BeginRenderingLayer();
                {
                    Graphics.DrawMan( pCenter );
                }
                Graphics.EndRenderingLayer();
            }
            Graphics.EndLightingLayer();
        }
        Graphics.EndRenderingLayer();

Graphics.BeginRenderingLayer = PushMatrix, EndRenderingLayer = PopMatrix Video.MapRenderingMode = Ortho Projection and Scene Rotation/Zoom CenterCamera does a translate to the opposite of the X/Y/Z, such that the character is now centered at X/Y/Z in the middle of the screen.

Any thoughts? Maybe I've confused some of my code here a little?

1
Normally sun is defined as directional light. - Luca

1 Answers

0
votes

I figure, ideally, the sun will be a fixed light source, not a vector, so the w/fourth index in the position vector should be 1.0f.

As far as anything happening over basic human scales is concerned, the Sun is infinitely far away. It's pretty much the definitive "directional light". So unless you are rendering across hundreds or thousands of miles, the differences in the direction of sunlight will be entirely irrelevant.

In short: you should use a directional light, just like everyone else.