| async function init() { | async function init() { | ||||
| const viewer = new ThreeViewer({ | const viewer = new ThreeViewer({ | ||||
| canvas: document.getElementById('mcanvas') as HTMLCanvasElement, | canvas: document.getElementById('mcanvas') as HTMLCanvasElement, | ||||
| debug: true, | |||||
| msaa: false, | msaa: false, | ||||
| rgbm: false, | rgbm: false, | ||||
| zPrepass: false, | zPrepass: false, | ||||
| autoScale: true, | autoScale: true, | ||||
| }) | }) | ||||
| const model = result?.getObjectByName('node_damagedHelmet_-6514') | const model = result?.getObjectByName('node_damagedHelmet_-6514') | ||||
| const ms = viewer.assetManager.materials.getAllMaterials() | |||||
| // viewer.assetManager.materials.exportMaterial(ms[0]) | |||||
| console.log(ms) | |||||
| const materail = new PhysicalMaterial({ | |||||
| 'metadata': { | |||||
| 'version': 4.6, | |||||
| 'type': 'Material', | |||||
| 'generator': 'Material.toJSON', | |||||
| }, | |||||
| 'uuid': '82d03dfe-a6b8-4d10-94bb-002435fb11af', | |||||
| 'type': 'MeshStandardMaterial2', | |||||
| 'name': 'black', | |||||
| 'color': 13355979, | |||||
| 'roughness': 0.711963684287597, | |||||
| 'metalness': 0.5432713428027529, | |||||
| 'sheen': 0, | |||||
| 'sheenColor': 0, | |||||
| 'sheenRoughness': 1, | |||||
| 'emissive': 0, | |||||
| 'specularIntensity': 1, | |||||
| 'specularColor': 16777215, | |||||
| 'clearcoat': 0, | |||||
| 'clearcoatRoughness': 0, | |||||
| 'iridescence': 0, | |||||
| 'iridescenceIOR': 1.3, | |||||
| 'iridescenceThicknessRange': [ | |||||
| 100, | |||||
| 400, | |||||
| ], | |||||
| 'anisotropy': 0, | |||||
| 'anisotropyRotation': 0, | |||||
| 'map': '2006c0db-c059-438d-baf4-ee6b89095f22', | |||||
| 'bumpMap': '2006c0db-c059-438d-baf4-ee6b89095f22', | |||||
| 'bumpScale': 0.009999999999999981, | |||||
| 'roughnessMap': '2006c0db-c059-438d-baf4-ee6b89095f22', | |||||
| 'envMapIntensity': 1, | |||||
| 'reflectivity': 0.49999999999999983, | |||||
| 'transmission': 0, | |||||
| 'thickness': 0, | |||||
| 'attenuationDistance': 0, | |||||
| 'attenuationColor': 16777215, | |||||
| 'side': 2, | |||||
| 'depthFunc': 3, | |||||
| 'depthTest': true, | |||||
| 'depthWrite': true, | |||||
| 'colorWrite': true, | |||||
| 'stencilWrite': false, | |||||
| 'stencilWriteMask': 255, | |||||
| 'stencilFunc': 519, | |||||
| 'stencilRef': 0, | |||||
| 'stencilFuncMask': 255, | |||||
| 'stencilFail': 7680, | |||||
| 'stencilZFail': 7680, | |||||
| 'stencilZPass': 7680, | |||||
| 'fog': false, | |||||
| 'userData': { | |||||
| 'gltfExtensions': {}, | |||||
| '_9c068557-570d-46f4-9c6d-f106319ed7f1_version': 66, | |||||
| '_triplanarMapping': { | |||||
| 'enable': true, | |||||
| 'scaleFactor': 2.6021818714306635, | |||||
| 'blendFactor': 1, | |||||
| 'offsetFactor': 0, | |||||
| }, | |||||
| 'uuid': '82d03dfe-a6b8-4d10-94bb-002435fb11af', | |||||
| }, | |||||
| 'textures': [ | |||||
| { | |||||
| 'metadata': { | |||||
| 'version': 4.6, | |||||
| 'type': 'Texture', | |||||
| 'generator': 'Texture.toJSON', | |||||
| }, | |||||
| 'uuid': '2006c0db-c059-438d-baf4-ee6b89095f22', | |||||
| 'name': '', | |||||
| 'image': '45a746eb-0369-414b-bc32-359ea8296101', | |||||
| 'mapping': 300, | |||||
| 'channel': 0, | |||||
| 'repeat': [ | |||||
| 1, | |||||
| 1, | |||||
| ], | |||||
| 'offset': [ | |||||
| 0, | |||||
| 0, | |||||
| ], | |||||
| 'center': [ | |||||
| 0, | |||||
| 0, | |||||
| ], | |||||
| 'rotation': 0, | |||||
| 'wrap': [ | |||||
| 1000, | |||||
| 1000, | |||||
| ], | |||||
| 'format': 1023, | |||||
| 'internalFormat': null, | |||||
| 'type': 1009, | |||||
| 'colorSpace': 'srgb-linear', | |||||
| 'encoding': 3000, | |||||
| 'minFilter': 1008, | |||||
| 'magFilter': 1006, | |||||
| 'anisotropy': 1, | |||||
| 'flipY': false, | |||||
| 'generateMipmaps': true, | |||||
| 'premultiplyAlpha': false, | |||||
| 'unpackAlignment': 4, | |||||
| 'userData': { | |||||
| 'rootPath': '/files/source/carbon_2_91262f99f0.jpg', | |||||
| }, | |||||
| }, | |||||
| ], | |||||
| 'images': [], | |||||
| }) | |||||
| // viewer.assetManager.materials.exportMaterial(materail) | |||||
| console.log(materail) | |||||
| // viewer.assetManager.materials.applyMaterial(materail, 'Material_MR') | |||||
| const materials = (model?.materials || []) as PhysicalMaterial[] | const materials = (model?.materials || []) as PhysicalMaterial[] | ||||
| ui.setupPluginUi(bloom) | ui.setupPluginUi(bloom) |
| export const DUMMY: string | export const DUMMY: string | ||||
| export const CESIUM_ION_API_TOKEN: string |
| selected.classList.remove('selected'); | selected.classList.remove('selected'); | ||||
| target.classList.add('selected'); | target.classList.add('selected'); | ||||
| selected = target; | selected = target; | ||||
| iframe.src = target.href; | |||||
| iframe.src = target.href.replace('http://localhost:9229', 'http://localhost:9229/examples'); | |||||
| sidebar.dataset.selectedExample = target.innerText; | sidebar.dataset.selectedExample = target.innerText; | ||||
| window.location.hash = "#" + target.getAttribute("href").slice(2); | window.location.hash = "#" + target.getAttribute("href").slice(2); | ||||
| if(scroll){ | if(scroll){ |
| <!DOCTYPE html> | |||||
| <html lang="zh-CN"> | |||||
| <head> | |||||
| <meta charset="UTF-8"> | |||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||||
| <title>正交相机示例 - 防止透视效果</title> | |||||
| <style> | |||||
| body { | |||||
| margin: 0; | |||||
| padding: 0; | |||||
| font-family: Arial, sans-serif; | |||||
| background: #f0f0f0; | |||||
| } | |||||
| .container { | |||||
| display: flex; | |||||
| height: 100vh; | |||||
| } | |||||
| .viewer-container { | |||||
| flex: 1; | |||||
| position: relative; | |||||
| } | |||||
| .controls-panel { | |||||
| width: 300px; | |||||
| background: white; | |||||
| padding: 20px; | |||||
| box-shadow: -2px 0 5px rgba(0,0,0,0.1); | |||||
| overflow-y: auto; | |||||
| } | |||||
| .control-group { | |||||
| margin-bottom: 20px; | |||||
| padding: 15px; | |||||
| border: 1px solid #ddd; | |||||
| border-radius: 5px; | |||||
| } | |||||
| .control-group h3 { | |||||
| margin: 0 0 10px 0; | |||||
| color: #333; | |||||
| } | |||||
| .control-item { | |||||
| margin-bottom: 10px; | |||||
| } | |||||
| label { | |||||
| display: block; | |||||
| margin-bottom: 5px; | |||||
| font-weight: bold; | |||||
| color: #555; | |||||
| } | |||||
| input, select, button { | |||||
| width: 100%; | |||||
| padding: 8px; | |||||
| border: 1px solid #ccc; | |||||
| border-radius: 3px; | |||||
| box-sizing: border-box; | |||||
| } | |||||
| button { | |||||
| background: #007bff; | |||||
| color: white; | |||||
| border: none; | |||||
| cursor: pointer; | |||||
| margin-top: 5px; | |||||
| } | |||||
| button:hover { | |||||
| background: #0056b3; | |||||
| } | |||||
| .info { | |||||
| background: #e7f3ff; | |||||
| padding: 10px; | |||||
| border-radius: 5px; | |||||
| margin-bottom: 20px; | |||||
| font-size: 14px; | |||||
| line-height: 1.4; | |||||
| } | |||||
| .comparison { | |||||
| display: grid; | |||||
| grid-template-columns: 1fr 1fr; | |||||
| gap: 10px; | |||||
| margin-bottom: 20px; | |||||
| } | |||||
| .comparison-item { | |||||
| text-align: center; | |||||
| padding: 10px; | |||||
| background: #f8f9fa; | |||||
| border-radius: 5px; | |||||
| } | |||||
| .comparison-item.active { | |||||
| background: #007bff; | |||||
| color: white; | |||||
| } | |||||
| </style> | |||||
| </head> | |||||
| <body> | |||||
| <div class="container"> | |||||
| <div class="viewer-container" id="viewer-container"></div> | |||||
| <div class="controls-panel"> | |||||
| <div class="info"> | |||||
| <strong>正交相机 vs 透视相机</strong><br> | |||||
| 正交相机可以消除透视效果,使远近物体保持相同的大小比例,常用于建筑设计、工程图纸等需要精确比例的场景。 | |||||
| </div> | |||||
| <div class="comparison"> | |||||
| <div class="comparison-item active" id="ortho-btn"> | |||||
| 正交相机<br> | |||||
| <small>无透视效果</small> | |||||
| </div> | |||||
| <div class="comparison-item" id="perspective-btn"> | |||||
| 透视相机<br> | |||||
| <small>有透视效果</small> | |||||
| </div> | |||||
| </div> | |||||
| <div class="control-group"> | |||||
| <h3>相机控制</h3> | |||||
| <div class="control-item"> | |||||
| <label>相机类型:</label> | |||||
| <select id="camera-type"> | |||||
| <option value="orthographic">正交相机 (Orthographic)</option> | |||||
| <option value="perspective">透视相机 (Perspective)</option> | |||||
| </select> | |||||
| </div> | |||||
| <div class="control-item"> | |||||
| <label>控制模式:</label> | |||||
| <select id="controls-mode"> | |||||
| <option value="orbit">轨道控制 (Orbit)</option> | |||||
| <option value="">无控制</option> | |||||
| </select> | |||||
| </div> | |||||
| </div> | |||||
| <div class="control-group" id="ortho-controls"> | |||||
| <h3>正交相机设置</h3> | |||||
| <div class="control-item"> | |||||
| <label>视锥大小 (Frustum Size): <span id="frustum-value">10</span></label> | |||||
| <input type="range" id="frustum-size" min="1" max="50" value="10" step="0.5"> | |||||
| </div> | |||||
| <div class="control-item"> | |||||
| <label>缩放 (Zoom): <span id="zoom-value">1</span></label> | |||||
| <input type="range" id="zoom" min="0.1" max="5" value="1" step="0.1"> | |||||
| </div> | |||||
| </div> | |||||
| <div class="control-group" id="perspective-controls" style="display: none;"> | |||||
| <h3>透视相机设置</h3> | |||||
| <div class="control-item"> | |||||
| <label>视野角度 (FOV): <span id="fov-value">75</span>°</label> | |||||
| <input type="range" id="fov" min="10" max="120" value="75" step="1"> | |||||
| </div> | |||||
| </div> | |||||
| <div class="control-group"> | |||||
| <h3>相机位置</h3> | |||||
| <div class="control-item"> | |||||
| <label>X: <span id="pos-x-value">0</span></label> | |||||
| <input type="range" id="pos-x" min="-20" max="20" value="0" step="0.5"> | |||||
| </div> | |||||
| <div class="control-item"> | |||||
| <label>Y: <span id="pos-y-value">0</span></label> | |||||
| <input type="range" id="pos-y" min="-20" max="20" value="0" step="0.5"> | |||||
| </div> | |||||
| <div class="control-item"> | |||||
| <label>Z: <span id="pos-z-value">10</span></label> | |||||
| <input type="range" id="pos-z" min="1" max="50" value="10" step="0.5"> | |||||
| </div> | |||||
| </div> | |||||
| <div class="control-group"> | |||||
| <h3>预设视角</h3> | |||||
| <button onclick="setPresetView('front')">正视图</button> | |||||
| <button onclick="setPresetView('side')">侧视图</button> | |||||
| <button onclick="setPresetView('top')">俯视图</button> | |||||
| <button onclick="setPresetView('isometric')">等轴测图</button> | |||||
| </div> | |||||
| <div class="control-group"> | |||||
| <h3>场景操作</h3> | |||||
| <button onclick="addTestObjects()">添加测试物体</button> | |||||
| <button onclick="clearScene()">清空场景</button> | |||||
| <button onclick="resetCamera()">重置相机</button> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script type="module" src="./script.js"></script> | |||||
| </body> | |||||
| </html> |
| { | |||||
| "f6ca7063-ce33-40c6-b873-82791534a3b4": "carbon_2_91262f99f0.jpg", | |||||
| "2006c0db-c059-438d-baf4-ee6b89095f22": "carbon_2_91262f99f0.jpg", | |||||
| "baf5b508-0b08-444d-9979-f3c84bbfa323": "linear_1_normal_08f8a394d3.jpg", | |||||
| "f2e0f3c4-6976-4bab-b521-acb49ed371d0": "linear_1_rough_2_780be85ab7.jpg", | |||||
| "478281ff-6f5c-4845-8bd2-2cdc74d831a3": "inclusions_grunge_5_6382461295.jpg", | |||||
| "99ab38c4-ef4a-4e2f-8066-28cb9e15dd2b": "pearl_skin_940cd78f7b.jpg", | |||||
| "26872679-2b36-41bd-9ab7-546943b48df6": "fingerprints_8sdrcs.jpg", | |||||
| "01633c96-f534-4470-a89d-7012af497bba": "fabric_2_4a5822dd63.jpg", | |||||
| "b10e891c-408c-4b07-b4ed-0d81e7172975": "fabric_classic_f644678645.jpg", | |||||
| "f653065c-b38b-4fdb-a70a-19f37593e192": "fabric_silk_a65df8c866.jpg", | |||||
| "759b063f-fda9-4be3-a73d-302f19a8b6c1": "fabric_velvet_blue_1_8e70c20c1c.jpg", | |||||
| "69fd174d-9657-478a-a796-2b7929b71466": "fabric_velvet_map_4447fa9490.jpg", | |||||
| "0185c97c-ed4c-43f1-ba6f-0dac8b568718": "fabric_velvet_blue_2_c536b8a8dd.jpg", | |||||
| "f643b12d-1ff5-4588-a584-33b757829914": "fabric_velvet_purple_165700018e.jpg", | |||||
| "f36d5ef5-2574-4c7d-a7a7-f67cd1e47268": "fabric_velvet_red_d3cf4ae949.jpg", | |||||
| "7e70a5df-99d5-4842-a4d6-9dcfc810d4e9": "fabric_velvet_turquoise_1b38c40747.jpg", | |||||
| "1f97d457-56df-4a9e-977d-ba62dd87ae12": "leather_1_4akmum.jpg", | |||||
| "a4478dfb-3291-4fea-8f05-aaf9342de389": "leather_6_roughness_2_fd858002a0.jpg", | |||||
| "a14f335a-9bc1-4df3-8b91-e44c5a7be712": "leather_6_roughness_1_4441597857.jpg", | |||||
| "89a8bde6-7124-4e03-b50f-0a1fd5ef17f7": "leather_wrinkled_map_3ffaa3483b.jpg", | |||||
| "782828bd-2ce1-4095-b0f4-9a500014f2c5": "leather_wrinkled_normal_5544ac7b45.jpg", | |||||
| "1ce4e51c-6764-4593-9465-c22550fbf31e": "leather_wrinkled_rough_4313bb9584.jpg", | |||||
| "98efb2c7-21c7-475e-acb4-29cfc317f473": "leather_snake_80de78cccf.jpg", | |||||
| "14bb0c2c-f697-46b7-b879-c947e327fb01": "leather_snake_rough_8a73f07b97.jpg", | |||||
| "9bacb937-8c33-47d2-a58c-42d6188ec008": "marble_6_5d40a6f169.jpg", | |||||
| "fe1d82db-60a7-4754-ae0b-89cf24462a89": "marble_8_c2eee3b170.jpg", | |||||
| "aea1bde0-a3b9-4a3a-bec2-ee854cc37019": "marble_5_a1249b3e91.jpg", | |||||
| "1a9b7a33-d79e-4018-880e-264fbb5ffd8a": "marble_7_168358ec01.jpg", | |||||
| "94a0f3a2-09bc-4d8c-8598-7d4d55b2f6ea": "material_1_444dde60f4.jpg", | |||||
| "0df25a88-19ff-40ed-8446-e7272d298b5c": "material_2_e598c42be2.jpg", | |||||
| "f53ac75c-ffa8-4361-802f-3bdd7f148f83": "material_3_dfa43db1a7.jpg", | |||||
| "a850158c-7548-49d8-93f0-491d848c2987": "material_4_efed0a8e21.jpg", | |||||
| "44f2c900-d90e-4627-a907-1bd2973df739": "cabochon_1_8ef8f2df48.jpg", | |||||
| "c911f4bd-6095-45c4-aa21-da8c02c6fe49": "cabochon_2_7d94b3cf15.jpg", | |||||
| "7bec0400-ed39-474a-b148-fe52c02c5b78": "paper_normal_d9e58544bd.jpg", | |||||
| "243d1ba6-a3af-453e-98bf-9e6233ec1145": "paper_1_5bcb9eaa44.jpg", | |||||
| "d7431eee-79bb-44f3-8025-dabde1f24c3e": "pearl_5_8b5524cb10.jpg", | |||||
| "343e7722-41f9-49bd-9bc2-ecf1b08aec14": "pearl_4_cc8f4325de.jpg", | |||||
| "3ba3b395-0402-4295-9acb-3cad0612543b": "pearl_11_copy_1_07e34078e0.jpg", | |||||
| "7da03783-bf40-4b33-9aff-905d5b70e743": "pearl_normal_4_e927980198.jpg", | |||||
| "58f2964b-19ce-4d30-84b1-5ed902ea85e8": "pearl_normal_3_36b32cdddf.jpg", | |||||
| "6277c9af-4562-49cf-a4a0-883201ef927c": "pearl_10a_be0f6bad82.jpg", | |||||
| "217174f0-b415-49b3-9146-e82b42f3b439": "pearl_normal_7_7e6009266c.jpg", | |||||
| "bde78d44-5594-4583-8169-00478183b204": "pearl_3_12b64dffce.jpg", | |||||
| "21a57d7b-414b-42f6-9b12-afb5ee284234": "pearl_normal_7_7e6009266c.jpg", | |||||
| "ede2515f-6f2f-451a-886e-a9af2c858123": "inclusions_grunge_5b_ca84ee3cbb.jpg", | |||||
| "c6f41124-1506-456a-9412-3d041a45d5e3": "pearl_normal_6_834fa48e5b.jpg", | |||||
| "4dffb495-6825-4f05-a2eb-5a2162e6b615": "pearl_10_1_ca6847ea21.jpg", | |||||
| "acf9b77b-ea78-43ea-b2c2-c8a872bc757b": "pearl_normal_3_36b32cdddf.jpg", | |||||
| "c89fea78-ee4d-4055-977a-bd4629a97a86": "pearl_2_e57f975911.jpg", | |||||
| "0133f2fa-d09f-4c70-97b7-4321546e547b": "pearl_1_947a15df6f.jpg", | |||||
| "0ef5329e-ac67-42af-be6b-ed8eaa842674": "pearl_normal_4_e927980198.jpg", | |||||
| "ad9a5a8f-b018-44de-bda7-25ee1a03f8bd": "pearl_9_193cbdf8ee.jpg", | |||||
| "0eb539af-222f-443f-b894-c7cc26b7d860": "pearl_10_1_ca6847ea21.jpg", | |||||
| "9b0c3c88-e7f5-410c-8655-cf27d34c6c41": "pearl_normal_3_36b32cdddf.jpg", | |||||
| "bd1ca871-20b3-4702-a14b-1b82aff55657": "gem_achat_1_42097449b5.jpg", | |||||
| "9b179358-a9b7-456b-bbc1-d7915d91a154": "gem_achat_2_82db1c3216.jpg", | |||||
| "a15cbba5-a774-4ace-9891-d7a7dd42e907": "gem_achat_3_e6e5a4b708.jpg", | |||||
| "8f2c59bf-41ff-4e51-a653-2e3d26bbd2ff": "gem_achat_4_1a4f69cc81.jpg", | |||||
| "44a21a79-9ad7-45f7-b3f5-e537ee3e4ab7": "gem_achat_5_e58c5cb472.jpg", | |||||
| "66913e49-c8a4-414d-ae1e-be332277e9ef": "gem_achat_6_05e489f186.jpg", | |||||
| "70b3cbe7-8f42-4066-906e-8ea9e591843d": "gem_achat_7_ed8bfc6d25.jpg", | |||||
| "4ca9c287-a7bd-4280-9fde-d5483db37f57": "gem_achat_8_b398ad7a44.jpg", | |||||
| "07db7042-e412-4770-a426-81057c5ab44b": "gem_achat_9_fc04347937.jpg", | |||||
| "4eef5243-5ad7-4546-9ece-bd2aa95330b9": "jade_1_c1grkc.jpg", | |||||
| "6c149111-7655-4a57-868c-6c658b771cf4": "jade_2_d1rgz.jpg", | |||||
| "708243d7-8aa8-42c9-8719-d99d393789c9": "jasper_red_39o7av.jpg", | |||||
| "e07a9cb1-ecab-41b4-90ad-418dfb80f847": "lapis_lazuli_2_2530d89c8c.jpg", | |||||
| "9c3499be-725f-4a77-a88f-697dc6f7bce9": "malachite_2_cfa6d28984.jpg", | |||||
| "ba1b8637-cf8f-4ace-88f5-b75dee253c64": "malachit_3_f225016b43.jpg", | |||||
| "5c41495d-ac84-4b76-bd8a-6b14653966d1": "malachite_1_2_7a8200b58e.jpg", | |||||
| "c1621611-4dab-4080-a388-d783503a2d2b": "quarz_rose_3896t.jpg", | |||||
| "3799ac4b-b37f-4e95-9ce0-f6f0aa3e3f30": "grunge_5_a5e81gl.jpg", | |||||
| "065efa69-27cf-4a8b-9819-b94e57c3a569": "turquoise_2_eef647d93b.jpg", | |||||
| "6ccdd8ab-955c-4f15-a6e2-78cdaa72768d": "ivory_b13ff0ffa8.jpg", | |||||
| "3577358d-9f7a-4214-ab3a-a9cf6a47686e": "horn_6c9a3bba89.jpg", | |||||
| "d323e33e-9de6-4b65-92d0-1072d6f01f7c": "wood_329bd7b8b5.jpg", | |||||
| "4d50b17e-6d38-40d2-a57e-74ff04d35eaf": "wood_bump_5b98b6225c.jpg", | |||||
| "bd46a03b-af90-49f6-b00f-0e75903f964b": "cork_map_d9a5c49531.jpg", | |||||
| "c900b5ad-6062-4d5e-85a5-dc30d4bae104": "wood_1_map_2e51911106.jpg", | |||||
| "e7396cf5-2169-4614-aa64-3394319b0818": "wood_1_normal_d203a4ce30.png", | |||||
| "5983bee3-b3a4-42d2-8d52-a25665d11536": "wood_1_rough_a883e8f72d.jpg", | |||||
| "91e8d4c8-45b0-4c7f-8511-fd35131588c3": "wood_2_map_cefdbd38db.jpg", | |||||
| "1c98ef9e-1f8c-4b22-97c4-a4d0040c28f0": "wood_2_normal_7bda20fd0a.jpg", | |||||
| "f7dd9881-012f-4443-9462-7a88191b9d47": "wood_2_rough_1df716de77.jpg", | |||||
| "25053bd3-c9f3-4406-8751-d756430bbaf2": "wood_ebony_93e5d75711.jpg", | |||||
| "6f24fcd2-6b5a-45c4-bd8b-0d88f5dd7bb7": "wood_ebony_bump_f955a9daff.jpg" | |||||
| } |
| # Texture 使用统计报告 | |||||
| 生成时间: 2025/7/21 09:29:49 | |||||
| ## 总体统计 | |||||
| - 总文件数: 81 | |||||
| - 总UUID数: 87 | |||||
| - 使用的字段数: 5 | |||||
| - 总使用次数: 305 | |||||
| ## 字段使用统计 | |||||
| | 字段名 | 使用次数 | 不同纹理数 | | |||||
| |--------|----------|------------| | |||||
| | map | 127 | undefined | | |||||
| | roughnessMap | 78 | undefined | | |||||
| | bumpMap | 68 | undefined | | |||||
| | normalMap | 31 | undefined | | |||||
| | metalnessMap | 1 | undefined | | |||||
| ## 最常用的纹理 UUID (前20个) | |||||
| | UUID | 文件名 | 使用次数 | 使用字段 | | |||||
| |------|--------|----------|----------| | |||||
| | 1f97d457-56df-4a9e-977d-ba62dd87ae12 | leather_1_4akmum.jpg | 33 | bumpMap, roughnessMap, metalnessMap | | |||||
| | a4478dfb-3291-4fea-8f05-aaf9342de389 | leather_6_roughness_2_fd858002a0.jpg | 20 | map, bumpMap | | |||||
| | 243d1ba6-a3af-453e-98bf-9e6233ec1145 | paper_1_5bcb9eaa44.jpg | 18 | map, bumpMap | | |||||
| | 69fd174d-9657-478a-a796-2b7929b71466 | fabric_velvet_map_4447fa9490.jpg | 15 | bumpMap, roughnessMap, map | | |||||
| | b10e891c-408c-4b07-b4ed-0d81e7172975 | fabric_classic_f644678645.jpg | 14 | map, bumpMap | | |||||
| | 14bb0c2c-f697-46b7-b879-c947e327fb01 | leather_snake_rough_8a73f07b97.jpg | 14 | bumpMap, roughnessMap | | |||||
| | 26872679-2b36-41bd-9ab7-546943b48df6 | fingerprints_8sdrcs.jpg | 12 | roughnessMap | | |||||
| | f653065c-b38b-4fdb-a70a-19f37593e192 | fabric_silk_a65df8c866.jpg | 12 | map, bumpMap | | |||||
| | ede2515f-6f2f-451a-886e-a9af2c858123 | inclusions_grunge_5b_ca84ee3cbb.jpg | 12 | roughnessMap | | |||||
| | a14f335a-9bc1-4df3-8b91-e44c5a7be712 | leather_6_roughness_1_4441597857.jpg | 10 | roughnessMap | | |||||
| | 01633c96-f534-4470-a89d-7012af497bba | fabric_2_4a5822dd63.jpg | 9 | map | | |||||
| | bde78d44-5594-4583-8169-00478183b204 | pearl_3_12b64dffce.jpg | 8 | map | | |||||
| | 98efb2c7-21c7-475e-acb4-29cfc317f473 | leather_snake_80de78cccf.jpg | 7 | map | | |||||
| | 3ba3b395-0402-4295-9acb-3cad0612543b | pearl_11_copy_1_07e34078e0.jpg | 5 | map | | |||||
| | acf9b77b-ea78-43ea-b2c2-c8a872bc757b | pearl_normal_3_36b32cdddf.jpg | 5 | normalMap | | |||||
| | 4d50b17e-6d38-40d2-a57e-74ff04d35eaf | wood_bump_5b98b6225c.jpg | 5 | roughnessMap, map | | |||||
| | 478281ff-6f5c-4845-8bd2-2cdc74d831a3 | inclusions_grunge_5_6382461295.jpg | 4 | map, bumpMap | | |||||
| | 21a57d7b-414b-42f6-9b12-afb5ee284234 | pearl_normal_7_7e6009266c.jpg | 4 | normalMap | | |||||
| | 2006c0db-c059-438d-baf4-ee6b89095f22 | carbon_2_91262f99f0.jpg | 3 | map, bumpMap, roughnessMap | | |||||
| | 58f2964b-19ce-4d30-84b1-5ed902ea85e8 | pearl_normal_3_36b32cdddf.jpg | 3 | normalMap | | |||||
| ## 最常用的文件 (前20个) | |||||
| | 文件名 | 使用次数 | UUID数量 | | |||||
| |--------|----------|----------| | |||||
| | leather_1_4akmum.jpg | 33 | 1 | | |||||
| | leather_6_roughness_2_fd858002a0.jpg | 20 | 1 | | |||||
| | paper_1_5bcb9eaa44.jpg | 18 | 1 | | |||||
| | fabric_velvet_map_4447fa9490.jpg | 15 | 1 | | |||||
| | fabric_classic_f644678645.jpg | 14 | 1 | | |||||
| | leather_snake_rough_8a73f07b97.jpg | 14 | 1 | | |||||
| | fingerprints_8sdrcs.jpg | 12 | 1 | | |||||
| | fabric_silk_a65df8c866.jpg | 12 | 1 | | |||||
| | inclusions_grunge_5b_ca84ee3cbb.jpg | 12 | 1 | | |||||
| | leather_6_roughness_1_4441597857.jpg | 10 | 1 | | |||||
| | fabric_2_4a5822dd63.jpg | 9 | 1 | | |||||
| | pearl_normal_3_36b32cdddf.jpg | 9 | 3 | | |||||
| | pearl_3_12b64dffce.jpg | 8 | 1 | | |||||
| | leather_snake_80de78cccf.jpg | 7 | 1 | | |||||
| | pearl_normal_7_7e6009266c.jpg | 6 | 2 | | |||||
| | carbon_2_91262f99f0.jpg | 5 | 2 | | |||||
| | pearl_11_copy_1_07e34078e0.jpg | 5 | 1 | | |||||
| | wood_bump_5b98b6225c.jpg | 5 | 1 | | |||||
| | inclusions_grunge_5_6382461295.jpg | 4 | 1 | | |||||
| | pearl_normal_4_e927980198.jpg | 4 | 2 | | |||||
| ## 详细字段分析 | |||||
| ### map | |||||
| - 使用次数: 127 | |||||
| - 不同纹理数: undefined | |||||
| 使用该字段的纹理 (前10个): | |||||
| - leather_6_roughness_2_fd858002a0.jpg (a4478dfb-3291-4fea-8f05-aaf9342de389): 10 次 | |||||
| - fabric_2_4a5822dd63.jpg (01633c96-f534-4470-a89d-7012af497bba): 9 次 | |||||
| - paper_1_5bcb9eaa44.jpg (243d1ba6-a3af-453e-98bf-9e6233ec1145): 9 次 | |||||
| - pearl_3_12b64dffce.jpg (bde78d44-5594-4583-8169-00478183b204): 8 次 | |||||
| - fabric_classic_f644678645.jpg (b10e891c-408c-4b07-b4ed-0d81e7172975): 7 次 | |||||
| - leather_snake_80de78cccf.jpg (98efb2c7-21c7-475e-acb4-29cfc317f473): 7 次 | |||||
| - fabric_silk_a65df8c866.jpg (f653065c-b38b-4fdb-a70a-19f37593e192): 6 次 | |||||
| - pearl_11_copy_1_07e34078e0.jpg (3ba3b395-0402-4295-9acb-3cad0612543b): 5 次 | |||||
| - wood_329bd7b8b5.jpg (d323e33e-9de6-4b65-92d0-1072d6f01f7c): 3 次 | |||||
| - wood_1_map_2e51911106.jpg (c900b5ad-6062-4d5e-85a5-dc30d4bae104): 3 次 | |||||
| ### roughnessMap | |||||
| - 使用次数: 78 | |||||
| - 不同纹理数: undefined | |||||
| 使用该字段的纹理 (前10个): | |||||
| - leather_1_4akmum.jpg (1f97d457-56df-4a9e-977d-ba62dd87ae12): 16 次 | |||||
| - fingerprints_8sdrcs.jpg (26872679-2b36-41bd-9ab7-546943b48df6): 12 次 | |||||
| - inclusions_grunge_5b_ca84ee3cbb.jpg (ede2515f-6f2f-451a-886e-a9af2c858123): 12 次 | |||||
| - leather_6_roughness_1_4441597857.jpg (a14f335a-9bc1-4df3-8b91-e44c5a7be712): 10 次 | |||||
| - fabric_velvet_map_4447fa9490.jpg (69fd174d-9657-478a-a796-2b7929b71466): 7 次 | |||||
| - leather_snake_rough_8a73f07b97.jpg (14bb0c2c-f697-46b7-b879-c947e327fb01): 7 次 | |||||
| - wood_bump_5b98b6225c.jpg (4d50b17e-6d38-40d2-a57e-74ff04d35eaf): 4 次 | |||||
| - wood_1_rough_a883e8f72d.jpg (5983bee3-b3a4-42d2-8d52-a25665d11536): 3 次 | |||||
| - wood_2_rough_1df716de77.jpg (f7dd9881-012f-4443-9462-7a88191b9d47): 3 次 | |||||
| - leather_wrinkled_rough_4313bb9584.jpg (1ce4e51c-6764-4593-9465-c22550fbf31e): 2 次 | |||||
| ### bumpMap | |||||
| - 使用次数: 68 | |||||
| - 不同纹理数: undefined | |||||
| 使用该字段的纹理 (前10个): | |||||
| - leather_1_4akmum.jpg (1f97d457-56df-4a9e-977d-ba62dd87ae12): 16 次 | |||||
| - leather_6_roughness_2_fd858002a0.jpg (a4478dfb-3291-4fea-8f05-aaf9342de389): 10 次 | |||||
| - paper_1_5bcb9eaa44.jpg (243d1ba6-a3af-453e-98bf-9e6233ec1145): 9 次 | |||||
| - fabric_classic_f644678645.jpg (b10e891c-408c-4b07-b4ed-0d81e7172975): 7 次 | |||||
| - fabric_velvet_map_4447fa9490.jpg (69fd174d-9657-478a-a796-2b7929b71466): 7 次 | |||||
| - leather_snake_rough_8a73f07b97.jpg (14bb0c2c-f697-46b7-b879-c947e327fb01): 7 次 | |||||
| - fabric_silk_a65df8c866.jpg (f653065c-b38b-4fdb-a70a-19f37593e192): 6 次 | |||||
| - inclusions_grunge_5_6382461295.jpg (478281ff-6f5c-4845-8bd2-2cdc74d831a3): 2 次 | |||||
| - carbon_2_91262f99f0.jpg (f6ca7063-ce33-40c6-b873-82791534a3b4): 1 次 | |||||
| - carbon_2_91262f99f0.jpg (2006c0db-c059-438d-baf4-ee6b89095f22): 1 次 | |||||
| ### normalMap | |||||
| - 使用次数: 31 | |||||
| - 不同纹理数: undefined | |||||
| 使用该字段的纹理 (前10个): | |||||
| - pearl_normal_3_36b32cdddf.jpg (acf9b77b-ea78-43ea-b2c2-c8a872bc757b): 5 次 | |||||
| - pearl_normal_7_7e6009266c.jpg (21a57d7b-414b-42f6-9b12-afb5ee284234): 4 次 | |||||
| - pearl_normal_3_36b32cdddf.jpg (58f2964b-19ce-4d30-84b1-5ed902ea85e8): 3 次 | |||||
| - wood_1_normal_d203a4ce30.png (e7396cf5-2169-4614-aa64-3394319b0818): 3 次 | |||||
| - wood_2_normal_7bda20fd0a.jpg (1c98ef9e-1f8c-4b22-97c4-a4d0040c28f0): 3 次 | |||||
| - leather_wrinkled_normal_5544ac7b45.jpg (782828bd-2ce1-4095-b0f4-9a500014f2c5): 2 次 | |||||
| - pearl_normal_4_e927980198.jpg (7da03783-bf40-4b33-9aff-905d5b70e743): 2 次 | |||||
| - pearl_normal_7_7e6009266c.jpg (217174f0-b415-49b3-9146-e82b42f3b439): 2 次 | |||||
| - pearl_normal_6_834fa48e5b.jpg (c6f41124-1506-456a-9412-3d041a45d5e3): 2 次 | |||||
| - pearl_normal_4_e927980198.jpg (0ef5329e-ac67-42af-be6b-ed8eaa842674): 2 次 | |||||
| ### metalnessMap | |||||
| - 使用次数: 1 | |||||
| - 不同纹理数: undefined | |||||
| 使用该字段的纹理 (前10个): | |||||
| - leather_1_4akmum.jpg (1f97d457-56df-4a9e-977d-ba62dd87ae12): 1 次 | |||||
| "rimraf": "^5.0.1", | "rimraf": "^5.0.1", | ||||
| "rollup-plugin-glsl": "^1.3.0", | "rollup-plugin-glsl": "^1.3.0", | ||||
| "rollup-plugin-license": "^3.0.1", | "rollup-plugin-license": "^3.0.1", | ||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.158.1004/package.tgz", | |||||
| "three": "file:./package.tgz", | |||||
| "tslib": "^2.5.0", | "tslib": "^2.5.0", | ||||
| "typedoc": "^0.28.4", | "typedoc": "^0.28.4", | ||||
| "typescript": "5.8.3", | "typescript": "5.8.3", | ||||
| "vitepress-plugin-nprogress": "^0.0.4" | "vitepress-plugin-nprogress": "^0.0.4" | ||||
| }, | }, | ||||
| "dependencies": { | "dependencies": { | ||||
| "@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.158.1004/package.tgz", | |||||
| "@types/three": "file:./type.package.tgz", | |||||
| "@types/webxr": "^0.5.1", | "@types/webxr": "^0.5.1", | ||||
| "@types/wicg-file-system-access": "^2020.9.5", | "@types/wicg-file-system-access": "^2020.9.5", | ||||
| "popmotion": "^11.0.5", | "popmotion": "^11.0.5", | ||||
| "uiconfig.js": "^0.1.5" | "uiconfig.js": "^0.1.5" | ||||
| }, | }, | ||||
| "peerDependencies": { | "peerDependencies": { | ||||
| "three": "https://github.com/repalash/three.js-modded/releases/download/v0.158.1004/package.tgz" | |||||
| "three": "file:./package.tgz" | |||||
| }, | }, | ||||
| "peerDependenciesMeta": { | "peerDependenciesMeta": { | ||||
| "three": { | "three": { |
| import tippy from 'tippy.js' | import tippy from 'tippy.js' | ||||
| import tippyStyles from 'tippy.js/dist/tippy.css?inline' | import tippyStyles from 'tippy.js/dist/tippy.css?inline' | ||||
| import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane' | ||||
| import { | |||||
| i18nMap, | |||||
| } from './cn.js' | |||||
| const i18n = (label) => { | |||||
| const zh = i18nMap[label] | |||||
| if (zh) { | |||||
| return `${zh}` | |||||
| } | |||||
| return label | |||||
| } | |||||
| export class TweakpaneEditorPlugin extends AViewerPluginSync { | export class TweakpaneEditorPlugin extends AViewerPluginSync { | ||||
| public static readonly PluginType: string = 'TweakpaneEditorPlugin' | public static readonly PluginType: string = 'TweakpaneEditorPlugin' | ||||
| this.modePlugins = this.modeKeys.map(key => plugins[key]) | this.modePlugins = this.modeKeys.map(key => plugins[key]) | ||||
| this.modeDivs = this.modeKeys.map((key, i) => { | this.modeDivs = this.modeKeys.map((key, i) => { | ||||
| const d = createDiv({ | const d = createDiv({ | ||||
| innerHTML: key, classList: ['mode-button', 'button-bar-button'], | |||||
| innerHTML: i18n(key), classList: ['mode-button', 'button-bar-button'], | |||||
| }) | }) | ||||
| d.onclick = () => this.setSelectedMode(i) | d.onclick = () => this.setSelectedMode(i) | ||||
| buttonsContainer.appendChild(d) | buttonsContainer.appendChild(d) |
| const i18nMap = { | |||||
| // 二级标题 | |||||
| 'Viewer': '查看器', | |||||
| 'Scene': '场景', | |||||
| 'Interaction': '交互', | |||||
| 'GBuffer': 'GBuffer', | |||||
| 'Post-processing': '后处理', | |||||
| 'Export': '导出', | |||||
| 'Configurator': '配置器', | |||||
| 'Animation': '动画', | |||||
| 'Extras': '扩展功能', | |||||
| 'Debug': '调试', | |||||
| } | |||||
| export { | |||||
| i18nMap, | |||||
| } |
| "devDependencies": { | "devDependencies": { | ||||
| "tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz", | "tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz", | ||||
| "uiconfig-tweakpane": "^0.0.10", | "uiconfig-tweakpane": "^0.0.10", | ||||
| "uiconfig.js": "^0.1.5" | |||||
| "uiconfig.js": "file:./../../../uiconfig/" | |||||
| }, | }, | ||||
| "dependencies": { | "dependencies": { | ||||
| "threepipe": "file:./../../src/" | "threepipe": "file:./../../src/" |
| lockfileVersion: '6.0' | |||||
| settings: | |||||
| autoInstallPeers: true | |||||
| excludeLinksFromLockfile: false | |||||
| dependencies: | |||||
| threepipe: | |||||
| specifier: file:./../../src/ | |||||
| version: file:../../src | |||||
| devDependencies: | |||||
| tweakpane-image-plugin: | |||||
| specifier: https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz | |||||
| version: '@github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz' | |||||
| uiconfig-tweakpane: | |||||
| specifier: ^0.0.10 | |||||
| version: 0.0.10 | |||||
| uiconfig.js: | |||||
| specifier: ^0.1.5 | |||||
| version: 0.1.6 | |||||
| packages: | |||||
| /@tweakpane/core@1.1.8: | |||||
| resolution: {integrity: sha512-psvBf6Cbm3YSZOTmDFWkcGzHYMnw7gVZM3jw+TfbzErIC+sMXPQb85h4ayW04w2u7AGg8jD0gHXSCg5wd+rafg==} | |||||
| dev: true | |||||
| /@tweenjs/tween.js@18.6.4: | |||||
| resolution: {integrity: sha512-lB9lMjuqjtuJrx7/kOkqQBtllspPIN+96OvTCeJ2j5FEzinoAXTdAMFnDAQT1KVPRlnYfBrqxtqP66vDM40xxQ==} | |||||
| dev: true | |||||
| /@types/stats.js@0.17.4: | |||||
| resolution: {integrity: sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==} | |||||
| dev: true | |||||
| /@types/three@0.152.1: | |||||
| resolution: {integrity: sha512-PMOCQnx9JRmq+2OUGTPoY9h1hTWD2L7/nmuW/SyNq1Vbq3Lwt3MNdl3wYSa4DvLTGv62NmIXD9jYdAOwohwJyw==} | |||||
| dependencies: | |||||
| '@tweenjs/tween.js': 18.6.4 | |||||
| '@types/stats.js': 0.17.4 | |||||
| '@types/webxr': 0.5.22 | |||||
| fflate: 0.6.10 | |||||
| lil-gui: 0.17.0 | |||||
| dev: true | |||||
| /@types/webxr@0.5.22: | |||||
| resolution: {integrity: sha512-Vr6Stjv5jPRqH690f5I5GLjVk8GSsoQSYJ2FVd/3jJF7KaqfwPi3ehfBS96mlQ2kPCwZaX6U0rG2+NGHBKkA/A==} | |||||
| dev: true | |||||
| /fflate@0.6.10: | |||||
| resolution: {integrity: sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==} | |||||
| dev: true | |||||
| /lil-gui@0.17.0: | |||||
| resolution: {integrity: sha512-MVBHmgY+uEbmJNApAaPbtvNh1RCAeMnKym82SBjtp5rODTYKWtM+MXHCifLe2H2Ti1HuBGBtK/5SyG4ShQ3pUQ==} | |||||
| dev: true | |||||
| /uiconfig-tweakpane@0.0.10: | |||||
| resolution: {integrity: sha512-VF67oUg7M9EXKR3IO+TXS6jP28qfT1ci/C4Inu8CjruJk8qBfUjuxKBU5kLXH97rE5dM0xLvLg/rYxRlpJ8mog==} | |||||
| dependencies: | |||||
| '@types/three': 0.152.1 | |||||
| uiconfig.js: 0.1.6 | |||||
| dev: true | |||||
| /uiconfig.js@0.1.6: | |||||
| resolution: {integrity: sha512-mKLsocK8EaI+DXJfRkfhppXrrSiushom2xoRSH4kibwkObj2ATqUiwKrW7paxm5LxN4HIE+NFlA0p5KQWbgWxQ==} | |||||
| dev: true | |||||
| '@github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz': | |||||
| resolution: {tarball: https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz} | |||||
| name: tweakpane-image-plugin | |||||
| version: 1.1.404 | |||||
| dependencies: | |||||
| '@tweakpane/core': 1.1.8 | |||||
| dev: true | |||||
| file:../../src: | |||||
| resolution: {directory: ../../src, type: directory} | |||||
| name: src | |||||
| dev: false |
| import replace from '@rollup/plugin-replace'; | import replace from '@rollup/plugin-replace'; | ||||
| import glsl from 'rollup-plugin-glsl'; | import glsl from 'rollup-plugin-glsl'; | ||||
| import path from 'node:path'; | import path from 'node:path'; | ||||
| import {fileURLToPath, URL} from 'node:url'; | |||||
| const isProd = process.env.NODE_ENV === 'production' | const isProd = process.env.NODE_ENV === 'production' | ||||
| const { name, version, author } = packageJson | const { name, version, author } = packageJson | ||||
| }, | }, | ||||
| }, | }, | ||||
| resolve: { | |||||
| alias: { | |||||
| 'uiconfig-tweakpane': fileURLToPath(new URL('../../../uiconfig-tweakpane/dist/index.mjs', import.meta.url)), | |||||
| }, | |||||
| }, | |||||
| plugins: [ | plugins: [ | ||||
| isProd ? dts({tsconfigPath: './tsconfig.json'}) : null, | isProd ? dts({tsconfigPath: './tsconfig.json'}) : null, | ||||
| replace({ | replace({ |
| (c as any)['__' + mType] = newMat | (c as any)['__' + mType] = newMat | ||||
| } | } | ||||
| } | } | ||||
| if (material?.CustomMaterialType) { | |||||
| c.CustomMaterialType = material?.CustomMaterialType | |||||
| } | |||||
| if (material?.CustomMaterialTypeConfig) { | |||||
| c.CustomMaterialTypeConfig = material?.CustomMaterialTypeConfig | |||||
| } | |||||
| // console.log(c) | |||||
| return applied | return applied | ||||
| } | } | ||||
| isLineMaterial2?: boolean | isLineMaterial2?: boolean | ||||
| isUnlitLineMaterial?: boolean | isUnlitLineMaterial?: boolean | ||||
| CustomMaterialTypeConfig?: any | |||||
| CustomMaterialType?:any | |||||
| // [key: string]: any | // [key: string]: any | ||||
| } | } | ||||
| import {ITexture} from '../ITexture' | import {ITexture} from '../ITexture' | ||||
| import {iMaterialUI} from './IMaterialUi' | import {iMaterialUI} from './IMaterialUi' | ||||
| // const ff1 = ` | |||||
| // #define STANDARD | |||||
| // #ifdef PHYSICAL | |||||
| // \t#define IOR | |||||
| // \t#define USE_SPECULAR | |||||
| // #endif | |||||
| // uniform vec3 diffuse; | |||||
| // uniform vec3 emissive; | |||||
| // uniform float roughness; | |||||
| // uniform float metalness; | |||||
| // uniform float opacity; | |||||
| // #ifdef IOR | |||||
| // \tuniform float ior; | |||||
| // #endif | |||||
| // #ifdef USE_SPECULAR | |||||
| // \tuniform float specularIntensity; | |||||
| // \tuniform vec3 specularColor; | |||||
| // \t#ifdef USE_SPECULAR_COLORMAP | |||||
| // \t\tuniform sampler2D specularColorMap; | |||||
| // \t#endif | |||||
| // \t#ifdef USE_SPECULAR_INTENSITYMAP | |||||
| // \t\tuniform sampler2D specularIntensityMap; | |||||
| // \t#endif | |||||
| // #endif | |||||
| // #ifdef USE_CLEARCOAT | |||||
| // \tuniform float clearcoat; | |||||
| // \tuniform float clearcoatRoughness; | |||||
| // #endif | |||||
| // #ifdef USE_IRIDESCENCE | |||||
| // \tuniform float iridescence; | |||||
| // \tuniform float iridescenceIOR; | |||||
| // \tuniform float iridescenceThicknessMinimum; | |||||
| // \tuniform float iridescenceThicknessMaximum; | |||||
| // #endif | |||||
| // #ifdef USE_SHEEN | |||||
| // \tuniform vec3 sheenColor; | |||||
| // \tuniform float sheenRoughness; | |||||
| // \t#ifdef USE_SHEEN_COLORMAP | |||||
| // \t\tuniform sampler2D sheenColorMap; | |||||
| // \t#endif | |||||
| // \t#ifdef USE_SHEEN_ROUGHNESSMAP | |||||
| // \t\tuniform sampler2D sheenRoughnessMap; | |||||
| // \t#endif | |||||
| // #endif | |||||
| // #ifdef USE_ANISOTROPY | |||||
| // \tuniform vec2 anisotropyVector; | |||||
| // \t#ifdef USE_ANISOTROPYMAP | |||||
| // \t\tuniform sampler2D anisotropyMap; | |||||
| // \t#endif | |||||
| // #endif | |||||
| // varying vec3 vViewPosition; | |||||
| // | |||||
| // struct TriplanarUV{vec2 x;vec2 y;vec2 z;};uniform float triplanarScale;uniform float triplanarBlend;uniform float triplanarOffset;vec3 getTriplanarWeights(in vec3 position,in vec3 normal){vec3 triW=abs(normal);triW=clamp(triW-vec3(triplanarOffset),vec3(0.),vec3(1.));triW=pow(triW,vec3(triplanarBlend));return triW/(triW.x+triW.y+triW.z);}TriplanarUV getTriplanarUV(in vec3 position,in vec3 normal){TriplanarUV triUV;triUV.x=position.zy*triplanarScale;triUV.y=position.xz*triplanarScale;triUV.z=position.xy*triplanarScale;if(normal.x<0.){triUV.x.x=-triUV.x.x;}if(normal.y<0.){triUV.y.x=-triUV.y.x;}if(normal.z>=0.){triUV.z.x=-triUV.z.x;}return triUV;}vec4 textureTriplanar(in sampler2D tex,in vec3 position,in vec3 normal){TriplanarUV triUV=getTriplanarUV(position,normal);vec4 texX=texture2D(tex,triUV.x);vec4 texY=texture2D(tex,triUV.y);vec4 texZ=texture2D(tex,triUV.z);vec3 triW=getTriplanarWeights(position,normal);return texX*triW.x+texY*triW.y+texZ*triW.z;} | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // varying vec3 vWorldPosition; | |||||
| // #endif | |||||
| // varying vec3 vWorldNormal; | |||||
| // #include <common> | |||||
| // #include <packing> | |||||
| // #include <dithering_pars_fragment> | |||||
| // #include <color_pars_fragment> | |||||
| // #include <uv_pars_fragment> | |||||
| // #include <map_pars_fragment> | |||||
| // #include <alphamap_pars_fragment> | |||||
| // #include <alphatest_pars_fragment> | |||||
| // #include <alphahash_pars_fragment> | |||||
| // #include <aomap_pars_fragment> | |||||
| // #include <lightmap_pars_fragment> | |||||
| // #include <emissivemap_pars_fragment> | |||||
| // #include <iridescence_fragment> | |||||
| // #include <cube_uv_reflection_fragment> | |||||
| // #include <envmap_common_pars_fragment> | |||||
| // #include <envmap_physical_pars_fragment> | |||||
| // #include <fog_pars_fragment> | |||||
| // #include <lights_pars_begin> | |||||
| // #include <normal_pars_fragment> | |||||
| // #include <lights_physical_pars_fragment> | |||||
| // #include <transmission_pars_fragment> | |||||
| // #include <shadowmap_pars_fragment> | |||||
| // #ifdef USE_BUMPMAP | |||||
| // \tuniform sampler2D bumpMap; | |||||
| // \tuniform float bumpScale; | |||||
| // \tvec2 dHdxy_fwd() { | |||||
| // \t\tvec3 dSTdx = dFdx( vWorldPosition ); | |||||
| // \t\tvec3 dSTdy = dFdy( vWorldPosition ); | |||||
| // vec3 normal_ = normalize(vWorldNormal); | |||||
| // float Hll = bumpScale * textureTriplanar( bumpMap, vWorldPosition, normal_ ).x; | |||||
| // float dBx = bumpScale * textureTriplanar( bumpMap, vWorldPosition + dSTdx, normal_ ).x - Hll; | |||||
| // float dBy = bumpScale * textureTriplanar( bumpMap, vWorldPosition + dSTdy, normal_ ).x - Hll; | |||||
| // \t\treturn vec2( dBx, dBy ); | |||||
| // \t} | |||||
| // \tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { | |||||
| // #ifdef BUMP_MAP_SCALE_LEGACY | |||||
| // | |||||
| // \t\tvec3 vSigmaX = ( dFdx( surf_pos.xyz ) ); | |||||
| // \t\tvec3 vSigmaY = ( dFdy( surf_pos.xyz ) ); | |||||
| // | |||||
| // #else | |||||
| // | |||||
| // \t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); | |||||
| // \t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); | |||||
| // | |||||
| // #endif | |||||
| // \t\tvec3 vN = surf_norm; | |||||
| // \t\tvec3 R1 = cross( vSigmaY, vN ); | |||||
| // \t\tvec3 R2 = cross( vN, vSigmaX ); | |||||
| // \t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection; | |||||
| // \t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); | |||||
| // \t\treturn normalize( abs( fDet ) * surf_norm - vGrad ); | |||||
| // \t} | |||||
| // #endif | |||||
| // #include <normalmap_pars_fragment> | |||||
| // #include <clearcoat_pars_fragment> | |||||
| // #include <iridescence_pars_fragment> | |||||
| // #include <roughnessmap_pars_fragment> | |||||
| // #include <metalnessmap_pars_fragment> | |||||
| // #include <logdepthbuf_pars_fragment> | |||||
| // #include <clipping_planes_pars_fragment> | |||||
| // | |||||
| // | |||||
| // uniform float ssrPower; | |||||
| // uniform float ssrIntensity; | |||||
| // uniform float ssrMaskFrontFactor; | |||||
| // uniform vec3 ssrBoost; | |||||
| // uniform sampler2D tSSRMap; | |||||
| // uniform sampler2D tLastFrame; | |||||
| // #define tSSRMapTexelToLinear( value ) ( value ) | |||||
| // #define tLastFrameTexelToLinear( value ) RGBM16ToLinear ( value ) | |||||
| // | |||||
| // #if 1 | |||||
| // // #if SSR_INLINE | |||||
| // #ifndef BASIC_HELPERS | |||||
| // #define BASIC_HELPERS | |||||
| // float saturate2(float v,float mx){return max(0.,min(mx,v));}vec3 saturate2(vec3 v){return max(vec3(0.),min(vec3(1.),v));} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // #define THREE_PACKING_INCLUDED | |||||
| // #ifndef BASIC_CAMERA_HELPERS | |||||
| // #define BASIC_CAMERA_HELPERS | |||||
| // uniform vec2 cameraNearFar;uniform vec3 cameraPositionWorld;uniform mat4 projection; | |||||
| // #ifndef THREE_PACKING_INCLUDED | |||||
| // #define THREE_PACKING_INCLUDED | |||||
| // #include <packing> | |||||
| // #endif | |||||
| // float linstep(float edge0,float edge1,float value){return clamp((value-edge0)/(edge1-edge0),0.,1.);}float depthToViewZ(const in float depth){return(depth>0.999)?-cameraNearFar.y*1000.:-mix(cameraNearFar.x,cameraNearFar.y,depth);}float viewZToDepth(const in float viewZ){return linstep(-cameraNearFar.x,-cameraNearFar.y,viewZ);}vec4 viewToScreen3(const in vec3 pos){vec4 projected=projection*vec4(pos,1.);projected.z=pos.z;projected.w=1./projected.w;projected.xyz*=projected.w;projected.xy=0.5+0.5*projected.xy;return projected;}vec3 screenToView(const in vec2 uv,const in float viewZ){vec2 uv_=2.*uv-1.;float xe=-(uv_.x+projection[2][0])*viewZ/projection[0][0];float ye=-(uv_.y+projection[2][1])*viewZ/projection[1][1];return vec3(xe,ye,viewZ);} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // #ifndef BASIC_RANDOM_HELPERS | |||||
| // #define BASIC_RANDOM_HELPERS | |||||
| // uniform float frameCount;float random(float n){return fract(sin(n)*43758.5453123);}float random2(vec2 n,float x){n+=x;return fract(sin(dot(n.xy,vec2(12.9898,78.233)))*43758.5453);}float random3(vec3 v){v=fract(v*443.8975);v+=dot(v,v.yzx+19.19);return fract((v.x+v.y)*v.z);}float interleavedGradientNoise(const in vec2 fragCoord,const in float seed){vec3 magic=vec3(0.06711056,0.00583715,52.9829189);return fract(magic.z*fract(dot(fragCoord.xy+seed*vec2(2.083,4.867),magic.xy)));}vec3 hash3(vec2 p){vec3 q=vec3(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)),dot(p,vec2(419.2,371.9)));return fract(sin(q)*43758.5453);} | |||||
| // #endif | |||||
| // | |||||
| // #define PI 3.141592653589793 | |||||
| // mat3 GetTangentBasis(vec3 TangentZ){vec3 up=vec3(0.,0.,1.);vec3 TangentX=normalize(cross(dot(TangentZ,up)<0.8?up:vec3(1.,0.,0.),TangentZ));vec3 TangentY=cross(TangentZ,TangentX);return mat3(TangentX,TangentY,TangentZ);}vec4 CosineSampleHemisphere(vec2 E){float Phi=2.*PI*E.x;float CosTheta=sqrt(E.y);float SinTheta=sqrt(1.-CosTheta*CosTheta);vec3 H;H.x=SinTheta*cos(Phi);H.y=SinTheta*sin(Phi);H.z=CosTheta;float PDF=CosTheta*(1./PI);return vec4(H,PDF);}vec4 UniformSampleHemisphere(vec2 E){float Phi=2.*PI*E.x;float CosTheta=E.y;float SinTheta=sqrt(1.-CosTheta*CosTheta);vec3 H;H.x=SinTheta*cos(Phi);H.y=SinTheta*sin(Phi);H.z=CosTheta;float PDF=1./(2.*PI);return vec4(H,PDF);}vec2 UniformSampleDiskConcentric(vec2 E){vec2 p=2.*E-1.;float Radius;float Phi;if(abs(p.x)>abs(p.y)){Radius=p.x;Phi=(PI/4.)*(p.y/p.x);}else{Radius=p.y;Phi=(PI/2.)-(PI/4.)*(p.x/p.y);}return vec2(Radius*cos(Phi),Radius*sin(Phi));}vec2 UniformSampleDiskConcentricApprox(vec2 E){vec2 sf=E*sqrt(2.)-sqrt(0.5);vec2 sq=sf*sf;float root=sqrt(2.*max(sq.x,sq.y)-min(sq.x,sq.y));if(sq.x>sq.y){sf.x=sf.x>0.?root:-root;}else{sf.y=sf.y>0.?root:-root;}return sf;} | |||||
| // #ifndef UNPACK_GBUFFER_SNIPPET | |||||
| // #define UNPACK_GBUFFER_SNIPPET | |||||
| // uniform sampler2D tNormalDepth;float unpack16(vec2 value){return value.x+value.y/255.;}vec3 unpackNormal(vec2 enc){vec2 fenc=enc*4.-2.;float f=dot(fenc,fenc);float g=sqrt(1.-f/4.);return vec3(fenc*g,1.-f/2.);}float unpackDepth(vec2 uncodedDepth){float x=unpack16(uncodedDepth.xy);return x*x;}float getDepth(vec2 uv){vec4 uncodedDepth=texture2D(tNormalDepth,uv);return unpackDepth(uncodedDepth.xy);}void getDepthNormal(const in vec2 uv,out float depth,out vec3 normal){vec4 uncodedDepth=texture2D(tNormalDepth,uv);depth=unpackDepth(uncodedDepth.xy);normal=unpackNormal(uncodedDepth.zw);}vec3 getViewNormal(const in vec2 uv){return unpackNormal(texture2D(tNormalDepth,uv).zw);} | |||||
| // #if defined(GBUFFER_HAS_FLAGS) && GBUFFER_HAS_FLAGS == 1 | |||||
| // uniform sampler2D tGBufferFlags; | |||||
| // #endif | |||||
| // ivec4 getGBufferFlags(const in vec2 uv){ | |||||
| // #if defined(GBUFFER_HAS_FLAGS) && GBUFFER_HAS_FLAGS == 1 | |||||
| // return ivec4(texture2D(tGBufferFlags,uv)*255.); | |||||
| // #else | |||||
| // return ivec4(1); | |||||
| // #endif | |||||
| // } | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // #ifndef SSRT_PARS_SNIP | |||||
| // #define SSRT_PARS_SNIP | |||||
| // #define pow2(a)a*a | |||||
| // float getDepth2(const in vec2 uv,const in float lod){float viewDepth=getDepth(uv);return depthToViewZ(viewDepth);} | |||||
| // #define LOD_DEPTH 1.0 | |||||
| // #define LOD_COLOR 5.0 | |||||
| // void _traceRay(in vec4 ray_origin,in vec4 ray_dir,in float tolerance,inout vec3 state,in int loopMax,in float iStepCount){vec4 sample_uv;float d,hit;float dLod=0.; | |||||
| // #pragma unroll_loop_start | |||||
| // for(int i=0;i<8;i++){if(UNROLLED_LOOP_INDEX<loopMax){sample_uv=ray_origin+ray_dir*state.y;d=getDepth2(sample_uv.xy,dLod);d=sample_uv.z/sample_uv.w-d;if(abs(d+tolerance)<tolerance){hit=clamp(state.x/(state.x-d),0.,1.)-1.;hit=(state.y+hit*iStepCount);state.z=min(state.z,hit);}state.x=d;state.y+=1.*iStepCount;}} | |||||
| // #pragma unroll_loop_end | |||||
| // }vec3 traceRay(in vec3 ray_origin_view,in vec3 ray_dir_view,in float tolerance,inout vec3 state,in int _STEP_COUNT){vec4 sample_uv;vec4 ray_origin=viewToScreen3(ray_origin_view);vec3 ray_end_view=ray_origin_view+ray_dir_view;vec4 ray_dir=viewToScreen3(ray_end_view);vec2 clamp_end=clamp(ray_dir.xy,vec2(0.),vec2(1.));vec2 correction=abs(ray_dir.xy-clamp_end);correction=(step(0.01,correction)*correction/(abs(clamp_end-ray_origin.xy)+0.01))+1.;correction.x=1./min(max(correction.y,correction.x),10.);ray_dir=ray_dir-ray_origin;ray_dir.xyw*=correction.x;float iStepCount=1./float(_STEP_COUNT);tolerance*=0.125;_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT,iStepCount);if(_STEP_COUNT>8&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-8,iStepCount);if(_STEP_COUNT>15&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-16,iStepCount);if(_STEP_COUNT>23&&state.z>0.98)_traceRay(ray_origin,ray_dir,tolerance,state,_STEP_COUNT-16,iStepCount);sample_uv=ray_origin+ray_dir*state.z;sample_uv.z/=sample_uv.w;state.z=state.z<0.999?state.z:9999999.;return sample_uv.xyz;} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // uniform float objectRadius;uniform float radius;uniform float tolerance;uniform bool autoRadius; | |||||
| // #ifndef D_sceneBoundingRadius | |||||
| // #define D_sceneBoundingRadius | |||||
| // uniform float sceneBoundingRadius; | |||||
| // #endif | |||||
| // vec3 ComputeReflectionL(vec3 N,vec2 E,vec3 V,float rough){float rough4=rough*rough*rough*rough;float phi=2.*PI*E.x;float cos_theta=pow(max(E.y,0.000001),rough4/(2.-rough4));float sin_theta=sqrt(max(0.,1.-cos_theta*cos_theta));vec3 half_vec=vec3(sin_theta*cos(phi),sin_theta*sin(phi),cos_theta);vec3 tangentX=normalize(cross(abs(N.z)<0.999?vec3(0.,0.,1.):vec3(1.,0.,0.),N));vec3 tangentY=cross(N,tangentX);half_vec=half_vec.x*tangentX+half_vec.y*tangentY+half_vec.z*N;vec3 ray_dir=(2.*dot(V,half_vec))*half_vec-V;return ray_dir;}vec2 GetRandomE(float seed){vec2 rand_e;rand_e.x=interleavedGradientNoise(gl_FragCoord.xy,frameCount*117.);rand_e.y=fract(rand_e.x*38.65435);rand_e.y=mix(rand_e.y,1.,0.7);return rand_e;}vec4 calculateSSR(in float seed,in vec3 screenPos,in vec3 normal,in float radiusFactor,in float roughness){vec3 viewPos=screenToView(screenPos.xy,screenPos.z);normal=normalize(normal);vec2 E=GetRandomE(seed);vec3 L=ComputeReflectionL(normal,E,-normalize(viewPos),roughness);L=normalize(L);float cameraDist=length(cameraPositionWorld);float rayLen=objectRadius*sceneBoundingRadius;rayLen=autoRadius?min(max(mix(max(0.,(cameraDist+rayLen)+viewPos.z),max(0.,-viewPos.z-max(0.,cameraDist-rayLen)),L.z*0.5+0.5),rayLen*0.1),rayLen*5.):rayLen;rayLen*=radiusFactor;float r=interleavedGradientNoise(gl_FragCoord.xy,frameCount+seed);rayLen=max(rayLen,0.001);int steps=SSR_STEP_COUNT/(frameCount<float(SSR_LOW_QUALITY_FRAMES)?2:1);vec3 state=vec3(0.,(r+0.5)/float(steps),2.);viewPos+=normal*max(-0.0001*viewPos.z,0.001);vec3 screenHitP=traceRay(viewPos,L*rayLen,tolerance*rayLen,state,steps);if(state.z<0.9999){vec3 hitColor=(tLastFrameTexelToLinear(texture2D(tLastFrame,screenHitP.xy))).rgb;float ssrWeight=1.;return vec4(hitColor*ssrWeight,1.);}return vec4(0.);} | |||||
| // // #endif // SSR_INLINE | |||||
| // #endif | |||||
| // | |||||
| // #ifndef SIMPLE_CAMERA_HELPERS | |||||
| // #define SIMPLE_CAMERA_HELPERS | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // uniform mat4 projectionMatrix; | |||||
| // #endif | |||||
| // vec3 viewToScreen(const in vec3 pos){vec4 projected=projectionMatrix*vec4(pos,1.);return vec3(0.5+0.5*projected.xy/projected.w,projected.w);} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // | |||||
| // | |||||
| // uniform sampler2D tSSAOMap; | |||||
| // #define tSSAOMapTexelToLinear( value ) ( value ) | |||||
| // | |||||
| // #ifndef SIMPLE_CAMERA_HELPERS | |||||
| // #define SIMPLE_CAMERA_HELPERS | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // uniform mat4 projectionMatrix; | |||||
| // #endif | |||||
| // vec3 viewToScreen(const in vec3 pos){vec4 projected=projectionMatrix*vec4(pos,1.);return vec3(0.5+0.5*projected.xy/projected.w,projected.w);} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // | |||||
| // | |||||
| // | |||||
| // | |||||
| // | |||||
| // uniform float ssaoPower; | |||||
| // uniform float ssgiIntensity; | |||||
| // uniform sampler2D tSSGIMap; | |||||
| // #define tSSGIMapTexelToLinear( value ) ( value ) | |||||
| // | |||||
| // | |||||
| // #ifndef SIMPLE_CAMERA_HELPERS | |||||
| // #define SIMPLE_CAMERA_HELPERS | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // uniform mat4 projectionMatrix; | |||||
| // #endif | |||||
| // vec3 viewToScreen(const in vec3 pos){vec4 projected=projectionMatrix*vec4(pos,1.);return vec3(0.5+0.5*projected.xy/projected.w,projected.w);} | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // | |||||
| // void main() { | |||||
| // \t// mainStart | |||||
| // #include <clipping_planes_fragment> | |||||
| // \tvec4 diffuseColor = vec4( diffuse, opacity ); | |||||
| // \tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); | |||||
| // \tvec3 totalEmissiveRadiance = emissive; | |||||
| // \t#include <logdepthbuf_fragment> | |||||
| // \t#ifdef USE_MAP | |||||
| // \tvec4 sampledDiffuseColor = textureTriplanar( map, vWorldPosition, normalize(vWorldNormal) ); | |||||
| // \t#ifdef DECODE_VIDEO_TEXTURE | |||||
| // \t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); | |||||
| // | |||||
| // \t#endif | |||||
| // \tdiffuseColor *= sampledDiffuseColor; | |||||
| // #endif | |||||
| // \t#include <color_fragment> | |||||
| // \t#include <alphamap_fragment> | |||||
| // \t#include <alphatest_fragment> | |||||
| // \t#include <alphahash_fragment> | |||||
| // \tfloat roughnessFactor = roughness; | |||||
| // #ifdef USE_ROUGHNESSMAP | |||||
| // \tvec4 texelRoughness = textureTriplanar( roughnessMap, vWorldPosition, normalize(vWorldNormal)); | |||||
| // \troughnessFactor *= texelRoughness.g; | |||||
| // #endif | |||||
| // \tfloat metalnessFactor = metalness; | |||||
| // #ifdef USE_METALNESSMAP | |||||
| // \tvec4 texelMetalness = textureTriplanar( metalnessMap, vWorldPosition, normalize(vWorldNormal)); | |||||
| // \tmetalnessFactor *= texelMetalness.b; | |||||
| // #endif | |||||
| // \t#include <normal_fragment_begin> | |||||
| // \t#ifdef USE_NORMALMAP_OBJECTSPACE | |||||
| // \tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; | |||||
| // \t#ifdef FLIP_SIDED | |||||
| // \t\tnormal = - normal; | |||||
| // \t#endif | |||||
| // \t#ifdef DOUBLE_SIDED | |||||
| // \t\tnormal = normal * faceDirection; | |||||
| // \t#endif | |||||
| // \tnormal = normalize( normalMatrix * normal ); | |||||
| // #elif defined( USE_NORMALMAP_TANGENTSPACE ) | |||||
| // \tvec3 mapN = textureTriplanar( normalMap, vWorldPosition, normalize(vWorldNormal) ).xyz * 2.0 - 1.0; | |||||
| // \tmapN.xy *= normalScale; | |||||
| // \tnormal = normalize( tbn * mapN ); | |||||
| // #elif defined( USE_BUMPMAP ) | |||||
| // \tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); | |||||
| // #endif | |||||
| // \t#include <clearcoat_normal_fragment_begin> | |||||
| // \t#include <clearcoat_normal_fragment_maps> | |||||
| // \t#include <emissivemap_fragment> | |||||
| // \t// beforeAccumulation | |||||
| // #include <lights_physical_fragment> | |||||
| // \t#include <lights_fragment_begin> | |||||
| // \t#include <lights_fragment_maps> | |||||
| // \t#include <lights_fragment_end> | |||||
| // | |||||
| // | |||||
| // | |||||
| // #if defined(SSR_ENABLED) && SSR_ENABLED > 0 | |||||
| // vec3 screenPos=viewToScreen(geometryPosition);vec4 ssrColor=vec4(0,0,0,0);float alphaModifier=1.-clamp(material.roughness*.3,0.,1.);alphaModifier*=ssrIntensity; | |||||
| // #if defined(SSR_MASK_FRONT_RAYS) && SSR_MASK_FRONT_RAYS > 0 | |||||
| // alphaModifier*=clamp(-4.*dot(geometryViewDir,normal)+(4.+ssrMaskFrontFactor),0.,1.); | |||||
| // #endif | |||||
| // #ifdef USE_TRANSMISSION | |||||
| // alphaModifier*=1.-transmission; | |||||
| // #endif | |||||
| // float vignette=1.;if(true){float fadeStrength=0.1;float dist=max(0.,min(min(1.-screenPos.x,1.-screenPos.y),min(screenPos.x,screenPos.y)));float fade=dist*dist/(fadeStrength+0.001);fade=clamp(fade,0.,1.);fade=pow(fade,0.3);vignette=fade;}alphaModifier*=vignette;vec3 specularColor=EnvironmentBRDF(geometryNormal,geometryViewDir,material.specularColor.rgb,material.specularF90,material.roughness);if(length(specularColor.rgb)*alphaModifier>0.01&&roughnessFactor<0.9){ | |||||
| // #if defined(SSR_INLINE) && SSR_INLINE > 0 | |||||
| // ssrColor=calculateSSR(8.,vec3(screenPos.xy,geometryPosition.z),geometryNormal,1.,material.roughness); | |||||
| // #else | |||||
| // ssrColor=tSSRMapTexelToLinear(texture2D(tSSRMap,screenPos.xy)); | |||||
| // #endif | |||||
| // }ssrColor.rgb*=ssrBoost;ssrColor.a*=alphaModifier;ssrColor.a=min(ssrColor.a,1.); | |||||
| // #if defined(SSR_NON_PHYSICAL) && SSR_NON_PHYSICAL > 0 | |||||
| // diffuseColor.a=max(ssrColor.a,diffuseColor.a*diffuseColor.a);reflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,saturate(diffuseColor.rgb*ssrColor.rgb),1.);reflectedLight.indirectDiffuse=diffuseColor.rgb*(1.-ssrColor.a);reflectedLight.directDiffuse=vec3(0.);reflectedLight.directSpecular=vec3(0.); | |||||
| // #else | |||||
| // reflectedLight.indirectSpecular=mix(reflectedLight.indirectSpecular,saturate(specularColor.rgb*ssrColor.rgb),ssrColor.a); | |||||
| // #endif | |||||
| // #endif | |||||
| // | |||||
| // | |||||
| // // reflectedLight.directDiffuse = vec3(0.); | |||||
| // // reflectedLight.indirectDiffuse = vec3(0.); | |||||
| // // reflectedLight.directSpecular = vec3(0.); | |||||
| // // reflectedLight.indirectSpecular = vec3(0.); | |||||
| // | |||||
| // | |||||
| // // beforeModulation | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // #if defined(SSAO_ENABLED) && SSAO_ENABLED > 0 | |||||
| // float ambientOcclusion=tSSAOMapTexelToLinear(texture2D(tSSAOMap,viewToScreen(vViewPosition.xyz).xy)).r;reflectedLight.indirectDiffuse*=ambientOcclusion; | |||||
| // #if defined( USE_ENVMAP ) | |||||
| // float dotNV=saturate(dot(geometryNormal,geometryViewDir));reflectedLight.indirectSpecular*=computeSpecularOcclusion(dotNV,ambientOcclusion,material.roughness); | |||||
| // #endif | |||||
| // #else | |||||
| // #include <aomap_fragment> | |||||
| // #endif | |||||
| // #endif | |||||
| // | |||||
| // \t// afterModulation | |||||
| // vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; | |||||
| // \tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; | |||||
| // \t#include <transmission_fragment> | |||||
| // \tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; | |||||
| // \t#ifdef USE_SHEEN | |||||
| // \t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); | |||||
| // \t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; | |||||
| // \t#endif | |||||
| // \t#ifdef USE_CLEARCOAT | |||||
| // \t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); | |||||
| // \t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); | |||||
| // \t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; | |||||
| // \t#endif | |||||
| // \t#include <opaque_fragment> | |||||
| // \t#include <tonemapping_fragment> | |||||
| // \t#include <colorspace_fragment> | |||||
| // \t#include <fog_fragment> | |||||
| // \t#include <premultiplied_alpha_fragment> | |||||
| // \t#include <dithering_fragment> | |||||
| // }` | |||||
| // | |||||
| // const fv2 = ` | |||||
| // #define STANDARD | |||||
| // varying vec3 vViewPosition; | |||||
| // #ifdef USE_TRANSMISSION | |||||
| // \tvarying vec3 vWorldPosition; | |||||
| // #endif | |||||
| // | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // varying vec3 vWorldPosition; | |||||
| // #endif | |||||
| // varying vec3 vWorldNormal; | |||||
| // #include <common> | |||||
| // #include <uv_pars_vertex> | |||||
| // #include <displacementmap_pars_vertex> | |||||
| // #include <color_pars_vertex> | |||||
| // #include <fog_pars_vertex> | |||||
| // #include <normal_pars_vertex> | |||||
| // #include <morphtarget_pars_vertex> | |||||
| // #include <skinning_pars_vertex> | |||||
| // #include <shadowmap_pars_vertex> | |||||
| // #include <logdepthbuf_pars_vertex> | |||||
| // #include <clipping_planes_pars_vertex> | |||||
| // void main() { | |||||
| // \t// mainStart | |||||
| // #include <uv_vertex> | |||||
| // \t#include <color_vertex> | |||||
| // \t#include <morphcolor_vertex> | |||||
| // \t#include <beginnormal_vertex> | |||||
| // \t#include <morphnormal_vertex> | |||||
| // \t#include <skinbase_vertex> | |||||
| // \t#include <skinnormal_vertex> | |||||
| // \t#include <defaultnormal_vertex> | |||||
| // \t#include <normal_vertex> | |||||
| // \t#include <begin_vertex> | |||||
| // \t#include <morphtarget_vertex> | |||||
| // \t#include <skinning_vertex> | |||||
| // \t#include <displacementmap_vertex> | |||||
| // \t#include <project_vertex> | |||||
| // \t#include <logdepthbuf_vertex> | |||||
| // \t#include <clipping_planes_vertex> | |||||
| // \tvViewPosition = - mvPosition.xyz; | |||||
| // \t#include <worldpos_vertex> | |||||
| // // same as worldpos_vertex.glsl.js but added a ! | |||||
| // #if !(defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0) | |||||
| // vec4 worldPosition = vec4( transformed, 1.0 ); | |||||
| // #ifdef USE_INSTANCING | |||||
| // worldPosition = instanceMatrix * worldPosition; | |||||
| // #endif | |||||
| // worldPosition = modelMatrix * worldPosition; | |||||
| // #endif | |||||
| // | |||||
| // #ifndef USE_TRANSMISSION | |||||
| // vWorldPosition = worldPosition.xyz; | |||||
| // #endif | |||||
| // vWorldNormal = normalize((modelMatrix * vec4(objectNormal, 0.)).xyz); | |||||
| // | |||||
| // \t#include <shadowmap_vertex> | |||||
| // \t#include <fog_vertex> | |||||
| // #ifdef USE_TRANSMISSION | |||||
| // \tvWorldPosition = worldPosition.xyz; | |||||
| // #endif | |||||
| // }` | |||||
| /** | /** | ||||
| * And extension of three.js MeshPhysicalMaterial that can be assigned to objects, and support threepipe features, uiconfig, and serialization. | * And extension of three.js MeshPhysicalMaterial that can be assigned to objects, and support threepipe features, uiconfig, and serialization. | ||||
| * | * | ||||
| shader.defines && (shader.defines.INVERSE_ALPHAMAP = this.userData.inverseAlphaMap ? 1 : 0) | shader.defines && (shader.defines.INVERSE_ALPHAMAP = this.userData.inverseAlphaMap ? 1 : 0) | ||||
| // Object.assign(shader.defines, { | |||||
| // 'STANDARD': '', | |||||
| // 'PHYSICAL': '', | |||||
| // 'FIX_ENV_DIRECTION': '1', | |||||
| // 'SSR_ENABLED': 1, | |||||
| // 'SSAO_ENABLED': 1, | |||||
| // 'SSCS_ENABLED': 0, | |||||
| // 'SSCS_STEP_COUNT': 2, | |||||
| // 'SSCS_DEBUG': 0, | |||||
| // 'SSRTAO_ENABLED': 0, | |||||
| // 'INVERSE_ALPHAMAP': 0, | |||||
| // 'SSR_STEP_COUNT': 16, | |||||
| // 'SSR_LOW_QUALITY_FRAMES': 0, | |||||
| // 'PERSPECTIVE_CAMERA': '1', | |||||
| // 'SSR_INLINE': '1', | |||||
| // 'SSR_MASK_FRONT_RAYS': 1, | |||||
| // 'SSR_NON_PHYSICAL': '0', | |||||
| // 'USE_UV': '', | |||||
| // 'ORTHOGRAPHIC_CAMERA': '0', | |||||
| // }) | |||||
| // console.log('shader', shader) | |||||
| // shader.fragmentShader = ff1 | |||||
| // shader.vertexShader = fv2 | |||||
| super.onBeforeCompile(shader, renderer) | super.onBeforeCompile(shader, renderer) | ||||
| } | } | ||||
| export default defineConfig({ | export default defineConfig({ | ||||
| optimizeDeps: { | optimizeDeps: { | ||||
| exclude: ['uiconfig.js', 'ts-browser-helpers'], | |||||
| exclude: [ | |||||
| 'uiconfig.js', | |||||
| 'ts-browser-helpers', | |||||
| ], | |||||
| }, | }, | ||||
| // define: { | // define: { | ||||
| // 'process.env': process.env | // 'process.env': process.env | ||||
| exclude: [/uiconfig.js/, /ts-browser-helpers/], | exclude: [/uiconfig.js/, /ts-browser-helpers/], | ||||
| }, | }, | ||||
| rollupOptions: { | rollupOptions: { | ||||
| external: [ | |||||
| 'three', | |||||
| /^three\/addons\//, | |||||
| /^three\/examples\//, | |||||
| ], | |||||
| output: { | output: { | ||||
| // inlineDynamicImports: false, | // inlineDynamicImports: false, | ||||
| }, | }, |