<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      【光照】UnityURP[光照貼圖]GPU instancing在靜態(tài)動(dòng)態(tài)物體上的應(yīng)用

      【從UnityURP開始探索游戲渲染】專欄-直達(dá)

      靜態(tài)物體GPU Instancing與光照貼圖

      ?技術(shù)要點(diǎn)?:

      • ?靜態(tài)標(biāo)記?:物體需標(biāo)記為Batching Static,但需禁用靜態(tài)合批以避免與GPU Instancing沖突。
      • ?光照貼圖綁定?:通過LightmapIndexLightmapScaleOffset手動(dòng)綁定烘焙結(jié)果。
      • ?Shader適配?:需在著色器中添加實(shí)例化支持與光照貼圖采樣邏輯。

      ?示例代碼?:

      • StaticInstancingExample.cs

        using UnityEngine;
        
        [ExecuteAlways]
        public class StaticInstancingExample : MonoBehaviour {
            public Mesh mesh;
            public Material material;
            public int instanceCount = 100;
            private Matrix4x4[] matrices;
            private Vector4[] lightmapOffsets;
        
            void Start() {
                // 生成實(shí)例變換矩陣
                matrices = new Matrix4x4[instanceCount];
                lightmapOffsets = new Vector4[instanceCount];
                for (int i = 0; i < instanceCount; i++) {
                    Vector3 pos = Random.insideUnitSphere * 10f;
                    matrices[i] = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one);
        
                    // 模擬不同光照貼圖偏移(需與烘焙數(shù)據(jù)匹配)
                    lightmapOffsets[i] = new Vector4(1, 1, i % 2 * 0.5f, i / 2 * 0.5f);
                }
            }
        
            void Update() {
                MaterialPropertyBlock props = new MaterialPropertyBlock();
                props.SetVectorArray("_LightmapST", lightmapOffsets); // 傳遞光照貼圖UV偏移
                Graphics.DrawMeshInstanced(mesh, 0, material, matrices, instanceCount, props);
            }
        }
        

      ?實(shí)現(xiàn)說明?:

      • 使用MaterialPropertyBlock傳遞每實(shí)例的光照貼圖UV偏移參數(shù)。
      • 著色器中需聲明UNITY_LIGHTMAP_ON宏并采樣unity_Lightmap紋理。

      動(dòng)態(tài)物體GPU Instancing與光照探針

      ?技術(shù)要點(diǎn)?:

      • ?光照探針替代?:動(dòng)態(tài)物體依賴Light Probes獲取間接光照。
      • ?混合光源支持?:光源設(shè)為Mixed模式,靜態(tài)陰影烘焙到光照貼圖,動(dòng)態(tài)物體接收實(shí)時(shí)陰影。
      • ?實(shí)例化屬性擴(kuò)展?:通過MaterialPropertyBlock傳遞探針數(shù)據(jù)。

      ?示例代碼?:

      • DynamicInstancingExample.cs

        using UnityEngine;
        
        public class DynamicInstancingExample : MonoBehaviour {
            public Mesh mesh;
            public Material material;
            public int instanceCount = 100;
            private Matrix4x4[] matrices;
        
            void Start() {
                matrices = new Matrix4x4[instanceCount];
                for (int i = 0; i < instanceCount; i++) {
                    Vector3 pos = Random.insideUnitSphere * 10f;
                    matrices[i] = Matrix4x4.TRS(pos, Quaternion.identity, Vector3.one);
                }
            }
        
            void Update() {
                MaterialPropertyBlock props = new MaterialPropertyBlock();
        
                // 為每個(gè)實(shí)例設(shè)置光照探針數(shù)據(jù)
                LightProbes.GetInterpolatedProbe(transform.position, null, out var probe);
                props.AddVector("_LightProbeData", new Vector4(probe.occlusion, 0, 0, 0));
        
                Graphics.DrawMeshInstanced(mesh, 0, material, matrices, instanceCount, props);
            }
        }
        

      ?實(shí)現(xiàn)說明?:

      • 通過LightProbes.GetInterpolatedProbe獲取動(dòng)態(tài)物體的光照探針數(shù)據(jù)。
      • 著色器中需使用SHADERGRAPH_BAKED_LIGHT_PROBES宏處理探針數(shù)據(jù)。

      Shader適配關(guān)鍵代碼(URP Shader Graph)

      • ?靜態(tài)光照貼圖采樣?:在Shader Graph中添加Lightmap節(jié)點(diǎn),并通過Custom Function節(jié)點(diǎn)接入實(shí)例化的UV偏移參數(shù)。
      • ?動(dòng)態(tài)探針支持?:添加Baked Light Probes節(jié)點(diǎn),并與實(shí)例化屬性_LightProbeData關(guān)聯(lián)。

      ?優(yōu)先級(jí)注意?:若同時(shí)啟用SRP Batcher,需確保材質(zhì)兼容性(禁用MaterialPropertyBlock


      【從UnityURP開始探索游戲渲染】專欄-直達(dá)
      (歡迎點(diǎn)贊留言探討,更多人加入進(jìn)來能更加完善這個(gè)探索的過程,??)

      posted @ 2025-10-10 10:33  SmalBox  閱讀(89)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 深夜福利啪啪片| 惠安县| 国产人妻人伦精品婷婷| 国产亚洲精品久久综合阿香| 日本中文字幕亚洲乱码| 色一情一区二区三区四区| 成av人片一区二区久久| 亚洲成色精品一二三区| 久艹视频免费看| 国产日产亚洲系列av| 国产精品自在线拍国产| 深夜精品免费在线观看| 人妻少妇精品视频专区| 国产69精品久久久久99尤物| 情欲少妇人妻100篇| 天天摸天天做天天添欧美| 熟女系列丰满熟妇AV| 桃花岛亚洲成在人线AV| 国产免费一区二区三区在线观看 | 久久精品国产福利一区二区| а√在线中文网新版地址在线| 亚洲欧美精品aaaaaa片| 婷婷久久香蕉五月综合加勒比 | 老师扒下内裤让我爽了一夜| 久久久午夜精品福利内容 | 国产精品色哟哟在线观看| 东京热无码国产精品| 国产精品高清国产三级囯产AV| 久久精品青青大伊人av| 久久国产精品无码网站| 亚洲国产精品人人做人人爱| 国产成人拍国产亚洲精品| 精品无套挺进少妇内谢| 国产午夜精品福利视频| 精品人妻伦九区久久69| 国产毛片三区二区一区| 亚洲国产欧美在线人成| 国产成人亚洲一区二区三区| 久久人人97超碰国产精品| 色综合天天综合天天更新| 日本免费最新高清不卡视频|