-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About light module #40
Comments
Hello again, as i said in the previous discussion, i am not an expert in implementing lightning tecniques, so i will just explain the basics about how it works in the engine and where you can look to implement your own. BasicsUsually, if you want to achieve a whole illuminated scene with multiple lights and effects you go for Deferred rendering, you can read the basics about how it works there or googling. This allow you to implement a lot of lighting tecniques more easily. To keep it simple and to study just the basics i used only a directional light (the sun basically), rendered using Forward Rendering. This process usually is solwer in terms of performance and could be a bit more complicated. So as i said, in my engine there's just a directional light, adding more lights (such as point lights) could be done but require quite some changes, either improving the Forward Rendering code or switching the whole engine to Deferred rendering. Notice that i didn't use any of the tecniques to achieve good lightning such as specular/normal/... textures. ShadowsThat was just the basics to render lights, rendering the shadows is another whole topic, and could be more difficult to understand and implement. Rendering a shadow is basically "capturing" the scene from the light point of view and so compute where the mesh are projected. I really suggest you to look at LearnOpenGL-/Shadow-Mapping to understand the basics. Every light could be different: while a directional light is basically rendering the scene from another point of view, a point light need to know how the scene looks from every angle, so it ususlly contains 6 (cubemmap)/8 shadow textures. It could look easy as long as you have a single light, when you want multiple lights with shadows from each one of them, things gets harder because you can't allocate lots of shadow textures in the GPU and need to choose which to pick or implement optimization tecniques, but these are more advanced topic i will not explain right now. If you want you can give a look at this presentation. ExamplesBasic examples you can look at (All of them use Forward Rendering):
If you want examples with Deferred Rendering: In the engineSo, once again, right now my engine use only a single directional light for the sun, is exactly the same as the first example linked above (Basic shadowmapping). The resources are created here: StandardShadowmapping.cpp. As everything else it need to be in a command buffer, this is here: StandardCommandBuffer.cpp#L99. Basically first it render the shadow commands and then the actual game adding the information from the shadow rendering. I suggest you to analyze it with Renderdoc if you have time. (You need to download the last .exe from Releases). The main rendering order is here: RenderManager.cpp#L429 and as i said before, first there are the shadow commands and then the final command that produce the final result. EndThese are just the basics, if you need to know more go read other resources and look at examples, i'm not an expert in this yet, so i can't help you so much. |
Thanks man, i have known this principle! |
Hello, i'm comeback again : )
Nowadays, i'm studying the light model.
Your engine are using the plane lights with a single light source, is right?
But what the principle to compute the shadow, any document will be helpful, thank you very much!
The text was updated successfully, but these errors were encountered: