From ddd059dc718c41b2f84c2727d82e5e72cd6371bb Mon Sep 17 00:00:00 2001 From: Myway Date: Tue, 17 Jan 2023 16:39:05 +0800 Subject: [PATCH] add highp lightmap macro (#14081) --- cocos/render-scene/scene/model.ts | 9 +++++++++ cocos/scene-graph/scene-globals.ts | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cocos/render-scene/scene/model.ts b/cocos/render-scene/scene/model.ts index b0728b747c..9e067160eb 100644 --- a/cocos/render-scene/scene/model.ts +++ b/cocos/render-scene/scene/model.ts @@ -55,6 +55,10 @@ const stationaryLightMapPatches: IMacroPatch[] = [ { name: 'CC_USE_LIGHTMAP', value: 2 }, ]; +const highpLightMapPatches: IMacroPatch[] = [ + { name: 'CC_LIGHT_MAP_VERSION', value: 2 }, +]; + const lightProbePatches: IMacroPatch[] = [ { name: 'CC_USE_LIGHT_PROBE', value: true }, ]; @@ -971,6 +975,11 @@ export class Model { const lightmapPathes = stationary ? stationaryLightMapPatches : staticLightMapPatches; patches = patches ? patches.concat(lightmapPathes) : lightmapPathes; + + // use highp lightmap + if (this.node.scene.globals.bakedWithHighpLightmap) { + patches = patches.concat(highpLightMapPatches); + } } if (this._useLightProbe) { patches = patches ? patches.concat(lightProbePatches) : lightProbePatches; diff --git a/cocos/scene-graph/scene-globals.ts b/cocos/scene-graph/scene-globals.ts index 3aea69c424..514b68b555 100644 --- a/cocos/scene-graph/scene-globals.ts +++ b/cocos/scene-graph/scene-globals.ts @@ -1444,6 +1444,14 @@ export class SceneGlobals { @serializable public bakedWithStationaryMainLight = false; + /** + * @en bake lightmap with highp mode + * @zh 是否使用高精度模式烘培光照图 + */ + @editable + @serializable + public bakedWithHighpLightmap = false; + /** * @en Activate and initialize the global configurations of the scene, no need to invoke manually. * @zh 启用和初始化场景全局配置,不需要手动调用