本文整理汇总了C++中Model3D::isShadowReceiver方法的典型用法代码示例。如果您正苦于以下问题:C++ Model3D::isShadowReceiver方法的具体用法?C++ Model3D::isShadowReceiver怎么用?C++ Model3D::isShadowReceiver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model3D
的用法示例。
在下文中一共展示了Model3D::isShadowReceiver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: biasMatrix
bool OpenGLRenderer::renderModel3D(Model3D &model3D, Camera &camera, LightingShader &shader, DirectLight *sun,
std::vector<PointLight *> &pointLights, std::vector<SpotLight *> &spotLights, float ambientK,
RenderTarget &renderTarget, bool disableDepth)
{
glm::mat4 biasMatrix(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);
GLuint textureUnit = 0;
GLuint dummyTextureUnit = 0;
__(glDepthRangef(camera.getNear(), camera.getFar()));
/* Calculate MVP matrix */
glm::mat4 MVP = camera.getPerspectiveMatrix() * camera.getViewMatrix() * model3D.getModelMatrix();
/* Calculate normal matrix */
glm::mat3 normalMatrix = glm::transpose(glm::inverse(glm::mat3(model3D.getModelMatrix())));
/* Cast the model into an internal type */
OpenGLAsset3D *glObject = static_cast<OpenGLAsset3D *>(model3D.getAsset3D());
/* TODO: is this even used????? below we enable it always :P */
if (disableDepth) {
glDisable(GL_DEPTH_TEST);
} else {
glEnable(GL_DEPTH_TEST);
}
if (getWireframeMode() == Renderer::RENDER_WIREFRAME_ONLY) {
__(glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
__(glEnable(GL_LINE_SMOOTH));
__(glDisable(GL_CULL_FACE));
} else {
__(glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
__(glDisable(GL_LINE_SMOOTH));
__(glEnable(GL_CULL_FACE));
}
/* Bind the render target */
renderTarget.bind();
{
__(glEnable(GL_MULTISAMPLE));
__(glEnable(GL_DEPTH_TEST));
__(glBlendEquation(GL_FUNC_ADD));
__(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
__(glEnable(GL_BLEND));
/* Bind program to upload the uniform */
shader.attach();
/* Send our transformation to the currently bound shader, in the "MVP" uniform */
shader.setUniformMat4("u_MVPMatrix", &MVP);
shader.setUniformMat4("u_viewMatrix", &camera.getViewMatrix());
shader.setUniformMat4("u_modelMatrix", &model3D.getModelMatrix());
shader.setUniformMat3("u_normalMatrix", &normalMatrix);
shader.setUniformTexture2D("u_diffuseMap", textureUnit++);
shader.setUniformFloat("u_ambientK", ambientK);
/* Activate and bind unit 0 for the dummy texture */
dummyTextureUnit = textureUnit++;
__(glActiveTexture(GL_TEXTURE0 + dummyTextureUnit));
__(glBindTexture(GL_TEXTURE_2D, _dummyTexture));
/* Set the sun light */
if (sun != NULL) {
glm::mat4 shadowMVP = sun->getProjectionMatrix() * sun->getViewMatrix() * model3D.getModelMatrix();
shadowMVP = biasMatrix * shadowMVP;
shader.setDirectLight(*sun);
shader.setUniformUint("u_numDirectLights", 1);
/* TODO: This has to be set in a matrix array */
shader.setUniformMat4("u_shadowMVPDirectLight", &shadowMVP);
shader.setUniformTexture2D("u_shadowMapDirectLight", textureUnit);
__(glActiveTexture(GL_TEXTURE0 + textureUnit));
if (model3D.isShadowReceiver()) {
sun->getShadowMap()->bindDepth();
} else {
__(glBindTexture(GL_TEXTURE_2D, _noshadowTexture));
}
textureUnit++;
} else {
shader.setUniformUint("u_numDirectLights", 0);
shader.setUniformTexture2D("u_shadowMapDirectLight", dummyTextureUnit);
}
/* Point lights */
glm::mat4 *shadowMVPArray = new glm::mat4[pointLights.size()];
GLuint texturesArray[OpenGLLightingShader::MAX_LIGHTS];
for (uint32_t numLight = 0; numLight < pointLights.size(); ++numLight) {
shader.setPointLight(numLight, *pointLights[numLight]);
/* Calculate adjusted shadow map matrix */
glm::mat4 shadowMVP =
pointLights[numLight]->getProjectionMatrix() * pointLights[numLight]->getViewMatrix() * model3D.getModelMatrix();
shadowMVPArray[numLight] = biasMatrix * shadowMVP;
texturesArray[numLight] = textureUnit;
//.........这里部分代码省略.........