@@ -355,11 +355,11 @@ bool RenderSystem::checkPBRFrabebufferUpdate(Material& material){
355355 material.emissiveTexture .isFramebufferOutdated () );
356356}
357357
358- bool RenderSystem::checkPBRTextures (Material& material){
358+ bool RenderSystem::checkPBRTextures (Material& material, bool receiveLights ){
359359 bool hasBaseColor = !material.baseColorTexture .empty ();
360360
361361 bool hasOtherPBRTextures = false ;
362- if (hasLights) {
362+ if (hasLights && receiveLights ) {
363363 hasOtherPBRTextures = !material.metallicRoughnessTexture .empty () ||
364364 !material.normalTexture .empty () ||
365365 !material.occlusionTexture .empty () ||
@@ -369,7 +369,7 @@ bool RenderSystem::checkPBRTextures(Material& material){
369369 return hasBaseColor || hasOtherPBRTextures;
370370}
371371
372- bool RenderSystem::loadPBRTextures (Material& material, ShaderData& shaderData, ObjectRender& render){
372+ bool RenderSystem::loadPBRTextures (Material& material, ShaderData& shaderData, ObjectRender& render, bool receiveLights ){
373373 TextureRender* textureRender = NULL ;
374374 std::pair<int , int > slotTex (-1 , -1 );
375375
@@ -384,7 +384,7 @@ bool RenderSystem::loadPBRTextures(Material& material, ShaderData& shaderData, O
384384 render.addTexture (slotTex, ShaderStageType::FRAGMENT , &emptyWhite);
385385 }
386386
387- if (hasLights){
387+ if (hasLights && receiveLights ){
388388 textureRender = material.metallicRoughnessTexture .getRender (&emptyWhite);
389389 slotTex = shaderData.getTextureIndex (TextureShaderType::METALLICROUGHNESS );
390390 if (textureRender){
@@ -433,10 +433,10 @@ bool RenderSystem::loadPBRTextures(Material& material, ShaderData& shaderData, O
433433 return true ;
434434}
435435
436- void RenderSystem::loadShadowTextures (ShaderData& shaderData, ObjectRender& render, bool receiveShadows){
436+ void RenderSystem::loadShadowTextures (ShaderData& shaderData, ObjectRender& render, bool receiveLights, bool receiveShadows){
437437 std::pair<int , int > slotTex (-1 , -1 );
438438
439- if (hasLights && hasShadows && receiveShadows){
439+ if (hasLights && receiveLights && hasShadows && receiveShadows){
440440 size_t num2DShadows = 0 ;
441441 size_t numCubeShadows = 0 ;
442442 auto lights = scene->getComponentArray <LightComponent>();
@@ -636,7 +636,7 @@ bool RenderSystem::loadMesh(Entity entity, MeshComponent& mesh, uint8_t pipeline
636636
637637 render.beginLoad (mesh.submeshes [i].primitiveType );
638638
639- bool hasPBRTextures = checkPBRTextures (mesh.submeshes [i].material );
639+ bool hasPBRTextures = checkPBRTextures (mesh.submeshes [i].material , mesh. receiveLights );
640640
641641 for (auto const & buf : buffers){
642642 if (buf.second ->isRenderAttributes ()) {
@@ -708,7 +708,7 @@ bool RenderSystem::loadMesh(Entity entity, MeshComponent& mesh, uint8_t pipeline
708708 if (terrain && !terrain->blendMap .empty ()){
709709 p_hasTexture1 = true ;
710710 }
711- if (hasLights){
711+ if (hasLights && mesh. receiveLights ){
712712 p_punctual = true ;
713713
714714 p_hasNormal = true ;
@@ -753,7 +753,7 @@ bool RenderSystem::loadMesh(Entity entity, MeshComponent& mesh, uint8_t pipeline
753753 if (hasFog){
754754 mesh.submeshes [i].slotFSFog = shaderData.getUniformBlockIndex (UniformBlockType::FS_FOG );
755755 }
756- if (hasLights){
756+ if (hasLights && mesh. receiveLights ){
757757 mesh.submeshes [i].slotFSLighting = shaderData.getUniformBlockIndex (UniformBlockType::FS_LIGHTING );
758758 if (hasShadows && mesh.receiveShadows ){
759759 mesh.submeshes [i].slotVSShadows = shaderData.getUniformBlockIndex (UniformBlockType::VS_SHADOWS );
@@ -770,10 +770,10 @@ bool RenderSystem::loadMesh(Entity entity, MeshComponent& mesh, uint8_t pipeline
770770 mesh.submeshes [i].slotVSMorphTarget = shaderData.getUniformBlockIndex (UniformBlockType::VS_MORPHTARGET );
771771 }
772772
773- if (!loadPBRTextures (mesh.submeshes [i].material , shaderData, mesh.submeshes [i].render )){
773+ if (!loadPBRTextures (mesh.submeshes [i].material , shaderData, mesh.submeshes [i].render , mesh. receiveLights )){
774774 return false ;
775775 }
776- loadShadowTextures (shaderData, mesh.submeshes [i].render , mesh.receiveShadows );
776+ loadShadowTextures (shaderData, mesh.submeshes [i].render , mesh.receiveLights , mesh. receiveShadows );
777777
778778 if (terrain){
779779 mesh.submeshes [i].slotVSTerrain = shaderData.getUniformBlockIndex (UniformBlockType::TERRAIN_VS_PARAMS );
@@ -1023,7 +1023,7 @@ bool RenderSystem::drawMesh(MeshComponent& mesh, Transform& transform, CameraCom
10231023
10241024 if (mesh.submeshes [i].needUpdateTexture || needUpdateFramebuffer){
10251025 ShaderData& shaderData = mesh.submeshes [i].shader .get ()->shaderData ;
1026- if (loadPBRTextures (mesh.submeshes [i].material , shaderData, mesh.submeshes [i].render )){
1026+ if (loadPBRTextures (mesh.submeshes [i].material , shaderData, mesh.submeshes [i].render , mesh. receiveLights )){
10271027 mesh.submeshes [i].needUpdateTexture = false ;
10281028 }
10291029 }
@@ -1037,7 +1037,7 @@ bool RenderSystem::drawMesh(MeshComponent& mesh, Transform& transform, CameraCom
10371037 render.applyUniformBlock (mesh.submeshes [i].slotFSFog , sizeof (float ) * 8 , &fs_fog);
10381038 }
10391039
1040- if (hasLights){
1040+ if (hasLights && mesh. receiveLights ){
10411041 render.applyUniformBlock (mesh.submeshes [i].slotFSLighting , sizeof (float ) * (16 * MAX_LIGHTS + 8 ), &fs_lighting);
10421042 if (hasShadows && mesh.receiveShadows ){
10431043 render.applyUniformBlock (mesh.submeshes [i].slotVSShadows , sizeof (float ) * (16 * MAX_SHADOWSMAP ), &vs_shadows);
@@ -1061,7 +1061,7 @@ bool RenderSystem::drawMesh(MeshComponent& mesh, Transform& transform, CameraCom
10611061 }
10621062 }
10631063
1064- if (hasLights){
1064+ if (hasLights && mesh. receiveLights ){
10651065 render.applyUniformBlock (mesh.submeshes [i].slotFSParams , sizeof (float ) * 12 , &mesh.submeshes [i].material );
10661066 }else {
10671067 render.applyUniformBlock (mesh.submeshes [i].slotFSParams , sizeof (float ) * 4 , &mesh.submeshes [i].material );
@@ -2841,7 +2841,7 @@ void RenderSystem::update(double dt){
28412841 if (mesh.submeshes [i].textureShadow ){
28422842 mesh.submeshes [i].needUpdateDepthTexture = true ;
28432843 }
2844- if (checkPBRTextures (mesh.submeshes [s].material )){
2844+ if (checkPBRTextures (mesh.submeshes [s].material , mesh. receiveLights )){
28452845 if (!(mesh.submeshes [s].shaderProperties & (1 << 1 )) && !(mesh.submeshes [s].shaderProperties & (1 << 2 ))){ // not 'Uv1' and not 'Uv2'
28462846 mesh.needReload = true ;
28472847 }
0 commit comments