1 Star 0 Fork 0

yunni/RendererModule

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
DrawCall.cpp 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
yunni 提交于 2022-11-19 21:23 . light culling 2
#include "DrawCall.h"
#include "Material.h"
#include "GL20/VBO.h"
#include "GL20/IBO.h"
#include "Light.h"
DrawCall::DrawCall()
:mMaterial(nullptr), mIBO(nullptr), mVBO(nullptr){
}
void DrawCall::Draw(Camera* camera) {
switch (mCatalog){
case kRenderCatalogForward:
ForwardRendering(camera);
break;
case kRenderCatalogDefferedGPass:
DefferedGPass(camera);
break;
case kRenderCatalogDefferedLightPass:
DefferedLightPass(camera);
break;
}
}
void DrawCall::ForwardRendering(Camera* camera) {
mVBO->Bind();
//set main light
//material base bind
//vbo->draw
static float main_light_pos[] = { -1.0f, 1.0f, 0.0f, 0.0f };
mMaterial->mBaseRenderPass->SetVec4("U_LightPosition", main_light_pos);
mMaterial->mBaseRenderPass->SetVec4("U_LightColor", Light::mMainLight->mDiffuse);
mMaterial->mBaseRenderPass->Bind(camera);
//lightmap->bind
//ambient,emissive
//shadow map
//Light::mMainLight->Bind
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
//for light in lights
// set light state
// material->add->bind(Camera)
// vbo->draw
for (auto iter = Light::mLights.begin(); iter != Light::mLights.end(); ++iter) {
static float add_light_pos[] = { 1.0f, 1.0f, 0.0f, 0.0f };
mMaterial->mAdditiveRenderPass->SetVec4("U_LightPosition", add_light_pos);
mMaterial->mAdditiveRenderPass->SetVec4("U_LightColor", (*iter)->mDiffuse);
mMaterial->mAdditiveRenderPass->Bind(camera);
//light->bind
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
}
//->deffered
mVBO->Unbind();
if (mNext != nullptr) {
Next<DrawCall>()->Draw(camera);
}
}
void DrawCall::DefferedGPass(Camera* camera) {
mVBO->Bind();
mMaterial->mBaseRenderPass->Bind(camera);
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
mVBO->Unbind();
if (mNext != nullptr) {
Next<DrawCall>()->Draw(camera);
}
}
void DrawCall::DefferedLightPass(Camera* camera) {
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/linlinstyle/renderer-module.git
git@gitee.com:linlinstyle/renderer-module.git
linlinstyle
renderer-module
RendererModule
master

搜索帮助