From 8c331ba6c16abb5fe25d0029d016749b2880d560 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Tue, 18 Jul 2023 15:50:04 +0800 Subject: [PATCH] add validPunctualLightsCulling func to custom pipeline --- cocos/rendering/custom/define.ts | 8 ++++---- cocos/rendering/custom/executor.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts index a461e93f1eb..35a5832108c 100644 --- a/cocos/rendering/custom/define.ts +++ b/cocos/rendering/custom/define.ts @@ -75,7 +75,7 @@ export function validPunctualLightsCulling (pipeline: BasicPipeline, camera: Cam const { spotLights } = camera.scene!; for (let i = 0; i < spotLights.length; i++) { const light = spotLights[i]; - if (light.baked) { + if (light.baked && !camera.node.scene.globals.disableLightmap) { continue; } @@ -88,7 +88,7 @@ export function validPunctualLightsCulling (pipeline: BasicPipeline, camera: Cam const { sphereLights } = camera.scene!; for (let i = 0; i < sphereLights.length; i++) { const light = sphereLights[i]; - if (light.baked) { + if (light.baked && !camera.node.scene.globals.disableLightmap) { continue; } geometry.Sphere.set(_sphere, light.position.x, light.position.y, light.position.z, light.range); @@ -117,8 +117,8 @@ export function validPunctualLightsCulling (pipeline: BasicPipeline, camera: Cam validPunctualLights.push(light); } } - // array push not supported. - pipeline.pipelineSceneData.validPunctualLights = validPunctualLights; + // in jsb, std::vector is not synchronized, so we need to assign it manually + sceneData.validPunctualLights = validPunctualLights; } const _cameras: Camera[] = []; diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts index 285fc02d679..732f36b4f64 100644 --- a/cocos/rendering/custom/executor.ts +++ b/cocos/rendering/custom/executor.ts @@ -59,7 +59,7 @@ import { RenderShadowMapBatchedQueue } from '../render-shadow-map-batched-queue' import { PlanarShadowQueue } from '../planar-shadow-queue'; import { DefaultVisitor, depthFirstSearch, ReferenceGraphView } from './graph'; import { VectorGraphColorMap } from './effect'; -import { getDescBindingFromName, getDescriptorSetDataFromLayout, getDescriptorSetDataFromLayoutId, getRenderArea, mergeSrcToTargetDesc, updateGlobalDescBinding } from './define'; +import { getDescBindingFromName, getDescriptorSetDataFromLayout, getDescriptorSetDataFromLayoutId, getRenderArea, mergeSrcToTargetDesc, updateGlobalDescBinding, validPunctualLightsCulling } from './define'; import { RenderReflectionProbeQueue } from '../render-reflection-probe-queue'; import { builtinResMgr } from '../../asset/asset-manager/builtin-res-mgr'; import { Texture2D } from '../../asset/assets/texture-2d'; @@ -1131,6 +1131,7 @@ class DevicePreSceneTask extends WebSceneTask { } if (sceneFlag & SceneFlags.DEFAULT_LIGHTING) { this._submitInfo.additiveLight = context.additiveLight; + validPunctualLightsCulling(context.pipeline, this.camera); this._submitInfo.additiveLight.gatherLightPasses(this.camera, this._cmdBuff, this._currentQueue.devicePass.layoutName); } if (sceneFlag & SceneFlags.PLANAR_SHADOW) {