Update models_material_pbr.c

This commit is contained in:
Ray 2021-06-03 21:04:23 +02:00
parent 0565fb9fb6
commit 7e68e733f5

View File

@ -279,17 +279,31 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
// Activate and enable texture for drawing to cubemap faces
rlActiveTextureSlot(0);
rlEnableTexture(panorama.id);
for (int i = 0; i < 6; i++)
{
// Set the view matrix for the current cube face
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
// Select the current cubemap face attachment for the fbo
// WARNING: This function by default enables->attach->disables fbo!!!
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
rlEnableFramebuffer(fbo);
rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
// Load and draw a cube, it uses the current enabled texture
rlClearScreenBuffers();
DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
rlDrawRenderBatchActive();
rlLoadDrawCube();
// ALTERNATIVE: Try to use internal batch system to draw the cube instead of rlLoadDrawCube
// for some reason this method does not work, maybe due to cube triangles definition? normals pointing out?
// TODO: Investigate this issue...
//rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
//rlClearScreenBuffers();
//DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
//rlDrawRenderBatchActive();
}
//------------------------------------------------------------------------------------------