Initial commit
This commit is contained in:
7
HTML/ThreeJS/node_modules/three/src/renderers/WebGL1Renderer.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/WebGL1Renderer.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { WebGLRenderer } from './WebGLRenderer.js';
|
||||
|
||||
class WebGL1Renderer extends WebGLRenderer {}
|
||||
|
||||
WebGL1Renderer.prototype.isWebGL1Renderer = true;
|
||||
|
||||
export { WebGL1Renderer };
|
||||
22
HTML/ThreeJS/node_modules/three/src/renderers/WebGL3DRenderTarget.js
generated
vendored
Normal file
22
HTML/ThreeJS/node_modules/three/src/renderers/WebGL3DRenderTarget.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { WebGLRenderTarget } from './WebGLRenderTarget.js';
|
||||
import { Data3DTexture } from '../textures/Data3DTexture.js';
|
||||
|
||||
class WebGL3DRenderTarget extends WebGLRenderTarget {
|
||||
|
||||
constructor( width, height, depth ) {
|
||||
|
||||
super( width, height );
|
||||
|
||||
this.depth = depth;
|
||||
|
||||
this.texture = new Data3DTexture( null, width, height, depth );
|
||||
|
||||
this.texture.isRenderTargetTexture = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WebGL3DRenderTarget.prototype.isWebGL3DRenderTarget = true;
|
||||
|
||||
export { WebGL3DRenderTarget };
|
||||
22
HTML/ThreeJS/node_modules/three/src/renderers/WebGLArrayRenderTarget.js
generated
vendored
Normal file
22
HTML/ThreeJS/node_modules/three/src/renderers/WebGLArrayRenderTarget.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { WebGLRenderTarget } from './WebGLRenderTarget.js';
|
||||
import { DataArrayTexture } from '../textures/DataArrayTexture.js';
|
||||
|
||||
class WebGLArrayRenderTarget extends WebGLRenderTarget {
|
||||
|
||||
constructor( width, height, depth ) {
|
||||
|
||||
super( width, height );
|
||||
|
||||
this.depth = depth;
|
||||
|
||||
this.texture = new DataArrayTexture( null, width, height, depth );
|
||||
|
||||
this.texture.isRenderTargetTexture = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WebGLArrayRenderTarget.prototype.isWebGLArrayRenderTarget = true;
|
||||
|
||||
export { WebGLArrayRenderTarget };
|
||||
147
HTML/ThreeJS/node_modules/three/src/renderers/WebGLCubeRenderTarget.js
generated
vendored
Normal file
147
HTML/ThreeJS/node_modules/three/src/renderers/WebGLCubeRenderTarget.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending, RGBAFormat } from '../constants.js';
|
||||
import { Mesh } from '../objects/Mesh.js';
|
||||
import { BoxGeometry } from '../geometries/BoxGeometry.js';
|
||||
import { ShaderMaterial } from '../materials/ShaderMaterial.js';
|
||||
import { cloneUniforms } from './shaders/UniformsUtils.js';
|
||||
import { WebGLRenderTarget } from './WebGLRenderTarget.js';
|
||||
import { CubeCamera } from '../cameras/CubeCamera.js';
|
||||
import { CubeTexture } from '../textures/CubeTexture.js';
|
||||
|
||||
class WebGLCubeRenderTarget extends WebGLRenderTarget {
|
||||
|
||||
constructor( size, options = {} ) {
|
||||
|
||||
super( size, size, options );
|
||||
|
||||
const image = { width: size, height: size, depth: 1 };
|
||||
const images = [ image, image, image, image, image, image ];
|
||||
|
||||
this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
|
||||
|
||||
// By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
|
||||
// in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
|
||||
// in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.
|
||||
|
||||
// three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped
|
||||
// and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture
|
||||
// as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures).
|
||||
|
||||
this.texture.isRenderTargetTexture = true;
|
||||
|
||||
this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
|
||||
this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
|
||||
|
||||
}
|
||||
|
||||
fromEquirectangularTexture( renderer, texture ) {
|
||||
|
||||
this.texture.type = texture.type;
|
||||
this.texture.format = RGBAFormat; // see #18859
|
||||
this.texture.encoding = texture.encoding;
|
||||
|
||||
this.texture.generateMipmaps = texture.generateMipmaps;
|
||||
this.texture.minFilter = texture.minFilter;
|
||||
this.texture.magFilter = texture.magFilter;
|
||||
|
||||
const shader = {
|
||||
|
||||
uniforms: {
|
||||
tEquirect: { value: null },
|
||||
},
|
||||
|
||||
vertexShader: /* glsl */`
|
||||
|
||||
varying vec3 vWorldDirection;
|
||||
|
||||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||||
|
||||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
vWorldDirection = transformDirection( position, modelMatrix );
|
||||
|
||||
#include <begin_vertex>
|
||||
#include <project_vertex>
|
||||
|
||||
}
|
||||
`,
|
||||
|
||||
fragmentShader: /* glsl */`
|
||||
|
||||
uniform sampler2D tEquirect;
|
||||
|
||||
varying vec3 vWorldDirection;
|
||||
|
||||
#include <common>
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 direction = normalize( vWorldDirection );
|
||||
|
||||
vec2 sampleUV = equirectUv( direction );
|
||||
|
||||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||||
|
||||
}
|
||||
`
|
||||
};
|
||||
|
||||
const geometry = new BoxGeometry( 5, 5, 5 );
|
||||
|
||||
const material = new ShaderMaterial( {
|
||||
|
||||
name: 'CubemapFromEquirect',
|
||||
|
||||
uniforms: cloneUniforms( shader.uniforms ),
|
||||
vertexShader: shader.vertexShader,
|
||||
fragmentShader: shader.fragmentShader,
|
||||
side: BackSide,
|
||||
blending: NoBlending
|
||||
|
||||
} );
|
||||
|
||||
material.uniforms.tEquirect.value = texture;
|
||||
|
||||
const mesh = new Mesh( geometry, material );
|
||||
|
||||
const currentMinFilter = texture.minFilter;
|
||||
|
||||
// Avoid blurred poles
|
||||
if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter;
|
||||
|
||||
const camera = new CubeCamera( 1, 10, this );
|
||||
camera.update( renderer, mesh );
|
||||
|
||||
texture.minFilter = currentMinFilter;
|
||||
|
||||
mesh.geometry.dispose();
|
||||
mesh.material.dispose();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
clear( renderer, color, depth, stencil ) {
|
||||
|
||||
const currentRenderTarget = renderer.getRenderTarget();
|
||||
|
||||
for ( let i = 0; i < 6; i ++ ) {
|
||||
|
||||
renderer.setRenderTarget( this, i );
|
||||
|
||||
renderer.clear( color, depth, stencil );
|
||||
|
||||
}
|
||||
|
||||
renderer.setRenderTarget( currentRenderTarget );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;
|
||||
|
||||
export { WebGLCubeRenderTarget };
|
||||
80
HTML/ThreeJS/node_modules/three/src/renderers/WebGLMultipleRenderTargets.js
generated
vendored
Normal file
80
HTML/ThreeJS/node_modules/three/src/renderers/WebGLMultipleRenderTargets.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import { WebGLRenderTarget } from './WebGLRenderTarget.js';
|
||||
|
||||
class WebGLMultipleRenderTargets extends WebGLRenderTarget {
|
||||
|
||||
constructor( width, height, count, options = {} ) {
|
||||
|
||||
super( width, height, options );
|
||||
|
||||
const texture = this.texture;
|
||||
|
||||
this.texture = [];
|
||||
|
||||
for ( let i = 0; i < count; i ++ ) {
|
||||
|
||||
this.texture[ i ] = texture.clone();
|
||||
this.texture[ i ].isRenderTargetTexture = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setSize( width, height, depth = 1 ) {
|
||||
|
||||
if ( this.width !== width || this.height !== height || this.depth !== depth ) {
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.depth = depth;
|
||||
|
||||
for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
|
||||
|
||||
this.texture[ i ].image.width = width;
|
||||
this.texture[ i ].image.height = height;
|
||||
this.texture[ i ].image.depth = depth;
|
||||
|
||||
}
|
||||
|
||||
this.dispose();
|
||||
|
||||
}
|
||||
|
||||
this.viewport.set( 0, 0, width, height );
|
||||
this.scissor.set( 0, 0, width, height );
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
copy( source ) {
|
||||
|
||||
this.dispose();
|
||||
|
||||
this.width = source.width;
|
||||
this.height = source.height;
|
||||
this.depth = source.depth;
|
||||
|
||||
this.viewport.set( 0, 0, this.width, this.height );
|
||||
this.scissor.set( 0, 0, this.width, this.height );
|
||||
|
||||
this.depthBuffer = source.depthBuffer;
|
||||
this.stencilBuffer = source.stencilBuffer;
|
||||
this.depthTexture = source.depthTexture;
|
||||
|
||||
this.texture.length = 0;
|
||||
|
||||
for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
|
||||
|
||||
this.texture[ i ] = source.texture[ i ].clone();
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true;
|
||||
|
||||
export { WebGLMultipleRenderTargets };
|
||||
106
HTML/ThreeJS/node_modules/three/src/renderers/WebGLRenderTarget.js
generated
vendored
Normal file
106
HTML/ThreeJS/node_modules/three/src/renderers/WebGLRenderTarget.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
import { EventDispatcher } from '../core/EventDispatcher.js';
|
||||
import { Texture } from '../textures/Texture.js';
|
||||
import { LinearFilter } from '../constants.js';
|
||||
import { Vector4 } from '../math/Vector4.js';
|
||||
|
||||
/*
|
||||
In options, we can specify:
|
||||
* Texture parameters for an auto-generated target texture
|
||||
* depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
|
||||
*/
|
||||
class WebGLRenderTarget extends EventDispatcher {
|
||||
|
||||
constructor( width, height, options = {} ) {
|
||||
|
||||
super();
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.depth = 1;
|
||||
|
||||
this.scissor = new Vector4( 0, 0, width, height );
|
||||
this.scissorTest = false;
|
||||
|
||||
this.viewport = new Vector4( 0, 0, width, height );
|
||||
|
||||
const image = { width: width, height: height, depth: 1 };
|
||||
|
||||
this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
|
||||
this.texture.isRenderTargetTexture = true;
|
||||
|
||||
this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
|
||||
this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
|
||||
this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
|
||||
|
||||
this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
|
||||
this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
|
||||
|
||||
this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
|
||||
|
||||
this.samples = options.samples !== undefined ? options.samples : 0;
|
||||
|
||||
}
|
||||
|
||||
setSize( width, height, depth = 1 ) {
|
||||
|
||||
if ( this.width !== width || this.height !== height || this.depth !== depth ) {
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.depth = depth;
|
||||
|
||||
this.texture.image.width = width;
|
||||
this.texture.image.height = height;
|
||||
this.texture.image.depth = depth;
|
||||
|
||||
this.dispose();
|
||||
|
||||
}
|
||||
|
||||
this.viewport.set( 0, 0, width, height );
|
||||
this.scissor.set( 0, 0, width, height );
|
||||
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
||||
return new this.constructor().copy( this );
|
||||
|
||||
}
|
||||
|
||||
copy( source ) {
|
||||
|
||||
this.width = source.width;
|
||||
this.height = source.height;
|
||||
this.depth = source.depth;
|
||||
|
||||
this.viewport.copy( source.viewport );
|
||||
|
||||
this.texture = source.texture.clone();
|
||||
|
||||
// ensure image object is not shared, see #20328
|
||||
|
||||
this.texture.image = Object.assign( {}, source.texture.image );
|
||||
|
||||
this.depthBuffer = source.depthBuffer;
|
||||
this.stencilBuffer = source.stencilBuffer;
|
||||
|
||||
if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
|
||||
|
||||
this.samples = source.samples;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.dispatchEvent( { type: 'dispose' } );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WebGLRenderTarget.prototype.isWebGLRenderTarget = true;
|
||||
|
||||
export { WebGLRenderTarget };
|
||||
2189
HTML/ThreeJS/node_modules/three/src/renderers/WebGLRenderer.js
generated
vendored
Normal file
2189
HTML/ThreeJS/node_modules/three/src/renderers/WebGLRenderer.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
259
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk.js
generated
vendored
Normal file
259
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk.js
generated
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js';
|
||||
import alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js';
|
||||
import alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';
|
||||
import alphatest_pars_fragment from './ShaderChunk/alphatest_pars_fragment.glsl.js';
|
||||
import aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';
|
||||
import aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';
|
||||
import begin_vertex from './ShaderChunk/begin_vertex.glsl.js';
|
||||
import beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';
|
||||
import bsdfs from './ShaderChunk/bsdfs.glsl.js';
|
||||
import bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js';
|
||||
import clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js';
|
||||
import clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js';
|
||||
import clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js';
|
||||
import clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js';
|
||||
import color_fragment from './ShaderChunk/color_fragment.glsl.js';
|
||||
import color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js';
|
||||
import color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js';
|
||||
import color_vertex from './ShaderChunk/color_vertex.glsl.js';
|
||||
import common from './ShaderChunk/common.glsl.js';
|
||||
import cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js';
|
||||
import defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js';
|
||||
import displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js';
|
||||
import displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js';
|
||||
import emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js';
|
||||
import emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js';
|
||||
import encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js';
|
||||
import encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js';
|
||||
import envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js';
|
||||
import envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js';
|
||||
import envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js';
|
||||
import envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js';
|
||||
import envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js';
|
||||
import fog_vertex from './ShaderChunk/fog_vertex.glsl.js';
|
||||
import fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js';
|
||||
import fog_fragment from './ShaderChunk/fog_fragment.glsl.js';
|
||||
import fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js';
|
||||
import gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js';
|
||||
import lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js';
|
||||
import lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js';
|
||||
import lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js';
|
||||
import lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js';
|
||||
import envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js';
|
||||
import lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js';
|
||||
import lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js';
|
||||
import lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js';
|
||||
import lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js';
|
||||
import lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js';
|
||||
import lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js';
|
||||
import lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';
|
||||
import lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';
|
||||
import lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';
|
||||
import logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';
|
||||
import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';
|
||||
import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';
|
||||
import logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';
|
||||
import map_fragment from './ShaderChunk/map_fragment.glsl.js';
|
||||
import map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';
|
||||
import map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';
|
||||
import map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';
|
||||
import metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';
|
||||
import metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';
|
||||
import morphcolor_vertex from './ShaderChunk/morphcolor_vertex.glsl.js';
|
||||
import morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';
|
||||
import morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';
|
||||
import morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';
|
||||
import normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';
|
||||
import normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';
|
||||
import normal_pars_fragment from './ShaderChunk/normal_pars_fragment.glsl.js';
|
||||
import normal_pars_vertex from './ShaderChunk/normal_pars_vertex.glsl.js';
|
||||
import normal_vertex from './ShaderChunk/normal_vertex.glsl.js';
|
||||
import normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';
|
||||
import clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';
|
||||
import clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';
|
||||
import clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js';
|
||||
import output_fragment from './ShaderChunk/output_fragment.glsl.js';
|
||||
import packing from './ShaderChunk/packing.glsl.js';
|
||||
import premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js';
|
||||
import project_vertex from './ShaderChunk/project_vertex.glsl.js';
|
||||
import dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js';
|
||||
import dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js';
|
||||
import roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js';
|
||||
import roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js';
|
||||
import shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js';
|
||||
import shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js';
|
||||
import shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js';
|
||||
import shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js';
|
||||
import skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js';
|
||||
import skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js';
|
||||
import skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js';
|
||||
import skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js';
|
||||
import specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js';
|
||||
import specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js';
|
||||
import tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js';
|
||||
import tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js';
|
||||
import transmission_fragment from './ShaderChunk/transmission_fragment.glsl.js';
|
||||
import transmission_pars_fragment from './ShaderChunk/transmission_pars_fragment.glsl.js';
|
||||
import uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js';
|
||||
import uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js';
|
||||
import uv_vertex from './ShaderChunk/uv_vertex.glsl.js';
|
||||
import uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js';
|
||||
import uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js';
|
||||
import uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js';
|
||||
import worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js';
|
||||
|
||||
import * as background from './ShaderLib/background.glsl.js';
|
||||
import * as cube from './ShaderLib/cube.glsl.js';
|
||||
import * as depth from './ShaderLib/depth.glsl.js';
|
||||
import * as distanceRGBA from './ShaderLib/distanceRGBA.glsl.js';
|
||||
import * as equirect from './ShaderLib/equirect.glsl.js';
|
||||
import * as linedashed from './ShaderLib/linedashed.glsl.js';
|
||||
import * as meshbasic from './ShaderLib/meshbasic.glsl.js';
|
||||
import * as meshlambert from './ShaderLib/meshlambert.glsl.js';
|
||||
import * as meshmatcap from './ShaderLib/meshmatcap.glsl.js';
|
||||
import * as meshnormal from './ShaderLib/meshnormal.glsl.js';
|
||||
import * as meshphong from './ShaderLib/meshphong.glsl.js';
|
||||
import * as meshphysical from './ShaderLib/meshphysical.glsl.js';
|
||||
import * as meshtoon from './ShaderLib/meshtoon.glsl.js';
|
||||
import * as points from './ShaderLib/points.glsl.js';
|
||||
import * as shadow from './ShaderLib/shadow.glsl.js';
|
||||
import * as sprite from './ShaderLib/sprite.glsl.js';
|
||||
|
||||
export const ShaderChunk = {
|
||||
alphamap_fragment: alphamap_fragment,
|
||||
alphamap_pars_fragment: alphamap_pars_fragment,
|
||||
alphatest_fragment: alphatest_fragment,
|
||||
alphatest_pars_fragment: alphatest_pars_fragment,
|
||||
aomap_fragment: aomap_fragment,
|
||||
aomap_pars_fragment: aomap_pars_fragment,
|
||||
begin_vertex: begin_vertex,
|
||||
beginnormal_vertex: beginnormal_vertex,
|
||||
bsdfs: bsdfs,
|
||||
bumpmap_pars_fragment: bumpmap_pars_fragment,
|
||||
clipping_planes_fragment: clipping_planes_fragment,
|
||||
clipping_planes_pars_fragment: clipping_planes_pars_fragment,
|
||||
clipping_planes_pars_vertex: clipping_planes_pars_vertex,
|
||||
clipping_planes_vertex: clipping_planes_vertex,
|
||||
color_fragment: color_fragment,
|
||||
color_pars_fragment: color_pars_fragment,
|
||||
color_pars_vertex: color_pars_vertex,
|
||||
color_vertex: color_vertex,
|
||||
common: common,
|
||||
cube_uv_reflection_fragment: cube_uv_reflection_fragment,
|
||||
defaultnormal_vertex: defaultnormal_vertex,
|
||||
displacementmap_pars_vertex: displacementmap_pars_vertex,
|
||||
displacementmap_vertex: displacementmap_vertex,
|
||||
emissivemap_fragment: emissivemap_fragment,
|
||||
emissivemap_pars_fragment: emissivemap_pars_fragment,
|
||||
encodings_fragment: encodings_fragment,
|
||||
encodings_pars_fragment: encodings_pars_fragment,
|
||||
envmap_fragment: envmap_fragment,
|
||||
envmap_common_pars_fragment: envmap_common_pars_fragment,
|
||||
envmap_pars_fragment: envmap_pars_fragment,
|
||||
envmap_pars_vertex: envmap_pars_vertex,
|
||||
envmap_physical_pars_fragment: envmap_physical_pars_fragment,
|
||||
envmap_vertex: envmap_vertex,
|
||||
fog_vertex: fog_vertex,
|
||||
fog_pars_vertex: fog_pars_vertex,
|
||||
fog_fragment: fog_fragment,
|
||||
fog_pars_fragment: fog_pars_fragment,
|
||||
gradientmap_pars_fragment: gradientmap_pars_fragment,
|
||||
lightmap_fragment: lightmap_fragment,
|
||||
lightmap_pars_fragment: lightmap_pars_fragment,
|
||||
lights_lambert_vertex: lights_lambert_vertex,
|
||||
lights_pars_begin: lights_pars_begin,
|
||||
lights_toon_fragment: lights_toon_fragment,
|
||||
lights_toon_pars_fragment: lights_toon_pars_fragment,
|
||||
lights_phong_fragment: lights_phong_fragment,
|
||||
lights_phong_pars_fragment: lights_phong_pars_fragment,
|
||||
lights_physical_fragment: lights_physical_fragment,
|
||||
lights_physical_pars_fragment: lights_physical_pars_fragment,
|
||||
lights_fragment_begin: lights_fragment_begin,
|
||||
lights_fragment_maps: lights_fragment_maps,
|
||||
lights_fragment_end: lights_fragment_end,
|
||||
logdepthbuf_fragment: logdepthbuf_fragment,
|
||||
logdepthbuf_pars_fragment: logdepthbuf_pars_fragment,
|
||||
logdepthbuf_pars_vertex: logdepthbuf_pars_vertex,
|
||||
logdepthbuf_vertex: logdepthbuf_vertex,
|
||||
map_fragment: map_fragment,
|
||||
map_pars_fragment: map_pars_fragment,
|
||||
map_particle_fragment: map_particle_fragment,
|
||||
map_particle_pars_fragment: map_particle_pars_fragment,
|
||||
metalnessmap_fragment: metalnessmap_fragment,
|
||||
metalnessmap_pars_fragment: metalnessmap_pars_fragment,
|
||||
morphcolor_vertex: morphcolor_vertex,
|
||||
morphnormal_vertex: morphnormal_vertex,
|
||||
morphtarget_pars_vertex: morphtarget_pars_vertex,
|
||||
morphtarget_vertex: morphtarget_vertex,
|
||||
normal_fragment_begin: normal_fragment_begin,
|
||||
normal_fragment_maps: normal_fragment_maps,
|
||||
normal_pars_fragment: normal_pars_fragment,
|
||||
normal_pars_vertex: normal_pars_vertex,
|
||||
normal_vertex: normal_vertex,
|
||||
normalmap_pars_fragment: normalmap_pars_fragment,
|
||||
clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,
|
||||
clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,
|
||||
clearcoat_pars_fragment: clearcoat_pars_fragment,
|
||||
output_fragment: output_fragment,
|
||||
packing: packing,
|
||||
premultiplied_alpha_fragment: premultiplied_alpha_fragment,
|
||||
project_vertex: project_vertex,
|
||||
dithering_fragment: dithering_fragment,
|
||||
dithering_pars_fragment: dithering_pars_fragment,
|
||||
roughnessmap_fragment: roughnessmap_fragment,
|
||||
roughnessmap_pars_fragment: roughnessmap_pars_fragment,
|
||||
shadowmap_pars_fragment: shadowmap_pars_fragment,
|
||||
shadowmap_pars_vertex: shadowmap_pars_vertex,
|
||||
shadowmap_vertex: shadowmap_vertex,
|
||||
shadowmask_pars_fragment: shadowmask_pars_fragment,
|
||||
skinbase_vertex: skinbase_vertex,
|
||||
skinning_pars_vertex: skinning_pars_vertex,
|
||||
skinning_vertex: skinning_vertex,
|
||||
skinnormal_vertex: skinnormal_vertex,
|
||||
specularmap_fragment: specularmap_fragment,
|
||||
specularmap_pars_fragment: specularmap_pars_fragment,
|
||||
tonemapping_fragment: tonemapping_fragment,
|
||||
tonemapping_pars_fragment: tonemapping_pars_fragment,
|
||||
transmission_fragment: transmission_fragment,
|
||||
transmission_pars_fragment: transmission_pars_fragment,
|
||||
uv_pars_fragment: uv_pars_fragment,
|
||||
uv_pars_vertex: uv_pars_vertex,
|
||||
uv_vertex: uv_vertex,
|
||||
uv2_pars_fragment: uv2_pars_fragment,
|
||||
uv2_pars_vertex: uv2_pars_vertex,
|
||||
uv2_vertex: uv2_vertex,
|
||||
worldpos_vertex: worldpos_vertex,
|
||||
|
||||
background_vert: background.vertex,
|
||||
background_frag: background.fragment,
|
||||
cube_vert: cube.vertex,
|
||||
cube_frag: cube.fragment,
|
||||
depth_vert: depth.vertex,
|
||||
depth_frag: depth.fragment,
|
||||
distanceRGBA_vert: distanceRGBA.vertex,
|
||||
distanceRGBA_frag: distanceRGBA.fragment,
|
||||
equirect_vert: equirect.vertex,
|
||||
equirect_frag: equirect.fragment,
|
||||
linedashed_vert: linedashed.vertex,
|
||||
linedashed_frag: linedashed.fragment,
|
||||
meshbasic_vert: meshbasic.vertex,
|
||||
meshbasic_frag: meshbasic.fragment,
|
||||
meshlambert_vert: meshlambert.vertex,
|
||||
meshlambert_frag: meshlambert.fragment,
|
||||
meshmatcap_vert: meshmatcap.vertex,
|
||||
meshmatcap_frag: meshmatcap.fragment,
|
||||
meshnormal_vert: meshnormal.vertex,
|
||||
meshnormal_frag: meshnormal.fragment,
|
||||
meshphong_vert: meshphong.vertex,
|
||||
meshphong_frag: meshphong.fragment,
|
||||
meshphysical_vert: meshphysical.vertex,
|
||||
meshphysical_frag: meshphysical.fragment,
|
||||
meshtoon_vert: meshtoon.vertex,
|
||||
meshtoon_frag: meshtoon.fragment,
|
||||
points_vert: points.vertex,
|
||||
points_frag: points.fragment,
|
||||
shadow_vert: shadow.vertex,
|
||||
shadow_frag: shadow.fragment,
|
||||
sprite_vert: sprite.vertex,
|
||||
sprite_frag: sprite.fragment
|
||||
};
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ALPHAMAP
|
||||
|
||||
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ALPHAMAP
|
||||
|
||||
uniform sampler2D alphaMap;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ALPHATEST
|
||||
|
||||
if ( diffuseColor.a < alphaTest ) discard;
|
||||
|
||||
#endif
|
||||
`;
|
||||
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js
generated
vendored
Normal file
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ALPHATEST
|
||||
uniform float alphaTest;
|
||||
#endif
|
||||
`;
|
||||
18
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js
generated
vendored
Normal file
18
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_AOMAP
|
||||
|
||||
// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
|
||||
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
|
||||
|
||||
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
||||
|
||||
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
||||
|
||||
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
||||
|
||||
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js
generated
vendored
Normal file
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_AOMAP
|
||||
|
||||
uniform sampler2D aoMap;
|
||||
uniform float aoMapIntensity;
|
||||
|
||||
#endif
|
||||
`;
|
||||
3
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js
generated
vendored
Normal file
3
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default /* glsl */`
|
||||
vec3 transformed = vec3( position );
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
vec3 objectNormal = vec3( normal );
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
vec3 objectTangent = vec3( tangent.xyz );
|
||||
|
||||
#endif
|
||||
`;
|
||||
258
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js
generated
vendored
Normal file
258
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
export default /* glsl */`
|
||||
|
||||
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
||||
|
||||
return RECIPROCAL_PI * diffuseColor;
|
||||
|
||||
} // validated
|
||||
|
||||
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
||||
|
||||
// Original approximation by Christophe Schlick '94
|
||||
// float fresnel = pow( 1.0 - dotVH, 5.0 );
|
||||
|
||||
// Optimized variant (presented by Epic at SIGGRAPH '13)
|
||||
// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
|
||||
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
||||
|
||||
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
||||
|
||||
} // validated
|
||||
|
||||
// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
|
||||
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
||||
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
||||
|
||||
float a2 = pow2( alpha );
|
||||
|
||||
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
||||
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
||||
|
||||
return 0.5 / max( gv + gl, EPSILON );
|
||||
|
||||
}
|
||||
|
||||
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
|
||||
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
|
||||
// alpha is "roughness squared" in Disney’s reparameterization
|
||||
float D_GGX( const in float alpha, const in float dotNH ) {
|
||||
|
||||
float a2 = pow2( alpha );
|
||||
|
||||
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1
|
||||
|
||||
return RECIPROCAL_PI * a2 / pow2( denom );
|
||||
|
||||
}
|
||||
|
||||
// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
|
||||
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
|
||||
|
||||
float alpha = pow2( roughness ); // UE4's roughness
|
||||
|
||||
vec3 halfDir = normalize( lightDir + viewDir );
|
||||
|
||||
float dotNL = saturate( dot( normal, lightDir ) );
|
||||
float dotNV = saturate( dot( normal, viewDir ) );
|
||||
float dotNH = saturate( dot( normal, halfDir ) );
|
||||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||||
|
||||
vec3 F = F_Schlick( f0, f90, dotVH );
|
||||
|
||||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
||||
|
||||
float D = D_GGX( alpha, dotNH );
|
||||
|
||||
return F * ( V * D );
|
||||
|
||||
}
|
||||
|
||||
// Rect Area Light
|
||||
|
||||
// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
|
||||
// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt
|
||||
// code: https://github.com/selfshadow/ltc_code/
|
||||
|
||||
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
||||
|
||||
const float LUT_SIZE = 64.0;
|
||||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||||
|
||||
float dotNV = saturate( dot( N, V ) );
|
||||
|
||||
// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )
|
||||
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
||||
|
||||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||||
|
||||
return uv;
|
||||
|
||||
}
|
||||
|
||||
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
||||
|
||||
// Real-Time Area Lighting: a Journey from Research to Production (p.102)
|
||||
// An approximation of the form factor of a horizon-clipped rectangle.
|
||||
|
||||
float l = length( f );
|
||||
|
||||
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
||||
|
||||
}
|
||||
|
||||
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
||||
|
||||
float x = dot( v1, v2 );
|
||||
|
||||
float y = abs( x );
|
||||
|
||||
// rational polynomial approximation to theta / sin( theta ) / 2PI
|
||||
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
||||
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
||||
float v = a / b;
|
||||
|
||||
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
||||
|
||||
return cross( v1, v2 ) * theta_sintheta;
|
||||
|
||||
}
|
||||
|
||||
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
||||
|
||||
// bail if point is on back side of plane of light
|
||||
// assumes ccw winding order of light vertices
|
||||
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
||||
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
||||
vec3 lightNormal = cross( v1, v2 );
|
||||
|
||||
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
||||
|
||||
// construct orthonormal basis around N
|
||||
vec3 T1, T2;
|
||||
T1 = normalize( V - N * dot( V, N ) );
|
||||
T2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system
|
||||
|
||||
// compute transform
|
||||
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
||||
|
||||
// transform rect
|
||||
vec3 coords[ 4 ];
|
||||
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
||||
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
||||
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
||||
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
||||
|
||||
// project rect onto sphere
|
||||
coords[ 0 ] = normalize( coords[ 0 ] );
|
||||
coords[ 1 ] = normalize( coords[ 1 ] );
|
||||
coords[ 2 ] = normalize( coords[ 2 ] );
|
||||
coords[ 3 ] = normalize( coords[ 3 ] );
|
||||
|
||||
// calculate vector form factor
|
||||
vec3 vectorFormFactor = vec3( 0.0 );
|
||||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
||||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
||||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
||||
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
||||
|
||||
// adjust for horizon clipping
|
||||
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
||||
|
||||
/*
|
||||
// alternate method of adjusting for horizon clipping (see referece)
|
||||
// refactoring required
|
||||
float len = length( vectorFormFactor );
|
||||
float z = vectorFormFactor.z / len;
|
||||
|
||||
const float LUT_SIZE = 64.0;
|
||||
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
||||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||||
|
||||
// tabulated horizon-clipped sphere, apparently...
|
||||
vec2 uv = vec2( z * 0.5 + 0.5, len );
|
||||
uv = uv * LUT_SCALE + LUT_BIAS;
|
||||
|
||||
float scale = texture2D( ltc_2, uv ).w;
|
||||
|
||||
float result = len * scale;
|
||||
*/
|
||||
|
||||
return vec3( result );
|
||||
|
||||
}
|
||||
|
||||
// End Rect Area Light
|
||||
|
||||
|
||||
float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {
|
||||
|
||||
// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)
|
||||
return 0.25;
|
||||
|
||||
}
|
||||
|
||||
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
||||
|
||||
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
||||
|
||||
}
|
||||
|
||||
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
||||
|
||||
vec3 halfDir = normalize( lightDir + viewDir );
|
||||
|
||||
float dotNH = saturate( dot( normal, halfDir ) );
|
||||
float dotVH = saturate( dot( viewDir, halfDir ) );
|
||||
|
||||
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
||||
|
||||
float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );
|
||||
|
||||
float D = D_BlinnPhong( shininess, dotNH );
|
||||
|
||||
return F * ( G * D );
|
||||
|
||||
} // validated
|
||||
|
||||
#if defined( USE_SHEEN )
|
||||
|
||||
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
||||
float D_Charlie( float roughness, float dotNH ) {
|
||||
|
||||
float alpha = pow2( roughness );
|
||||
|
||||
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"
|
||||
float invAlpha = 1.0 / alpha;
|
||||
float cos2h = dotNH * dotNH;
|
||||
float sin2h = max( 1.0 - cos2h, 0.0078125 ); // 2^(-14/2), so sin2h^2 > 0 in fp16
|
||||
|
||||
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
||||
|
||||
}
|
||||
|
||||
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
||||
float V_Neubelt( float dotNV, float dotNL ) {
|
||||
|
||||
// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
|
||||
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
||||
|
||||
}
|
||||
|
||||
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
||||
|
||||
vec3 halfDir = normalize( lightDir + viewDir );
|
||||
|
||||
float dotNL = saturate( dot( normal, lightDir ) );
|
||||
float dotNV = saturate( dot( normal, viewDir ) );
|
||||
float dotNH = saturate( dot( normal, halfDir ) );
|
||||
|
||||
float D = D_Charlie( sheenRoughness, dotNH );
|
||||
float V = V_Neubelt( dotNV, dotNL );
|
||||
|
||||
return sheenColor * ( D * V );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
44
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js
generated
vendored
Normal file
44
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_BUMPMAP
|
||||
|
||||
uniform sampler2D bumpMap;
|
||||
uniform float bumpScale;
|
||||
|
||||
// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
|
||||
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
|
||||
|
||||
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
|
||||
|
||||
vec2 dHdxy_fwd() {
|
||||
|
||||
vec2 dSTdx = dFdx( vUv );
|
||||
vec2 dSTdy = dFdy( vUv );
|
||||
|
||||
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
|
||||
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
|
||||
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
|
||||
|
||||
return vec2( dBx, dBy );
|
||||
|
||||
}
|
||||
|
||||
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
||||
|
||||
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
||||
|
||||
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
|
||||
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
|
||||
vec3 vN = surf_norm; // normalized
|
||||
|
||||
vec3 R1 = cross( vSigmaY, vN );
|
||||
vec3 R2 = cross( vN, vSigmaX );
|
||||
|
||||
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
||||
|
||||
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
||||
return normalize( abs( fDet ) * surf_norm - vGrad );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
vec3 clearcoatNormal = geometryNormal;
|
||||
|
||||
#endif
|
||||
`;
|
||||
18
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js
generated
vendored
Normal file
18
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||||
|
||||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
|
||||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
clearcoatNormal = normalize( vTBN * clearcoatMapN );
|
||||
|
||||
#else
|
||||
|
||||
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
21
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js
generated
vendored
Normal file
21
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export default /* glsl */`
|
||||
|
||||
#ifdef USE_CLEARCOATMAP
|
||||
|
||||
uniform sampler2D clearcoatMap;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||||
|
||||
uniform sampler2D clearcoatRoughnessMap;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLEARCOAT_NORMALMAP
|
||||
|
||||
uniform sampler2D clearcoatNormalMap;
|
||||
uniform vec2 clearcoatNormalScale;
|
||||
|
||||
#endif
|
||||
`;
|
||||
33
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js
generated
vendored
Normal file
33
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
export default /* glsl */`
|
||||
#if NUM_CLIPPING_PLANES > 0
|
||||
|
||||
vec4 plane;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
||||
|
||||
plane = clippingPlanes[ i ];
|
||||
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
||||
|
||||
bool clipped = true;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
||||
|
||||
plane = clippingPlanes[ i ];
|
||||
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
if ( clipped ) discard;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
#if NUM_CLIPPING_PLANES > 0
|
||||
|
||||
varying vec3 vClipPosition;
|
||||
|
||||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#if NUM_CLIPPING_PLANES > 0
|
||||
|
||||
varying vec3 vClipPosition;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#if NUM_CLIPPING_PLANES > 0
|
||||
|
||||
vClipPosition = - mvPosition.xyz;
|
||||
|
||||
#endif
|
||||
`;
|
||||
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js
generated
vendored
Normal file
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_COLOR_ALPHA )
|
||||
|
||||
diffuseColor *= vColor;
|
||||
|
||||
#elif defined( USE_COLOR )
|
||||
|
||||
diffuseColor.rgb *= vColor;
|
||||
|
||||
#endif
|
||||
`;
|
||||
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js
generated
vendored
Normal file
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_COLOR_ALPHA )
|
||||
|
||||
varying vec4 vColor;
|
||||
|
||||
#elif defined( USE_COLOR )
|
||||
|
||||
varying vec3 vColor;
|
||||
|
||||
#endif
|
||||
`;
|
||||
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js
generated
vendored
Normal file
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_COLOR_ALPHA )
|
||||
|
||||
varying vec4 vColor;
|
||||
|
||||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
||||
|
||||
varying vec3 vColor;
|
||||
|
||||
#endif
|
||||
`;
|
||||
23
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js
generated
vendored
Normal file
23
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_COLOR_ALPHA )
|
||||
|
||||
vColor = vec4( 1.0 );
|
||||
|
||||
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
||||
|
||||
vColor = vec3( 1.0 );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_COLOR
|
||||
|
||||
vColor *= color;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_INSTANCING_COLOR
|
||||
|
||||
vColor.xyz *= instanceColor.xyz;
|
||||
|
||||
#endif
|
||||
`;
|
||||
116
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js
generated
vendored
Normal file
116
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
export default /* glsl */`
|
||||
#define PI 3.141592653589793
|
||||
#define PI2 6.283185307179586
|
||||
#define PI_HALF 1.5707963267948966
|
||||
#define RECIPROCAL_PI 0.3183098861837907
|
||||
#define RECIPROCAL_PI2 0.15915494309189535
|
||||
#define EPSILON 1e-6
|
||||
|
||||
#ifndef saturate
|
||||
// <tonemapping_pars_fragment> may have defined saturate() already
|
||||
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
||||
#endif
|
||||
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
||||
|
||||
float pow2( const in float x ) { return x*x; }
|
||||
float pow3( const in float x ) { return x*x*x; }
|
||||
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
||||
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
||||
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
|
||||
|
||||
// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.
|
||||
// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
|
||||
highp float rand( const in vec2 uv ) {
|
||||
|
||||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||||
|
||||
return fract( sin( sn ) * c );
|
||||
|
||||
}
|
||||
|
||||
#ifdef HIGH_PRECISION
|
||||
float precisionSafeLength( vec3 v ) { return length( v ); }
|
||||
#else
|
||||
float precisionSafeLength( vec3 v ) {
|
||||
float maxComponent = max3( abs( v ) );
|
||||
return length( v / maxComponent ) * maxComponent;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct IncidentLight {
|
||||
vec3 color;
|
||||
vec3 direction;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
struct ReflectedLight {
|
||||
vec3 directDiffuse;
|
||||
vec3 directSpecular;
|
||||
vec3 indirectDiffuse;
|
||||
vec3 indirectSpecular;
|
||||
};
|
||||
|
||||
struct GeometricContext {
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec3 viewDir;
|
||||
#ifdef USE_CLEARCOAT
|
||||
vec3 clearcoatNormal;
|
||||
#endif
|
||||
};
|
||||
|
||||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||||
|
||||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||||
|
||||
}
|
||||
|
||||
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
||||
|
||||
// dir can be either a direction vector or a normal vector
|
||||
// upper-left 3x3 of matrix is assumed to be orthogonal
|
||||
|
||||
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
||||
|
||||
}
|
||||
|
||||
mat3 transposeMat3( const in mat3 m ) {
|
||||
|
||||
mat3 tmp;
|
||||
|
||||
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
||||
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
||||
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
||||
|
||||
return tmp;
|
||||
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Relative_luminance
|
||||
float linearToRelativeLuminance( const in vec3 color ) {
|
||||
|
||||
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
|
||||
|
||||
return dot( weights, color.rgb );
|
||||
|
||||
}
|
||||
|
||||
bool isPerspectiveMatrix( mat4 m ) {
|
||||
|
||||
return m[ 2 ][ 3 ] == - 1.0;
|
||||
|
||||
}
|
||||
|
||||
vec2 equirectUv( in vec3 dir ) {
|
||||
|
||||
// dir is assumed to be unit length
|
||||
|
||||
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
||||
|
||||
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
||||
|
||||
return vec2( u, v );
|
||||
|
||||
}
|
||||
`;
|
||||
191
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js
generated
vendored
Normal file
191
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
export default /* glsl */`
|
||||
#ifdef ENVMAP_TYPE_CUBE_UV
|
||||
|
||||
#define cubeUV_minMipLevel 4.0
|
||||
#define cubeUV_minTileSize 16.0
|
||||
|
||||
// These shader functions convert between the UV coordinates of a single face of
|
||||
// a cubemap, the 0-5 integer index of a cube face, and the direction vector for
|
||||
// sampling a textureCube (not generally normalized ).
|
||||
|
||||
float getFace( vec3 direction ) {
|
||||
|
||||
vec3 absDirection = abs( direction );
|
||||
|
||||
float face = - 1.0;
|
||||
|
||||
if ( absDirection.x > absDirection.z ) {
|
||||
|
||||
if ( absDirection.x > absDirection.y )
|
||||
|
||||
face = direction.x > 0.0 ? 0.0 : 3.0;
|
||||
|
||||
else
|
||||
|
||||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||||
|
||||
} else {
|
||||
|
||||
if ( absDirection.z > absDirection.y )
|
||||
|
||||
face = direction.z > 0.0 ? 2.0 : 5.0;
|
||||
|
||||
else
|
||||
|
||||
face = direction.y > 0.0 ? 1.0 : 4.0;
|
||||
|
||||
}
|
||||
|
||||
return face;
|
||||
|
||||
}
|
||||
|
||||
// RH coordinate system; PMREM face-indexing convention
|
||||
vec2 getUV( vec3 direction, float face ) {
|
||||
|
||||
vec2 uv;
|
||||
|
||||
if ( face == 0.0 ) {
|
||||
|
||||
uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x
|
||||
|
||||
} else if ( face == 1.0 ) {
|
||||
|
||||
uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y
|
||||
|
||||
} else if ( face == 2.0 ) {
|
||||
|
||||
uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z
|
||||
|
||||
} else if ( face == 3.0 ) {
|
||||
|
||||
uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x
|
||||
|
||||
} else if ( face == 4.0 ) {
|
||||
|
||||
uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y
|
||||
|
||||
} else {
|
||||
|
||||
uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z
|
||||
|
||||
}
|
||||
|
||||
return 0.5 * ( uv + 1.0 );
|
||||
|
||||
}
|
||||
|
||||
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
||||
|
||||
float face = getFace( direction );
|
||||
|
||||
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
||||
|
||||
mipInt = max( mipInt, cubeUV_minMipLevel );
|
||||
|
||||
float faceSize = exp2( mipInt );
|
||||
|
||||
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;
|
||||
|
||||
if ( face > 2.0 ) {
|
||||
|
||||
uv.y += faceSize;
|
||||
|
||||
face -= 3.0;
|
||||
|
||||
}
|
||||
|
||||
uv.x += face * faceSize;
|
||||
|
||||
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
||||
|
||||
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
||||
|
||||
uv.x *= CUBEUV_TEXEL_WIDTH;
|
||||
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
||||
|
||||
#ifdef texture2DGradEXT
|
||||
|
||||
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; // disable anisotropic filtering
|
||||
|
||||
#else
|
||||
|
||||
return texture2D( envMap, uv ).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// These defines must match with PMREMGenerator
|
||||
|
||||
#define r0 1.0
|
||||
#define v0 0.339
|
||||
#define m0 - 2.0
|
||||
#define r1 0.8
|
||||
#define v1 0.276
|
||||
#define m1 - 1.0
|
||||
#define r4 0.4
|
||||
#define v4 0.046
|
||||
#define m4 2.0
|
||||
#define r5 0.305
|
||||
#define v5 0.016
|
||||
#define m5 3.0
|
||||
#define r6 0.21
|
||||
#define v6 0.0038
|
||||
#define m6 4.0
|
||||
|
||||
float roughnessToMip( float roughness ) {
|
||||
|
||||
float mip = 0.0;
|
||||
|
||||
if ( roughness >= r1 ) {
|
||||
|
||||
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
|
||||
|
||||
} else if ( roughness >= r4 ) {
|
||||
|
||||
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
|
||||
|
||||
} else if ( roughness >= r5 ) {
|
||||
|
||||
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
|
||||
|
||||
} else if ( roughness >= r6 ) {
|
||||
|
||||
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
|
||||
|
||||
} else {
|
||||
|
||||
mip = - 2.0 * log2( 1.16 * roughness ); // 1.16 = 1.79^0.25
|
||||
}
|
||||
|
||||
return mip;
|
||||
|
||||
}
|
||||
|
||||
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
||||
|
||||
float mip = clamp( roughnessToMip( roughness ), m0, CUBEUV_MAX_MIP );
|
||||
|
||||
float mipF = fract( mip );
|
||||
|
||||
float mipInt = floor( mip );
|
||||
|
||||
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
||||
|
||||
if ( mipF == 0.0 ) {
|
||||
|
||||
return vec4( color0, 1.0 );
|
||||
|
||||
} else {
|
||||
|
||||
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
||||
|
||||
return vec4( mix( color0, color1, mipF ), 1.0 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js
generated
vendored
Normal file
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default /* glsl */`
|
||||
void main() {
|
||||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
`;
|
||||
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js
generated
vendored
Normal file
5
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default /* glsl */`
|
||||
void main() {
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
}
|
||||
`;
|
||||
36
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js
generated
vendored
Normal file
36
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export default /* glsl */`
|
||||
vec3 transformedNormal = objectNormal;
|
||||
|
||||
#ifdef USE_INSTANCING
|
||||
|
||||
// this is in lieu of a per-instance normal-matrix
|
||||
// shear transforms in the instance matrix are not supported
|
||||
|
||||
mat3 m = mat3( instanceMatrix );
|
||||
|
||||
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
||||
|
||||
transformedNormal = m * transformedNormal;
|
||||
|
||||
#endif
|
||||
|
||||
transformedNormal = normalMatrix * transformedNormal;
|
||||
|
||||
#ifdef FLIP_SIDED
|
||||
|
||||
transformedNormal = - transformedNormal;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||||
|
||||
#ifdef FLIP_SIDED
|
||||
|
||||
transformedTangent = - transformedTangent;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_DISPLACEMENTMAP
|
||||
|
||||
uniform sampler2D displacementMap;
|
||||
uniform float displacementScale;
|
||||
uniform float displacementBias;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_DISPLACEMENTMAP
|
||||
|
||||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef DITHERING
|
||||
|
||||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||||
|
||||
#endif
|
||||
`;
|
||||
20
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js
generated
vendored
Normal file
20
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export default /* glsl */`
|
||||
#ifdef DITHERING
|
||||
|
||||
// based on https://www.shadertoy.com/view/MslGR8
|
||||
vec3 dithering( vec3 color ) {
|
||||
//Calculate grid position
|
||||
float grid_position = rand( gl_FragCoord.xy );
|
||||
|
||||
//Shift the individual colors differently, thus making it even harder to see the dithering pattern
|
||||
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
||||
|
||||
//modify shift acording to grid position.
|
||||
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
||||
|
||||
//shift the color by dither_shift
|
||||
return color + dither_shift_RGB;
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_EMISSIVEMAP
|
||||
|
||||
vec4 emissiveColor = texture2D( emissiveMap, vUv );
|
||||
|
||||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_EMISSIVEMAP
|
||||
|
||||
uniform sampler2D emissiveMap;
|
||||
|
||||
#endif
|
||||
`;
|
||||
3
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js
generated
vendored
Normal file
3
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default /* glsl */`
|
||||
gl_FragColor = linearToOutputTexel( gl_FragColor );
|
||||
`;
|
||||
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js
generated
vendored
Normal file
11
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export default /* glsl */`
|
||||
|
||||
vec4 LinearToLinear( in vec4 value ) {
|
||||
return value;
|
||||
}
|
||||
|
||||
vec4 LinearTosRGB( in vec4 value ) {
|
||||
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
||||
}
|
||||
|
||||
`;
|
||||
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js
generated
vendored
Normal file
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ENVMAP
|
||||
|
||||
uniform float envMapIntensity;
|
||||
uniform float flipEnvMap;
|
||||
|
||||
#ifdef ENVMAP_TYPE_CUBE
|
||||
uniform samplerCube envMap;
|
||||
#else
|
||||
uniform sampler2D envMap;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
66
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
generated
vendored
Normal file
66
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ENVMAP
|
||||
|
||||
#ifdef ENV_WORLDPOS
|
||||
|
||||
vec3 cameraToFrag;
|
||||
|
||||
if ( isOrthographic ) {
|
||||
|
||||
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||||
|
||||
} else {
|
||||
|
||||
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
||||
|
||||
}
|
||||
|
||||
// Transforming Normal Vectors with the Inverse Transformation
|
||||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||||
|
||||
#ifdef ENVMAP_MODE_REFLECTION
|
||||
|
||||
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
||||
|
||||
#else
|
||||
|
||||
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
vec3 reflectVec = vReflect;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENVMAP_TYPE_CUBE
|
||||
|
||||
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
||||
|
||||
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
||||
|
||||
vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
|
||||
|
||||
#else
|
||||
|
||||
vec4 envColor = vec4( 0.0 );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENVMAP_BLENDING_MULTIPLY
|
||||
|
||||
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
||||
|
||||
#elif defined( ENVMAP_BLENDING_MIX )
|
||||
|
||||
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
||||
|
||||
#elif defined( ENVMAP_BLENDING_ADD )
|
||||
|
||||
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
21
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js
generated
vendored
Normal file
21
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ENVMAP
|
||||
|
||||
uniform float reflectivity;
|
||||
|
||||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
||||
|
||||
#define ENV_WORLDPOS
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENV_WORLDPOS
|
||||
|
||||
varying vec3 vWorldPosition;
|
||||
uniform float refractionRatio;
|
||||
#else
|
||||
varying vec3 vReflect;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
22
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js
generated
vendored
Normal file
22
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ENVMAP
|
||||
|
||||
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
|
||||
|
||||
#define ENV_WORLDPOS
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENV_WORLDPOS
|
||||
|
||||
varying vec3 vWorldPosition;
|
||||
|
||||
#else
|
||||
|
||||
varying vec3 vReflect;
|
||||
uniform float refractionRatio;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
62
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js
generated
vendored
Normal file
62
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_ENVMAP )
|
||||
|
||||
#ifdef ENVMAP_MODE_REFRACTION
|
||||
|
||||
uniform float refractionRatio;
|
||||
|
||||
#endif
|
||||
|
||||
vec3 getIBLIrradiance( const in vec3 normal ) {
|
||||
|
||||
#if defined( ENVMAP_TYPE_CUBE_UV )
|
||||
|
||||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||||
|
||||
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
||||
|
||||
return PI * envMapColor.rgb * envMapIntensity;
|
||||
|
||||
#else
|
||||
|
||||
return vec3( 0.0 );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
||||
|
||||
#if defined( ENVMAP_TYPE_CUBE_UV )
|
||||
|
||||
vec3 reflectVec;
|
||||
|
||||
#ifdef ENVMAP_MODE_REFLECTION
|
||||
|
||||
reflectVec = reflect( - viewDir, normal );
|
||||
|
||||
// Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.
|
||||
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
||||
|
||||
#else
|
||||
|
||||
reflectVec = refract( - viewDir, normal, refractionRatio );
|
||||
|
||||
#endif
|
||||
|
||||
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
||||
|
||||
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
||||
|
||||
return envMapColor.rgb * envMapIntensity;
|
||||
|
||||
#else
|
||||
|
||||
return vec3( 0.0 );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
37
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
generated
vendored
Normal file
37
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ENVMAP
|
||||
|
||||
#ifdef ENV_WORLDPOS
|
||||
|
||||
vWorldPosition = worldPosition.xyz;
|
||||
|
||||
#else
|
||||
|
||||
vec3 cameraToVertex;
|
||||
|
||||
if ( isOrthographic ) {
|
||||
|
||||
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
||||
|
||||
} else {
|
||||
|
||||
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
||||
|
||||
}
|
||||
|
||||
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||||
|
||||
#ifdef ENVMAP_MODE_REFLECTION
|
||||
|
||||
vReflect = reflect( cameraToVertex, worldNormal );
|
||||
|
||||
#else
|
||||
|
||||
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
17
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js
generated
vendored
Normal file
17
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_FOG
|
||||
|
||||
#ifdef FOG_EXP2
|
||||
|
||||
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
||||
|
||||
#else
|
||||
|
||||
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
||||
|
||||
#endif
|
||||
|
||||
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
||||
|
||||
#endif
|
||||
`;
|
||||
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js
generated
vendored
Normal file
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_FOG
|
||||
|
||||
uniform vec3 fogColor;
|
||||
varying float vFogDepth;
|
||||
|
||||
#ifdef FOG_EXP2
|
||||
|
||||
uniform float fogDensity;
|
||||
|
||||
#else
|
||||
|
||||
uniform float fogNear;
|
||||
uniform float fogFar;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_FOG
|
||||
|
||||
varying float vFogDepth;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_FOG
|
||||
|
||||
vFogDepth = - mvPosition.z;
|
||||
|
||||
#endif
|
||||
`;
|
||||
26
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js
generated
vendored
Normal file
26
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export default /* glsl */`
|
||||
|
||||
#ifdef USE_GRADIENTMAP
|
||||
|
||||
uniform sampler2D gradientMap;
|
||||
|
||||
#endif
|
||||
|
||||
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
||||
|
||||
// dotNL will be from -1.0 to 1.0
|
||||
float dotNL = dot( normal, lightDirection );
|
||||
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
||||
|
||||
#ifdef USE_GRADIENTMAP
|
||||
|
||||
return vec3( texture2D( gradientMap, coord ).r );
|
||||
|
||||
#else
|
||||
|
||||
return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
`;
|
||||
16
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js
generated
vendored
Normal file
16
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_LIGHTMAP
|
||||
|
||||
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
||||
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
||||
|
||||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||||
|
||||
lightMapIrradiance *= PI;
|
||||
|
||||
#endif
|
||||
|
||||
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
||||
|
||||
#endif
|
||||
`;
|
||||
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js
generated
vendored
Normal file
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_LIGHTMAP
|
||||
|
||||
uniform sampler2D lightMap;
|
||||
uniform float lightMapIntensity;
|
||||
|
||||
#endif
|
||||
`;
|
||||
152
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
generated
vendored
Normal file
152
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
export default /* glsl */`
|
||||
/**
|
||||
* This is a template that can be used to light a material, it uses pluggable
|
||||
* RenderEquations (RE)for specific lighting scenarios.
|
||||
*
|
||||
* Instructions for use:
|
||||
* - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined
|
||||
* - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???
|
||||
* - Create a material parameter that is to be passed as the third parameter to your lighting functions.
|
||||
*
|
||||
* TODO:
|
||||
* - Add area light support.
|
||||
* - Add sphere light support.
|
||||
* - Add diffuse light probe (irradiance cubemap) support.
|
||||
*/
|
||||
|
||||
GeometricContext geometry;
|
||||
|
||||
geometry.position = - vViewPosition;
|
||||
geometry.normal = normal;
|
||||
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
geometry.clearcoatNormal = clearcoatNormal;
|
||||
|
||||
#endif
|
||||
|
||||
IncidentLight directLight;
|
||||
|
||||
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
||||
|
||||
PointLight pointLight;
|
||||
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
||||
PointLightShadow pointLightShadow;
|
||||
#endif
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||||
|
||||
pointLight = pointLights[ i ];
|
||||
|
||||
getPointLightInfo( pointLight, geometry, directLight );
|
||||
|
||||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
||||
pointLightShadow = pointLightShadows[ i ];
|
||||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
||||
#endif
|
||||
|
||||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
||||
|
||||
SpotLight spotLight;
|
||||
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
||||
SpotLightShadow spotLightShadow;
|
||||
#endif
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||||
|
||||
spotLight = spotLights[ i ];
|
||||
|
||||
getSpotLightInfo( spotLight, geometry, directLight );
|
||||
|
||||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
||||
spotLightShadow = spotLightShadows[ i ];
|
||||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||||
#endif
|
||||
|
||||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
||||
|
||||
DirectionalLight directionalLight;
|
||||
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
||||
DirectionalLightShadow directionalLightShadow;
|
||||
#endif
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||||
|
||||
directionalLight = directionalLights[ i ];
|
||||
|
||||
getDirectionalLightInfo( directionalLight, geometry, directLight );
|
||||
|
||||
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
||||
directionalLightShadow = directionalLightShadows[ i ];
|
||||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||||
#endif
|
||||
|
||||
RE_Direct( directLight, geometry, material, reflectedLight );
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
||||
|
||||
RectAreaLight rectAreaLight;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
||||
|
||||
rectAreaLight = rectAreaLights[ i ];
|
||||
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( RE_IndirectDiffuse )
|
||||
|
||||
vec3 iblIrradiance = vec3( 0.0 );
|
||||
|
||||
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
||||
|
||||
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
||||
|
||||
#if ( NUM_HEMI_LIGHTS > 0 )
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||||
|
||||
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( RE_IndirectSpecular )
|
||||
|
||||
vec3 radiance = vec3( 0.0 );
|
||||
vec3 clearcoatRadiance = vec3( 0.0 );
|
||||
|
||||
#endif
|
||||
`;
|
||||
13
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js
generated
vendored
Normal file
13
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export default /* glsl */`
|
||||
#if defined( RE_IndirectDiffuse )
|
||||
|
||||
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( RE_IndirectSpecular )
|
||||
|
||||
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
||||
|
||||
#endif
|
||||
`;
|
||||
38
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js
generated
vendored
Normal file
38
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
export default /* glsl */`
|
||||
#if defined( RE_IndirectDiffuse )
|
||||
|
||||
#ifdef USE_LIGHTMAP
|
||||
|
||||
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
||||
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
||||
|
||||
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
||||
|
||||
lightMapIrradiance *= PI;
|
||||
|
||||
#endif
|
||||
|
||||
irradiance += lightMapIrradiance;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
||||
|
||||
iblIrradiance += getIBLIrradiance( geometry.normal );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
||||
|
||||
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
122
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js
generated
vendored
Normal file
122
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
export default /* glsl */`
|
||||
vec3 diffuse = vec3( 1.0 );
|
||||
|
||||
GeometricContext geometry;
|
||||
geometry.position = mvPosition.xyz;
|
||||
geometry.normal = normalize( transformedNormal );
|
||||
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
||||
|
||||
GeometricContext backGeometry;
|
||||
backGeometry.position = geometry.position;
|
||||
backGeometry.normal = -geometry.normal;
|
||||
backGeometry.viewDir = geometry.viewDir;
|
||||
|
||||
vLightFront = vec3( 0.0 );
|
||||
vIndirectFront = vec3( 0.0 );
|
||||
#ifdef DOUBLE_SIDED
|
||||
vLightBack = vec3( 0.0 );
|
||||
vIndirectBack = vec3( 0.0 );
|
||||
#endif
|
||||
|
||||
IncidentLight directLight;
|
||||
float dotNL;
|
||||
vec3 directLightColor_Diffuse;
|
||||
|
||||
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
|
||||
|
||||
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
|
||||
|
||||
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_POINT_LIGHTS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
||||
|
||||
getPointLightInfo( pointLights[ i ], geometry, directLight );
|
||||
|
||||
dotNL = dot( geometry.normal, directLight.direction );
|
||||
directLightColor_Diffuse = directLight.color;
|
||||
|
||||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_SPOT_LIGHTS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
||||
|
||||
getSpotLightInfo( spotLights[ i ], geometry, directLight );
|
||||
|
||||
dotNL = dot( geometry.normal, directLight.direction );
|
||||
directLightColor_Diffuse = directLight.color;
|
||||
|
||||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#endif
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_DIR_LIGHTS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
||||
|
||||
getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
|
||||
|
||||
dotNL = dot( geometry.normal, directLight.direction );
|
||||
directLightColor_Diffuse = directLight.color;
|
||||
|
||||
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_HEMI_LIGHTS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
||||
|
||||
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
`;
|
||||
223
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
generated
vendored
Normal file
223
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
export default /* glsl */`
|
||||
uniform bool receiveShadow;
|
||||
uniform vec3 ambientLightColor;
|
||||
uniform vec3 lightProbe[ 9 ];
|
||||
|
||||
// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
|
||||
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
|
||||
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
||||
|
||||
// normal is assumed to have unit length
|
||||
|
||||
float x = normal.x, y = normal.y, z = normal.z;
|
||||
|
||||
// band 0
|
||||
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
||||
|
||||
// band 1
|
||||
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
||||
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
||||
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
||||
|
||||
// band 2
|
||||
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
||||
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
||||
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
||||
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
||||
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
||||
|
||||
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
||||
|
||||
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
||||
|
||||
return irradiance;
|
||||
|
||||
}
|
||||
|
||||
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
||||
|
||||
vec3 irradiance = ambientLightColor;
|
||||
|
||||
return irradiance;
|
||||
|
||||
}
|
||||
|
||||
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
||||
|
||||
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
|
||||
|
||||
// based upon Frostbite 3 Moving to Physically-based Rendering
|
||||
// page 32, equation 26: E[window1]
|
||||
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
||||
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
||||
|
||||
if ( cutoffDistance > 0.0 ) {
|
||||
|
||||
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
||||
|
||||
}
|
||||
|
||||
return distanceFalloff;
|
||||
|
||||
#else
|
||||
|
||||
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
||||
|
||||
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
||||
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
||||
|
||||
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
||||
|
||||
}
|
||||
|
||||
#if NUM_DIR_LIGHTS > 0
|
||||
|
||||
struct DirectionalLight {
|
||||
vec3 direction;
|
||||
vec3 color;
|
||||
};
|
||||
|
||||
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
||||
|
||||
void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
|
||||
|
||||
light.color = directionalLight.color;
|
||||
light.direction = directionalLight.direction;
|
||||
light.visible = true;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if NUM_POINT_LIGHTS > 0
|
||||
|
||||
struct PointLight {
|
||||
vec3 position;
|
||||
vec3 color;
|
||||
float distance;
|
||||
float decay;
|
||||
};
|
||||
|
||||
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
||||
|
||||
// light is an out parameter as having it as a return value caused compiler errors on some devices
|
||||
void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
|
||||
|
||||
vec3 lVector = pointLight.position - geometry.position;
|
||||
|
||||
light.direction = normalize( lVector );
|
||||
|
||||
float lightDistance = length( lVector );
|
||||
|
||||
light.color = pointLight.color;
|
||||
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
||||
light.visible = ( light.color != vec3( 0.0 ) );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if NUM_SPOT_LIGHTS > 0
|
||||
|
||||
struct SpotLight {
|
||||
vec3 position;
|
||||
vec3 direction;
|
||||
vec3 color;
|
||||
float distance;
|
||||
float decay;
|
||||
float coneCos;
|
||||
float penumbraCos;
|
||||
};
|
||||
|
||||
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
||||
|
||||
// light is an out parameter as having it as a return value caused compiler errors on some devices
|
||||
void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
|
||||
|
||||
vec3 lVector = spotLight.position - geometry.position;
|
||||
|
||||
light.direction = normalize( lVector );
|
||||
|
||||
float angleCos = dot( light.direction, spotLight.direction );
|
||||
|
||||
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
||||
|
||||
if ( spotAttenuation > 0.0 ) {
|
||||
|
||||
float lightDistance = length( lVector );
|
||||
|
||||
light.color = spotLight.color * spotAttenuation;
|
||||
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
||||
light.visible = ( light.color != vec3( 0.0 ) );
|
||||
|
||||
} else {
|
||||
|
||||
light.color = vec3( 0.0 );
|
||||
light.visible = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
struct RectAreaLight {
|
||||
vec3 color;
|
||||
vec3 position;
|
||||
vec3 halfWidth;
|
||||
vec3 halfHeight;
|
||||
};
|
||||
|
||||
// Pre-computed values of LinearTransformedCosine approximation of BRDF
|
||||
// BRDF approximation Texture is 64x64
|
||||
uniform sampler2D ltc_1; // RGBA Float
|
||||
uniform sampler2D ltc_2; // RGBA Float
|
||||
|
||||
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if NUM_HEMI_LIGHTS > 0
|
||||
|
||||
struct HemisphereLight {
|
||||
vec3 direction;
|
||||
vec3 skyColor;
|
||||
vec3 groundColor;
|
||||
};
|
||||
|
||||
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
||||
|
||||
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
||||
|
||||
float dotNL = dot( normal, hemiLight.direction );
|
||||
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
||||
|
||||
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
||||
|
||||
return irradiance;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
BlinnPhongMaterial material;
|
||||
material.diffuseColor = diffuseColor.rgb;
|
||||
material.specularColor = specular;
|
||||
material.specularShininess = shininess;
|
||||
material.specularStrength = specularStrength;
|
||||
`;
|
||||
34
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js
generated
vendored
Normal file
34
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
export default /* glsl */`
|
||||
varying vec3 vViewPosition;
|
||||
|
||||
struct BlinnPhongMaterial {
|
||||
|
||||
vec3 diffuseColor;
|
||||
vec3 specularColor;
|
||||
float specularShininess;
|
||||
float specularStrength;
|
||||
|
||||
};
|
||||
|
||||
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||||
vec3 irradiance = dotNL * directLight.color;
|
||||
|
||||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
|
||||
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
||||
|
||||
}
|
||||
|
||||
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
|
||||
}
|
||||
|
||||
#define RE_Direct RE_Direct_BlinnPhong
|
||||
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
|
||||
|
||||
#define Material_LightProbeLOD( material ) (0)
|
||||
`;
|
||||
95
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js
generated
vendored
Normal file
95
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
export default /* glsl */`
|
||||
PhysicalMaterial material;
|
||||
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
||||
|
||||
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
||||
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
||||
|
||||
material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.
|
||||
material.roughness += geometryRoughness;
|
||||
material.roughness = min( material.roughness, 1.0 );
|
||||
|
||||
#ifdef IOR
|
||||
|
||||
#ifdef SPECULAR
|
||||
|
||||
float specularIntensityFactor = specularIntensity;
|
||||
vec3 specularColorFactor = specularColor;
|
||||
|
||||
#ifdef USE_SPECULARINTENSITYMAP
|
||||
|
||||
specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPECULARCOLORMAP
|
||||
|
||||
specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
||||
|
||||
#else
|
||||
|
||||
float specularIntensityFactor = 1.0;
|
||||
vec3 specularColorFactor = vec3( 1.0 );
|
||||
material.specularF90 = 1.0;
|
||||
|
||||
#endif
|
||||
|
||||
material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
||||
|
||||
#else
|
||||
|
||||
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
||||
material.specularF90 = 1.0;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
material.clearcoat = clearcoat;
|
||||
material.clearcoatRoughness = clearcoatRoughness;
|
||||
material.clearcoatF0 = vec3( 0.04 );
|
||||
material.clearcoatF90 = 1.0;
|
||||
|
||||
#ifdef USE_CLEARCOATMAP
|
||||
|
||||
material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
||||
|
||||
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
|
||||
|
||||
#endif
|
||||
|
||||
material.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model
|
||||
material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
||||
material.clearcoatRoughness += geometryRoughness;
|
||||
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHEEN
|
||||
|
||||
material.sheenColor = sheenColor;
|
||||
|
||||
#ifdef USE_SHEENCOLORMAP
|
||||
|
||||
material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
||||
|
||||
#ifdef USE_SHEENROUGHNESSMAP
|
||||
|
||||
material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
214
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
generated
vendored
Normal file
214
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
export default /* glsl */`
|
||||
struct PhysicalMaterial {
|
||||
|
||||
vec3 diffuseColor;
|
||||
float roughness;
|
||||
vec3 specularColor;
|
||||
float specularF90;
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
float clearcoat;
|
||||
float clearcoatRoughness;
|
||||
vec3 clearcoatF0;
|
||||
float clearcoatF90;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHEEN
|
||||
vec3 sheenColor;
|
||||
float sheenRoughness;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// temporary
|
||||
vec3 clearcoatSpecular = vec3( 0.0 );
|
||||
vec3 sheenSpecular = vec3( 0.0 );
|
||||
|
||||
// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from
|
||||
// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found
|
||||
// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
||||
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
|
||||
|
||||
float dotNV = saturate( dot( normal, viewDir ) );
|
||||
|
||||
float r2 = roughness * roughness;
|
||||
|
||||
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
||||
|
||||
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
||||
|
||||
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
||||
|
||||
return saturate( DG * RECIPROCAL_PI );
|
||||
|
||||
}
|
||||
|
||||
// Analytical approximation of the DFG LUT, one half of the
|
||||
// split-sum approximation used in indirect specular lighting.
|
||||
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
|
||||
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
|
||||
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
||||
|
||||
float dotNV = saturate( dot( normal, viewDir ) );
|
||||
|
||||
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
||||
|
||||
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
||||
|
||||
vec4 r = roughness * c0 + c1;
|
||||
|
||||
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
||||
|
||||
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
||||
|
||||
return fab;
|
||||
|
||||
}
|
||||
|
||||
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
||||
|
||||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||||
|
||||
return specularColor * fab.x + specularF90 * fab.y;
|
||||
|
||||
}
|
||||
|
||||
// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
|
||||
// Approximates multiscattering in order to preserve energy.
|
||||
// http://www.jcgt.org/published/0008/01/03/
|
||||
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
||||
|
||||
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
||||
|
||||
vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
|
||||
|
||||
float Ess = fab.x + fab.y;
|
||||
float Ems = 1.0 - Ess;
|
||||
|
||||
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21
|
||||
vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
||||
|
||||
singleScatter += FssEss;
|
||||
multiScatter += Fms * Ems;
|
||||
|
||||
}
|
||||
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
vec3 normal = geometry.normal;
|
||||
vec3 viewDir = geometry.viewDir;
|
||||
vec3 position = geometry.position;
|
||||
vec3 lightPos = rectAreaLight.position;
|
||||
vec3 halfWidth = rectAreaLight.halfWidth;
|
||||
vec3 halfHeight = rectAreaLight.halfHeight;
|
||||
vec3 lightColor = rectAreaLight.color;
|
||||
float roughness = material.roughness;
|
||||
|
||||
vec3 rectCoords[ 4 ];
|
||||
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction
|
||||
rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
||||
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
||||
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
||||
|
||||
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
||||
|
||||
vec4 t1 = texture2D( ltc_1, uv );
|
||||
vec4 t2 = texture2D( ltc_2, uv );
|
||||
|
||||
mat3 mInv = mat3(
|
||||
vec3( t1.x, 0, t1.y ),
|
||||
vec3( 0, 1, 0 ),
|
||||
vec3( t1.z, 0, t1.w )
|
||||
);
|
||||
|
||||
// LTC Fresnel Approximation by Stephen Hill
|
||||
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
|
||||
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
||||
|
||||
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
||||
|
||||
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
||||
|
||||
vec3 irradiance = dotNL * directLight.color;
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
||||
|
||||
vec3 ccIrradiance = dotNLcc * directLight.color;
|
||||
|
||||
clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHEEN
|
||||
|
||||
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
||||
|
||||
#endif
|
||||
|
||||
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
|
||||
|
||||
|
||||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
}
|
||||
|
||||
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
|
||||
}
|
||||
|
||||
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
||||
|
||||
#ifdef USE_CLEARCOAT
|
||||
|
||||
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHEEN
|
||||
|
||||
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
||||
|
||||
#endif
|
||||
|
||||
// Both indirect specular and indirect diffuse light accumulate here
|
||||
|
||||
vec3 singleScattering = vec3( 0.0 );
|
||||
vec3 multiScattering = vec3( 0.0 );
|
||||
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
||||
|
||||
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
||||
|
||||
vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
|
||||
|
||||
reflectedLight.indirectSpecular += radiance * singleScattering;
|
||||
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
||||
|
||||
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
||||
|
||||
}
|
||||
|
||||
#define RE_Direct RE_Direct_Physical
|
||||
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
||||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
||||
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
||||
|
||||
// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
||||
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
||||
|
||||
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
||||
|
||||
}
|
||||
`;
|
||||
4
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js
generated
vendored
Normal file
4
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default /* glsl */`
|
||||
ToonMaterial material;
|
||||
material.diffuseColor = diffuseColor.rgb;
|
||||
`;
|
||||
28
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js
generated
vendored
Normal file
28
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
export default /* glsl */`
|
||||
varying vec3 vViewPosition;
|
||||
|
||||
struct ToonMaterial {
|
||||
|
||||
vec3 diffuseColor;
|
||||
|
||||
};
|
||||
|
||||
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
||||
|
||||
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
|
||||
}
|
||||
|
||||
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
||||
|
||||
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
||||
|
||||
}
|
||||
|
||||
#define RE_Direct RE_Direct_Toon
|
||||
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
||||
|
||||
#define Material_LightProbeLOD( material ) (0)
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||||
|
||||
// Doing a strict comparison with == 1.0 can cause noise artifacts
|
||||
// on some platforms. See issue #17623.
|
||||
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||||
|
||||
#endif
|
||||
`;
|
||||
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js
generated
vendored
Normal file
9
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
||||
|
||||
uniform float logDepthBufFC;
|
||||
varying float vFragDepth;
|
||||
varying float vIsPerspective;
|
||||
|
||||
#endif
|
||||
`;
|
||||
16
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js
generated
vendored
Normal file
16
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_LOGDEPTHBUF
|
||||
|
||||
#ifdef USE_LOGDEPTHBUF_EXT
|
||||
|
||||
varying float vFragDepth;
|
||||
varying float vIsPerspective;
|
||||
|
||||
#else
|
||||
|
||||
uniform float logDepthBufFC;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
22
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js
generated
vendored
Normal file
22
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_LOGDEPTHBUF
|
||||
|
||||
#ifdef USE_LOGDEPTHBUF_EXT
|
||||
|
||||
vFragDepth = 1.0 + gl_Position.w;
|
||||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||||
|
||||
#else
|
||||
|
||||
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
||||
|
||||
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
||||
|
||||
gl_Position.z *= gl_Position.w;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
17
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js
generated
vendored
Normal file
17
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_MAP
|
||||
|
||||
vec4 sampledDiffuseColor = texture2D( map, vUv );
|
||||
|
||||
#ifdef DECODE_VIDEO_TEXTURE
|
||||
|
||||
// inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
|
||||
|
||||
sampledDiffuseColor = 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 );
|
||||
|
||||
#endif
|
||||
|
||||
diffuseColor *= sampledDiffuseColor;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_MAP
|
||||
|
||||
uniform sampler2D map;
|
||||
|
||||
#endif
|
||||
`;
|
||||
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js
generated
vendored
Normal file
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||||
|
||||
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_MAP
|
||||
|
||||
diffuseColor *= texture2D( map, uv );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_ALPHAMAP
|
||||
|
||||
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
||||
|
||||
#endif
|
||||
`;
|
||||
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js
generated
vendored
Normal file
19
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
||||
|
||||
uniform mat3 uvTransform;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_MAP
|
||||
|
||||
uniform sampler2D map;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_ALPHAMAP
|
||||
|
||||
uniform sampler2D alphaMap;
|
||||
|
||||
#endif
|
||||
`;
|
||||
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js
generated
vendored
Normal file
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default /* glsl */`
|
||||
float metalnessFactor = metalness;
|
||||
|
||||
#ifdef USE_METALNESSMAP
|
||||
|
||||
vec4 texelMetalness = texture2D( metalnessMap, vUv );
|
||||
|
||||
// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
|
||||
metalnessFactor *= texelMetalness.b;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_METALNESSMAP
|
||||
|
||||
uniform sampler2D metalnessMap;
|
||||
|
||||
#endif
|
||||
`;
|
||||
24
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js
generated
vendored
Normal file
24
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
export default /* glsl */`
|
||||
#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
|
||||
|
||||
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
|
||||
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)
|
||||
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
|
||||
vColor *= morphTargetBaseInfluence;
|
||||
|
||||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||||
|
||||
#if defined( USE_COLOR_ALPHA )
|
||||
|
||||
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
||||
|
||||
#elif defined( USE_COLOR )
|
||||
|
||||
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
27
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js
generated
vendored
Normal file
27
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_MORPHNORMALS
|
||||
|
||||
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
|
||||
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)
|
||||
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
|
||||
objectNormal *= morphTargetBaseInfluence;
|
||||
|
||||
#ifdef MORPHTARGETS_TEXTURE
|
||||
|
||||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||||
|
||||
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
||||
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
||||
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
||||
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
38
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js
generated
vendored
Normal file
38
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_MORPHTARGETS
|
||||
|
||||
uniform float morphTargetBaseInfluence;
|
||||
|
||||
#ifdef MORPHTARGETS_TEXTURE
|
||||
|
||||
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
||||
uniform sampler2DArray morphTargetsTexture;
|
||||
uniform vec2 morphTargetsTextureSize;
|
||||
|
||||
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
||||
|
||||
float texelIndex = float( vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset );
|
||||
float y = floor( texelIndex / morphTargetsTextureSize.x );
|
||||
float x = texelIndex - y * morphTargetsTextureSize.x;
|
||||
|
||||
vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );
|
||||
return texture( morphTargetsTexture, morphUV );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifndef USE_MORPHNORMALS
|
||||
|
||||
uniform float morphTargetInfluences[ 8 ];
|
||||
|
||||
#else
|
||||
|
||||
uniform float morphTargetInfluences[ 4 ];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
36
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js
generated
vendored
Normal file
36
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_MORPHTARGETS
|
||||
|
||||
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
|
||||
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)
|
||||
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
|
||||
transformed *= morphTargetBaseInfluence;
|
||||
|
||||
#ifdef MORPHTARGETS_TEXTURE
|
||||
|
||||
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
||||
|
||||
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
||||
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
||||
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
||||
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
||||
|
||||
#ifndef USE_MORPHNORMALS
|
||||
|
||||
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
||||
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
||||
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
||||
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
48
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js
generated
vendored
Normal file
48
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
export default /* glsl */`
|
||||
float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
||||
|
||||
#ifdef FLAT_SHADED
|
||||
|
||||
// Workaround for Adreno GPUs not able to do dFdx( vViewPosition )
|
||||
|
||||
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
|
||||
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
||||
vec3 normal = normalize( cross( fdx, fdy ) );
|
||||
|
||||
#else
|
||||
|
||||
vec3 normal = normalize( vNormal );
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
normal = normal * faceDirection;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
vec3 tangent = normalize( vTangent );
|
||||
vec3 bitangent = normalize( vBitangent );
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
tangent = tangent * faceDirection;
|
||||
bitangent = bitangent * faceDirection;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
|
||||
|
||||
mat3 vTBN = mat3( tangent, bitangent, normal );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// non perturbed normal for clearcoat among others
|
||||
|
||||
vec3 geometryNormal = normal;
|
||||
|
||||
`;
|
||||
41
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js
generated
vendored
Normal file
41
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
export default /* glsl */`
|
||||
|
||||
#ifdef OBJECTSPACE_NORMALMAP
|
||||
|
||||
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
|
||||
|
||||
#ifdef FLIP_SIDED
|
||||
|
||||
normal = - normal;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DOUBLE_SIDED
|
||||
|
||||
normal = normal * faceDirection;
|
||||
|
||||
#endif
|
||||
|
||||
normal = normalize( normalMatrix * normal );
|
||||
|
||||
#elif defined( TANGENTSPACE_NORMALMAP )
|
||||
|
||||
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
||||
mapN.xy *= normalScale;
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
normal = normalize( vTBN * mapN );
|
||||
|
||||
#else
|
||||
|
||||
normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
|
||||
|
||||
#endif
|
||||
|
||||
#elif defined( USE_BUMPMAP )
|
||||
|
||||
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
||||
|
||||
#endif
|
||||
`;
|
||||
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js
generated
vendored
Normal file
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export default /* glsl */`
|
||||
#ifndef FLAT_SHADED
|
||||
|
||||
varying vec3 vNormal;
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
varying vec3 vTangent;
|
||||
varying vec3 vBitangent;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js
generated
vendored
Normal file
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export default /* glsl */`
|
||||
#ifndef FLAT_SHADED
|
||||
|
||||
varying vec3 vNormal;
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
varying vec3 vTangent;
|
||||
varying vec3 vBitangent;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js
generated
vendored
Normal file
14
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export default /* glsl */`
|
||||
#ifndef FLAT_SHADED // normal is computed with derivatives when FLAT_SHADED
|
||||
|
||||
vNormal = normalize( transformedNormal );
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
vTangent = normalize( transformedTangent );
|
||||
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
45
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js
generated
vendored
Normal file
45
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_NORMALMAP
|
||||
|
||||
uniform sampler2D normalMap;
|
||||
uniform vec2 normalScale;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef OBJECTSPACE_NORMALMAP
|
||||
|
||||
uniform mat3 normalMatrix;
|
||||
|
||||
#endif
|
||||
|
||||
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
||||
|
||||
// Normal Mapping Without Precomputed Tangents
|
||||
// http://www.thetenthplanet.de/archives/1180
|
||||
|
||||
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
|
||||
|
||||
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
|
||||
|
||||
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
||||
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
||||
vec2 st0 = dFdx( vUv.st );
|
||||
vec2 st1 = dFdy( vUv.st );
|
||||
|
||||
vec3 N = surf_norm; // normalized
|
||||
|
||||
vec3 q1perp = cross( q1, N );
|
||||
vec3 q0perp = cross( N, q0 );
|
||||
|
||||
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
||||
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
||||
|
||||
float det = max( dot( T, T ), dot( B, B ) );
|
||||
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
|
||||
|
||||
return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js
generated
vendored
Normal file
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default /* glsl */`
|
||||
#ifdef OPAQUE
|
||||
diffuseColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
// https://github.com/mrdoob/three.js/pull/22425
|
||||
#ifdef USE_TRANSMISSION
|
||||
diffuseColor.a *= transmissionAlpha + 0.1;
|
||||
#endif
|
||||
|
||||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
||||
`;
|
||||
54
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js
generated
vendored
Normal file
54
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
export default /* glsl */`
|
||||
vec3 packNormalToRGB( const in vec3 normal ) {
|
||||
return normalize( normal ) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
||||
return 2.0 * rgb.xyz - 1.0;
|
||||
}
|
||||
|
||||
const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)
|
||||
const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)
|
||||
|
||||
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
||||
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
||||
|
||||
const float ShiftRight8 = 1. / 256.;
|
||||
|
||||
vec4 packDepthToRGBA( const in float v ) {
|
||||
vec4 r = vec4( fract( v * PackFactors ), v );
|
||||
r.yzw -= r.xyz * ShiftRight8; // tidy overflow
|
||||
return r * PackUpscale;
|
||||
}
|
||||
|
||||
float unpackRGBAToDepth( const in vec4 v ) {
|
||||
return dot( v, UnpackFactors );
|
||||
}
|
||||
|
||||
vec4 pack2HalfToRGBA( vec2 v ) {
|
||||
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
||||
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
||||
}
|
||||
|
||||
vec2 unpackRGBATo2Half( vec4 v ) {
|
||||
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
||||
}
|
||||
|
||||
// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions
|
||||
|
||||
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
||||
return ( viewZ + near ) / ( near - far );
|
||||
}
|
||||
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
|
||||
return linearClipZ * ( near - far ) - near;
|
||||
}
|
||||
|
||||
// NOTE: https://twitter.com/gonnavis/status/1377183786949959682
|
||||
|
||||
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
||||
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
||||
}
|
||||
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
|
||||
return ( near * far ) / ( ( far - near ) * invClipZ - far );
|
||||
}
|
||||
`;
|
||||
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js
generated
vendored
Normal file
8
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export default /* glsl */`
|
||||
#ifdef PREMULTIPLIED_ALPHA
|
||||
|
||||
// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
|
||||
gl_FragColor.rgb *= gl_FragColor.a;
|
||||
|
||||
#endif
|
||||
`;
|
||||
13
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js
generated
vendored
Normal file
13
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export default /* glsl */`
|
||||
vec4 mvPosition = vec4( transformed, 1.0 );
|
||||
|
||||
#ifdef USE_INSTANCING
|
||||
|
||||
mvPosition = instanceMatrix * mvPosition;
|
||||
|
||||
#endif
|
||||
|
||||
mvPosition = modelViewMatrix * mvPosition;
|
||||
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
`;
|
||||
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js
generated
vendored
Normal file
12
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default /* glsl */`
|
||||
float roughnessFactor = roughness;
|
||||
|
||||
#ifdef USE_ROUGHNESSMAP
|
||||
|
||||
vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
||||
|
||||
// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture
|
||||
roughnessFactor *= texelRoughness.g;
|
||||
|
||||
#endif
|
||||
`;
|
||||
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js
generated
vendored
Normal file
7
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_ROUGHNESSMAP
|
||||
|
||||
uniform sampler2D roughnessMap;
|
||||
|
||||
#endif
|
||||
`;
|
||||
310
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js
generated
vendored
Normal file
310
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,310 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SHADOWMAP
|
||||
|
||||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
|
||||
struct DirectionalLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
};
|
||||
|
||||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
|
||||
struct SpotLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
};
|
||||
|
||||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
|
||||
struct PointLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
float shadowCameraNear;
|
||||
float shadowCameraFar;
|
||||
};
|
||||
|
||||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
// TODO (abelnation): create uniforms for area light shadows
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
||||
|
||||
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
||||
|
||||
}
|
||||
|
||||
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
||||
|
||||
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
||||
|
||||
}
|
||||
|
||||
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
||||
|
||||
float occlusion = 1.0;
|
||||
|
||||
vec2 distribution = texture2DDistribution( shadow, uv );
|
||||
|
||||
float hard_shadow = step( compare , distribution.x ); // Hard Shadow
|
||||
|
||||
if (hard_shadow != 1.0 ) {
|
||||
|
||||
float distance = compare - distribution.x ;
|
||||
float variance = max( 0.00000, distribution.y * distribution.y );
|
||||
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
|
||||
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
|
||||
occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
||||
|
||||
}
|
||||
return occlusion;
|
||||
|
||||
}
|
||||
|
||||
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
||||
|
||||
float shadow = 1.0;
|
||||
|
||||
shadowCoord.xyz /= shadowCoord.w;
|
||||
shadowCoord.z += shadowBias;
|
||||
|
||||
// if ( something && something ) breaks ATI OpenGL shader compiler
|
||||
// if ( all( something, something ) ) using this instead
|
||||
|
||||
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
||||
bool inFrustum = all( inFrustumVec );
|
||||
|
||||
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
||||
|
||||
bool frustumTest = all( frustumTestVec );
|
||||
|
||||
if ( frustumTest ) {
|
||||
|
||||
#if defined( SHADOWMAP_TYPE_PCF )
|
||||
|
||||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||||
|
||||
float dx0 = - texelSize.x * shadowRadius;
|
||||
float dy0 = - texelSize.y * shadowRadius;
|
||||
float dx1 = + texelSize.x * shadowRadius;
|
||||
float dy1 = + texelSize.y * shadowRadius;
|
||||
float dx2 = dx0 / 2.0;
|
||||
float dy2 = dy0 / 2.0;
|
||||
float dx3 = dx1 / 2.0;
|
||||
float dy3 = dy1 / 2.0;
|
||||
|
||||
shadow = (
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
||||
) * ( 1.0 / 17.0 );
|
||||
|
||||
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
||||
|
||||
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
||||
float dx = texelSize.x;
|
||||
float dy = texelSize.y;
|
||||
|
||||
vec2 uv = shadowCoord.xy;
|
||||
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
||||
uv -= f * texelSize;
|
||||
|
||||
shadow = (
|
||||
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
||||
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
||||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
||||
f.x ) +
|
||||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
||||
f.x ) +
|
||||
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
||||
f.y ) +
|
||||
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
||||
f.y ) +
|
||||
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
||||
f.x ),
|
||||
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
||||
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
||||
f.x ),
|
||||
f.y )
|
||||
) * ( 1.0 / 9.0 );
|
||||
|
||||
#elif defined( SHADOWMAP_TYPE_VSM )
|
||||
|
||||
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||||
|
||||
#else // no percentage-closer filtering:
|
||||
|
||||
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return shadow;
|
||||
|
||||
}
|
||||
|
||||
// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
|
||||
// vector suitable for 2D texture mapping. This code uses the following layout for the
|
||||
// 2D texture:
|
||||
//
|
||||
// xzXZ
|
||||
// y Y
|
||||
//
|
||||
// Y - Positive y direction
|
||||
// y - Negative y direction
|
||||
// X - Positive x direction
|
||||
// x - Negative x direction
|
||||
// Z - Positive z direction
|
||||
// z - Negative z direction
|
||||
//
|
||||
// Source and test bed:
|
||||
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
|
||||
|
||||
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
||||
|
||||
// Number of texels to avoid at the edge of each square
|
||||
|
||||
vec3 absV = abs( v );
|
||||
|
||||
// Intersect unit cube
|
||||
|
||||
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
||||
absV *= scaleToCube;
|
||||
|
||||
// Apply scale to avoid seams
|
||||
|
||||
// two texels less per square (one texel will do for NEAREST)
|
||||
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
||||
|
||||
// Unwrap
|
||||
|
||||
// space: -1 ... 1 range for each square
|
||||
//
|
||||
// #X## dim := ( 4 , 2 )
|
||||
// # # center := ( 1 , 1 )
|
||||
|
||||
vec2 planar = v.xy;
|
||||
|
||||
float almostATexel = 1.5 * texelSizeY;
|
||||
float almostOne = 1.0 - almostATexel;
|
||||
|
||||
if ( absV.z >= almostOne ) {
|
||||
|
||||
if ( v.z > 0.0 )
|
||||
planar.x = 4.0 - v.x;
|
||||
|
||||
} else if ( absV.x >= almostOne ) {
|
||||
|
||||
float signX = sign( v.x );
|
||||
planar.x = v.z * signX + 2.0 * signX;
|
||||
|
||||
} else if ( absV.y >= almostOne ) {
|
||||
|
||||
float signY = sign( v.y );
|
||||
planar.x = v.x + 2.0 * signY + 2.0;
|
||||
planar.y = v.z * signY - 2.0;
|
||||
|
||||
}
|
||||
|
||||
// Transform to UV space
|
||||
|
||||
// scale := 0.5 / dim
|
||||
// translate := ( center + 0.5 ) / dim
|
||||
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
||||
|
||||
}
|
||||
|
||||
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
||||
|
||||
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
||||
|
||||
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
||||
// the vector from the light to the world-space position of the fragment.
|
||||
vec3 lightToPosition = shadowCoord.xyz;
|
||||
|
||||
// dp = normalized distance from light to fragment position
|
||||
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
|
||||
dp += shadowBias;
|
||||
|
||||
// bd3D = base direction 3D
|
||||
vec3 bd3D = normalize( lightToPosition );
|
||||
|
||||
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
||||
|
||||
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
||||
|
||||
return (
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
||||
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
||||
) * ( 1.0 / 9.0 );
|
||||
|
||||
#else // no percentage-closer filtering
|
||||
|
||||
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
`;
|
||||
63
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js
generated
vendored
Normal file
63
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SHADOWMAP
|
||||
|
||||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
|
||||
struct DirectionalLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
};
|
||||
|
||||
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
|
||||
struct SpotLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
};
|
||||
|
||||
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||||
|
||||
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
|
||||
struct PointLightShadow {
|
||||
float shadowBias;
|
||||
float shadowNormalBias;
|
||||
float shadowRadius;
|
||||
vec2 shadowMapSize;
|
||||
float shadowCameraNear;
|
||||
float shadowCameraFar;
|
||||
};
|
||||
|
||||
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
// TODO (abelnation): uniforms for area light shadows
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif
|
||||
`;
|
||||
60
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js
generated
vendored
Normal file
60
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SHADOWMAP
|
||||
|
||||
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
|
||||
|
||||
// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.
|
||||
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
||||
vec4 shadowWorldPosition;
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||||
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
|
||||
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
||||
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
// TODO (abelnation): update vAreaShadowCoord with area light info
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif
|
||||
`;
|
||||
66
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js
generated
vendored
Normal file
66
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
export default /* glsl */`
|
||||
float getShadowMask() {
|
||||
|
||||
float shadow = 1.0;
|
||||
|
||||
#ifdef USE_SHADOWMAP
|
||||
|
||||
#if NUM_DIR_LIGHT_SHADOWS > 0
|
||||
|
||||
DirectionalLightShadow directionalLight;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
directionalLight = directionalLightShadows[ i ];
|
||||
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
||||
|
||||
SpotLightShadow spotLight;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
spotLight = spotLightShadows[ i ];
|
||||
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
#if NUM_POINT_LIGHT_SHADOWS > 0
|
||||
|
||||
PointLightShadow pointLight;
|
||||
|
||||
#pragma unroll_loop_start
|
||||
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
||||
|
||||
pointLight = pointLightShadows[ i ];
|
||||
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
||||
|
||||
}
|
||||
#pragma unroll_loop_end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if NUM_RECT_AREA_LIGHTS > 0
|
||||
|
||||
// TODO (abelnation): update shadow for Area light
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
return shadow;
|
||||
|
||||
}
|
||||
`;
|
||||
10
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js
generated
vendored
Normal file
10
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SKINNING
|
||||
|
||||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||||
|
||||
#endif
|
||||
`;
|
||||
48
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js
generated
vendored
Normal file
48
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SKINNING
|
||||
|
||||
uniform mat4 bindMatrix;
|
||||
uniform mat4 bindMatrixInverse;
|
||||
|
||||
#ifdef BONE_TEXTURE
|
||||
|
||||
uniform highp sampler2D boneTexture;
|
||||
uniform int boneTextureSize;
|
||||
|
||||
mat4 getBoneMatrix( const in float i ) {
|
||||
|
||||
float j = i * 4.0;
|
||||
float x = mod( j, float( boneTextureSize ) );
|
||||
float y = floor( j / float( boneTextureSize ) );
|
||||
|
||||
float dx = 1.0 / float( boneTextureSize );
|
||||
float dy = 1.0 / float( boneTextureSize );
|
||||
|
||||
y = dy * ( y + 0.5 );
|
||||
|
||||
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
||||
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
||||
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
||||
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
||||
|
||||
mat4 bone = mat4( v1, v2, v3, v4 );
|
||||
|
||||
return bone;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uniform mat4 boneMatrices[ MAX_BONES ];
|
||||
|
||||
mat4 getBoneMatrix( const in float i ) {
|
||||
|
||||
mat4 bone = boneMatrices[ int(i) ];
|
||||
return bone;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
15
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js
generated
vendored
Normal file
15
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SKINNING
|
||||
|
||||
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
||||
|
||||
vec4 skinned = vec4( 0.0 );
|
||||
skinned += boneMatX * skinVertex * skinWeight.x;
|
||||
skinned += boneMatY * skinVertex * skinWeight.y;
|
||||
skinned += boneMatZ * skinVertex * skinWeight.z;
|
||||
skinned += boneMatW * skinVertex * skinWeight.w;
|
||||
|
||||
transformed = ( bindMatrixInverse * skinned ).xyz;
|
||||
|
||||
#endif
|
||||
`;
|
||||
20
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js
generated
vendored
Normal file
20
HTML/ThreeJS/node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export default /* glsl */`
|
||||
#ifdef USE_SKINNING
|
||||
|
||||
mat4 skinMatrix = mat4( 0.0 );
|
||||
skinMatrix += skinWeight.x * boneMatX;
|
||||
skinMatrix += skinWeight.y * boneMatY;
|
||||
skinMatrix += skinWeight.z * boneMatZ;
|
||||
skinMatrix += skinWeight.w * boneMatW;
|
||||
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
||||
|
||||
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
||||
|
||||
#ifdef USE_TANGENT
|
||||
|
||||
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
`;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user