UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

126 lines 6.63 kB
// Do not edit. import { ShaderStore } from "../../Engines/shaderStore.js"; const name = "openpbrBaseLayerData"; const shader = `var base_color=vec3f(0.8);var base_metalness: f32=0.0;var base_diffuse_roughness: f32=0.0;var specular_weight: f32=1.0;var specular_roughness: f32=0.3;var specular_color: vec3f=vec3f(1.0);var specular_roughness_anisotropy: f32=0.0;var specular_ior: f32=1.5;var alpha: f32=1.0;var geometry_tangent: vec2f=vec2f(1.0,0.0); #ifdef BASE_WEIGHT let baseWeightFromTexture: vec4f=textureSample(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset); #endif #ifdef BASE_COLOR let baseColorFromTexture: vec4f=textureSample(baseColorSampler,baseColorSamplerSampler,fragmentInputs.vBaseColorUV+uvOffset); #endif #ifdef BASE_METALNESS let metallicFromTexture: vec4f=textureSample(baseMetalnessSampler,baseMetalnessSamplerSampler,fragmentInputs.vBaseMetalnessUV+uvOffset); #endif #ifdef BASE_DIFFUSE_ROUGHNESS let baseDiffuseRoughnessFromTexture: f32=textureSample(baseDiffuseRoughnessSampler,baseDiffuseRoughnessSamplerSampler,fragmentInputs.vBaseDiffuseRoughnessUV+uvOffset).r; #endif #ifdef GEOMETRY_TANGENT let geometryTangentFromTexture: vec3f=textureSample(geometryTangentSampler,geometryTangentSamplerSampler,fragmentInputs.vGeometryTangentUV+uvOffset).rgb; #endif #ifdef SPECULAR_ROUGHNESS_ANISOTROPY let anisotropyFromTexture: f32=textureSample(specularRoughnessAnisotropySampler,specularRoughnessAnisotropySamplerSampler,fragmentInputs.vSpecularRoughnessAnisotropyUV+uvOffset).r*uniforms.vSpecularRoughnessAnisotropyInfos.y; #endif #ifdef GEOMETRY_OPACITY let opacityFromTexture: vec4f=textureSample(geometryOpacitySampler,geometryOpacitySamplerSampler,fragmentInputs.vGeometryOpacityUV+uvOffset); #endif #ifdef DECAL let decalFromTexture: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset); #endif #ifdef SPECULAR_COLOR let specularColorFromTexture: vec4f=textureSample(specularColorSampler,specularColorSamplerSampler,fragmentInputs.vSpecularColorUV+uvOffset); #endif #if defined(SPECULAR_WEIGHT) #ifdef SPECULAR_WEIGHT_IN_ALPHA let specularWeightFromTexture: f32=textureSample(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).a; #else let specularWeightFromTexture: f32=textureSample(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).r; #endif #endif #if defined(ANISOTROPIC) || defined(FUZZ) let noise=textureSample(blueNoiseSampler,blueNoiseSamplerSampler,fragmentInputs.position.xy/256.0).xyz; #endif #if defined(ROUGHNESSSTOREINMETALMAPGREEN) && defined(BASE_METALNESS) let roughnessFromTexture: f32=metallicFromTexture.g; #elif defined(SPECULAR_ROUGHNESS) let roughnessFromTexture: f32=textureSample(specularRoughnessSampler,specularRoughnessSamplerSampler,fragmentInputs.vSpecularRoughnessUV+uvOffset).r; #endif base_color=uniforms.vBaseColor.rgb; #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) base_color*=fragmentInputs.vColor.rgb; #endif #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) alpha*=fragmentInputs.vColor.a; #endif base_color*=vec3(uniforms.vBaseWeight);alpha=uniforms.vBaseColor.a;base_metalness=uniforms.vReflectanceInfo.x;base_diffuse_roughness=uniforms.vBaseDiffuseRoughness;specular_roughness=uniforms.vReflectanceInfo.y;specular_color=uniforms.vSpecularColor.rgb;specular_weight=uniforms.vReflectanceInfo.a;specular_ior=uniforms.vReflectanceInfo.z;specular_roughness_anisotropy=uniforms.vSpecularAnisotropy.b;geometry_tangent=uniforms.vSpecularAnisotropy.rg; #ifdef BASE_COLOR #ifdef BASE_COLOR_GAMMA base_color*=toLinearSpace(baseColorFromTexture.rgb); #else base_color*=baseColorFromTexture.rgb; #endif base_color*=uniforms.vBaseColorInfos.y; #endif #ifdef BASE_WEIGHT base_color*=baseWeightFromTexture.r; #endif #if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE) alpha*=baseColorFromTexture.a; #elif defined(GEOMETRY_OPACITY) alpha*=opacityFromTexture.a;alpha*=uniforms.vGeometryOpacityInfos.y; #endif #ifdef ALPHATEST #if DEBUGMODE != 88 if (alpha<ALPHATESTVALUE) discard; #endif #ifndef ALPHABLEND alpha=1.0; #endif #endif #ifdef BASE_METALNESS #ifdef METALLNESSSTOREINMETALMAPBLUE base_metalness*=metallicFromTexture.b; #else base_metalness*=metallicFromTexture.r; #endif #endif #ifdef BASE_DIFFUSE_ROUGHNESS base_diffuse_roughness*=baseDiffuseRoughnessFromTexture*uniforms.vBaseDiffuseRoughnessInfos.y; #endif #ifdef SPECULAR_COLOR #ifdef SPECULAR_COLOR_GAMMA specular_color*=toLinearSpace(specularColorFromTexture.rgb); #else specular_color*=specularColorFromTexture.rgb; #endif #endif #ifdef SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE specular_weight*=specularColorFromTexture.a; #elif defined(SPECULAR_WEIGHT) specular_weight*=specularWeightFromTexture; #endif #if defined(SPECULAR_ROUGHNESS) || (defined(ROUGHNESSSTOREINMETALMAPGREEN) && defined(BASE_METALNESS)) specular_roughness*=roughnessFromTexture; #endif #ifdef GEOMETRY_TANGENT {let tangentFromTexture: vec2f=normalize(geometryTangentFromTexture.xy*vec2f(2.0f)-vec2f(1.0f));let tangent_angle_texture: f32=atan2(tangentFromTexture.y,tangentFromTexture.x);let tangent_angle_uniform: f32=atan2(geometry_tangent.y,geometry_tangent.x);let tangent_angle: f32=tangent_angle_texture+tangent_angle_uniform;geometry_tangent=vec2f(cos(tangent_angle),sin(tangent_angle));} #endif #if defined(GEOMETRY_TANGENT) && defined(SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE) specular_roughness_anisotropy*=geometryTangentFromTexture.b; #elif defined(SPECULAR_ROUGHNESS_ANISOTROPY) specular_roughness_anisotropy*=anisotropyFromTexture; #endif #ifdef DETAIL let detailRoughness: f32=mix(0.5f,detailColor.b,vDetailInfos.w);let loLerp: f32=mix(0.f,specular_roughness,detailRoughness*2.f);let hiLerp: f32=mix(specular_roughness,1.f,(detailRoughness-0.5f)*2.f);specular_roughness=mix(loLerp,hiLerp,step(detailRoughness,0.5f)); #endif #ifdef USE_GLTF_STYLE_ANISOTROPY let baseAlpha: f32=specular_roughness*specular_roughness;let roughnessT: f32=mix(baseAlpha,1.0f,specular_roughness_anisotropy*specular_roughness_anisotropy);let roughnessB: f32=baseAlpha;specular_roughness_anisotropy=1.0f-roughnessB/max(roughnessT,0.00001f);specular_roughness=sqrt(roughnessT/sqrt(2.0f/(1.0f+(1.0f-specular_roughness_anisotropy)*(1.0f-specular_roughness_anisotropy)))); #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name]) { ShaderStore.IncludesShadersStoreWGSL[name] = shader; } /** @internal */ export const openpbrBaseLayerDataWGSL = { name, shader }; //# sourceMappingURL=openpbrBaseLayerData.js.map