UNPKG

@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
import{d as e,B as r,F as a,e as n,U as o}from"./index-DFZFpUG-.esm.min.js";import{c as s}from"./cubemap-skybox-material-Dv1ZF8tN.esm.min.js";import{s as i}from"./skybox.vertex-Ban7q6IM-DcsSq_1-.esm.min.js";import{S as t}from"./scene-uniforms-Cr9D1h23.esm.min.js";function f(f,c,m,u,p){const d=f.surface.engine,l=f.clearColor,x=function(n,s){const i=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]),t=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{posBuffer:e(n,i,r.VERTEX),idxBuffer:e(n,t,r.INDEX)}}(d,m),g=s("skybox-hdr",t+i,"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>{let 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);}"),v=function(e,r,o,s,i,t){const f=new a(28);return f[0]=f[5]=f[10]=f[15]=1,f[12]=r[0],f[13]=r[1],f[14]=r[2],f[16]=o[0],f[17]=o[1],f[18]=o[2],f[20]=s[0],f[21]=s[1],f[22]=s[2],f[24]=i,f[25]=t,n(e,f)}(d,u,p,[l.r,l.g,l.b],f.imageProcessing.exposure,f.imageProcessing.contrast),b=g.createBindGroup(d,v,c.specularCubeView,c.cubeSampler),B={order:0,isTransparent:!1,bind:(e,r)=>({renderable:B,pipeline:g.getPipeline(e,r),draw:e=>(e.setBindGroup(1,b),e.setVertexBuffer(0,x.posBuffer),e.setIndexBuffer(x.idxBuffer,"uint16"),e.drawIndexed(36),1)})};return B}export{f as buildHdrSkyboxRenderable}; //# sourceMappingURL=background-hdr-skybox-DYg6QZQK.esm.min.js.map