@pmndrs/vanilla
Advanced tools
Comparing version 1.20.1 to 1.20.2
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./MeshDiscardMaterial.cjs.js"),r=require("./MeshTransmissionMaterial.cjs.js"),s=require("./SpotLightMaterial.cjs.js"),a=require("./BlurPass.cjs.js"),t=require("./ConvolutionMaterial.cjs.js"),i=require("./MeshReflectorMaterial.cjs.js"),M=require("./MeshDistortMaterial.cjs.js"),l=require("./MeshWobbleMaterial.cjs.js");require("../core/shaderMaterial.cjs.js"),require("three"),exports.MeshDiscardMaterial=e.MeshDiscardMaterial,exports.MeshTransmissionMaterial=r.MeshTransmissionMaterial,exports.SpotLightMaterial=s.SpotLightMaterial,exports.BlurPass=a.BlurPass,exports.ConvolutionMaterial=t.ConvolutionMaterial,exports.MeshReflectorMaterial=i.MeshReflectorMaterial,exports.MeshDistortMaterial=M.MeshDistortMaterial,exports.MeshWobbleMaterial=l.MeshWobbleMaterial; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./MeshDiscardMaterial.cjs.js"),r=require("./MeshTransmissionMaterial.cjs.js"),s=require("./SpotLightMaterial.cjs.js"),a=require("./BlurPass.cjs.js"),t=require("./ConvolutionMaterial.cjs.js"),i=require("./MeshReflectorMaterial.cjs.js"),M=require("./MeshDistortMaterial.cjs.js"),l=require("./MeshWobbleMaterial.cjs.js");require("../core/shaderMaterial.cjs.js"),require("three"),require("../helpers/constants.cjs.js"),exports.MeshDiscardMaterial=e.MeshDiscardMaterial,exports.MeshTransmissionMaterial=r.MeshTransmissionMaterial,exports.SpotLightMaterial=s.SpotLightMaterial,exports.BlurPass=a.BlurPass,exports.ConvolutionMaterial=t.ConvolutionMaterial,exports.MeshReflectorMaterial=i.MeshReflectorMaterial,exports.MeshDistortMaterial=M.MeshDistortMaterial,exports.MeshWobbleMaterial=l.MeshWobbleMaterial; |
@@ -11,1 +11,2 @@ export { MeshDiscardMaterial } from './MeshDiscardMaterial.js'; | ||
import 'three'; | ||
import '../helpers/constants.js'; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("three");const o=require("../core/shaderMaterial.cjs.js").shaderMaterial({depth:null,opacity:1,attenuation:2.5,anglePower:12,spotPosition:new n.Vector3(0,0,0),lightColor:new n.Color("white"),cameraNear:0,cameraFar:1,resolution:new n.Vector2(0,0),transparent:!0,depthWrite:!1},"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation;\n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity;\n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",`\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n #include <${parseInt(n.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);exports.SpotLightMaterial=o; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("three"),e=require("../core/shaderMaterial.cjs.js"),o=require("../helpers/constants.cjs.js");const t=e.shaderMaterial({depth:null,opacity:1,attenuation:2.5,anglePower:12,spotPosition:new n.Vector3(0,0,0),lightColor:new n.Color("white"),cameraNear:0,cameraFar:1,resolution:new n.Vector2(0,0),transparent:!0,depthWrite:!1},"\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main() {\n // compute intensity\n vNormal = normalize(normalMatrix * normal);\n vec4 worldPosition = modelMatrix * vec4(position, 1);\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n\n vIntensity = 1.0 - saturate(distance(worldPosition.xyz, spotPosition) / attenuation);\n\n gl_Position = projectionMatrix * viewPosition;\n\n #include <logdepthbuf_vertex>\n }",`\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n\n uniform vec3 lightColor;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float opacity;\n\n #include <packing>\n #include <logdepthbuf_pars_fragment>\n\n float readDepth(sampler2D depthSampler, vec2 uv) {\n float fragCoordZ = texture(depthSampler, uv).r;\n\n // https://github.com/mrdoob/three.js/issues/23072\n #ifdef USE_LOGDEPTHBUF\n float viewZ = 1.0 - exp2(fragCoordZ * log(cameraFar + 1.0) / log(2.0));\n #else\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n #endif\n\n return viewZ;\n }\n\n void main() {\n #include <logdepthbuf_fragment>\n\n vec3 normal = vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity = pow(dot(normal, vec3(0, 0, 1)), anglePower);\n float intensity = vIntensity * angleIntensity;\n\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 uv = gl_FragCoord.xy / resolution;\n intensity *= smoothstep(0.0, 1.0, vViewZ - readDepth(depth, uv));\n }\n\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n #include <${o.version>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);exports.SpotLightMaterial=t; |
@@ -1,3 +0,4 @@ | ||
import { REVISION, Vector3, Color, Vector2 } from 'three'; | ||
import { Vector3, Color, Vector2 } from 'three'; | ||
import { shaderMaterial } from '../core/shaderMaterial.js'; | ||
import { version } from '../helpers/constants.js'; | ||
@@ -18,3 +19,2 @@ const SpotLightMaterial = shaderMaterial({ | ||
varying vec3 vNormal; | ||
varying vec3 vWorldPosition; | ||
varying float vViewZ; | ||
@@ -25,23 +25,23 @@ varying float vIntensity; | ||
#include <common> | ||
#include <logdepthbuf_pars_vertex> | ||
void main() { | ||
// compute intensity | ||
vNormal = normalize( normalMatrix * normal ); | ||
vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); | ||
vWorldPosition = worldPosition.xyz; | ||
vNormal = normalize(normalMatrix * normal); | ||
vec4 worldPosition = modelMatrix * vec4(position, 1); | ||
vec4 viewPosition = viewMatrix * worldPosition; | ||
vViewZ = viewPosition.z; | ||
float intensity = distance(worldPosition.xyz, spotPosition) / attenuation; | ||
intensity = 1.0 - clamp(intensity, 0.0, 1.0); | ||
vIntensity = intensity; | ||
// set gl_Position | ||
gl_Position = projectionMatrix * viewPosition; | ||
vIntensity = 1.0 - saturate(distance(worldPosition.xyz, spotPosition) / attenuation); | ||
gl_Position = projectionMatrix * viewPosition; | ||
#include <logdepthbuf_vertex> | ||
}`, /* glsl */` | ||
#include <packing> | ||
varying vec3 vNormal; | ||
varying float vViewZ; | ||
varying float vIntensity; | ||
varying vec3 vNormal; | ||
varying vec3 vWorldPosition; | ||
uniform vec3 lightColor; | ||
uniform vec3 spotPosition; | ||
uniform float attenuation; | ||
uniform float anglePower; | ||
@@ -52,33 +52,40 @@ uniform sampler2D depth; | ||
uniform float cameraFar; | ||
varying float vViewZ; | ||
varying float vIntensity; | ||
uniform float opacity; | ||
float readDepth( sampler2D depthSampler, vec2 coord ) { | ||
float fragCoordZ = texture2D( depthSampler, coord ).x; | ||
float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar); | ||
#include <packing> | ||
#include <logdepthbuf_pars_fragment> | ||
float readDepth(sampler2D depthSampler, vec2 uv) { | ||
float fragCoordZ = texture(depthSampler, uv).r; | ||
// https://github.com/mrdoob/three.js/issues/23072 | ||
#ifdef USE_LOGDEPTHBUF | ||
float viewZ = 1.0 - exp2(fragCoordZ * log(cameraFar + 1.0) / log(2.0)); | ||
#else | ||
float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar); | ||
#endif | ||
return viewZ; | ||
} | ||
void main() { | ||
float d = 1.0; | ||
void main() { | ||
#include <logdepthbuf_fragment> | ||
vec3 normal = vec3(vNormal.x, vNormal.y, abs(vNormal.z)); | ||
float angleIntensity = pow(dot(normal, vec3(0, 0, 1)), anglePower); | ||
float intensity = vIntensity * angleIntensity; | ||
// fades when z is close to sampled depth, meaning the cone is intersecting existing geometry | ||
bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0; | ||
if (isSoft) { | ||
vec2 sUv = gl_FragCoord.xy / resolution; | ||
d = readDepth(depth, sUv); | ||
vec2 uv = gl_FragCoord.xy / resolution; | ||
intensity *= smoothstep(0.0, 1.0, vViewZ - readDepth(depth, uv)); | ||
} | ||
float intensity = vIntensity; | ||
vec3 normal = vec3(vNormal.x, vNormal.y, abs(vNormal.z)); | ||
float angleIntensity = pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower ); | ||
intensity *= angleIntensity; | ||
// fades when z is close to sampled depth, meaning the cone is intersecting existing geometry | ||
if (isSoft) { | ||
intensity *= smoothstep(0., 1., vViewZ - d); | ||
} | ||
gl_FragColor = vec4(lightColor, intensity * opacity); | ||
#include <tonemapping_fragment> | ||
#include <${parseInt(REVISION.replace(/\D+/g, '')) >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}> | ||
#include <${version >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}> | ||
}`); | ||
export { SpotLightMaterial }; |
{ | ||
"name": "@pmndrs/vanilla", | ||
"version": "1.20.1", | ||
"version": "1.20.2", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
Sorry, the diff of this file is too big to display
365794
4764