@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
3 lines (2 loc) • 2.11 kB
JavaScript
function e(e){const{_hasUvTransform:r,_hasVertexColor:o,_hasUv2:t,_hasAnyNormal:a,_hasEmissiveTexture:s,_hasSpecGloss:l}=e,u=t?e._uv2Mask:0,n=e=>u&e?"input.uv2":"input.uv",m=!!(32&u),c=!!((e._features2??0)&1<<28),p=e=>[{_name:`${e}UVm`,_type:"vec4<f32>"},{_name:`${e}UVt`,_type:"vec4<f32>"}],i=(e,o)=>r?`${e}UV`:n(o),v=(e,o)=>r?`let ${e}UV = txfUV(${n(o)}, material.${e}UVm, material.${e}UVt.xy);\n`:"",_=r?"fn txfUV(uv: vec2<f32>, m: vec4<f32>, t: vec2<f32>) -> vec2<f32> {\nreturn vec2<f32>(dot(m.xy, uv), dot(m.zw, uv)) + t;\n}\n":"",x=[];t&&x.push({_name:"uv2",_type:"vec2<f32>",_gpuFormat:"float32x2",_arrayStride:8}),o&&x.push({_name:"color",_type:"vec4<f32>",_gpuFormat:"float32x4",_arrayStride:16});const f=[];t&&f.push({_name:"uv2",_type:"vec2<f32>"}),o&&f.push({_name:"vColor",_type:"vec4<f32>"});const y=[];r&&(y.push(...p("baseColor")),a&&y.push(...p("normal")),y.push(...p("orm")),c&&y.push(...p("occl")),s&&y.push(...p("emissive")),l&&y.push(...p("specGloss")));const h=[];m&&h.push({_name:"occlusionTexture",_type:{_kind:"texture",_textureType:"texture_2d<f32>"},_visibility:2},{_name:"occlusionSampler_",_type:{_kind:"sampler",_samplerType:"sampler"},_visibility:2});let d="";t&&(d+="out.uv2 = uv2;\n"),o&&(d+="out.vColor = color;\n");return{extraVertexAttributes:x,extraVaryings:f,extraMaterialUboFields:y,extraBindings:h,vertexBodyExtra:d,fragmentHelpers:_,fragmentPrelude:r?v("baseColor",1)+(a?v("normal",4):"")+v("orm",2)+(c?v("occl",0):"")+(s?v("emissive",8):"")+(l?v("specGloss",16):""):"",uvForBaseColor:i("baseColor",1),uvForNormal:i("normal",4),uvForOrm:i("orm",2),uvForEmissive:i("emissive",8),uvForSpecGloss:i("specGloss",16),baseColorMod:o?"\nbaseColor *= input.vColor.rgb;\nalpha *= input.vColor.a;":"",normalScaleMod:"let scaledNormal = vec3<f32>(normalMapRaw.xy * material.normalScale, normalMapRaw.z);\n",occlusionOverride:m?"let occlusion = textureSample(occlusionTexture, occlusionSampler_, input.uv2).r;":c?"let occlusion = textureSample(ormTexture, ormSampler, occlUV).r;":null}}export{e as createPbrTemplateExt};
//# sourceMappingURL=pbr-template-ext-DPcV-en5.esm.min.js.map