@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) • 1.97 kB
JavaScript
import{f as e,B as r,F as a,j as n,U as o,k as s}from"./index-B8IgtevW.esm.min.js";import{c as t}from"./cubemap-skybox-material-JpKAlKzF.esm.min.js";import{s as i}from"./skybox.vertex-Ban7q6IM-DcsSq_1-.esm.min.js";const c="struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}";async function f(m,p,u,d,l){const v=m.surface.engine,[x,b]=function(n,s){const t=new a([-s,-s,-s,s,-s,-s,-s,s,-s,s,s,-s,-s,-s,s,s,-s,s,-s,s,s,s,s,s]),i=new o([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[e(n,t,r.VERTEX),e(n,i,r.INDEX)]}(v,u),g=await(m._environmentSkyboxShaderComposer?.(c,"hdr"))??c,h=t("skybox-hdr",s+i,g),w=function(e,r,o,s,t,i){const c=new a(28);return c[0]=c[5]=c[10]=c[15]=1,c[12]=r[0],c[13]=r[1],c[14]=r[2],c[16]=o[0],c[17]=o[1],c[18]=o[2],c[20]=s.r,c[21]=s.g,c[22]=s.b,c[24]=t,c[25]=i,n(e,c)}(v,d,l,m.clearColor,m.imageProcessing.exposure,m.imageProcessing.contrast),y=h.createBindGroup(v,w,p.specularCubeView,p.cubeSampler),_={order:0,isTransparent:!1,bind:(e,r)=>({renderable:_,pipeline:h.getPipeline(e,r),draw:e=>(e.setBindGroup(1,y),e.setVertexBuffer(0,x),e.setIndexBuffer(b,"uint16"),e.drawIndexed(36),1)}),_rebuild:()=>f(m,p,u,d,l)};return _}export{f as buildHdrSkyboxRenderable};
//# sourceMappingURL=background-hdr-skybox-BTd3RR4P.esm.min.js.map