@threepipe/webgi-plugins 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.md +13 -23
- package/THIRD_PARTY_NOTICES.md +243 -0
- package/dist/dependencies.txt +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4536 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4545 -18
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/buffer/VelocityBufferPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts +3 -2
- package/dist/plugins/extras/AdvancedGroundPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/AnisotropyPlugin.d.ts.map +1 -1
- package/dist/plugins/extras/WatchHandsPlugin.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +24 -24
- package/dist/plugins/postprocessing/SSGIPlugin.d.ts +3 -2
- package/dist/plugins/postprocessing/SSGIPlugin.d.ts.map +1 -1
- package/dist/plugins/postprocessing/SSReflectionPlugin.d.ts +1 -1
- package/dist/utils/ShadowMapBaker.d.ts +1 -1
- package/dist/utils/ShadowMapBaker.d.ts.map +1 -1
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/AdvancedGroundPlugin.html +69 -0
- package/docs/classes/AnisotropyPlugin.html +40 -0
- package/docs/classes/BloomPlugin.html +37 -0
- package/docs/classes/BloomPluginPass.html +34 -0
- package/docs/classes/DepthOfFieldPlugin.html +41 -0
- package/docs/classes/DepthOfFieldPluginPass.html +37 -0
- package/docs/classes/OutlinePlugin.html +75 -0
- package/docs/classes/OutlineRenderPass.html +25 -0
- package/docs/classes/SSContactShadowsPlugin.html +37 -0
- package/docs/classes/SSGIPlugin.html +42 -0
- package/docs/classes/SSGIPluginPass.html +44 -0
- package/docs/classes/SSReflectionPlugin.html +43 -0
- package/docs/classes/SSReflectionPluginPass.html +45 -0
- package/docs/classes/SSVelocityMaterial.html +7 -0
- package/docs/classes/TemporalAAPlugin.html +37 -0
- package/docs/classes/TemporalAAPluginPass.html +33 -0
- package/docs/classes/VelocityBufferPlugin.html +41 -0
- package/docs/classes/WatchHandsPlugin.html +39 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1 -0
- package/docs/types/OutlinePluginPass.html +1 -0
- package/docs/types/OutlinePluginTarget.html +1 -0
- package/docs/types/SSGIPluginTarget.html +1 -0
- package/docs/types/SSReflectionPluginTarget.html +1 -0
- package/docs/types/VelocityBufferPluginPass.html +1 -0
- package/docs/types/VelocityBufferPluginTarget.html +1 -0
- package/docs/variables/anisotropyGLTFExtension.html +1 -0
- package/docs/variables/webgiPlugins.html +1 -0
- package/package.json +23 -22
- package/src/global.d.ts +27 -0
- package/src/index.ts +1 -0
- package/src/passes/BilateralFilterPass.ts +62 -0
- package/src/passes/shaders/ssaoBilateral.glsl +89 -0
- package/src/plugins/buffer/VelocityBufferPlugin.ts +270 -0
- package/src/plugins/buffer/shaders/VelocityBufferPlugin.mat.frag.glsl +46 -0
- package/src/plugins/buffer/shaders/VelocityBufferPlugin.mat.vert.glsl +51 -0
- package/src/plugins/buffer/shaders/VelocityBufferPlugin.unpack.glsl +8 -0
- package/src/plugins/extras/AdvancedGroundPlugin.ts +385 -0
- package/src/plugins/extras/AnisotropyPlugin.ts +519 -0
- package/src/plugins/extras/WatchHandsPlugin.ts +156 -0
- package/src/plugins/extras/shaders/anisotropyBsdf.glsl +64 -0
- package/src/plugins/extras/shaders/anisotropyTBN.glsl +35 -0
- package/src/plugins/index.ts +38 -0
- package/src/plugins/postprocessing/BloomPlugin.ts +374 -0
- package/src/plugins/postprocessing/DepthOfFieldPlugin.ts +470 -0
- package/src/plugins/postprocessing/OutlinePlugin.ts +476 -0
- package/src/plugins/postprocessing/SSContactShadowsPlugin.ts +374 -0
- package/src/plugins/postprocessing/SSGIPlugin.ts +597 -0
- package/src/plugins/postprocessing/SSReflectionPlugin.ts +563 -0
- package/src/plugins/postprocessing/TemporalAAPlugin.ts +301 -0
- package/src/plugins/postprocessing/shaders/dofBlurBox.glsl +46 -0
- package/src/plugins/postprocessing/shaders/dofCombine.glsl +68 -0
- package/src/plugins/postprocessing/shaders/dofComputeCoC.glsl +21 -0
- package/src/plugins/postprocessing/shaders/dofExpandCoC.glsl +56 -0
- package/src/plugins/postprocessing/shaders/dofPoissonBox.glsl +90 -0
- package/src/plugins/postprocessing/shaders/giPatch.glsl +53 -0
- package/src/plugins/postprocessing/shaders/hdrBloom.glsl +101 -0
- package/src/plugins/postprocessing/shaders/outline.glsl +60 -0
- package/src/plugins/postprocessing/shaders/outlineDepthFrag.glsl +22 -0
- package/src/plugins/postprocessing/shaders/outlineDepthVert.glsl +26 -0
- package/src/plugins/postprocessing/shaders/poissonDiskSamples.glsl +19 -0
- package/src/plugins/postprocessing/shaders/samplePointHelpers.glsl +3 -0
- package/src/plugins/postprocessing/shaders/ssrPatch.glsl +145 -0
- package/src/plugins/postprocessing/shaders/ssreflectionMain.glsl +69 -0
- package/src/plugins/postprocessing/shaders/ssrt.glsl +118 -0
- package/src/utils/FSShadowMaterial.ts +65 -0
- package/src/utils/RandomizedDirectionalLight.ts +288 -0
- package/src/utils/Reflector2.ts +309 -0
- package/src/utils/ShadowMapBaker.ts +527 -0
- package/src/utils/shaders/computeScreenSpaceVelocity.glsl +16 -0
- package/src/utils/shaders/getWorldPositionFromViewZ.glsl +9 -0
- package/src/utils/shaders/poissonDiskSamples.glsl +19 -0
- package/src/utils/shaders/reflectorSample.glsl +54 -0
- package/src/utils/shaders/seperableBlurShaderMasked.glsl +28 -0
- package/src/utils/shaders/seperableShadowBlur.glsl +21 -0
- package/src/utils/shaders/ssreflection.glsl +141 -0
- package/src/utils/shaders/ssrtao.glsl +275 -0
- package/src/utils/shaders/temporalaa.glsl +233 -0
- package/src/utils/shaders.ts +24 -0
- package/tsconfig.json +39 -44
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>webgiPlugins | WebGi Rendering Plugins</title><meta name="description" content="Documentation for WebGi Rendering Plugins"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">WebGi Rendering Plugins</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">webgiPlugins</a></li></ul><h1>Variable webgiPlugins<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">webgiPlugins</span><span class="tsd-signature-symbol">:</span> (<br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/TemporalAAPlugin.html" class="tsd-signature-type tsd-kind-class">TemporalAAPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/VelocityBufferPlugin.html" class="tsd-signature-type tsd-kind-class">VelocityBufferPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/BloomPlugin.html" class="tsd-signature-type tsd-kind-class">BloomPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/SSReflectionPlugin.html" class="tsd-signature-type tsd-kind-class">SSReflectionPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/SSContactShadowsPlugin.html" class="tsd-signature-type tsd-kind-class">SSContactShadowsPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/DepthOfFieldPlugin.html" class="tsd-signature-type tsd-kind-class">DepthOfFieldPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/OutlinePlugin.html" class="tsd-signature-type tsd-kind-class">OutlinePlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/SSGIPlugin.html" class="tsd-signature-type tsd-kind-class">SSGIPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/AnisotropyPlugin.html" class="tsd-signature-type tsd-kind-class">AnisotropyPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/AdvancedGroundPlugin.html" class="tsd-signature-type tsd-kind-class">AdvancedGroundPlugin</a><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <a href="../classes/WatchHandsPlugin.html" class="tsd-signature-type tsd-kind-class">WatchHandsPlugin</a><br/>)<span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/repalash/threepipe/blob/420d8339f71059a68fd15378efd3f45fa7f8b55a/plugins/webgi-plugins/src/plugins/index.ts#L26" class="external" target="_blank">plugins/webgi-plugins/src/plugins/index.ts:26</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">WebGi Rendering Plugins</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threepipe/webgi-plugins",
|
|
3
|
-
"version": "0.6.4",
|
|
4
3
|
"description": "WebGi - Realistic Rendering Plugins for ThreePipe.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"type": "module",
|
|
4
|
+
"version": "0.7.0",
|
|
5
|
+
"dependencies": {},
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"threepipe": ">=0.5.1"
|
|
8
|
+
},
|
|
11
9
|
"exports": {
|
|
12
10
|
".": {
|
|
13
11
|
"types": "./dist/index.d.ts",
|
|
@@ -19,17 +17,23 @@
|
|
|
19
17
|
"require": "./dist/"
|
|
20
18
|
}
|
|
21
19
|
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"module": "dist/index.mjs",
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
22
24
|
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src",
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"docs",
|
|
30
|
+
"tsconfig.json",
|
|
23
31
|
"LICENSE",
|
|
24
32
|
"NOTICE",
|
|
25
|
-
"
|
|
26
|
-
"dist",
|
|
27
|
-
"tsconfig.json"
|
|
33
|
+
"THIRD_PARTY_NOTICES.md"
|
|
28
34
|
],
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"url": "git://github.com/repalash/threepipe-webgi.git"
|
|
32
|
-
},
|
|
35
|
+
"author": "repalash <palash@shaders.app> (https://repalash.com)",
|
|
36
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
33
37
|
"keywords": [
|
|
34
38
|
"3d",
|
|
35
39
|
"three.js",
|
|
@@ -42,17 +46,14 @@
|
|
|
42
46
|
"webgi",
|
|
43
47
|
"canvas"
|
|
44
48
|
],
|
|
45
|
-
"author": "repalash <palash@shaders.app> (https://repalash.com)",
|
|
46
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
47
49
|
"bugs": {
|
|
48
50
|
"url": "https://github.com/repalash/threepipe/issues"
|
|
49
51
|
},
|
|
50
|
-
"homepage": "https://webgi.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
52
|
+
"homepage": "https://threepipe.org/package/webgi-plugins.html",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git://github.com/repalash/threepipe.git",
|
|
56
|
+
"directory": "plugins/webgi-plugins"
|
|
53
57
|
},
|
|
54
|
-
"browserslist": [
|
|
55
|
-
"defaults"
|
|
56
|
-
],
|
|
57
58
|
"sideEffects": false
|
|
58
59
|
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare module '*.glsl' {
|
|
2
|
+
const content: string
|
|
3
|
+
export default content
|
|
4
|
+
}
|
|
5
|
+
declare module '*.vert' {
|
|
6
|
+
const content: string
|
|
7
|
+
export default content
|
|
8
|
+
}
|
|
9
|
+
declare module '*.frag' {
|
|
10
|
+
const content: string
|
|
11
|
+
export default content
|
|
12
|
+
}
|
|
13
|
+
// declare module '*.module.css' {
|
|
14
|
+
// const content: any
|
|
15
|
+
// export default content
|
|
16
|
+
// export const stylesheet: string
|
|
17
|
+
// }
|
|
18
|
+
declare module '*.css?inline' {
|
|
19
|
+
const content: string
|
|
20
|
+
export default content
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// export {}
|
|
24
|
+
|
|
25
|
+
// hack for typedoc
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
// declare type OffscreenCanvas = HTMLCanvasElement
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugins'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ssaoBilateral from './shaders/ssaoBilateral.glsl'
|
|
2
|
+
import {
|
|
3
|
+
CopyShader,
|
|
4
|
+
ExtendedShaderPass, getOrCall,
|
|
5
|
+
IPass,
|
|
6
|
+
IWebGLRenderer,
|
|
7
|
+
serialize,
|
|
8
|
+
uniform, ValOrFunc,
|
|
9
|
+
Vector2,
|
|
10
|
+
WebGLRenderTarget
|
|
11
|
+
} from "threepipe";
|
|
12
|
+
|
|
13
|
+
export class BilateralFilterPass extends ExtendedShaderPass implements IPass {
|
|
14
|
+
@serialize() @uniform() smoothEnabled = true
|
|
15
|
+
@serialize() @uniform() edgeSharpness = 0.1
|
|
16
|
+
// @serialize() @uniform() smoothSigma = new Vector4(1, 0.2, 4., 1)
|
|
17
|
+
// @serialize() @uniform() smoothScale = new Vector4(0, 10, 1, 0)
|
|
18
|
+
|
|
19
|
+
constructor(public target?: ValOrFunc<WebGLRenderTarget|undefined>, sourceAccessor = 'rgba') {
|
|
20
|
+
super({
|
|
21
|
+
vertexShader: CopyShader.vertexShader,
|
|
22
|
+
fragmentShader: `
|
|
23
|
+
// for gbuffer
|
|
24
|
+
#include <packing>
|
|
25
|
+
#define THREE_PACKING_INCLUDED
|
|
26
|
+
` + ssaoBilateral,
|
|
27
|
+
uniforms: {
|
|
28
|
+
bilDirection: {value: new Vector2(1, 0)},
|
|
29
|
+
// tNormalDepth: {value: null},
|
|
30
|
+
tDiffuse: {value: null},
|
|
31
|
+
tDiffuseSize: {value: new Vector2()},
|
|
32
|
+
},
|
|
33
|
+
defines: {
|
|
34
|
+
['B_SRC_ACCESSOR']: sourceAccessor,
|
|
35
|
+
},
|
|
36
|
+
}, 'tDiffuse')
|
|
37
|
+
this.clear = false
|
|
38
|
+
this.needsSwap = false
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render(renderer: IWebGLRenderer, writeBuffer: WebGLRenderTarget, _readBuffer: WebGLRenderTarget, deltaTime: number, maskActive: boolean) {
|
|
42
|
+
if (!this.enabled) return
|
|
43
|
+
const target = getOrCall(this.target)
|
|
44
|
+
if(!target) return
|
|
45
|
+
|
|
46
|
+
this.uniforms.bilDirection.value.set(1, 0)
|
|
47
|
+
|
|
48
|
+
this.uniforms.tDiffuse.value = target.texture
|
|
49
|
+
this.uniforms.tDiffuseSize.value.set(this.uniforms.tDiffuse.value?.image.width || 0, this.uniforms.tDiffuse.value?.image.height || 0)
|
|
50
|
+
super.render(renderer, writeBuffer, target, deltaTime, maskActive)
|
|
51
|
+
|
|
52
|
+
this.uniforms.bilDirection.value.set(0, 1)
|
|
53
|
+
this.uniforms.tDiffuse.value = writeBuffer.texture
|
|
54
|
+
this.uniforms.tDiffuseSize.value.set(this.uniforms.tDiffuse.value?.image.width || 0, this.uniforms.tDiffuse.value?.image.height || 0)
|
|
55
|
+
super.render(renderer, target, writeBuffer, deltaTime, maskActive)
|
|
56
|
+
|
|
57
|
+
// this.uniforms.bilDirection.value.set(-1, -1)
|
|
58
|
+
// this.uniforms.tDiffuse2.value = target.texture
|
|
59
|
+
// super.render(renderer, writeBuffer, readBuffer, deltaTime, maskActive)
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
|
|
2
|
+
uniform vec2 tDiffuseSize; //tDiffuse is the color buffer
|
|
3
|
+
//uniform vec2 tDiffuse2Size;
|
|
4
|
+
uniform vec2 bilDirection;
|
|
5
|
+
varying vec2 vUv;
|
|
6
|
+
|
|
7
|
+
uniform bool smoothEnabled;
|
|
8
|
+
|
|
9
|
+
uniform float edgeSharpness;
|
|
10
|
+
|
|
11
|
+
vec4 bilaterialAO(){
|
|
12
|
+
vec4 color = clamp((texture2D(tDiffuse, vUv.xy)).B_SRC_ACCESSOR, 0., 5.);
|
|
13
|
+
|
|
14
|
+
if(!smoothEnabled) return color;
|
|
15
|
+
|
|
16
|
+
float depth; vec3 normal;
|
|
17
|
+
getDepthNormal(vUv.xy, depth, normal);
|
|
18
|
+
|
|
19
|
+
float gaussianWeights[4];
|
|
20
|
+
gaussianWeights[0] = 0.153170;
|
|
21
|
+
gaussianWeights[1] = 0.144893;
|
|
22
|
+
gaussianWeights[2] = 0.122649;
|
|
23
|
+
gaussianWeights[3] = 0.092902;
|
|
24
|
+
|
|
25
|
+
float Z = gaussianWeights[0] + 0.03;
|
|
26
|
+
vec4 final_colour = Z * color;
|
|
27
|
+
vec2 nuv;
|
|
28
|
+
vec4 cc; float dp; vec3 nor; // cc is color, np is position, dp is depth, nor is normal
|
|
29
|
+
vec2 direction = bilDirection / tDiffuseSize.xy;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// -1, 1, -2, 2, -3, 3
|
|
33
|
+
|
|
34
|
+
#pragma unroll_loop_start
|
|
35
|
+
for (int i = 0; i < 6; i++){
|
|
36
|
+
|
|
37
|
+
direction *= -1.;
|
|
38
|
+
nuv = vUv + 2. * direction * float( UNROLLED_LOOP_INDEX / 2 + 1 ); // clamp to screen border
|
|
39
|
+
getDepthNormal(nuv, dp, nor);
|
|
40
|
+
|
|
41
|
+
if(dp < 0.999) {
|
|
42
|
+
|
|
43
|
+
float normalCloseness = dot(normal, nor);
|
|
44
|
+
normalCloseness *= normalCloseness;
|
|
45
|
+
float normalError = (1.0 - normalCloseness) * 8.;
|
|
46
|
+
float normalWeight = max((1.0 - normalError * edgeSharpness), 0.00);
|
|
47
|
+
|
|
48
|
+
float depthWeight = max(0.0, 1.0 - edgeSharpness * 4000. * abs(depth - dp));
|
|
49
|
+
|
|
50
|
+
float kernelWeight = gaussianWeights[UNROLLED_LOOP_INDEX / 2] + 0.03;
|
|
51
|
+
float bilateralWeight = kernelWeight * depthWeight * normalWeight;
|
|
52
|
+
|
|
53
|
+
Z += bilateralWeight;
|
|
54
|
+
|
|
55
|
+
cc = clamp((texture2D(tDiffuse, nuv)).B_SRC_ACCESSOR, 0., 5.);// clamp(texsample(tDiffuse, float(i), float(j)), 0., 1.);
|
|
56
|
+
final_colour += bilateralWeight*cc;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
#pragma unroll_loop_end
|
|
62
|
+
|
|
63
|
+
final_colour /= Z;
|
|
64
|
+
// final_colour.a = color.a;
|
|
65
|
+
return final_colour;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
void main() {
|
|
70
|
+
|
|
71
|
+
vec4 ao = clamp(bilaterialAO(), vec4(0.), vec4(1.));
|
|
72
|
+
// ao.a = 1.;
|
|
73
|
+
gl_FragColor = ao;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//float normpdf(in float x, in float sigma){
|
|
78
|
+
// return exp(-0.5*x*x/(sigma*sigma));
|
|
79
|
+
// // return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;
|
|
80
|
+
//}
|
|
81
|
+
//uniform vec4 smoothSigma; // color, depth, pixel, normal
|
|
82
|
+
//uniform vec4 smoothScale; // color, depth, pixel, normal
|
|
83
|
+
//factor = 1.;
|
|
84
|
+
//factor *= normpdf( length(cc-color) * smoothScale.x, smoothSigma.x); //color
|
|
85
|
+
//factor *= normpdf(sqrt(abs(dp-depth)) * smoothScale.y, smoothSigma.y); //depth
|
|
86
|
+
//factor *= normpdf( float( i/2 + 1 ) * smoothScale.z, smoothSigma.z); //pixel distance
|
|
87
|
+
//factor *= normpdf((1.-dot(normal, nor)) * smoothScale.w, smoothSigma.w); //normal
|
|
88
|
+
//factor *= normpdf(sqrt(length(np-pos))*smoothScale.y, smoothSigma.y); // position.
|
|
89
|
+
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BufferGeometry,
|
|
3
|
+
Camera,
|
|
4
|
+
Color,
|
|
5
|
+
DoubleSide,
|
|
6
|
+
GBufferRenderPass,
|
|
7
|
+
ICamera,
|
|
8
|
+
IObject3D,
|
|
9
|
+
IRenderManager,
|
|
10
|
+
IScene,
|
|
11
|
+
IUniform,
|
|
12
|
+
IWebGLRenderer,
|
|
13
|
+
LinearSRGBColorSpace,
|
|
14
|
+
MaterialExtension,
|
|
15
|
+
Matrix3,
|
|
16
|
+
Matrix4,
|
|
17
|
+
NoBlending,
|
|
18
|
+
PipelinePassPlugin,
|
|
19
|
+
Scene,
|
|
20
|
+
ShaderMaterial,
|
|
21
|
+
shaderReplaceString,
|
|
22
|
+
Texture,
|
|
23
|
+
TextureDataType,
|
|
24
|
+
ThreeViewer,
|
|
25
|
+
uiFolderContainer,
|
|
26
|
+
uiImage,
|
|
27
|
+
Group,
|
|
28
|
+
UnsignedByteType,
|
|
29
|
+
Vector2,
|
|
30
|
+
WebGLRenderer,
|
|
31
|
+
WebGLRenderTarget,
|
|
32
|
+
} from 'threepipe'
|
|
33
|
+
import VelocityBufferUnpack from './shaders/VelocityBufferPlugin.unpack.glsl'
|
|
34
|
+
import ssVelocityVert from './shaders/VelocityBufferPlugin.mat.vert.glsl'
|
|
35
|
+
import ssVelocityFrag from './shaders/VelocityBufferPlugin.mat.frag.glsl'
|
|
36
|
+
import {TemporalAAPlugin} from '../postprocessing/TemporalAAPlugin'
|
|
37
|
+
|
|
38
|
+
// type VelocityBufferPluginTarget = WebGLRenderTarget
|
|
39
|
+
export type VelocityBufferPluginTarget = WebGLRenderTarget
|
|
40
|
+
export type VelocityBufferPluginPass = GBufferRenderPass<'velocityBuffer', VelocityBufferPluginTarget>
|
|
41
|
+
/**
|
|
42
|
+
* Velocity Buffer Plugin
|
|
43
|
+
*
|
|
44
|
+
* Adds a pre-render pass to render the normal buffer to a render target that can be used for postprocessing.
|
|
45
|
+
* @category Plugins
|
|
46
|
+
*/
|
|
47
|
+
@uiFolderContainer('Velocity Buffer Plugin (for TAA)')
|
|
48
|
+
export class VelocityBufferPlugin
|
|
49
|
+
extends PipelinePassPlugin<VelocityBufferPluginPass, 'velocityBuffer'> {
|
|
50
|
+
|
|
51
|
+
readonly passId = 'velocityBuffer'
|
|
52
|
+
public static readonly PluginType = 'VelocityBuffer'
|
|
53
|
+
public static readonly OldPluginType = 'VelocityBufferPlugin' // todo swap
|
|
54
|
+
|
|
55
|
+
target?: VelocityBufferPluginTarget
|
|
56
|
+
@uiImage('Velocity Buffer', {readOnly: true}) texture?: Texture
|
|
57
|
+
readonly material: SSVelocityMaterial = new SSVelocityMaterial()
|
|
58
|
+
|
|
59
|
+
// @onChange2(VelocityBufferPlugin.prototype._createTarget)
|
|
60
|
+
// @uiDropdown('Buffer Type', threeConstMappings.TextureDataType.uiConfig)
|
|
61
|
+
readonly bufferType: TextureDataType // cannot be changed after creation (for now)
|
|
62
|
+
|
|
63
|
+
protected _createTarget(recreate = true) {
|
|
64
|
+
if (!this._viewer) return
|
|
65
|
+
if (recreate) this._disposeTarget()
|
|
66
|
+
|
|
67
|
+
if (!this.target) this.target = this._viewer.renderManager.createTarget<VelocityBufferPluginTarget>(
|
|
68
|
+
{
|
|
69
|
+
depthBuffer: true,
|
|
70
|
+
// samples: v.renderManager.composerTarget.samples || 0,
|
|
71
|
+
samples: 0,
|
|
72
|
+
type: this.bufferType,
|
|
73
|
+
// magFilter: NearestFilter,
|
|
74
|
+
// minFilter: NearestFilter,
|
|
75
|
+
generateMipmaps: false,
|
|
76
|
+
colorSpace: LinearSRGBColorSpace,
|
|
77
|
+
})
|
|
78
|
+
this.texture = this.target.texture
|
|
79
|
+
this.texture.name = 'velocityBuffer'
|
|
80
|
+
|
|
81
|
+
if (this._pass) this._pass.target = this.target
|
|
82
|
+
}
|
|
83
|
+
protected _disposeTarget() {
|
|
84
|
+
if (!this._viewer) return
|
|
85
|
+
if (this.target) {
|
|
86
|
+
this._viewer.renderManager.disposeTarget(this.target)
|
|
87
|
+
this.target = undefined
|
|
88
|
+
}
|
|
89
|
+
this.texture = undefined
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected _createPass() {
|
|
93
|
+
this._createTarget(true)
|
|
94
|
+
if (!this.target) throw new Error('VelocityBufferPlugin: target not created')
|
|
95
|
+
this.material.userData.isGBufferMaterial = true
|
|
96
|
+
const v = this._viewer!
|
|
97
|
+
const pass = new class extends GBufferRenderPass {
|
|
98
|
+
private _firstCall = true
|
|
99
|
+
render(renderer: IWebGLRenderer, writeBuffer?: WebGLRenderTarget | null, readBuffer?: WebGLRenderTarget, deltaTime?: number, maskActive?: boolean) {
|
|
100
|
+
if (v.renderManager.frameCount > 0) return
|
|
101
|
+
if (!this.enabled || !this.camera) return
|
|
102
|
+
const mat = this.overrideMaterial as ShaderMaterial
|
|
103
|
+
mat.uniforms.currentProjectionViewMatrix.value.copy(this.camera.projectionMatrix).multiply(this.camera.matrixWorldInverse)
|
|
104
|
+
if (this._firstCall) {
|
|
105
|
+
mat.uniforms.lastProjectionViewMatrix.value.copy(mat.uniforms.currentProjectionViewMatrix.value)
|
|
106
|
+
this._firstCall = false
|
|
107
|
+
}
|
|
108
|
+
super.render(renderer, writeBuffer, readBuffer, deltaTime, maskActive)
|
|
109
|
+
mat.uniforms.lastProjectionViewMatrix.value.copy(mat.uniforms.currentProjectionViewMatrix.value)
|
|
110
|
+
}
|
|
111
|
+
}(this.passId, this.target, this.material, new Color(0.5, 0.5, 0.5), 1) // clear color 0.5 means 0 velocity
|
|
112
|
+
const preprocessMaterial = pass.preprocessMaterial
|
|
113
|
+
// `disabled` is the opposite of renderToGBuffer; undefined keeps the material's own renderToGBuffer
|
|
114
|
+
pass.preprocessMaterial = (m) => {
|
|
115
|
+
const disabled = m.userData[VelocityBufferPlugin.PluginType]?.disabled
|
|
116
|
+
return preprocessMaterial(m, disabled === undefined ? undefined : !disabled)
|
|
117
|
+
}
|
|
118
|
+
pass.before = ['render']
|
|
119
|
+
pass.after = []
|
|
120
|
+
pass.required = ['render']
|
|
121
|
+
return pass as any
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// automatically register the unpack extension with TAA plugin
|
|
125
|
+
protected readonly _attachToTaa: boolean
|
|
126
|
+
|
|
127
|
+
constructor(
|
|
128
|
+
bufferType: TextureDataType = UnsignedByteType,
|
|
129
|
+
enabled = true,
|
|
130
|
+
_attachToTaa = true
|
|
131
|
+
) {
|
|
132
|
+
super()
|
|
133
|
+
this.enabled = enabled
|
|
134
|
+
this.bufferType = bufferType
|
|
135
|
+
this._attachToTaa = _attachToTaa
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
onAdded(viewer: ThreeViewer) {
|
|
139
|
+
super.onAdded(viewer)
|
|
140
|
+
viewer.forPlugin(TemporalAAPlugin, (taa) => {
|
|
141
|
+
this._attachToTaa && taa.pass?.material.registerMaterialExtensions([this.unpackExtension])
|
|
142
|
+
}, (taa)=>{
|
|
143
|
+
taa.pass?.material?.unregisterMaterialExtensions([this.unpackExtension])
|
|
144
|
+
}, this)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
onRemove(viewer: ThreeViewer): void {
|
|
148
|
+
this._disposeTarget()
|
|
149
|
+
return super.onRemove(viewer)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
unpackExtension: MaterialExtension = {
|
|
153
|
+
shaderExtender: (shader)=>{
|
|
154
|
+
if(this.isDisabled()) return
|
|
155
|
+
shader.fragmentShader = shaderReplaceString(shader.fragmentShader,
|
|
156
|
+
'#pragma <velocity_unpack>',
|
|
157
|
+
'\n' + VelocityBufferUnpack + '\n')
|
|
158
|
+
},
|
|
159
|
+
computeCacheKey: ()=>this.isDisabled() ? '' : 'vb',
|
|
160
|
+
extraUniforms: {
|
|
161
|
+
tVelocity: ()=>({value: !this.isDisabled() ? this.target?.texture:null}),
|
|
162
|
+
},
|
|
163
|
+
extraDefines: {
|
|
164
|
+
['HAS_VELOCITY_BUFFER']: ()=>!this.isDisabled() && this.target?.texture ? 1 : undefined,
|
|
165
|
+
},
|
|
166
|
+
priority: 100,
|
|
167
|
+
isCompatible: () => true,
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setDirty() {
|
|
171
|
+
super.setDirty();
|
|
172
|
+
this.unpackExtension.setDirty?.()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
protected _beforeRender(scene: IScene, camera: ICamera, renderManager: IRenderManager): boolean {
|
|
176
|
+
if (!super._beforeRender(scene, camera, renderManager)) return false
|
|
177
|
+
const pass = this.pass
|
|
178
|
+
if (!pass) return false
|
|
179
|
+
if (renderManager.frameCount > 0) return false
|
|
180
|
+
pass.scene = scene
|
|
181
|
+
pass.camera = camera
|
|
182
|
+
camera.updateShaderProperties(pass.overrideMaterial as ShaderMaterial)
|
|
183
|
+
return true
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
declare module 'threepipe' {
|
|
190
|
+
interface IMaterialUserData {
|
|
191
|
+
[VelocityBufferPlugin.PluginType]?: {
|
|
192
|
+
/**
|
|
193
|
+
* Disables rendering to the velocity buffer.
|
|
194
|
+
*/
|
|
195
|
+
disabled?: boolean
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export class SSVelocityMaterial extends ShaderMaterial {
|
|
200
|
+
|
|
201
|
+
constructor() {
|
|
202
|
+
super({
|
|
203
|
+
vertexShader: ssVelocityVert,
|
|
204
|
+
fragmentShader: ssVelocityFrag,
|
|
205
|
+
uniforms: {
|
|
206
|
+
cameraNearFar: {value: new Vector2(0.1, 1000)},
|
|
207
|
+
alphaMap: {value: null},
|
|
208
|
+
alphaTest: {value: null},
|
|
209
|
+
alphaMapTransform: {value: /* @__PURE__*/ new Matrix3()},
|
|
210
|
+
currentProjectionViewMatrix: {value: new Matrix4()},
|
|
211
|
+
lastProjectionViewMatrix: {value: new Matrix4()},
|
|
212
|
+
},
|
|
213
|
+
blending: NoBlending, // todo?
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
extraUniformsToUpload: Record<string, IUniform> = {
|
|
218
|
+
modelMatrixPrevious: {value: new Matrix4().identity()},
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private _previousWorldMatrices: Record<string, Matrix4> = {}
|
|
222
|
+
|
|
223
|
+
// this gets called for each object.
|
|
224
|
+
onBeforeRender(_r: WebGLRenderer, _s: Scene, _c: Camera, _geometry: BufferGeometry, object: IObject3D, group: Group) {
|
|
225
|
+
super.onBeforeRender(_r, _s, _c, _geometry, object, group)
|
|
226
|
+
const prevMatrix = this._previousWorldMatrices[object.uuid]
|
|
227
|
+
this.extraUniformsToUpload.modelMatrixPrevious.value.copy(prevMatrix ?? object.matrixWorld)
|
|
228
|
+
|
|
229
|
+
// todo: make sure all objects are only rendered once.
|
|
230
|
+
if (prevMatrix) {
|
|
231
|
+
prevMatrix.copy(object.matrixWorld)
|
|
232
|
+
} else {
|
|
233
|
+
this._previousWorldMatrices[object.uuid] = object.matrixWorld.clone()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// todo: add support for all this in the shaders.
|
|
237
|
+
let mat = object.material
|
|
238
|
+
|
|
239
|
+
if (Array.isArray(mat)) { // todo: add support for multi materials.
|
|
240
|
+
mat = mat[0]
|
|
241
|
+
}
|
|
242
|
+
this.uniforms.alphaMap.value = mat?.alphaMap ?? null
|
|
243
|
+
this.uniforms.alphaTest.value = !mat || !mat.alphaTest || mat.alphaTest < 0.0000001 ? 0.001 : mat.alphaTest
|
|
244
|
+
|
|
245
|
+
let x = this.uniforms.alphaMap.value ? 1 : undefined
|
|
246
|
+
if (x !== this.defines.USE_ALPHAMAP) {
|
|
247
|
+
if (x === undefined) {
|
|
248
|
+
delete this.defines.USE_ALPHAMAP
|
|
249
|
+
delete this.defines.ALPHAMAP_UV
|
|
250
|
+
} else {
|
|
251
|
+
this.defines.USE_ALPHAMAP = x
|
|
252
|
+
this.defines.ALPHAMAP_UV = 'uv' // uv_vertex needs the channel for vAlphaMapUv, as in GBufferMaterial
|
|
253
|
+
}
|
|
254
|
+
this.needsUpdate = true
|
|
255
|
+
}
|
|
256
|
+
const alphaMap = this.uniforms.alphaMap.value as Texture | null
|
|
257
|
+
if (alphaMap) {
|
|
258
|
+
if (alphaMap.matrixAutoUpdate) alphaMap.updateMatrix()
|
|
259
|
+
this.uniforms.alphaMapTransform.value.copy(alphaMap.matrix)
|
|
260
|
+
}
|
|
261
|
+
x = mat?.userData.ALPHA_I_RGBA_PACKING ? 1 : undefined
|
|
262
|
+
if (x !== this.defines.ALPHA_I_RGBA_PACKING) {
|
|
263
|
+
if (x === undefined) delete this.defines.ALPHA_I_RGBA_PACKING
|
|
264
|
+
else this.defines.ALPHA_I_RGBA_PACKING = x
|
|
265
|
+
this.needsUpdate = true
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
this.side = mat?.side ?? DoubleSide
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#ifdef USE_ALPHAMAP
|
|
2
|
+
#define USE_UV
|
|
3
|
+
#include <packing>
|
|
4
|
+
uniform sampler2D alphaMap;
|
|
5
|
+
uniform float alphaTest;
|
|
6
|
+
#endif
|
|
7
|
+
#include <uv_pars_fragment>
|
|
8
|
+
|
|
9
|
+
varying vec3 vWorldPosition;
|
|
10
|
+
varying vec3 vWorldPositionPrevious;
|
|
11
|
+
uniform mat4 currentProjectionViewMatrix;
|
|
12
|
+
uniform mat4 lastProjectionViewMatrix;
|
|
13
|
+
|
|
14
|
+
vec2 computeScreenSpaceVelocity2() {
|
|
15
|
+
vec4 currentPositionClip = currentProjectionViewMatrix * vec4(vWorldPosition, 1.0);
|
|
16
|
+
vec4 prevPositionClip = lastProjectionViewMatrix * vec4(vWorldPositionPrevious, 1.0);
|
|
17
|
+
|
|
18
|
+
vec2 currentPositionNDC = currentPositionClip.xy / currentPositionClip.w;
|
|
19
|
+
vec2 prevPositionNDC = prevPositionClip.xy / prevPositionClip.w;
|
|
20
|
+
|
|
21
|
+
if(prevPositionNDC.x >= 1.0 || prevPositionNDC.x <= -1.0 || prevPositionNDC.x >= 1.0 || prevPositionNDC.y <= -1.0) {
|
|
22
|
+
return vec2(0.0);
|
|
23
|
+
}
|
|
24
|
+
return 0.5 * (currentPositionNDC - prevPositionNDC);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void main() {
|
|
28
|
+
// alpha test like the GBuffer material, so cut-out texels do not write the mesh's motion
|
|
29
|
+
#ifdef USE_ALPHAMAP
|
|
30
|
+
float alphaMapValue =
|
|
31
|
+
#ifdef ALPHA_I_RGBA_PACKING
|
|
32
|
+
1. - unpackRGBAToDepth( texture2D( alphaMap, vAlphaMapUv ) );
|
|
33
|
+
#else
|
|
34
|
+
texture2D( alphaMap, vAlphaMapUv ).g;
|
|
35
|
+
#endif
|
|
36
|
+
if ( alphaMapValue < alphaTest ) discard;
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
vec2 velocity = clamp(computeScreenSpaceVelocity2(), -1.0, 1.0);
|
|
40
|
+
velocity = sign(velocity) * pow(abs(velocity), vec2(1./4.));
|
|
41
|
+
velocity = velocity * 0.5 + 0.5;
|
|
42
|
+
gl_FragColor = vec4(velocity.x, velocity.y, 1., 1.);
|
|
43
|
+
|
|
44
|
+
// float speed = length(computeScreenSpaceVelocity2());
|
|
45
|
+
// gl_FragColor = vec4(speed, speed, speed, 1.);
|
|
46
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#ifdef USE_ALPHAMAP
|
|
2
|
+
#define USE_UV
|
|
3
|
+
#endif
|
|
4
|
+
#include <uv_pars_vertex>
|
|
5
|
+
#include <batching_pars_vertex>
|
|
6
|
+
#include <morphtarget_pars_vertex>
|
|
7
|
+
#include <skinning_pars_vertex>
|
|
8
|
+
#include <logdepthbuf_pars_vertex>
|
|
9
|
+
#include <clipping_planes_pars_vertex>
|
|
10
|
+
|
|
11
|
+
//varying vec3 vViewPosition;
|
|
12
|
+
|
|
13
|
+
varying vec3 vWorldPosition;
|
|
14
|
+
varying vec3 vWorldPositionPrevious;
|
|
15
|
+
|
|
16
|
+
uniform mat4 modelMatrixPrevious;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
|
|
20
|
+
#include <uv_vertex>
|
|
21
|
+
#include <batching_vertex>
|
|
22
|
+
#include <skinbase_vertex>
|
|
23
|
+
|
|
24
|
+
#include <begin_vertex>
|
|
25
|
+
#include <morphtarget_vertex>
|
|
26
|
+
#include <skinning_vertex>
|
|
27
|
+
#include <displacementmap_vertex>
|
|
28
|
+
|
|
29
|
+
// project_vertex
|
|
30
|
+
|
|
31
|
+
vec4 mvPosition = vec4( transformed, 1.0 );
|
|
32
|
+
|
|
33
|
+
#ifdef USE_INSTANCING
|
|
34
|
+
|
|
35
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
36
|
+
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
vWorldPosition = (modelMatrix * mvPosition).xyz;
|
|
40
|
+
vWorldPositionPrevious = (modelMatrixPrevious * mvPosition).xyz;
|
|
41
|
+
|
|
42
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
43
|
+
|
|
44
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
45
|
+
|
|
46
|
+
#include <logdepthbuf_vertex>
|
|
47
|
+
#include <clipping_planes_vertex>
|
|
48
|
+
|
|
49
|
+
// vViewPosition = - mvPosition.xyz;
|
|
50
|
+
|
|
51
|
+
}
|