Design a site like this with WordPress.com
Get started

Ahmad Fauzan

Game Engine Programmer

Game Programming Journey – November & December 2019

Progress

Zooid Engine

In October, I implemented Depth Pre-Pass into the Deferred rendering. With Depth Pre-Pass, the result can be used to make GPU occlusion queries. The queries are simply asking whether the object should be rendered or not.

How it works is by sending the draw to GPU and ask if any fragment passed. Instead of passing the model itself, passing a simple bounding box would be enough. Of course, the query can be false positive but in very rare cases (well, depending on the scene setup). Better than occluding something that should be rendered.

Besides the objects, I also implement a query for Light frustum, whether we should process the light or part of the light. The occlusion query for the light frustum helps for reducing shadow maps generation load. For example, directional light has four cascaded shadow maps based on distance from the camera. Instead of generating all four shadow maps, we can check the last three cascade shadow frustum against the scene depth. If the frustum query is failed, then we don’t need to generate the shadow maps for that frustum. Let’s say, the camera looking closely into a curtain, generating shadow maps behind the curtain is really a waste of time and the player can’t see any shadow behind the curtain anyway.

Figure 1. Looking to the curtain in the Sponza scene with only Directional Light.
GPU Profiler for Scene in Figure 1. The top is without the scene occlusion queries. The bottom one is with. As you can see, there are SceneOcclusionQueries and ShadowOcclusionQueries in the bottom one. In GBufferRenderPass, the time is shorter because the number of models being passed into GPU decreased during the SceneOcclusionQueries. The comparison of ShadowDepthPass in both profilers is the number of the depth map it renders to. As the bottom one, it only renders depth map 2 out of 3 (CSM based on View Frustrum), because the third one didn’t pass the ShadowOcclusionQueries.

Overall, the performance with and without scene occlusion queries is relatively the same in the engine implementation for the above case. Some optimizations can be done on how I implement the occlusion queries. Right now, the query results are retrieved immediately after all queries being posted to GPU, causing the CPU and GPU to be stalled in some amount of time (depending on how many models being processed). In the future, I can defer the result to the next frame, and using the result to determine whether the object is occluded or not. There is an interesting article about how to deal with this kind of problem and some other optimizations in GPU Gems 2.

Zooid UI

  • Implement window menus. This is a basic simple window menu. It is the menu where you see in the most modern OS on top of the window of an application, below the application name.
  • Implement rectangle masking and scroll bar, also make panel scrollable. The rectangle masking is used to mask the content outside a panel, so the content won’t be drawn anything outside the mask. The implementation in the OpenGL sample is using the Stencil buffer. Basically, the UI will tell the renderer to render the mask first (render to stencil) and then render everything after that to check if the object should be drawn using the mask (again, it’s a stencil test) until the mask is removed.
Zooid UI OpenGL Sample. There are window menus on the top of the application window. The content and text inside the panels being cut using rectangle masks.

Learning/Tutorial

  • (Book) Real-Time Rendering, Ch 9. Global Illumination. Subchapters: Refractions, Caustics, Global Subsurface, Radiosity, and Ray Tracing.
  • (Tutorial) DirectX 11 from Rastertek.com: Specular Mapping.
  • (Tutorial) DirectX 11 from Rastertek.com: Render to Texture.
  • (Tutorial) DirectX 11 from Rastertek.com: Fog.

Plans for 2020

The year 2019 is already ended. It’s time to make plans for 2020.

  • I have started “Game Programming Journey” since June 2019. The idea is to become a medium for me to keep track of things I’ve been working on, learning, and try to explain those in here. I definitely going to keep this running in 2020. If I can’t write a post for a month, I will try to post one the following month, to sum both months (This one for example).
  • In 2019, I’ve been focusing on the Zooid Engine rendering side: understanding the GPU flow, dealing with engine architecture, assets management, and implement some basic features. It still not satisfied me yet. This year, I will focus more on making the rendering looks more realistic. I will start working on PBR and then more related-rendering features.
  • Finishing Real-Time Rendering Book. It may take 3-4 more months for me to finish the book. I admit, when I’m reading a textbook like this, most often I will wander around the references to find something interesting. Once finished I will start another one. “Game Coding Complete” will be next.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: