Devlog #14 Shadow System and Daylight System

I decided to add a shadow system because I think this system will make more nice effect on the game visually. The game currently does not have dynamic lighting. In fact, there is no connection between the shadow system and the lighting system. The way the shadow system works will depend on an imaginary sun. The shadows will also move from east to west. However, as I said, this shadow system will not work exactly as intended. At some points, there will be obvious mistakes in the visual sense.

I have prepared a small demo where this shadow system is implemented. I get this result that's not bad for me:
Shadow System
Now it's time to associate it with the daylight system. But first, we will need to determine the duration of the day. I think 15 minutes is a reasonable amount of time in the real time. In other words, the length of the night and the length of the day will be 7.5 minutes. We will be able to follow the day-night cycle through the interface as a representative. Although I am not sure about the positioning part, I have a nice design in my mind. Let's start working on the GUI part.

I added a GUI as basic to track the daynight cycle. It's time to animate it in accordance with the daylight system.
Daynight Cycle Tracker
I adapted the moving process exactly as I wanted it:
Animate Daynight Cycle Tracker
So, how it works? I used RenderTexture feature of SFML. In a sense, I draw the textures of daylight cycle on an inactive canvas which the canvas becomes the rendertexture itself.. Then I take the texture of this canvas and give it to the object I created, and then render that object in the main window. The logic I used afterwards is quite simple. A picture frame and a picture inside it. You probably don't understand much from this part. If you don't know the point of SFML, it's normal that you don't understand.

I'm not sure about the design. I'm not sure about the use of this topbar panel. It seems like it's enough to make transparent the background color of topbar panel.
Just Daynight Cycle Tracker
As I said, I'm not sure how the design will be. However, this is not a top priority. Our priority is to ensure that the system works correctly.

Finally, I connected the shadow system and the daynight system. There are two type shadows. They are morning shadow and afternoon shadow. Also, I changed a little the angle of shadow.

Seems like a lot of progress has been made so far. However, there is still an ugliness. This ugliness is about the view of shadow. The areas where the shadows intersect are darker. 

Three hours later... I prevented the transparent shadows from overlapping too simply. I tried to understand how to use BlendMode for this simple solution but I still couldn't understand. Fortunately, it's no longer needed. Of course I have to learn about the BlendMode thing later. I have found a very limited but effective solution, and the result is as follows:
Shadows of Objecs in SFML
Now it's time to add these systems to our main game. 

Waiting...

It took me a while, but somehow I was able to implement it, and this is the test show:
Shadows in SFML
The shadows are only active for trees currently. Of course, it is not possible to achieve a perfect result in such a use. But still I am happy with the result. After this progress, I will deal with the design and positioning of the daynight cycle timebar. Let's end this devlog here for now. 

No comments:

Post a Comment