A Claude Code skill that reverse-engineers any animation frame by frame, then proves the copy moves the same.
Add the Liveblocks, Resend and React Bits examples
NiazMorshed20071588274b5889
diff --git a/site/public/examples/liveblocks-comments/assets/fonts/Inter-Variable.woff2 b/site/public/examples/liveblocks-comments/assets/fonts/Inter-Variable.woff2new file mode 100644index 0000000..d15208dBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/fonts/Inter-Variable.woff2 differdiff --git a/site/public/examples/liveblocks-comments/assets/fonts/LICENSE-inter.txt b/site/public/examples/liveblocks-comments/assets/fonts/LICENSE-inter.txtnew file mode 100644index 0000000..40589da--- /dev/null+++ b/site/public/examples/liveblocks-comments/assets/fonts/LICENSE-inter.txt@@ -0,0 +1,93 @@+Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-128.webp b/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-128.webpnew file mode 100644index 0000000..c8960a7Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-256.webp b/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-256.webpnew file mode 100644index 0000000..8d0bb80Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/alicia-henriquez-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-128.webp b/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-128.webpnew file mode 100644index 0000000..0a6c659Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-256.webp b/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-256.webpnew file mode 100644index 0000000..d9a9e61Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/chris-nicholas-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-128.webp b/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-128.webpnew file mode 100644index 0000000..58872daBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-256.webp b/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-256.webpnew file mode 100644index 0000000..8e1b43fBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/jonathan-rowny-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/liveblocks-ai.svg b/site/public/examples/liveblocks-comments/assets/people/liveblocks-ai.svgnew file mode 100644index 0000000..3005b86--- /dev/null+++ b/site/public/examples/liveblocks-comments/assets/people/liveblocks-ai.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 64 64" fill="none" role="img" aria-label="Generated avatar" data-shape="square" data-pattern="marble" data-version="2"><g filter="url(#blur-1b50a4f2)"><rect x="-32" y="-32" width="128" height="128" fill="#3d2133"/><rect x="-32" y="-32" width="128" height="128" fill="#e29ac2" opacity="0.4"/><path d="M10 8C21 0 44 1 55 13C66 24 66 43 53 55C41 67 18 66 8 53C-2 40 0 16 10 8Z" fill="#e29ac2" transform="translate(1.3 -0.1) rotate(-138 32 32) scale(1.16)"/><path d="M6 29C7 15 20 6 34 6C49 7 60 17 61 31C62 43 53 55 39 60C24 66 6 53 6 29Z" fill="#ffe6f4" transform="translate(-5.1 6.1) rotate(104 32 32) scale(1.01)" style="mix-blend-mode:soft-light"/><path d="M16 9C26 4 39 5 48 13C58 21 61 34 57 45C51 58 39 62 28 60C16 58 7 47 7 35C7 24 10 14 16 9Z" fill="#e29ac2" transform="translate(7.1 -0.1) rotate(-117 32 32) scale(1.11)" style="mix-blend-mode:soft-light"/></g><rect x="0" y="0" width="64" height="64" fill="white" opacity="0.2"/><rect x="0" y="0" width="64" height="64" fill="url(#hl-1b50a4f2)"/><defs><filter id="blur-1b50a4f2" x="-35%" y="-35%" width="170%" height="170%" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="5.5" edgeMode="none"/></filter><radialGradient id="hl-1b50a4f2" cx="38%" cy="28%" r="58%" gradientUnits="objectBoundingBox"><stop offset="0%" stop-color="white" stop-opacity="0.12"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><g transform="translate(16 16)" fill="black"><path d="M25.805 19.12c-6.996 2.312-9.325 4.642-11.637 11.638-.19.575-1.003.575-1.193 0-2.312-6.996-4.642-9.326-11.637-11.637-.576-.19-.576-1.004 0-1.194 6.996-2.311 9.325-4.641 11.637-11.637.19-.575 1.003-.575 1.193 0 2.312 6.996 4.642 9.326 11.637 11.637.575.19.575 1.004 0 1.194Z"/><path d="M30.879 7.632c-3.497 1.155-4.663 2.32-5.82 5.82-.094.287-.5.287-.596 0-1.155-3.498-2.32-4.664-5.82-5.82-.287-.095-.287-.501 0-.597 3.498-1.155 4.663-2.32 5.82-5.82a.314.314 0 0 1 .596 0c1.155 3.498 2.321 4.663 5.82 5.82.287.094.287.5 0 .597Z"/></g></svg>\ No newline at end of filediff --git a/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-128.webp b/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-128.webpnew file mode 100644index 0000000..ef43596Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-256.webp b/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-256.webpnew file mode 100644index 0000000..32618aaBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/nimesh-nayaju-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-128.webp b/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-128.webpnew file mode 100644index 0000000..fcefb95Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-256.webp b/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-256.webpnew file mode 100644index 0000000..5812852Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/olivier-foucherot-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-128.webp b/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-128.webpnew file mode 100644index 0000000..736eb3fBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-256.webp b/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-256.webpnew file mode 100644index 0000000..1a9dbfaBinary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/pierre-levaillant-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/steven-fabre-128.webp b/site/public/examples/liveblocks-comments/assets/people/steven-fabre-128.webpnew file mode 100644index 0000000..fb965f7Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/steven-fabre-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/steven-fabre-256.webp b/site/public/examples/liveblocks-comments/assets/people/steven-fabre-256.webpnew file mode 100644index 0000000..a4c8678Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/steven-fabre-256.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-128.webp b/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-128.webpnew file mode 100644index 0000000..c2708f5Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-128.webp differdiff --git a/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-256.webp b/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-256.webpnew file mode 100644index 0000000..6843594Binary files /dev/null and b/site/public/examples/liveblocks-comments/assets/people/vincent-driessen-256.webp differdiff --git a/site/public/examples/liveblocks-comments/index.html b/site/public/examples/liveblocks-comments/index.htmlnew file mode 100644index 0000000..278e66f--- /dev/null+++ b/site/public/examples/liveblocks-comments/index.html@@ -0,0 +1,238 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <title>liveblocks.io/comments hero slideshow, rebuilt with reanimate</title>+ <meta name="robots" content="noindex">+ <!--+ The animated demo under the hero of liveblocks.io/comments: an app window that cycles through five use cases+ (text editor, media player, whiteboard, website, video editor) every 6 s. On each change the drawing fades and+ blurs out, the next one springs in, the comment thread crossfades and, a second later, the panel glides and+ resizes to its new spot while the colours shift. Plain HTML + ES modules; src/motion.js ports the springs,+ tweens and colour mixing of motion (framer-motion), src/projection.js its layout animations.+ -->+ <link rel="preload" href="./assets/fonts/Inter-Variable.woff2" as="font" type="font/woff2" crossorigin>+ <link rel="stylesheet" href="./src/slideshow.css">+ <script type="module" src="./src/slideshow.js"></script>+</head>+<body>+ <svg width="0" height="0" style="position:absolute" aria-hidden="true">+ <symbol id="i-resolve" viewBox="0 0 16 16"><circle cx="8" cy="8" r="5.6" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M10.4 6.4 7.2 9.6 5.6 8" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></symbol>+ <symbol id="i-react" viewBox="0 0 16 16"><path d="M8.8 2.46a5.6 5.6 0 1 0 4.74 4.74" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 9.2s.6 1.2 2 1.2 2-1.2 2-1.2" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.4 6.4h0" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><circle cx="6.4" cy="6.4" r=".2" stroke="#A3A3A3" stroke-width="1.2"/><path d="M9.6 6.4h0" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9.6" cy="6.4" r=".2" stroke="#A3A3A3" stroke-width="1.2"/><path d="M10.4 4h3.2" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 2.4v3.2" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></symbol>+ <symbol id="i-more" viewBox="0 0 16 16"><circle cx="4" cy="8" r=".6" fill="#A3A3A3" stroke="#A3A3A3" stroke-width="1.2"/><circle cx="8" cy="8" r=".6" fill="#A3A3A3" stroke="#A3A3A3" stroke-width="1.2"/><circle cx="12" cy="8" r=".6" fill="#A3A3A3" stroke="#A3A3A3" stroke-width="1.2"/></symbol>+ <symbol id="i-chevron" viewBox="0 0 16 16"><path d="M11.2 7.2 8 10.4 4.8 7.2" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></symbol>+ </svg>++ <main class="lb-page">+ <section class="lb-hero" aria-label="Comments in five kinds of app: a text editor, a media player, a whiteboard, a website and a video editor, one after another.">+ <div class="lb-stage">+ <div class="lb-halo" aria-hidden="true"><div class="lb-halo__glow"></div></div>++ <div class="liveblocks-slideshow select-none aspect-1208/770" data-case="text-editor" aria-hidden="true">+ <div class="lb-panel">+ <div class="lb-panel__bg"></div>++ <div class="lb-thread lb-thread--text-editor" data-show="text-editor">+ <div class="lb-quote"><div class="lb-divider"></div><span class="lb-quote__text">was created in 2021</span></div>+ <div class="lb-c">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/jonathan-rowny-256.webp" srcset="./assets/people/jonathan-rowny-128.webp 1x, ./assets/people/jonathan-rowny-256.webp 2x" width="120" height="120" alt=""></div><div><span class="lb-c__name">Jonathan</span><span class="lb-c__time">8m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-resolve"/></svg></div><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text"><span class="lb-mention">@Alicia</span> Is this correct?</div></div>+ </div>+ <div class="lb-c lb-c--next">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/alicia-henriquez-256.webp" srcset="./assets/people/alicia-henriquez-128.webp 1x, ./assets/people/alicia-henriquez-256.webp 2x" width="120" height="120" alt=""></div><div><span class="lb-c__name">Alicia</span><span class="lb-c__time">now</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text">Can you double-check this <span class="lb-accent">@Liveblocks AI</span>?</div></div>+ </div>+ <div class="lb-c lb-c--next lb-c--last">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/liveblocks-ai.svg" width="120" height="120" alt=""></div><div><span class="lb-c__name">Liveblocks AI</span><span class="lb-c__time">2m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text">Yes, that sentence is correct. The date matches the doc metadata.</div></div>+ </div>+ </div>++ <div class="lb-thread lb-thread--audio" data-show="audio">+ <div class="lb-c">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/nimesh-nayaju-256.webp" srcset="./assets/people/nimesh-nayaju-128.webp 1x, ./assets/people/nimesh-nayaju-256.webp 2x" width="120" height="120" alt=""></div><div><span class="lb-c__name">Nimesh</span><span class="lb-c__time">36m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-resolve"/></svg></div><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text"><span class="lb-accent">00:46</span> Can we remove the reverb here?</div></div>+ </div>+ <div class="lb-c lb-c--next lb-c--last">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/liveblocks-ai.svg" width="120" height="120" alt=""></div><div><span class="lb-c__name">Liveblocks AI</span><span class="lb-c__time">12m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text"><span class="lb-accent">00:46</span> I can suggest a dry mix preset for that section if you’d like.</div></div>+ </div>+ </div>++ <div class="lb-thread lb-thread--whiteboard" data-show="whiteboard">+ <div class="lb-c">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/olivier-foucherot-256.webp" srcset="./assets/people/olivier-foucherot-128.webp 1x, ./assets/people/olivier-foucherot-256.webp 2x" width="120" height="120" alt=""></div><div><span class="lb-c__name">Olivier</span><span class="lb-c__time">16m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-resolve"/></svg></div><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body">+ <div class="lb-c__text">We should change this into a circle.</div>+ <div class="lb-reactions">+ <div class="lb-reaction"><span class="lb-emoji">👍</span><span class="lb-count lb-count--tight">3</span></div>+ <div class="lb-reaction"><span class="lb-emoji">✅</span><span class="lb-count">1</span></div>+ <div class="lb-reaction"><svg class="lb-1em" viewBox="0 0 16 16" fill="none" style="width:1em"><use href="#i-react"/></svg></div>+ </div>+ </div>+ </div>+ <div class="lb-c lb-c--next lb-c--last">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar"><img src="./assets/people/liveblocks-ai.svg" width="120" height="120" alt=""></div><div><span class="lb-c__name">Liveblocks AI</span><span class="lb-c__time">8m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text">Good call. A circle would match the style guide better.</div></div>+ </div>+ </div>++ <div class="lb-thread lb-thread--website" data-show="website">+ <div class="lb-c">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/chris-nicholas-256.webp" srcset="./assets/people/chris-nicholas-128.webp 1x, ./assets/people/chris-nicholas-256.webp 2x" width="120" height="120" alt=""></div><div><span class="lb-c__name">Chris</span><span class="lb-c__time">2m ago (edited)</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-resolve"/></svg></div><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body">+ <div class="lb-c__text">Can we make the logo bigger?</div>+ <div class="lb-reactions">+ <div class="lb-reaction lb-reaction--accent"><span class="lb-emoji">😅</span><span class="lb-count">6</span></div>+ <div class="lb-reaction"><svg viewBox="0 0 16 16" fill="none" style="width:1em"><use href="#i-react"/></svg></div>+ </div>+ </div>+ </div>+ <div class="lb-c lb-c--next lb-c--last">+ <div class="lb-c__head">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/liveblocks-ai.svg" width="120" height="120" alt=""></div><div><span class="lb-c__name">Liveblocks AI</span><span class="lb-c__time">now</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-resolve"/></svg></div><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-react"/></svg></div></div>+ </div>+ <div class="lb-c__body"><div class="lb-c__text">The header logo is currently 24px. Bumping it to 32px would keep it within the 8px grid.</div></div>+ </div>+ </div>++ <div class="lb-thread lb-thread--video" data-show="video">+ <div class="lb-threads-head"><div class="lb-divider"></div><div class="lb-threads-head__filter"><span>All threads</span><svg viewBox="0 0 16 16" fill="none"><use href="#i-chevron"/></svg></div></div>+ <div class="lb-section">+ <div class="lb-divider"></div>+ <div class="lb-c">+ <div class="lb-c__head lb-c__head--lg">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/steven-fabre-256.webp" srcset="./assets/people/steven-fabre-128.webp 1x, ./assets/people/steven-fabre-256.webp 2x" width="120" height="120" alt=""></div><div class="lb-c__names--col"><span class="lb-c__name">Steven</span><span class="lb-c__time">16m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-more"/></svg></div></div>+ </div>+ <div class="lb-c__body--video"><div class="lb-c__text"><span class="lb-accent">00:10</span> Can we switch these shots?</div></div>+ </div>+ </div>+ <div class="lb-section">+ <div class="lb-divider"></div>+ <div class="lb-c">+ <div class="lb-c__head lb-c__head--lg">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/pierre-levaillant-256.webp" srcset="./assets/people/pierre-levaillant-128.webp 1x, ./assets/people/pierre-levaillant-256.webp 2x" width="120" height="120" alt=""></div><div class="lb-c__names--col"><span class="lb-c__name">Pierre</span><span class="lb-c__time">5m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-more"/></svg></div></div>+ </div>+ <div class="lb-c__body--video">+ <div class="lb-c__text"><span class="lb-accent">00:42</span> This looks a bit off. Look at the attached screenshots.</div>+ <div class="lb-attachments"><div class="lb-attachment"></div><div class="lb-attachment"></div></div>+ </div>+ </div>+ <div class="lb-c lb-c--next lb-c--last">+ <div class="lb-c__head lb-c__head--lg">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/liveblocks-ai.svg" width="120" height="120" alt=""></div><div class="lb-c__names--col"><span class="lb-c__name">Liveblocks AI</span><span class="lb-c__time">now</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-more"/></svg></div></div>+ </div>+ <div class="lb-c__body--video"><div class="lb-c__text">The color grading at <span class="lb-accent">00:42</span> differs from the previous shot. Adjusting the exposure should help maintain consistency.</div></div>+ </div>+ </div>+ <div class="lb-section">+ <div class="lb-c">+ <div class="lb-c__head lb-c__head--lg">+ <div class="lb-c__who"><div class="lb-c__avatar lb-c__avatar--square"><img src="./assets/people/vincent-driessen-256.webp" srcset="./assets/people/vincent-driessen-128.webp 1x, ./assets/people/vincent-driessen-256.webp 2x" width="120" height="120" alt=""></div><div class="lb-c__names--col"><span class="lb-c__name">Vincent</span><span class="lb-c__time">2m ago</span></div></div>+ <div class="lb-c__tools"><div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><use href="#i-more"/></svg></div></div>+ </div>+ <div class="lb-c__body--video"><div class="lb-c__text"><span class="lb-accent">01:12</span> I love the color grading! 👌</div></div>+ </div>+ </div>+ </div>++ <div class="lb-composer">+ <div class="lb-composer__divider"></div>+ <div class="lb-composer__row">+ <div class="lb-composer__avatar">+ <div data-show="audio"><img src="./assets/people/steven-fabre-256.webp" srcset="./assets/people/steven-fabre-128.webp 1x, ./assets/people/steven-fabre-256.webp 2x" width="120" height="120" alt=""></div>+ <div data-show="whiteboard"><img src="./assets/people/steven-fabre-256.webp" srcset="./assets/people/steven-fabre-128.webp 1x, ./assets/people/steven-fabre-256.webp 2x" width="120" height="120" alt=""></div>+ </div>+ <div class="lb-composer__input">+ <span class="lb-composer__placeholder" data-show="text-editor audio whiteboard website">Reply to thread…</span>+ <span class="lb-composer__placeholder" data-show="video">Create a new thread…</span>+ </div>+ </div>+ <div class="lb-composer__actions">+ <div class="lb-composer__left">+ <div class="lb-composer__resolve" data-show="audio video">+ <svg viewBox="0 0 12 12" fill="none"><rect width="12" height="12" rx="3" fill="var(--hero-accent)"/><path d="M9 4 4.87 8 3 6.18" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>+ <span data-show="audio">Mark as resolved</span>+ <span data-show="video">Attach to current time</span>+ </div>+ <div class="lb-composer__tools" data-show="text-editor whiteboard">+ <div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><path d="M8 10.4a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8Z" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M10.4 5.6v2.96c0 .88.68 1.68 1.52 1.68a1.7 1.7 0 0 0 1.68-1.68V8a5.6 5.6 0 1 0-2.24 4.48" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ <div class="lb-icon"><svg viewBox="0 0 16 16" fill="none"><path d="M8 13.6A5.6 5.6 0 1 0 8 2.4a5.6 5.6 0 0 0 0 11.2Z" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 9.2s.6 1.2 2 1.2 2-1.2 2-1.2" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.4 6.4h0" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><circle cx="6.4" cy="6.4" r=".2" stroke="#A3A3A3" stroke-width="1.2"/><path d="M9.6 6.4h0" stroke="#A3A3A3" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><circle cx="9.6" cy="6.4" r=".2" stroke="#A3A3A3" stroke-width="1.2"/></svg></div>+ <div class="lb-icon lb-icon--px"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M11.2611 9.38924L8.28265 12.2852C7.04265 13.4908 4.98025 13.4908 3.74025 12.2852C2.50585 11.0852 2.50585 9.06924 3.74025 7.86924L8.32505 3.41084C9.15225 2.60604 10.5283 2.60524 11.3563 3.40844C12.1803 4.20844 12.1819 5.55404 11.3587 6.35564L6.76345 10.8132C6.55888 11.0068 6.28792 11.1147 6.00625 11.1147C5.72459 11.1147 5.45363 11.0068 5.24905 10.8132C5.15017 10.7178 5.07146 10.6035 5.01759 10.4771C4.96372 10.3506 4.93579 10.2147 4.93545 10.0772C4.93545 9.80124 5.04745 9.53644 5.24905 9.34124L8.27785 6.39964" stroke="#A3A3A3" stroke-width="1.2"/></svg></div>+ </div>+ </div>+ <div class="lb-send">+ <div class="lb-send__layer"><span class="lb-send__label" data-show="audio">Comment</span></div>+ <div class="lb-send__layer"><span class="lb-send__label" data-show="whiteboard">Send</span></div>+ <div class="lb-send__layer"><div class="lb-send__icon" data-show="text-editor website video"><svg class="lb-1em" viewBox="0 0 16 16" fill="none"><path d="M4 12.8 13.6 8 4 3.2 5.6 8 4 12.8Z" stroke="#fff" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5.6 8h8" stroke="#fff" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div>+ </div>+ </div>+ </div>+ </div>++ <div class="lb-app">+ <div class="lb-app__cover"></div>+ <div class="lb-app__glow" style="opacity:0"><div class="lb-app__line"></div><div class="lb-app__radial"></div></div>+ <svg class="lb-topbar" viewBox="0 0 1208 770" fill="none">+ <g fill="var(--hero-background-100)">+ <rect x="65" y="51.0691" width="106.038" height="21.2075" rx="10.6038"/>+ <g stroke="var(--hero-background-0)" stroke-width="2"><rect x="1078" y="51"/><rect x="1103" y="51"/><rect x="1128" y="51"/></g>+ </g>+ </svg>+ <!-- the scenes are added here by src/slideshow.js -->+ </div>+ </div>++ <div class="lb-tabs">+ <button class="lb-tab is-active" type="button" data-type="text-editor" aria-label="Text editor" style="--use-case-accent:#e89304" disabled>+ <div class="lb-tab__progress" style="opacity:0.3;transform:scaleX(0.1)"></div>+ <div class="lb-tab__icon"><svg width="16" height="16" fill="none"><path d="M11 2.5c.5-.5 1.79-.71 2.5 0s.5 2 0 2.5l-7.27 7.27a4 4 0 0 1-1.73 1.01L2 14l.72-2.5a4 4 0 0 1 1.01-1.73L11 2.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ <span class="lb-tab__name">Text editor</span>+ </button>+ <button class="lb-tab" type="button" data-type="audio" aria-label="Media player" style="--use-case-accent:#f44e6b">+ <div class="lb-tab__icon"><svg width="16" height="16" fill="none"><path d="M7 3.5 4 6H2a.5.5 0 0 0-.5.5v3c0 .28.22.5.5.5h2l3 2.5v-9Zm3 2c.62.63 1 1.62 1 2.5a3.7 3.7 0 0 1-1 2.5M12.5 3a7.4 7.4 0 0 1 2 5 7.4 7.4 0 0 1-2 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ </button>+ <button class="lb-tab" type="button" data-type="whiteboard" aria-label="Whiteboard" style="--use-case-accent:#0090ff">+ <div class="lb-tab__icon"><svg width="16" height="16" fill="none"><path d="M2.75 14h3c.41 0 .75-.34.75-.75v-3a.75.75 0 0 0-.75-.75h-3a.75.75 0 0 0-.75.75v3c0 .41.34.75.75.75Zm9 0a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Zm-6.7-8.29L7.6 2.1a.5.5 0 0 1 .82 0l2.54 3.62a.5.5 0 0 1-.41.79H5.46a.5.5 0 0 1-.4-.79Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ </button>+ <button class="lb-tab" type="button" data-type="website" aria-label="Website" style="--use-case-accent:#30a46c">+ <div class="lb-tab__icon"><svg width="16" height="16" fill="none"><path d="M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 2a8.52 8.52 0 0 0-2.5 6c0 2.23.9 4.38 2.5 6a8.52 8.52 0 0 0 2.5-6c0-2.23-.9-4.38-2.5-6ZM2 8h12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ </button>+ <button class="lb-tab" type="button" data-type="video" aria-label="Video editor" style="--use-case-accent:#8F6CEF">+ <div class="lb-tab__icon"><svg width="16" height="16" fill="none"><path d="M14.5 5.33 10.5 8l4 2.67V5.33Zm-13 .17v5c0 .83.67 1.5 1.5 1.5h6c.83 0 1.5-.67 1.5-1.5v-5C10.5 4.67 9.83 4 9 4H3c-.83 0-1.5.67-1.5 1.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg></div>+ </button>+ </div>+ </div>+ </section>+ </main>+</body>+</html>diff --git a/site/public/examples/liveblocks-comments/src/motion.js b/site/public/examples/liveblocks-comments/src/motion.jsnew file mode 100644index 0000000..09b1315--- /dev/null+++ b/site/public/examples/liveblocks-comments/src/motion.js@@ -0,0 +1,290 @@+// The parts of motion (framer-motion v12) that liveblocks.io's hero uses, ported so the copy moves on the same+// curves: the spring and tween generators (same formulas, same rest thresholds), motion's cubic-bezier solver,+// its colour mixing, and a frame loop that samples every animation at performance.now() once per frame.++// ---------- easing ----------++const calcBezier = (t, a1, a2) => (((1 - 3 * a2 + 3 * a1) * t + (3 * a2 - 6 * a1)) * t + 3 * a1) * t;++function binarySubdivide(x, lo, hi, x1, x2) {+ let cx;+ let ct;+ let i = 0;+ do {+ ct = lo + (hi - lo) / 2;+ cx = calcBezier(ct, x1, x2) - x;+ if (cx > 0) hi = ct;+ else lo = ct;+ } while (Math.abs(cx) > 1e-7 && ++i < 12);+ return ct;+}++export function cubicBezier(x1, y1, x2, y2) {+ if (x1 === y1 && x2 === y2) return (t) => t;+ return (t) => (t === 0 || t === 1 ? t : calcBezier(binarySubdivide(t, 0, 1, x1, x2), y1, y2));+}++export const EASE = {+ linear: (t) => t,+ easeIn: cubicBezier(0.42, 0, 1, 1),+ easeOut: cubicBezier(0, 0, 0.58, 1),+ easeInOut: cubicBezier(0.42, 0, 0.58, 1),+};++const easing = (e) => (typeof e === "function" ? e : Array.isArray(e) ? cubicBezier(...e) : EASE[e ?? "easeInOut"]);++// ---------- generators: next(ms since the animation's delay ended) -> { value, done } ----------++// motion's spring(): analytic solution, done when |velocity| <= restSpeed and |target - value| <= restDelta.+export function spring({ from, to, stiffness = 100, damping = 10, mass = 1, velocity = 0, restSpeed, restDelta }) {+ const V = to;+ const O = to - from;+ const E = -velocity / 1000; // motion: velocity: -millisecondsToSeconds(velocity)+ const B = damping / (2 * Math.sqrt(stiffness * mass));+ const W = Math.sqrt(stiffness / mass) / 1000;+ const granular = Math.abs(O) < 5;+ const rs = restSpeed ?? (granular ? 0.01 : 2);+ const rd = restDelta ?? (granular ? 0.005 : 0.5);+ let pos;+ let vel; // units per ms+ if (B < 1) {+ const y = W * Math.sqrt(1 - B * B);+ const b = (E + B * W * O) / y;+ const w = B * W * b + O * y;+ const T = B * W * O - b * y;+ pos = (t) => V - Math.exp(-B * W * t) * (b * Math.sin(y * t) + O * Math.cos(y * t));+ vel = (t) => Math.exp(-B * W * t) * (w * Math.sin(y * t) + T * Math.cos(y * t));+ } else if (B === 1) {+ const k = E + W * O;+ pos = (t) => V - Math.exp(-W * t) * (O + (E + W * O) * t);+ vel = (t) => Math.exp(-W * t) * (W * k * t - E);+ } else {+ const d = W * Math.sqrt(B * B - 1);+ const e = (E + B * W * O) / d;+ const i = B * W * e - O * d;+ const s = B * W * O - e * d;+ pos = (t) => V - (Math.exp(-B * W * t) * ((E + B * W * O) * Math.sinh(Math.min(d * t, 300)) + d * O * Math.cosh(Math.min(d * t, 300)))) / d;+ vel = (t) => Math.exp(-B * W * t) * (i * Math.sinh(Math.min(d * t, 300)) + s * Math.cosh(Math.min(d * t, 300)));+ }+ return (t) => {+ const p = pos(t);+ const done = Math.abs(vel(t) * 1000) <= rs && Math.abs(V - p) <= rd;+ return { value: done ? V : p, done };+ };+}++// motion's keyframes tween with one easing between two values.+export function tween({ from, to, duration = 300, ease }) {+ const f = easing(ease);+ return (t) => {+ const p = duration <= 0 ? 1 : Math.min(1, Math.max(0, t / duration));+ return { value: from + (to - from) * f(p), done: t >= duration };+ };+}++// ---------- colours (motion's mixColor: channels mixed as squares, rounded like its rgba transform) ----------++export function parseColor(c) {+ c = c.trim();+ if (c[0] === "#") {+ let h = c.slice(1);+ if (h.length <= 4) h = [...h].map((x) => x + x).join("");+ const n = parseInt(h.slice(0, 6), 16);+ return [(n >> 16) & 255, (n >> 8) & 255, n & 255, h.length === 8 ? parseInt(h.slice(6), 16) / 255 : 1];+ }+ const m = c.match(/[\d.]+/g).map(Number);+ return [m[0], m[1], m[2], m[3] ?? 1];+}++const mixLinear = (a, b, v) => {+ const e = v * (b * b - a * a) + a * a;+ return e < 0 ? 0 : Math.sqrt(e);+};++export function mixColor(from, to, v) {+ const a = parseColor(from);+ const b = parseColor(to);+ const ch = (i) => Math.round(Math.min(255, Math.max(0, mixLinear(a[i], b[i], v))));+ const alpha = Math.min(1, Math.max(0, a[3] + (b[3] - a[3]) * v));+ return `rgba(${ch(0)}, ${ch(1)}, ${ch(2)}, ${alpha})`;+}++// ---------- frame loop ----------++const anims = new Set();+const dirty = new Set(); // MotionEls to re-render this frame+const renders = new Set(); // run after every animation has stepped, once per frame+let scheduled = false;++function frame() {+ scheduled = false;+ const t = performance.now();+ for (const a of [...anims]) a.step(t);+ for (const m of dirty) m.render();+ dirty.clear();+ for (const r of [...renders]) r(t);+ if (anims.size || renders.size) schedule();+}++function schedule() {+ if (scheduled) return;+ scheduled = true;+ requestAnimationFrame(frame);+}++/** Runs fn(t) after the animations of every frame until the returned stop() is called. */+export function onRender(fn) {+ renders.add(fn);+ schedule();+ return () => renders.delete(fn);+}++/**+ * Animates one number. transition: { type: "spring", stiffness, damping, mass, delay (s), velocity }+ * or { duration (s), ease, delay (s) }. onUpdate(value) runs once per frame; the first frame samples+ * performance.now() - start, like motion's frame loop.+ */+export function animate(from, to, transition, onUpdate, { start = performance.now(), onComplete } = {}) {+ const tr = transition ?? {};+ const delay = (tr.delay ?? 0) * 1000;+ const gen =+ tr.type === "spring"+ ? spring({ from, to, stiffness: tr.stiffness, damping: tr.damping, mass: tr.mass, velocity: tr.velocity ?? 0, restSpeed: tr.restSpeed, restDelta: tr.restDelta })+ : tween({ from, to, duration: (tr.duration ?? 0.3) * 1000, ease: tr.ease });+ const a = {+ value: from,+ prev: from,+ prevAt: start,+ at: start,+ done: false,+ step(t) {+ const e = t - start - delay;+ if (e < 0) return;+ const r = gen(e);+ this.prev = this.value;+ this.prevAt = this.at;+ this.value = r.value;+ this.at = t;+ onUpdate(r.value);+ if (r.done) this.finish();+ },+ finish() {+ if (this.done) return;+ this.done = true;+ anims.delete(this);+ onComplete?.();+ },+ stop() {+ this.done = true;+ anims.delete(this);+ },+ // per second, from the last two frames (motion's MotionValue.getVelocity)+ velocity(t = performance.now()) {+ if (this.done || t - this.at > 30 || this.at === this.prevAt) return 0;+ return ((this.value - this.prev) / Math.min(this.at - this.prevAt, 30)) * 1000;+ },+ };+ anims.add(a);+ schedule();+ return a;+}++// ---------- motion values on elements ----------++const TRANSFORM_ORDER = ["x", "y", "scale", "scaleX", "scaleY", "rotateX"];+const DEFAULTS = { x: 0, y: 0, scale: 1, scaleX: 1, scaleY: 1, rotateX: 0 };+const fmt = { x: (v) => `translateX(${v}px)`, y: (v) => `translateY(${v}px)`, scale: (v) => `scale(${v})`, scaleX: (v) => `scaleX(${v})`, scaleY: (v) => `scaleY(${v})`, rotateX: (v) => `rotateX(${v}deg)` };++/**+ * An element whose opacity, transform, transform origin, blur and SVG path length are motion values, rendered+ * the way motion renders them: transforms in motion's fixed order ("none" when all are at rest), SVG children+ * transformed about their fill box, path length as pathLength=1 + stroke-dasharray.+ */+export class MotionEl {+ constructor(el, values = {}, { svgChild = false } = {}) {+ this.el = el;+ this.svgChild = svgChild;+ this.v = { ...values };+ this.running = {};+ this.render();+ }+ set(key, value) {+ this.v[key] = value;+ dirty.add(this);+ }+ render() {+ const { el, v } = this;+ const s = el.style;+ if ("opacity" in v) s.opacity = String(v.opacity);+ if ("blur" in v) s.filter = `blur(${v.blur}px)`;+ if ("width" in v) el.setAttribute("width", String(v.width));+ if ("height" in v) el.setAttribute("height", String(v.height));+ if ("rx" in v) el.setAttribute("rx", String(v.rx));+ if ("pathLength" in v) {+ el.setAttribute("pathLength", "1");+ el.setAttribute("stroke-dashoffset", "0px");+ el.setAttribute("stroke-dasharray", `${v.pathLength}px 1px`);+ }+ let tf = "";+ let any = false;+ for (const k of TRANSFORM_ORDER) {+ if (!(k in v)) continue;+ any = true;+ if (v[k] !== DEFAULTS[k]) tf += fmt[k](v[k]) + " ";+ }+ if (any) {+ s.transform = tf.trim() || "none";+ if (this.svgChild) {+ s.transformBox = "fill-box";+ if (!("originX" in v) && !("originY" in v)) s.transformOrigin = "50% 50%";+ }+ }+ if ("originX" in v || "originY" in v) {+ const ox = "originX" in v ? `${v.originX * 100}%` : "50%";+ const oy = "originY" in v ? `${v.originY * 100}%` : "50%";+ s.transformOrigin = `${ox} ${oy} 0`;+ if (this.svgChild) s.transformBox = "fill-box";+ }+ }+ /** Animates key from its current value to `to`; a running animation of the key is replaced (keeping its velocity). */+ to(key, to, transition, start) {+ const cur = this.running[key];+ const velocity = cur && !cur.done ? cur.velocity(start) : 0;+ cur?.stop();+ const from = this.v[key] ?? DEFAULTS[key] ?? 0;+ if (from === to && !velocity) return null;+ const tr = transition.type === "spring" ? { ...transition, velocity } : transition;+ const a = animate(from, to, tr, (val) => {+ this.v[key] = val;+ queueRender(this);+ }, { start });+ this.running[key] = a;+ return a;+ }+ /** Animates several keys with one transition (or a per-key transition map with a `default`). */+ animate(target, transition, start = performance.now()) {+ const out = [];+ for (const [k, val] of Object.entries(target)) {+ const tr = transition[k] ?? transition.default ?? transition;+ const a = this.to(k, val, tr, start);+ if (a) out.push(a);+ }+ return out;+ }+ stopAll() {+ for (const a of Object.values(this.running)) a.stop();+ }+}++function queueRender(m) {+ dirty.add(m);+}++/** Resolves once every animation in the list has finished (motion's AnimatePresence waits like this). */+export function whenDone(list) {+ return new Promise((resolve) => {+ const check = () => (list.every((a) => a.done) ? (stopCheck(), resolve()) : 0);+ const stopCheck = onRender(check);+ check();+ });+}diff --git a/site/public/examples/liveblocks-comments/src/projection.js b/site/public/examples/liveblocks-comments/src/projection.jsnew file mode 100644index 0000000..b6379ef--- /dev/null+++ b/site/public/examples/liveblocks-comments/src/projection.js@@ -0,0 +1,127 @@+// Layout animations the way framer-motion's projection does them: the DOM jumps to its new layout at once,+// and every `layout` element is then drawn at a box that moves from where it was to where it now is.+// A box is interpolated relative to its nearest layout ancestor's box (both interpolated), "position" nodes keep+// their new size and only move, and each element gets the translate + scale that maps its real layout box onto+// that box after its ancestors' transforms. Border radii given in px are corrected for the scale, as framer does.+import { animate, onRender } from "./motion.js";++const lerp = (a, b, p) => a + (b - a) * p;++export class LayoutGroup {+ /** root: the element boxes are measured against (it must not scale). */+ constructor(root) {+ this.root = root;+ this.nodes = [];+ this.anim = null;+ this.stopRender = null;+ }++ /** mode: true (position and size) or "position"; radius: () => px, for elements with a rounded corner. */+ add(el, mode = true, radius = null) {+ this.nodes.push({ el, mode, radius });+ this.sort();+ }++ remove(el) {+ const n = this.nodes.find((x) => x.el === el);+ if (!n) return;+ this.nodes.splice(this.nodes.indexOf(n), 1);+ this.sort();+ }++ // parents before children; each node's parent is its nearest ancestor that is a node+ sort() {+ const set = new Map(this.nodes.map((n) => [n.el, n]));+ for (const n of this.nodes) {+ n.parent = null;+ for (let p = n.el.parentElement; p && p !== this.root; p = p.parentElement) {+ if (set.has(p)) { n.parent = set.get(p); break; }+ }+ n.depth = 0;+ }+ for (const n of this.nodes) for (let p = n.parent; p; p = p.parent) n.depth++;+ this.nodes.sort((a, b) => a.depth - b.depth);+ }++ box(el) {+ const r = el.getBoundingClientRect();+ const o = this.root.getBoundingClientRect();+ return { x: r.left - o.left, y: r.top - o.top, w: r.width, h: r.height };+ }++ /**+ * Where everything is drawn now (mid-animation boxes included), then change(), then the new layout, then+ * animate from one to the other with `transition` (a motion transition; progress runs 0 -> 1000 like framer's).+ */+ change(change, transition, start = performance.now()) {+ for (const n of this.nodes) n.snap = n.el.isConnected ? this.box(n.el) : null;+ change();+ this.clear();+ for (const n of this.nodes) n.layout = this.box(n.el);+ for (const n of this.nodes) {+ if (!n.snap) n.snap = null; // new node: rides along at its place in its parent+ else if (n.mode === "position") n.snap = { ...n.snap, w: n.layout.w, h: n.layout.h };+ }+ this.anim?.stop();+ this.progress = 0;+ this.apply(0);+ this.anim = animate(0, 1000, transition, (v) => (this.progress = v / 1000), {+ start,+ onComplete: () => {+ this.anim = null;+ this.stopRender?.();+ this.stopRender = null;+ this.clear();+ },+ });+ if (!this.stopRender) this.stopRender = onRender(() => this.anim && this.apply(this.progress));+ }++ clear() {+ for (const n of this.nodes) {+ n.el.style.transform = "";+ n.el.style.transformOrigin = "";+ if (n.radius) n.el.style.borderRadius = `${n.radius()}px`;+ }+ }++ apply(p) {+ for (const n of this.nodes) {+ const L = n.layout;+ if (!L) continue;+ let T;+ const P = n.parent;+ if (P && P.target) {+ const s0 = n.snap && P.snap ? { x: n.snap.x - P.snap.x, y: n.snap.y - P.snap.y } : { x: L.x - P.layout.x, y: L.y - P.layout.y };+ const s1 = { x: L.x - P.layout.x, y: L.y - P.layout.y };+ T = {+ x: P.target.x + lerp(s0.x, s1.x, p),+ y: P.target.y + lerp(s0.y, s1.y, p),+ w: lerp(n.snap ? n.snap.w : L.w, L.w, p),+ h: lerp(n.snap ? n.snap.h : L.h, L.h, p),+ };+ } else {+ const S = n.snap ?? L;+ T = { x: lerp(S.x, L.x, p), y: lerp(S.y, L.y, p), w: lerp(S.w, L.w, p), h: lerp(S.h, L.h, p) };+ }+ n.target = T;+ // the ancestors' combined map, per axis: screen = a * layout + b+ const A = P?.map ?? { ax: 1, bx: 0, ay: 1, by: 0 };+ const sx = L.w > 0 && T.w > 0 ? T.w / (A.ax * L.w) : 1;+ const sy = L.h > 0 && T.h > 0 ? T.h / (A.ay * L.h) : 1;+ const tx = (T.x - A.bx) / A.ax - L.x;+ const ty = (T.y - A.by) / A.ay - L.y;+ n.map = { ax: A.ax * sx, bx: A.ax * (L.x - L.x * sx + tx) + A.bx, ay: A.ay * sy, by: A.ay * (L.y - L.y * sy + ty) + A.by };+ const near = (v, to, e) => Math.abs(v - to) < e;+ const still = near(tx, 0, 0.01) && near(ty, 0, 0.01) && near(sx, 1, 1e-4) && near(sy, 1, 1e-4);+ n.el.style.transformOrigin = "0 0";+ n.el.style.transform = still ? "" : `translate(${tx}px, ${ty}px) scale(${sx}, ${sy})`;+ if (n.radius) {+ const r = n.radius();+ const vx = L.w > 0 ? T.w / L.w : 1;+ const vy = L.h > 0 ? T.h / L.h : 1;+ n.el.style.borderRadius = near(vx, 1, 1e-4) && near(vy, 1, 1e-4) ? `${r}px` : `${r / vx}px / ${r / vy}px`;+ }+ }+ }+}diff --git a/site/public/examples/liveblocks-comments/src/scenes.js b/site/public/examples/liveblocks-comments/src/scenes.jsnew file mode 100644index 0000000..372db8b--- /dev/null+++ b/site/public/examples/liveblocks-comments/src/scenes.js@@ -0,0 +1,233 @@+// The five app drawings behind the comment panel, with the shapes, delays and springs of liveblocks.io's+// hero (motion variants $, q, et, er, en, ec, ed, em, ex, ep, ef, eg). Each scene enters when its use case+// starts and leaves (fades, shrinks to 90 % and blurs) when the next one starts.+import { MotionEl, whenDone } from "./motion.js";++const NS = "http://www.w3.org/2000/svg";+function s(tag, attrs = {}, ...kids) {+ const el = document.createElementNS(NS, tag);+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));+ el.append(...kids);+ return el;+}+function h(tag, cls, attrs = {}, ...kids) {+ const el = document.createElement(tag);+ if (cls) el.className = cls;+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));+ el.append(...kids);+ return el;+}++const Y = [0.5, 0, 0.75, 0]; // ease-in+const X = [0.75, 0, 0.25, 1];+const spring = (stiffness, damping, delay = 0) => ({ type: "spring", stiffness, damping, delay });+const FADE = { duration: 1, ease: Y };+const SCENE = { initial: { opacity: 0, scale: 1, blur: 0 }, entry: { opacity: 1, scale: 1, blur: 0 }, exit: { opacity: 0, scale: 0.9, blur: 20 } };++const avatar = (name) => {+ const img = h("img", "", { src: `./assets/people/${name}-256.webp`, srcset: `./assets/people/${name}-128.webp 1x, ./assets/people/${name}-256.webp 2x`, width: 120, height: 120, alt: "", decoding: "async" });+ return img;+};++const TEXT_EDITOR = [+ "M266 161.138C266 153.33 272.33 147 280.138 147H500.862C508.67 147 515 153.33 515 161.138V174.862C515 182.67 508.67 189 500.862 189H280.138C272.33 189 266 182.67 266 174.862V161.138Z",+ "M615.72 249.5c0-5.8 4.75-10.5 10.6-10.5h90.08c5.86 0 10.6 4.7 10.6 10.5s-4.75 10.5-10.6 10.5h-90.08c-5.85 0-10.6-4.7-10.6-10.5Zm-349.72 0c0-5.8 4.75-10.5 10.6-10.5h321.46c5.86 0 10.6 4.7 10.6 10.5s-4.74 10.5-10.6 10.5H276.6c-5.86 0-10.6-4.7-10.6-10.5Z",+ "M266 277.5C266 271.701 270.752 267 276.613 267H607.387C613.248 267 618 271.701 618 277.5C618 283.299 613.248 288 607.387 288H276.613C270.752 288 266 283.299 266 277.5Z",+ "M266 305.5C266 299.701 270.747 295 276.603 295H642.397C648.253 295 653 299.701 653 305.5C653 311.299 648.253 316 642.397 316H276.603C270.747 316 266 311.299 266 305.5Z",+ "M266 373.5C266 367.701 270.76 363 276.632 363H356.368C362.24 363 367 367.701 367 373.5C367 379.299 362.24 384 356.368 384H276.632C270.76 384 266 379.299 266 373.5Z",+ "M266 373.5C266 367.701 270.76 363 276.632 363H356.368C362.24 363 367 367.701 367 373.5C367 379.299 362.24 384 356.368 384H276.632C270.76 384 266 379.299 266 373.5Z",+ "M266 415.5C266 409.701 270.744 405 276.597 405H693.403C699.256 405 704 409.701 704 415.5C704 421.299 699.256 426 693.403 426H276.597C270.744 426 266 421.299 266 415.5Z",+ "M266 443.5C266 437.701 270.752 433 276.613 433H607.387C613.248 433 618 437.701 618 443.5C618 449.299 613.248 454 607.387 454H276.613C270.752 454 266 449.299 266 443.5Z",+ "M266 471.5C266 465.701 270.742 461 276.592 461H744.408C750.258 461 755 465.701 755 471.5C755 477.299 750.258 482 744.408 482H276.592C270.742 482 266 477.299 266 471.5Z",+ "M266 499.5C266 493.701 270.744 489 276.597 489H693.403C699.256 489 704 493.701 704 499.5C704 505.299 699.256 510 693.403 510H276.597C270.744 510 266 505.299 266 499.5Z",+ "M266 527.5C266 521.701 270.746 517 276.6 517H785.4C791.254 517 796 521.701 796 527.5C796 533.299 791.254 538 785.4 538H276.6C270.746 538 266 533.299 266 527.5Z",+];++// media player: one vertical line every 8 px from x=66, from this y down to 442+const WAVE = [344, 332, 328, 322, 337, 354, 342, 344, 350, 362, 398, 403, 392, 397, 384, 367, 342, 344, 337, 340, 332, 328, 330, 325, 348, 342, 362, 357, 354, 358, 373, 354, 334, 328, 328, 322, 337, 344, 357, 384, 394, 391, 404, 427, 414, 417, 404, 409, 414, 423, 412, 404, 407, 398, 404, 405, 402, 394, 378, 362, 344, 334, 328, 328, 322, 337, 344, 337, 364, 371, 337, 324, 323, 327, 334, 324, 344, 334, 337, 328, 322, 337, 344, 377, 381, 364, 357, 349, 337, 344, 364, 378, 375, 375, 371, 333, 344, 337, 354, 366, 358, 354, 354, 349, 337, 344, 377, 384, 394, 407, 434, 427, 414, 418, 416, 414, 414, 413, 387, 381, 378, 381, 374, 394, 378, 362, 358, 360, 364, 357, 344, 341, 337, 347, 357];++const WEBSITE = [+ "M524 191C524 186.582 527.582 183 532 183H676C680.418 183 684 186.582 684 191C684 195.418 680.418 199 676 199H532C527.582 199 524 195.418 524 191Z",+ "M298 235.5C298 224.178 307.178 215 318.5 215H887.5C898.822 215 908 224.178 908 235.5C908 246.822 898.822 256 887.5 256H318.5C307.178 256 298 246.822 298 235.5Z",+ "M401 287.5C401 281.701 405.701 277 411.5 277H796.5C802.299 277 807 281.701 807 287.5C807 293.299 802.299 298 796.5 298H411.5C405.701 298 401 293.299 401 287.5Z",+ "M421 321.547C420.999 315.772 425.698 311.09 431.497 311.088L774.497 311C780.296 310.999 784.998 315.679 785 321.453C785.001 327.228 780.302 331.91 774.503 331.912L431.503 332C425.704 332.001 421.001 327.321 421 321.547Z",+ "M504 378a14 14 0 0 1 14-14h66a14 14 0 1 1 0 28h-66a14 14 0 0 1-14-14Zm106 0a14 14 0 0 1 14-14h66a14 14 0 1 1 0 28h-66a14 14 0 0 1-14-14Z",+ "M140 474C139.999 465.163 147.162 458 155.999 458H1049.98C1058.82 458 1065.98 465.163 1065.98 474L1066 754C1066 762.837 1058.84 770 1050 770H156.018C147.182 770 140.018 762.837 140.018 754L140 474Z",+];++const WHITEBOARD_STROKE =+ "M408 656.63c51.15-39.78 110.26-68.7 162.88-106.47 19.36-13.9 37.05-30.07 53.35-47.42 6.76-7.2 13.04-14.98 16.35-24.42 2.78-7.96-6.34-6.02-11.86-5.52-15.57 1.42-25.6 12.27-30.86 26.47-23.9 64.62 78.52 49.33 111.39 40.57C787.1 519.07 859.18 478.2 906.47 412";++/**+ * A scene: its DOM nodes (appended to the app window), parts = [{ m: MotionEl, initial, entry, transition, exit?, exitTransition? }].+ * enter(start, animated) plays the entry (or jumps to it), exit(start) plays the exit and resolves when done.+ */+class Scene {+ constructor(nodes, parts, extra = {}) {+ this.nodes = nodes;+ this.parts = parts;+ Object.assign(this, extra);+ }+ enter(start, animated) {+ for (const p of this.parts) {+ if (!animated && !p.always) {+ Object.assign(p.m.v, p.entry);+ p.m.render();+ } else p.m.animate(p.entry, p.transition, start);+ }+ this.onEnter?.(start, animated);+ }+ async exit(start) {+ const anims = [];+ for (const p of this.parts) if (p.exit) anims.push(...p.m.animate(p.exit, p.exitTransition, start));+ await whenDone(anims);+ for (const p of this.parts) p.m.stopAll();+ for (const n of this.nodes) n.remove();+ this.onRemove?.();+ }+}++const sceneSvg = (attrs = {}) => s("svg", { class: "lb-scene", viewBox: "0 0 1208 770", xmlns: NS, ...attrs });++// variants $ on the scene's root (an <svg> or a div)+const rootPart = (el) => ({ m: new MotionEl(el, { ...SCENE.initial }), entry: SCENE.entry, transition: FADE, exit: SCENE.exit, exitTransition: FADE });++// the accent comment pin (variants q), at a spot given in % of the window+function pin(style) {+ const el = h("div", "lb-pin", { style });+ const wrap = h("div", "lb-layer", {}, el);+ const part = {+ m: new MotionEl(el, { opacity: 0, scale: 0, originX: 0, originY: 1 }),+ entry: { opacity: 1, scale: 1 },+ transition: spring(60, 11, 1.3),+ exit: { opacity: 0, scale: 0 },+ exitTransition: spring(60, 11, 0.8),+ };+ return { wrap, part };+}++function textEditor() {+ const g = s("g", { fill: "var(--hero-background-100)" });+ const root = sceneSvg();+ root.append(g);+ const parts = [rootPart(root)];+ TEXT_EDITOR.forEach((d, i) => {+ const p = g.appendChild(s("path", { d }));+ parts.push({ m: new MotionEl(p, { y: 50, opacity: 0 }, { svgChild: true }), entry: { y: 0, opacity: 1 }, transition: spring(60, 11, 1 + 0.1 * i) });+ });+ const { wrap, part } = pin("top:28.7%;left:59.27%");+ parts.push(part);+ return new Scene([root, wrap], parts);+}++function media() {+ const g = s("g", { "stroke-width": "2" });+ const root = sceneSvg({ fill: "none" });+ root.append(g);+ const parts = [rootPart(root)];+ const lines = WAVE.map((top, i) => {+ const x = 66 + 8 * i;+ const p = g.appendChild(s("path", { d: `M${x} ${top}L${x} 442`, class: "lb-wave", stroke: i < 30 ? "var(--hero-background-300)" : "var(--hero-background-200)" }));+ parts.push({ m: new MotionEl(p, { scaleY: 0.5, opacity: 0, originY: 1 }, { svgChild: true }), entry: { scaleY: 1, opacity: 1 }, transition: spring(111, 15, 1 + 0.01 * i) });+ return p;+ });+ // the played part grows by one line a second (useInterval, from 30)+ let played = 30;+ let timer = 0;+ const onEnter = () => {+ timer = setInterval(() => {+ played++;+ lines.forEach((p, i) => p.setAttribute("stroke", i < played ? "var(--hero-background-300)" : "var(--hero-background-200)"));+ }, 1000);+ };+ const onRemove = () => clearInterval(timer); // it keeps counting while the scene fades out++ const people = h("div", "lb-layer");+ const at = [+ ["12.91%", "#0090ff", "steven-fabre", 0],+ ["22.19%", "#30a46c", "alicia-henriquez", 0.2],+ ["36.92%", "#8F6CEF", "nimesh-nayaju", 0.4],+ ["78.48%", "#f44e6b", "jonathan-rowny", 0.8],+ ];+ parts.push(rootPart(people));+ for (const [left, accent, name, d] of at) {+ const el = people.appendChild(h("div", "lb-person lb-person--media", { style: `left:${left};--avatar-accent:${accent}` }, avatar(name)));+ parts.push({ m: new MotionEl(el, { opacity: 0, scale: 0, originY: 0 }), entry: { opacity: 1, scale: 1 }, transition: spring(60, 11, 1.4 + d) });+ }+ return new Scene([root, people], parts, { onEnter, onRemove });+}++function whiteboard() {+ const g = s("g");+ const root = sceneSvg({ fill: "none" });+ root.append(g);+ const circle = g.appendChild(s("circle", { cx: 714.5, cy: 285.5, r: 94.5, fill: "var(--hero-background-100)" }));+ const square = g.appendChild(s("rect", { x: 243, y: 286, width: 200, height: 200, rx: 8, fill: "var(--hero-background-100)" }));+ const stroke = g.appendChild(s("path", { d: WHITEBOARD_STROKE, stroke: "var(--hero-background-100)", "stroke-width": 8, "stroke-linecap": "round" }));+ const { wrap, part } = pin("bottom:57.66%;left:55.88%");+ const parts = [+ rootPart(root),+ { m: new MotionEl(circle, { x: 60, y: -80, opacity: 0 }, { svgChild: true }), entry: { x: 0, y: 0, opacity: 1 }, transition: spring(50, 11, 1) },+ { m: new MotionEl(square, { x: -80, y: 60, opacity: 0 }, { svgChild: true }), entry: { x: 0, y: 0, opacity: 1 }, transition: spring(50, 11, 1.2) },+ { m: new MotionEl(stroke, { pathLength: 0, opacity: 0 }, { svgChild: true }), entry: { pathLength: 1, opacity: 1 }, transition: { default: { ease: X, duration: 3, delay: 0.5 }, opacity: { ease: "easeInOut", duration: 0.5, delay: 1.3 } } },+ part,+ ];+ return new Scene([root, wrap], parts);+}++// variants ex: the frame tips up out of the screen, in perspective+const TILT = {+ initial: { opacity: 0, scale: 1.4, y: 200, rotateX: 45, originY: 1, blur: 0 },+ entry: { opacity: 1, scale: 1, y: 0, rotateX: 0, originY: 0.5, blur: 0 },+ exit: { opacity: 0, scale: 0.9, blur: 20, originY: 0.5 },+};+const tiltPart = (el) => ({ m: new MotionEl(el, { ...TILT.initial }), entry: TILT.entry, transition: spring(35, 9, 1), exit: TILT.exit, exitTransition: FADE });++function video() {+ const LONG = { duration: 7.2, ease: "linear" }; // 1.2 x the 6 s use case+ const track = s("path", { d: "M246 589H962", stroke: "var(--hero-background-200)", "stroke-width": 3, "stroke-linecap": "round" });+ const bar = s("path", { d: "M246 589H577", stroke: "white", "stroke-width": 4, "stroke-linecap": "round" });+ const barGroup = s("g", {}, bar);+ const head = s("circle", { cx: 577, cy: 589, r: 6, fill: "white" });+ const headGroup = s("g", {}, head);+ const controls = s("g", {}, track, barGroup, headGroup);+ const frame = s("rect", { x: 206, y: 180, width: 796, height: 448, rx: 12, fill: "var(--hero-background-100)" });+ const root = sceneSvg({ fill: "none" });+ root.append(s("g", { transform: "translate(0, -30)" }, frame, controls));+ const parts = [+ tiltPart(root),+ { m: new MotionEl(controls, { opacity: 0 }, { svgChild: true }), entry: { opacity: 1 }, transition: spring(60, 11, 1.75) },+ { m: new MotionEl(barGroup, { scaleX: 0, originX: 0 }, { svgChild: true }), entry: { scaleX: 1 }, transition: spring(40, 12, 2), always: true },+ { m: new MotionEl(bar, { scaleX: 1, originX: 0 }, { svgChild: true }), entry: { scaleX: 1.2 }, transition: LONG, always: true },+ { m: new MotionEl(headGroup, { x: -332, scale: 0 }, { svgChild: true }), entry: { x: 0, scale: 1 }, transition: spring(40, 12, 2), always: true },+ { m: new MotionEl(head, { x: 0 }, { svgChild: true }), entry: { x: 66.4 }, transition: LONG, always: true },+ ];+ const people = h("div", "lb-layer");+ parts.push(tiltPart(people));+ const at = [+ ["25.83%", "#0090ff", "steven-fabre", 0],+ ["39.57%", "#f44e6b", "pierre-levaillant", 0.1],+ ["62.57%", "#8F6CEF", "vincent-driessen", 0.3],+ ];+ for (const [left, accent, name, d] of at) {+ const el = people.appendChild(h("div", "lb-person lb-person--video", { style: `left:${left};--avatar-accent:${accent}` }, avatar(name)));+ parts.push({ m: new MotionEl(el, { opacity: 0, scale: 0, originY: 1 }), entry: { opacity: 1, scale: 1 }, transition: spring(60, 11, 2.2 + d) });+ }+ return new Scene([root, people], parts);+}++function website() {+ const g = s("g", { fill: "var(--hero-background-100)" });+ const root = sceneSvg();+ root.append(g);+ const parts = [rootPart(root)];+ WEBSITE.forEach((d, i) => {+ const p = g.appendChild(s("path", { d }));+ parts.push({ m: new MotionEl(p, { y: 50, opacity: 0 }, { svgChild: true }), entry: { y: 0, opacity: 1 }, transition: spring(60, 11, 1 + 0.1 * i) });+ });+ const { wrap, part } = pin("top:4.4%;left:13%");+ parts.push(part);+ return new Scene([root, wrap], parts);+}++export const SCENES = { "text-editor": textEditor, audio: media, whiteboard, website, video };diff --git a/site/public/examples/liveblocks-comments/src/slideshow.css b/site/public/examples/liveblocks-comments/src/slideshow.cssnew file mode 100644index 0000000..7596bb0--- /dev/null+++ b/site/public/examples/liveblocks-comments/src/slideshow.css@@ -0,0 +1,284 @@+/* liveblocks.io/comments hero slideshow. Sizes come from the original's utility classes; the comment panel is in+ em of calc(16px * --hero-scale), so the whole demo scales with the viewport like the original. */++/* Suisse Int'l (liveblocks.io's font) is licensed, so Inter stands in: its ascent/descent are set to Suisse's+ so lines sit at the same height, and a slight negative tracking (fitted on the demo's strings) gives the+ same advance widths. */+@font-face {+ font-family: "Inter LB";+ src: url("../assets/fonts/Inter-Variable.woff2") format("woff2");+ font-weight: 100 900;+ font-style: normal;+ font-display: block;+ ascent-override: 99%;+ descent-override: 31%;+ line-gap-override: 0%;+}++*, ::before, ::after { box-sizing: border-box; margin: 0; padding: 0; border: 0 solid; }+html { line-height: 1.5; -webkit-text-size-adjust: 100%; background: #000; }+body {+ min-height: 100vh;+ background: #000;+ color: #fff;+ font-family: "Inter LB", -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;+ -webkit-font-smoothing: antialiased;+ -moz-osx-font-smoothing: grayscale;+}+img, svg { display: block; vertical-align: middle; }+img { max-width: 100%; height: auto; }+button { font: inherit; letter-spacing: inherit; color: inherit; background: transparent; border-radius: 0; appearance: none; }++.lb-hero, .lb-hero * { letter-spacing: -0.018em; }+.lb-hero .lb-c__name, .lb-hero .lb-mention, .lb-hero .lb-accent, .lb-hero .lb-send__label, .lb-hero .lb-tab__name { letter-spacing: -0.016em; }++.lb-page { padding: 72.5px 0 96px; }++.lb-hero {+ --hero-scale: 1;+ --hero-accent: #e89304;+ --hero-halo: #C99236;+ --hero-background-0: #0F0D0A;+ --hero-background-100: #2E2C28;+ --hero-background-200: #4F4C47;+ --hero-background-300: #908B85;+ width: 100%;+ overflow: hidden;+ isolation: isolate;+}+@media (max-width: 1279.98px) { .lb-hero { --hero-scale: 0.8; } }+@media (max-width: 1023.98px) { .lb-hero { --hero-scale: 0.65; } }+@media (max-width: 767.98px) { .lb-hero { --hero-scale: 0.5; } }+@media (max-width: 639.98px) { .lb-hero { --hero-scale: 0.35; } }++.lb-stage { position: relative; height: calc(770px * var(--hero-scale)); max-width: 100%; opacity: 0; transform: translateY(10%); }++.lb-halo {+ pointer-events: none;+ position: absolute;+ left: calc((100% - 1208px * var(--hero-scale)) / 2);+ z-index: -50;+ aspect-ratio: 1208 / 770;+ width: calc(1208px * var(--hero-scale));+ opacity: 0;+ transform: scale(0.8);+}+.lb-halo__glow { position: absolute; left: -30%; right: -30%; top: -60%; bottom: 0; background-image: radial-gradient(closest-side, var(--hero-halo), transparent); }++/* the window: the element filmed on both pages. It also carries liveblocks.io's own class names+ (select-none, aspect-1208/770) so one selector finds it on both. */+.liveblocks-slideshow {+ pointer-events: none;+ position: absolute;+ left: calc((100% - 1208px * var(--hero-scale)) / 2);+ aspect-ratio: 1208 / 770;+ width: calc(1208px * var(--hero-scale));+ user-select: none;+}++/* ---------- the comment panel ---------- */+.lb-panel {+ position: absolute;+ z-index: 10;+ width: 26.5%;+ overflow: hidden;+ font-size: calc(16px * var(--hero-scale));+ border-radius: calc(8px * var(--hero-scale));+}+.is-settled .lb-panel, .is-settled .lb-panel__bg { will-change: transform; }+[data-case="text-editor"] .lb-panel { top: 28.7%; left: 62.4%; height: 43%; }+[data-case="audio"] .lb-panel { bottom: 41.8%; left: 36.8%; height: 29%; }+[data-case="whiteboard"] .lb-panel { bottom: 57.66%; left: 58.86%; height: 33%; }+[data-case="website"] .lb-panel { top: 4.4%; left: 16.3%; height: 29%; }+[data-case="video"] .lb-panel { top: 2.6%; right: 1.65%; bottom: 10%; }++.lb-panel__bg {+ position: absolute;+ inset: 0;+ z-index: -10;+ background: #fff;+ box-shadow: 0 0 0 1px rgba(1, 1, 1, 0.16), 0 2px 6px rgb(0 0 0 / 32%), 0 8px 26px rgb(0 0 0 / 48%);+ border-radius: calc(8px * var(--hero-scale));+}++.lb-thread { position: absolute; top: 0; left: 0; width: 100%; overflow: hidden; background: #fff; color: #000; opacity: 0; }+[data-case="text-editor"] .lb-thread--text-editor, [data-case="audio"] .lb-thread--audio, [data-case="whiteboard"] .lb-thread--whiteboard,+[data-case="website"] .lb-thread--website, [data-case="video"] .lb-thread--video { opacity: 1; }++.lb-divider { position: absolute; bottom: 0; left: 0; height: 0.0625em; width: 100%; background: #ECECEC; }++.lb-quote { position: relative; width: 100%; padding: 0.8125em; }+.lb-quote__text { position: relative; display: inline-block; padding: 0.125em 0.5em 0.125em 0.75em; font-size: 0.8125em; color: #424242; }+.lb-quote__text::before { content: ""; position: absolute; inset: 0; background: var(--hero-accent); opacity: 0.1; }+.lb-quote__text::after { content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 0.25em; background: var(--hero-accent); }++.lb-c { padding: 0.8125em; }+.lb-c--next { padding-top: 0; }+.lb-c--last { padding-bottom: 1.25em; }+.lb-c__head { display: flex; height: 1.375em; width: 100%; align-items: center; }+.lb-c__head--lg { height: 2em; }+.lb-c__who { display: flex; align-items: center; }+.lb-c__avatar { position: relative; margin-right: 0.5625em; height: 1.25em; width: 1.25em; }+.lb-c__head--lg .lb-c__avatar { height: 2em; width: 2em; }+.lb-c__avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: calc(infinity * 1px); }+.lb-c__avatar--square img { border-radius: 0.375em; }+.lb-c__names--col { display: flex; flex-direction: column; }+.lb-c__name { margin-right: 0.375em; font-size: 0.8125em; font-weight: 500; }+.lb-c__names--col .lb-c__name { margin-right: 0; }+.lb-c__time { font-size: 0.6875em; color: #727272; }+.lb-c__tools { margin-left: auto; display: flex; }+.lb-c__head--lg .lb-c__tools { align-self: flex-start; }+.lb-c__body { padding: 0.25em 0 0 1.75em; }+.lb-c__body--video { padding: 0.625em 0 0; }+.lb-c__text { font-size: 0.8125em; color: #424242; }++.lb-icon { display: flex; height: 1.375em; width: 1.375em; align-items: center; justify-content: center; }+.lb-icon svg, .lb-send svg.lb-1em { width: 1em; }++.lb-accent { font-weight: 500; color: var(--hero-accent); }+.lb-mention { position: relative; margin-right: 0.125em; display: inline-block; border-radius: 0.375em; font-weight: 500; color: var(--hero-accent); }+.lb-mention::before { content: ""; position: absolute; inset: 0 -0.25em; border-radius: inherit; background: var(--hero-accent); opacity: 0.1; }++.lb-reactions { margin-top: 0.5em; display: flex; gap: 0.375em; }+.lb-reaction { display: flex; height: 1.375em; align-items: center; justify-content: center; gap: 0.2em; border-radius: calc(infinity * 1px); border: 0.0625em solid #ECECEC; padding: 0 0.425em; }+.lb-reaction--accent { position: relative; border: 0; }+.lb-reaction--accent::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--hero-accent); opacity: 0.1; }+.lb-reaction--accent::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 0.0625em solid var(--hero-accent); opacity: 0.2; }+.lb-emoji {+ font-size: 0.75em;+ font-family: "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", "Android Emoji", "Segoe UI Emoji", "Segoe UI Symbol", EmojiSymbols, sans-serif;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 1em;+ white-space: nowrap;+}+.lb-count { margin-top: 0.25em; margin-left: 0.15em; font-size: 0.5625em; color: #A3A3A3; }+.lb-count--tight { line-height: 1; }+.lb-reaction--accent .lb-count { color: var(--hero-accent); opacity: 0.75; }++.lb-threads-head { position: relative; display: flex; width: 100%; padding: 0.8125em; }+.lb-threads-head__filter { margin-left: auto; display: flex; }+.lb-threads-head__filter span { font-size: 0.6875em; color: #727272; }+.lb-threads-head__filter svg { margin-left: 0.0625em; width: 1em; }+.lb-section { position: relative; width: 100%; }+.lb-attachments { margin-top: 0.625em; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 0.625em; }+.lb-attachment { aspect-ratio: 16 / 10; width: 100%; border-radius: 0.375em; border: 0.0625em solid #ECECEC; background: #F2F2F2; }++/* composer */+.lb-composer { position: absolute; bottom: 0; width: 100%; overflow: hidden; background: #fff; padding: 0.8125em; }+.lb-composer__divider { position: absolute; top: 0; left: 0; height: 0.0625em; width: 100%; background: #ECECEC; }+.lb-composer__row { position: relative; display: flex; align-items: center; }+.lb-composer__avatar { position: absolute; height: 1.25em; width: 1.25em; margin-left: -2.5em; }+[data-case="audio"] .lb-composer__avatar, [data-case="whiteboard"] .lb-composer__avatar { margin-left: 0; }+.lb-composer__avatar > div { position: absolute; inset: 0; opacity: 0; }+.lb-composer__avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: calc(infinity * 1px); }+.lb-composer__input { position: relative; height: 1.3em; width: 100%; }+[data-case="audio"] .lb-composer__input, [data-case="whiteboard"] .lb-composer__input { margin-left: 1.825em; }+.lb-composer__placeholder { position: absolute; left: 0; display: inline-block; font-size: 0.8125em; white-space: nowrap; color: #A3A3A3; }+.lb-composer__actions { display: flex; margin-top: 0.375em; }+[data-case="website"] .lb-composer__actions { margin-top: -1.325em; }+.lb-composer__left { position: relative; height: 100%; }+.lb-composer__resolve { position: absolute; top: 0.4em; left: 0; display: flex; align-items: center; white-space: nowrap; color: #000; opacity: 0; }+.lb-composer__resolve svg { margin-right: 0.375em; width: 0.75em; }+.lb-composer__resolve span { position: absolute; left: 1.625em; font-size: 0.675em; color: #727272; opacity: 0; }+.lb-composer__tools { position: absolute; top: 0; left: 0; display: flex; }++.lb-send { position: relative; margin-left: auto; height: 1.375em; width: 1.375em; background: var(--hero-accent); border-radius: calc(5px * var(--hero-scale)); }+[data-case="audio"] .lb-send { width: 4em; }+[data-case="whiteboard"] .lb-send { width: 2.75em; }+.lb-send__layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }+.lb-send__label { margin-top: 0.0625em; font-size: 0.675em; font-weight: 500; white-space: nowrap; color: #fff; opacity: 0; }+.lb-send__icon { position: absolute; }++/* ---------- the app window ---------- */+.lb-app {+ pointer-events: none;+ position: absolute;+ inset: 0;+ overflow: hidden;+ border-radius: calc(16px * var(--hero-scale));+ background: var(--hero-background-0);+ perspective: 1000px;+}+.lb-app::after { content: ""; pointer-events: none; position: absolute; inset: 0; border-radius: inherit; border: 1px solid #fdfcfc29; }+.lb-app__cover { position: absolute; inset: 0; z-index: 20; }+.lb-app__line {+ pointer-events: none; position: absolute; top: 0; left: 0; z-index: 1; height: 1px; width: 100%;+ background-image: linear-gradient(90deg, transparent 0%, var(--hero-halo) 50%, transparent 100%);+ opacity: 0.2;+}+.lb-app__radial {+ pointer-events: none; position: absolute; top: 0; left: 0; z-index: 1; height: 40%; width: 100%;+ border-top-left-radius: calc(16px * var(--hero-scale));+ border-top-right-radius: calc(16px * var(--hero-scale));+ background-image: radial-gradient(closest-side, var(--hero-halo) 0%, transparent 100%);+ background-size: 175% 200%;+ background-position: center 100%;+ opacity: 0.15;+}+.lb-topbar, .lb-scene { position: absolute; top: 0; left: 0; height: 100%; width: 100%; }+.lb-layer { position: absolute; inset: 0; }+.lb-wave { transition: stroke 500ms cubic-bezier(0.4, 0, 0.2, 1); }+.lb-pin {+ position: absolute;+ aspect-ratio: 1;+ width: 2.32%;+ border-radius: 42.86% 42.86% 42.86% 14.29%;+ background: var(--hero-accent);+}+.lb-person { position: absolute; aspect-ratio: 1; border-radius: calc(infinity * 1px); }+.lb-person img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; }+.lb-person--media { bottom: 38%; width: 1.3%; }+.lb-person--media img { box-shadow: 0 0 0 calc(2px * var(--hero-scale)) var(--hero-background-0), 0 0 0 calc(4px * var(--hero-scale)) var(--avatar-accent); }+.lb-person--video { bottom: 29.6%; width: 1.8%; }+.lb-person--video img { box-shadow: 0 0 0 calc(2px * var(--hero-scale)) var(--hero-background-100), 0 0 0 calc(4px * var(--hero-scale)) var(--avatar-accent); }++/* ---------- use-case tabs ---------- */+.lb-tabs {+ position: absolute;+ bottom: 0;+ z-index: 20;+ display: flex;+ width: 100%;+ align-items: center;+ justify-content: center;+ gap: 12px;+ background-image: linear-gradient(to top in oklab, #000 0%, transparent 100%);+ padding: 24px 0;+}+.lb-tab {+ --use-case-accent-light: color-mix(in srgb, var(--use-case-accent), #fff 50%);+ position: relative;+ display: flex;+ height: 36px;+ width: 36px;+ cursor: pointer;+ align-items: center;+ justify-content: center;+ overflow: hidden;+ border-radius: 100px;+ font-size: 14px;+ line-height: 20px;+ font-weight: 500;+ backdrop-filter: blur(12px);+}+.lb-tab.is-active { width: auto; padding: 6px 14px 6px 10px; cursor: default; }+.lb-tab::before {+ content: "";+ position: absolute;+ inset: 0;+ z-index: -10;+ border-radius: inherit;+ background: var(--use-case-accent);+ opacity: 0.2;+ transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);+}+.lb-tab:not(.is-active):hover::before, .lb-tab:focus-visible::before { opacity: 0.3; }+.lb-tab__progress { position: absolute; inset: 0; z-index: -10; transform-origin: left; background: var(--use-case-accent); }+.lb-tab__icon { color: var(--use-case-accent-light); }+.lb-tab__name { margin-left: 8px; white-space: nowrap; }++@media (prefers-reduced-motion: reduce) {+ .lb-wave { transition: none; }+}diff --git a/site/public/examples/liveblocks-comments/src/slideshow.js b/site/public/examples/liveblocks-comments/src/slideshow.jsnew file mode 100644index 0000000..b1c3506--- /dev/null+++ b/site/public/examples/liveblocks-comments/src/slideshow.js@@ -0,0 +1,228 @@+// liveblocks.io/comments hero slideshow. Every 6 s the next use case starts: the tabs re-flow at once, the old+// drawing fades and blurs out while the new one springs in, and a second later the comment thread crossfades,+// the panel glides to its new place and the colours change. Timings, springs and layout are liveblocks.io's+// (motion's MotionConfig transition, variants and layout animations), ported in motion.js and projection.js.+import { animate, MotionEl, mixColor } from "./motion.js";+import { LayoutGroup } from "./projection.js";+import { SCENES } from "./scenes.js";++const CASE_MS = 6000;+const CASES = [+ { type: "text-editor", name: "Text editor", accent: "#e89304", halo: "#C99236", bg: ["#0F0D0A", "#2E2C28", "#4F4C47", "#908B85"] },+ { type: "audio", name: "Media player", accent: "#f44e6b", halo: "#CE314C", bg: ["#0F0A0D", "#2E282B", "#4F474B", "#90858A"] },+ { type: "whiteboard", name: "Whiteboard", accent: "#0090ff", halo: "#0083E9", bg: ["#0A0D0F", "#282C2E", "#474C4F", "#858C90"] },+ { type: "website", name: "Website", accent: "#30a46c", halo: "#4FE09A", bg: ["#0A0F0B", "#282E29", "#474F49", "#859088"] },+ { type: "video", name: "Video editor", accent: "#8F6CEF", halo: "#724BDC", bg: ["#0C0A0F", "#2B282E", "#4A474F", "#898590"] },+];++const spring = (stiffness, damping, delay = 0) => ({ type: "spring", stiffness, damping, delay });+const IN_WINDOW = spring(60, 14, 1); // everything inside the window waits 1 s, then settles+const TABS = spring(100, 16);+const ON_LOAD = spring(60, 14, 0.8); // halo and window glow+const COLOUR = { duration: 0.3, ease: [0.25, 0.1, 0.35, 1], delay: 1 }; // motion's default tween for a colour+const FADE_OUT = { duration: 0.3, ease: [0.25, 0.1, 0.35, 1] };+const VARS = ["--hero-accent", "--hero-halo", "--hero-background-0", "--hero-background-100", "--hero-background-200", "--hero-background-300"];++const hero = document.querySelector(".lb-hero");+const stage = hero.querySelector(".lb-stage");+const win = hero.querySelector(".liveblocks-slideshow");+const panel = win.querySelector(".lb-panel");+const app = win.querySelector(".lb-app");+const tabRow = hero.querySelector(".lb-tabs");+const tabs = Object.fromEntries([...tabRow.querySelectorAll(".lb-tab")].map((b) => [b.dataset.type, b]));+const scale = () => parseFloat(getComputedStyle(hero).getPropertyValue("--hero-scale")) || 1;++let index = 0;+let timer = 0;++// ---------- colours: motion values on the hero, animated as colours ----------+const colours = [CASES[0].accent, CASES[0].halo, ...CASES[0].bg];+const colourAnims = [];+function setColours(c, start) {+ const to = [c.accent, c.halo, ...c.bg];+ VARS.forEach((name, i) => {+ colourAnims[i]?.stop();+ const from = colours[i];+ colourAnims[i] = animate(0, 1, COLOUR, (p) => {+ colours[i] = mixColor(from, to[i], p);+ hero.style.setProperty(name, colours[i]);+ }, { start });+ });+}++// ---------- the comment panel ----------+const shows = [...win.querySelectorAll("[data-show]")].map((el) => {+ const cases = el.dataset.show.split(" ");+ return { cases, m: new MotionEl(el, { opacity: cases.includes(CASES[0].type) ? 1 : 0 }) };+});+const sendRadius = (type) => (type === "whiteboard" || type === "website" ? 10 : 5) * scale();+const send = win.querySelector(".lb-send");+let sendR = sendRadius(CASES[0].type);+let sendAnim = null;++const panelGroup = new LayoutGroup(win);+const q = (sel) => [...panel.querySelectorAll(sel)];+panelGroup.add(panel, true, () => 8 * scale());+panelGroup.add(panel.querySelector(".lb-panel__bg"), true, () => 8 * scale());+for (const t of q(".lb-thread")) panelGroup.add(t, "position");+panelGroup.add(panel.querySelector(".lb-composer"));+panelGroup.add(panel.querySelector(".lb-composer__divider"), "position");+for (const el of q(".lb-composer__row, .lb-composer__avatar, .lb-composer__avatar > div, .lb-composer__input")) panelGroup.add(el);+for (const el of q(".lb-composer__placeholder")) panelGroup.add(el, "position");+for (const el of q(".lb-composer__actions, .lb-composer__left")) panelGroup.add(el);+for (const el of q(".lb-composer__resolve, .lb-composer__tools")) panelGroup.add(el, "position");+for (const el of q(".lb-composer__tools .lb-icon")) panelGroup.add(el);+panelGroup.add(send, true, () => sendR);+for (const el of q(".lb-send__layer, .lb-send__icon")) panelGroup.add(el);+for (const el of q(".lb-send__label")) panelGroup.add(el, "position");++// ---------- the window's top bar: three dots, or three tabs on the website ----------+const DOT = { y: -6, x: 0, width: 33.346, height: 33.346, rx: 16.673 };+const PILL = { y: 0, width: 80, height: 21.2075, rx: 10.6038 };+const PILLS = [{ ...PILL, x: -206.654 }, { ...PILL, x: -126.654 }, { ...PILL, x: -46.654 }];+const dots = [...app.querySelectorAll(".lb-topbar g g rect")].map((r) => new MotionEl(r, { ...DOT }, { svgChild: true }));+function setTopbar(type, start) {+ const web = type === "website";+ dots.forEach((m, i) => m.animate(web ? PILLS[i] : DOT, spring(50, 11, web ? [1, 1.1, 1.2][i] : [1.2, 1.1, 1][i]), start));+}++// ---------- the scene ----------+let scene = SCENES[CASES[0].type]();+app.append(...scene.nodes);+scene.enter(performance.now(), false);++// ---------- tabs ----------+const tabsGroup = new LayoutGroup(tabRow);+for (const b of Object.values(tabs)) {+ tabsGroup.add(b, true, () => 100);+ tabsGroup.add(b.querySelector(".lb-tab__icon"));+}+let name = new MotionEl(tabs[CASES[0].type].querySelector(".lb-tab__name"), { opacity: 1 });+tabsGroup.add(name.el, "position");+let progress = new MotionEl(tabs[CASES[0].type].querySelector(".lb-tab__progress"), { opacity: 0.3, scaleX: 0.1 });++function switchTabs(from, to, start) {+ const oldBtn = tabs[from.type];+ const newBtn = tabs[to.type];+ const leaving = name;+ const leavingBar = progress;+ // motion's popLayout: the leaving label is taken out of the flow where it stands, then fades+ const el = leaving.el;+ const pop = { top: el.offsetTop, left: el.offsetLeft, width: el.offsetWidth, height: el.offsetHeight };+ const label = document.createElement("span");+ label.className = "lb-tab__name";+ label.textContent = to.name;+ const bar = document.createElement("div");+ bar.className = "lb-tab__progress";+ tabsGroup.change(() => {+ Object.assign(el.style, { position: "absolute", top: `${pop.top}px`, left: `${pop.left}px`, width: `${pop.width}px`, height: `${pop.height}px` });+ oldBtn.classList.remove("is-active");+ oldBtn.disabled = false;+ newBtn.classList.add("is-active");+ newBtn.disabled = true;+ newBtn.prepend(bar);+ newBtn.append(label);+ tabsGroup.add(label, "position");+ }, TABS, start);+ name = new MotionEl(label, { opacity: 0 });+ name.animate({ opacity: 1 }, TABS, start);+ const out = leaving.animate({ opacity: 0 }, TABS, start)[0];+ whenFinished(out, () => {+ tabsGroup.remove(el);+ el.remove();+ });+ progress = new MotionEl(bar, { opacity: 0.3, scaleX: 0.1 });+ progress.animate({ scaleX: 1 }, { duration: CASE_MS / 1000, ease: "linear" }, start);+ whenFinished(leavingBar.animate({ opacity: 0 }, FADE_OUT, start)[0], () => leavingBar.el.remove());+}++function whenFinished(a, fn) {+ if (!a) return fn();+ const check = () => (a.done ? fn() : requestAnimationFrame(check));+ check();+}++// ---------- one use case to the next ----------+function show(i, start = performance.now()) {+ if (i === index) return;+ const from = CASES[index];+ const to = CASES[i];+ index = i;+ switchTabs(from, to, start);++ panelGroup.change(() => (win.dataset.case = to.type), IN_WINDOW, start);+ for (const s of shows) s.m.animate({ opacity: s.cases.includes(to.type) ? 1 : 0 }, IN_WINDOW, start);+ sendAnim?.stop();+ sendAnim = animate(sendR, sendRadius(to.type), { ...IN_WINDOW, velocity: sendAnim?.velocity(start) ?? 0 }, (v) => {+ sendR = v;+ if (!panelGroup.anim) send.style.borderRadius = `${v}px`;+ }, { start });+ setTopbar(to.type, start);+ setColours(to, start);++ scene.exit(start);+ scene = SCENES[to.type]();+ app.append(...scene.nodes);+ scene.enter(start, true);+}++function schedule() {+ clearTimeout(timer);+ timer = setTimeout(() => {+ show((index + 1) % CASES.length);+ schedule();+ }, CASE_MS);+}++// the radii follow --hero-scale, which changes at the breakpoints+addEventListener("resize", () => {+ if (!panelGroup.anim) panelGroup.clear();+ if (!sendAnim || sendAnim.done) {+ sendR = sendRadius(CASES[index].type);+ if (!panelGroup.anim) send.style.borderRadius = `${sendR}px`;+ }+});++for (const [type, b] of Object.entries(tabs)) {+ b.addEventListener("click", () => {+ clearTimeout(timer);+ show(CASES.findIndex((c) => c.type === type));+ schedule();+ });+}++// Off screen the slideshow waits; back on screen it moves on to the next use case. (liveblocks.io ignores the+// first observation; if that one says "off screen" it then never restarts, so here a page that starts scrolled+// away keeps cycling until the hero is first seen.)+let observed = false;+let seen = false;+new IntersectionObserver(([e]) => {+ if (!observed) {+ observed = true;+ seen = e.isIntersecting;+ return;+ }+ if (e.isIntersecting) {+ if (!seen) return void (seen = true);+ show((index + 1) % CASES.length);+ schedule();+ } else if (seen) clearTimeout(timer);+}).observe(hero);++// ---------- on load: the first case starts, the window rises and fades in, the halo and the glow come up ----------+// Like the original, the 6 s timer starts when the page is ready (a React effect there) and the entrance+// animations on the first frame after it (motion starts its animations in a frame).+schedule();+requestAnimationFrame(() => {+ const start = performance.now();+ animate(10, 0, { duration: 2, delay: 0.6, ease: [0.16, 1, 0.3, 1] }, (v) => (stage.style.transform = v === 0 ? "none" : `translateY(${v}%)`), {+ start,+ // the panel's own layers (will-change, as on liveblocks.io) are made once the window rests: made while+ // it rises, they kept whichever sub-pixel offset the browser last drew them at, which varied run to run+ onComplete: () => hero.classList.add("is-settled"),+ });+ animate(0, 1, { duration: 1, delay: 0.8, ease: "easeOut" }, (v) => (stage.style.opacity = String(v)), { start });+ new MotionEl(hero.querySelector(".lb-halo"), { opacity: 0, scale: 0.8 }).animate({ opacity: 0.2, scale: 1 }, ON_LOAD, start);+ new MotionEl(app.querySelector(".lb-app__glow"), { opacity: 0 }).animate({ opacity: 1 }, ON_LOAD, start);+ progress.animate({ scaleX: 1 }, { duration: CASE_MS / 1000, ease: "linear" }, start);+});diff --git a/site/public/examples/reactbits-fading-stars/index.html b/site/public/examples/reactbits-fading-stars/index.htmlnew file mode 100644index 0000000..5ec8f07--- /dev/null+++ b/site/public/examples/reactbits-fading-stars/index.html@@ -0,0 +1,21 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <title>pro.reactbits.dev “Fading Stars”, rebuilt with reanimate</title>+ <meta name="robots" content="noindex">+ <link rel="stylesheet" href="./src/fading-stars.css">+ <script type="module" src="./src/main.js"></script>+</head>+<body>+ <main class="page">+ <div class="preview">+ <div class="preview__frame">+ <!-- src/main.js draws the stars on a canvas in here -->+ <div class="fading-stars" role="img" aria-label="Violet stars rising from below the frame in a wide fan, each on a trail that fades behind it. Move the pointer over them to speed them up; click to launch a burst."></div>+ </div>+ </div>+ </main>+</body>+</html>diff --git a/site/public/examples/reactbits-fading-stars/src/fading-stars.css b/site/public/examples/reactbits-fading-stars/src/fading-stars.cssnew file mode 100644index 0000000..5cc62ca--- /dev/null+++ b/site/public/examples/reactbits-fading-stars/src/fading-stars.css@@ -0,0 +1,50 @@+/* pro.reactbits.dev "Fading Stars": the docs page's preview frame (dark theme) around the stars.+ Colours, border and radius are the docs page's computed styles; the stars fill a 1086 x 600 box, the+ preview's size in a 1440 px wide window. */++*, ::before, ::after { box-sizing: border-box; margin: 0; padding: 0; border: 0 solid; }+canvas { display: block; }++html, body { background: rgb(10 10 10); }++.page {+ min-height: 100vh;+ display: flex;+ justify-content: center;+ align-items: flex-start;+ padding: 48px 16px;+}++/* [data-preview-container] */+.preview {+ position: relative;+ /* On pro.reactbits.dev the preview sits at y = 346.5625 px; the same sub-pixel phase here puts the+ canvas and the frame's border on the same rows. */+ top: 0.5625px;+ width: 1088px;+ max-width: 100%;+ height: 602px;+ border: 1px solid rgb(31 31 31);+ border-radius: 16.8px;+ background: oklab(0.239291 0.0000108778 0.00000478327 / 0.2);+}++/* the rounded box the preview iframe sits in */+.preview__frame {+ position: absolute;+ inset: 0;+ border-radius: 16.8px;+ overflow: hidden;+ background: oklch(0.145 0 0);+}++/* the component's root: it fills its parent, 240 px at least */+.fading-stars {+ position: relative;+ isolation: isolate;+ width: 100%;+ height: 100%;+ min-height: 240px;+ overflow: hidden;+ background-color: #0a0a0a;+}diff --git a/site/public/examples/reactbits-fading-stars/src/fading-stars.js b/site/public/examples/reactbits-fading-stars/src/fading-stars.jsnew file mode 100644index 0000000..ab0b5d1--- /dev/null+++ b/site/public/examples/reactbits-fading-stars/src/fading-stars.js@@ -0,0 +1,825 @@+// pro.reactbits.dev "Fading Stars": stars rise from an origin below the frame along a fan of rays, each+// drawing a trail that fades behind it. They speed up as they go (warp acceleration), fade in near the+// bottom and out before the top, and come back in at the edge. At mount every star fades in over 0.9 s.+// Moving the pointer over them speeds up the flow (a spring eases it back over about a second); a click+// launches a shell of 64 stars that rises as an arc. Off screen it pauses.+//+// The simulation is the original's, step for step, with its own random generator (mulberry32, seed+// 24301, restarted on every mount), so it draws the same stars on every load. The original renders with+// three.js r181; here the same passes go through WebGL2 directly, with three's state for each draw:+// additive instanced quads into a half-float target, a bloom chain, and a composite with film grain.+// See .reanimate/reactbits-fading-stars.++import * as GLSL from "./shaders.js";++// The preview's props on pro.reactbits.dev (preset "Violet", dark theme): the component's defaults.+export const DEFAULTS = {+ colors: ["#5227FF", "#FF9FFC"],+ backgroundColor: "#0A0A0A",+ mode: "auto",+ direction: "up",+ spread: 150,+ focus: 0.35,+ originOffset: 0.18,+ originShift: 0,+ count: 480,+ speed: 0.16,+ speedVariance: 0.6,+ acceleration: 0.9,+ trailLength: 0.45,+ trailFade: 1.6,+ lineWidth: 1,+ starSize: 2.2,+ twinkle: 0.35,+ fadeIn: 0.06,+ fadeOut: 0.3,+ depth: 0.5,+ glow: 0.45,+ intensity: 1,+ grain: 0.3,+ interactive: true,+ thrust: 1,+ burst: 64,+ paused: false,+ quality: 1,+};++const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));+const finite = (v, d) => (Number.isFinite(v) ? v : d);+const smoothstep = (e0, e1, x) => {+ const t = clamp((x - e0) / (e1 - e0), 0, 1);+ return t * t * (3 - 2 * t);+};++// CSS colour → sRGB 0..1, through a 2D context so any CSS colour works.+function parseColor(ctx, css, fallback) {+ if (!ctx || typeof css !== "string") return fallback;+ ctx.fillStyle = "#010203";+ ctx.fillStyle = css;+ const out = String(ctx.fillStyle);+ if (out === "#010203" && css.trim().toLowerCase() !== "#010203") return fallback;+ if (out.startsWith("#")) {+ const hex = out.slice(1);+ return [parseInt(hex.slice(0, 2), 16) / 255, parseInt(hex.slice(2, 4), 16) / 255, parseInt(hex.slice(4, 6), 16) / 255];+ }+ const n = out.match(/[\d.]+/g);+ return !n || n.length < 3 ? fallback : [Number(n[0]) / 255, Number(n[1]) / 255, Number(n[2]) / 255];+}+const toLinear = (c) => (c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));+function toOklab([r8, g8, b8]) {+ const r = toLinear(r8), g = toLinear(g8), b = toLinear(b8);+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);+ return [+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,+ ];+}++// ---------------------------------------------------------------------------------------------------+// WebGL2, the way three.js r181 sets it up for this scene.++function compile(gl, vertex, fragment) {+ const shader = (type, src) => {+ const s = gl.createShader(type);+ gl.shaderSource(s, src);+ gl.compileShader(s);+ if (!gl.getShaderParameter(s, gl.COMPILE_STATUS) && !gl.isContextLost()) throw new Error(gl.getShaderInfoLog(s));+ return s;+ };+ const program = gl.createProgram();+ gl.attachShader(program, shader(gl.VERTEX_SHADER, GLSL.VERTEX_PREFIX + vertex));+ gl.attachShader(program, shader(gl.FRAGMENT_SHADER, GLSL.FRAGMENT_PREFIX + fragment));+ gl.linkProgram(program);+ if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) throw new Error(gl.getProgramInfoLog(program));+ const uniforms = {};+ const n = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS) || 0;+ for (let i = 0; i < n; i++) {+ const info = gl.getActiveUniform(program, i);+ uniforms[info.name] = gl.getUniformLocation(program, info.name);+ }+ const attrib = (name) => gl.getAttribLocation(program, name);+ return { program, uniforms, attrib };+}++function createRenderer(canvas) {+ // three r181 always asks for an alpha channel and leaves the rest at these values+ const gl = canvas.getContext("webgl2", {+ alpha: true,+ depth: true,+ stencil: false,+ antialias: false,+ premultipliedAlpha: true,+ preserveDrawingBuffer: false,+ powerPreference: "high-performance",+ failIfMajorPerformanceCaveat: false,+ });+ if (!gl) return null;+ // half-float targets when the GPU can render to them (three: HalfFloatType), else 8 bit+ const half = !!(gl.getExtension("EXT_color_buffer_float") || gl.getExtension("EXT_color_buffer_half_float"));+ gl.getExtension("OES_texture_float_linear");++ const programs = {+ trails: compile(gl, GLSL.trailVertex, GLSL.trailFragment),+ heads: compile(gl, GLSL.headVertex, GLSL.headFragment),+ down: compile(gl, GLSL.screenVertex, GLSL.downFragment),+ up: compile(gl, GLSL.screenVertex, GLSL.upFragment),+ composite: compile(gl, GLSL.screenVertex, GLSL.compositeFragment),+ };++ const staticBuffer = (target, data) => {+ const b = gl.createBuffer();+ gl.bindBuffer(target, b);+ gl.bufferData(target, data, gl.STATIC_DRAW);+ return b;+ };++ // full-screen quad: three's PlaneGeometry(2, 2)+ const quad = gl.createVertexArray();+ gl.bindVertexArray(quad);+ const quadPos = staticBuffer(gl.ARRAY_BUFFER, new Float32Array([-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0]));+ const quadUv = staticBuffer(gl.ARRAY_BUFFER, new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]));+ staticBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 2, 1, 2, 3, 1])); // stays bound to the vertex array+ for (const p of [programs.down, programs.up, programs.composite]) {+ const pos = p.attrib("position");+ const uv = p.attrib("uv");+ gl.bindBuffer(gl.ARRAY_BUFFER, quadPos);+ if (pos >= 0) { gl.enableVertexAttribArray(pos); gl.vertexAttribPointer(pos, 3, gl.FLOAT, false, 0, 0); }+ gl.bindBuffer(gl.ARRAY_BUFFER, quadUv);+ if (uv >= 0) { gl.enableVertexAttribArray(uv); gl.vertexAttribPointer(uv, 2, gl.FLOAT, false, 0, 0); }+ }+ gl.bindVertexArray(null);++ // star quads: one corner per vertex, the star itself from the instance buffer (12 floats a star)+ const corners = {+ trails: new Float32Array([0, -1, 0, 1, -1, 0, 0, 1, 0, 1, 1, 0]),+ heads: new Float32Array([-1, -1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0]),+ };+ const starIndex = new Uint16Array([0, 1, 2, 2, 1, 3]);+ const starVaos = {};+ let instanceBuffer = null;+ let instanceCapacity = 0;+ const buildStarVaos = () => {+ for (const name of ["trails", "heads"]) {+ if (starVaos[name]) gl.deleteVertexArray(starVaos[name].vao);+ const p = programs[name];+ const vao = gl.createVertexArray();+ gl.bindVertexArray(vao);+ const corner = staticBuffer(gl.ARRAY_BUFFER, corners[name]);+ const index = staticBuffer(gl.ELEMENT_ARRAY_BUFFER, starIndex);+ const pos = p.attrib("position");+ if (pos >= 0) { gl.enableVertexAttribArray(pos); gl.vertexAttribPointer(pos, 3, gl.FLOAT, false, 0, 0); }+ gl.bindBuffer(gl.ARRAY_BUFFER, instanceBuffer);+ ["aHead", "aShape", "aLook"].forEach((attr, k) => {+ const loc = p.attrib(attr);+ if (loc < 0) return;+ gl.enableVertexAttribArray(loc);+ gl.vertexAttribPointer(loc, 4, gl.FLOAT, false, 48, 16 * k);+ gl.vertexAttribDivisor(loc, 1);+ });+ gl.bindVertexArray(null);+ starVaos[name] = { vao, corner, index };+ }+ };++ const renderer = {+ gl,+ // (re)allocates the instance buffer for `data` (a new, larger Float32Array)+ setInstanceData(data) {+ if (instanceBuffer) gl.deleteBuffer(instanceBuffer);+ instanceBuffer = gl.createBuffer();+ gl.bindBuffer(gl.ARRAY_BUFFER, instanceBuffer);+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);+ instanceCapacity = data.length;+ buildStarVaos();+ },+ updateInstances(data, floats) {+ gl.bindBuffer(gl.ARRAY_BUFFER, instanceBuffer);+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, data, 0, Math.min(floats, instanceCapacity));+ },+ target(width, height) {+ const texture = gl.createTexture();+ gl.bindTexture(gl.TEXTURE_2D, texture);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);+ gl.texStorage2D(gl.TEXTURE_2D, 1, half ? gl.RGBA16F : gl.RGBA8, width, height);+ const framebuffer = gl.createFramebuffer();+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);+ return {+ texture, framebuffer, width, height,+ dispose() { gl.deleteFramebuffer(framebuffer); gl.deleteTexture(texture); },+ };+ },+ bind(target) {+ gl.bindFramebuffer(gl.FRAMEBUFFER, target ? target.framebuffer : null);+ gl.viewport(0, 0, target ? target.width : gl.drawingBufferWidth, target ? target.height : gl.drawingBufferHeight);+ },+ // the stars, added up: CustomBlending, AddEquation, ONE / ONE for colour and alpha+ drawStars(name, count, set) {+ if (!count) return;+ const p = programs[name];+ gl.useProgram(p.program);+ set(p.uniforms);+ gl.enable(gl.BLEND);+ gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);+ gl.blendFuncSeparate(gl.ONE, gl.ONE, gl.ONE, gl.ONE);+ gl.bindVertexArray(starVaos[name].vao);+ gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, count);+ gl.bindVertexArray(null);+ },+ // a full-screen pass, NoBlending; textures as [uniform, target] pairs+ drawPass(name, set, textures) {+ const p = programs[name];+ gl.useProgram(p.program);+ textures.forEach(([uniform, target], unit) => {+ gl.activeTexture(gl.TEXTURE0 + unit);+ gl.bindTexture(gl.TEXTURE_2D, target.texture);+ gl.uniform1i(p.uniforms[uniform], unit);+ });+ set(p.uniforms);+ gl.disable(gl.BLEND);+ gl.bindVertexArray(quad);+ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);+ gl.bindVertexArray(null);+ },+ clear() {+ gl.clearColor(0, 0, 0, 0);+ gl.clear(gl.COLOR_BUFFER_BIT);+ },+ dispose() {+ for (const p of Object.values(programs)) gl.deleteProgram(p.program);+ gl.getExtension("WEBGL_lose_context")?.loseContext();+ },+ };+ // three's defaults for a material with side FrontSide, no depth test+ gl.disable(gl.DEPTH_TEST);+ gl.depthMask(false);+ gl.enable(gl.CULL_FACE);+ gl.cullFace(gl.BACK);+ gl.frontFace(gl.CCW);+ return renderer;+}++// ---------------------------------------------------------------------------------------------------++/**+ * Mounts the stars into `root` (they fill it). Returns { sync(props), burst(), destroy() }, or null without+ * WebGL2.+ */+export function createFadingStars(root, initialProps = {}) {+ let props = { ...DEFAULTS, ...initialProps, reduced: !!initialProps.reduced };+ const doc = root.ownerDocument;+ const win = doc.defaultView ?? window;++ const canvas = doc.createElement("canvas");+ canvas.setAttribute("aria-hidden", "true");+ Object.assign(canvas.style, { position: "absolute", inset: "0", width: "100%", height: "100%", display: "block", pointerEvents: "none" });+ root.prepend(canvas);++ let renderer;+ try {+ renderer = createRenderer(canvas);+ } catch {+ renderer = null;+ }+ if (!renderer) {+ canvas.remove();+ return null;+ }+ let gl = renderer.gl;+ const ctx2d = doc.createElement("canvas").getContext("2d");++ // mulberry32, seeded the same on every mount+ let seed = 24301;+ const random = () => {+ let t = (seed = (seed + 0x6d2b79f5) >>> 0);+ t = Math.imul(t ^ (t >>> 15), 1 | t);+ return (((t ^= t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ (t >>> 14)) >>> 0) / 0x100000000;+ };++ const shared = { trailLab: [0, 0, 0], headLab: [0, 0, 0], background: [0, 0, 0] };++ let lines = null; // the stars, full size+ let downs = []; // bloom levels, each half the one before+ let ups = [];+ let capacity = 0;+ let instances = new Float32Array(0);+ let instanceCount = 0;+ let hasBuffer = false;+ const stars = [];+ const ray = { dx: 0, dy: 1, enter: 0, exit: 0 };++ let destroyed = false;+ let lost = false;+ let rafId = 0;+ let lastTs = 0;+ let inView = true;+ let width = 1; // CSS px+ let height = 1;+ let pixelRatio = 1;+ let time = 0;+ let grainSeed = 0;+ let pointerTravel = 0; // px the pointer moved since the last frame+ let thrustTarget = 0;+ let boostVelocity = 0;+ let boost = 0;+ let ink = false;+ let colorKey = "";+ let lastPointer = null;+ let tap = null;++ const ensureCapacity = (n) => {+ if (n <= capacity && hasBuffer) return;+ capacity = Math.max(64, 2 ** Math.ceil(Math.log2(Math.max(n, 1))));+ instances = new Float32Array(12 * capacity);+ renderer.setInstanceData(instances);+ hasBuffer = true;+ };+ const disposeTargets = () => {+ lines?.dispose();+ downs.forEach((t) => t.dispose());+ ups.forEach((t) => t.dispose());+ lines = null;+ downs = [];+ ups = [];+ };+ const running = () => !props.paused && !props.reduced;++ // The fan: origin beyond the edge the stars come from, the axis they travel along, and the angles+ // of the rays that cross the frame, bent toward the centre line by `focus`.+ const fan = () => {+ const p = props;+ const offset = clamp(finite(p.originOffset, 0.18), 0, 2) * Math.min(width, height);+ const shift = clamp(finite(p.originShift, 0), -1, 1);+ const dir = p.direction;+ let ox = 0.5 * width * (1 + shift);+ let oy = -offset;+ let ax = 0;+ let ay = 1;+ let unit = height;+ if (dir === "down") {+ oy = height + offset;+ ay = -1;+ } else if (dir === "left" || dir === "right") {+ ox = dir === "left" ? width + offset : -offset;+ oy = 0.5 * height * (1 - shift);+ ax = dir === "left" ? -1 : 1;+ ay = 0;+ unit = width;+ } else if (dir === "out") {+ oy = 0.5 * height;+ unit = 0.5 * Math.hypot(width, height);+ }+ const full = dir === "out";+ const half = full ? Math.PI : (clamp(finite(p.spread, 150), 1, 180) * Math.PI) / 360;+ let lo = -half;+ let hi = half;+ if (!full) {+ let min = Infinity;+ let max = -Infinity;+ for (let k = 0; k < 4; k++) {+ const cx = (k & 1 ? width : 0) - ox;+ const cy = (k & 2 ? height : 0) - oy;+ const angle = Math.atan2(ax * cy - ay * cx, ax * cx + ay * cy);+ min = Math.min(min, angle);+ max = Math.max(max, angle);+ }+ lo = Math.max(lo, min);+ if ((hi = Math.min(hi, max)) < lo) {+ lo = 0;+ hi = 0;+ }+ }+ const bend = full ? 0 : 4.5 * clamp(finite(p.focus, 0.35), 0, 1);+ const unbend = (x) => (bend < 0.001 ? x : Math.asinh(x * Math.sinh(bend)) / bend);+ return { ox, oy, ax, ay, unit: Math.max(unit, 1), half, lo, hi, full, bend, from: unbend(lo / half), to: unbend(hi / half) };+ };+ const angleOf = (f, q) => {+ if (f.full) return (2 * q - 1) * Math.PI;+ const x = f.from + (f.to - f.from) * q;+ return f.half * (f.bend < 0.001 ? x : Math.sinh(f.bend * x) / Math.sinh(f.bend));+ };+ // Where the ray at `angle` enters and leaves the frame, in fan units; false if it misses.+ const cast = (f, angle) => {+ const c = Math.cos(angle);+ const s = Math.sin(angle);+ const dx = f.ax * c - f.ay * s;+ const dy = f.ax * s + f.ay * c;+ let enter = 0;+ let exit = Infinity;+ if (Math.abs(dx) > 1e-9) {+ const a = -f.ox / dx;+ const b = (width - f.ox) / dx;+ enter = Math.max(enter, Math.min(a, b));+ exit = Math.min(exit, Math.max(a, b));+ } else if (f.ox < 0 || f.ox > width) exit = -1;+ if (Math.abs(dy) > 1e-9) {+ const a = -f.oy / dy;+ const b = (height - f.oy) / dy;+ enter = Math.max(enter, Math.min(a, b));+ exit = Math.min(exit, Math.max(a, b));+ } else if (f.oy < 0 || f.oy > height) exit = -1;+ ray.dx = dx;+ ray.dy = dy;+ ray.enter = enter / f.unit;+ ray.exit = exit / f.unit;+ return ray.exit - ray.enter > 1e-4;+ };+ // distance after travelling `t` under warp acceleration `a` (speed grows with distance)+ const travel = (r, t, a) => (a < 1e-4 ? r + t : (r + 1 / a) * Math.exp(a * t) - 1 / a);+ // a point `u` of the way along the ray, spaced so stars are evenly spread in time+ const along = (enter, exit, a, u) => {+ if (exit <= enter) return enter;+ if (a < 1e-4) return enter + (exit - enter) * u;+ const k = 1 / a;+ return (enter + k) * Math.pow((exit + k) / (enter + k), u) - k;+ };+ const newStar = (shell) => ({ q: 0, angle: 0, r: 0, pace: 0.5, layer: 1, gain: 1, seed: 0, glint: 0, age: 0, fade: 0, retire: 1, shell });+ const respawn = (star, f, atEdge, accel, margin) => {+ for (let i = 0; i < 4; i++) {+ star.q = random();+ star.pace = random();+ star.layer = random();+ star.gain = 0.55 + 0.45 * random();+ star.seed = random();+ star.glint = +(0.07 > random());+ if (cast(f, angleOf(f, star.q))) {+ star.r = atEdge ? Math.max(ray.enter - margin, 0) : along(ray.enter, ray.exit, accel, random());+ return;+ }+ }+ star.r = 0;+ };++ // One simulation step of `dt` seconds (0: just rebuild the instance data).+ const step = (dt) => {+ const p = props;+ const live = running();+ const f = fan();+ const speed = clamp(finite(p.speed, 0.16), 0, 2);+ const variance = clamp(finite(p.speedVariance, 0.6), 0, 1);+ const accel = clamp(finite(p.acceleration, 0.9), 0, 4);+ const trail = clamp(finite(p.trailLength, 0.45), 0, 2);+ const fadeIn = Math.max(clamp(finite(p.fadeIn, 0.06), 0, 1), 0.01);+ const fadeOut = clamp(finite(p.fadeOut, 0.3), 0, 1);+ const depth = clamp(finite(p.depth, 0.5), 0, 1);+ const margin = (2 * clamp(finite(p.starSize, 2.2), 0, 8) + 3) / f.unit;+ const flow = 1 + Math.max(boost, 0);++ // population: `count` stars in a 1280x720 frame, scaled by area+ {+ const scale = clamp(Math.sqrt((width * height) / 921600), 0.35, 1.6);+ const want = Math.round(clamp(finite(p.count, 480), 0, 3000) * clamp(finite(p.quality, 1), 0.25, 1) * scale);+ let have = 0;+ for (const s of stars) if (!s.shell && s.retire >= 1) have++;+ if (have < want) {+ for (let k = have; k < want; k++) {+ const s = newStar(false);+ respawn(s, f, false, accel, margin);+ s.fade = 0.9 * !!live;+ stars.push(s);+ }+ } else if (have > want) {+ let extra = have - want;+ for (let k = stars.length - 1; k >= 0 && extra > 0; k--) {+ const s = stars[k];+ if (!s.shell && !(s.retire < 1)) {+ s.retire = 0.999 * !!live;+ extra--;+ }+ }+ }+ }+ ensureCapacity(stars.length);++ let drawn = 0;+ let kept = 0;+ for (let k = 0; k < stars.length; k++) {+ const s = stars[k];+ if (dt > 0) {+ s.age += dt;+ if (s.retire < 1) s.retire -= dt / 0.5;+ }+ if (s.retire <= 0) continue;+ const layer = s.shell ? 1 : s.layer < depth ? 0.3 + 0.35 * (s.layer / Math.max(depth, 0.001)) : 1;+ const pace = s.shell ? 1.9 : Math.max(0.05, 1 + 0.9 * variance * (2 * s.pace - 1)) * (0.35 + 0.65 * layer);+ let inFrame = cast(f, s.shell ? s.angle : angleOf(f, s.q));+ if (inFrame && dt > 0 && speed > 0) s.r = travel(s.r, speed * pace * flow * dt, accel);+ let length = 0;+ let alpha = 0;+ if (inFrame) {+ length = Math.min((trail * pace * (1 + accel * s.r) * flow) / (1 + 0.6 * accel), Math.max(s.r - ray.enter, 0));+ const progress = (s.r - ray.enter) / (ray.exit - ray.enter);+ if (progress >= 1 && (fadeOut > 0 || s.r - length - margin >= ray.exit)) inFrame = false;+ else {+ const a = smoothstep(0, fadeIn, progress);+ const b = fadeOut > 0 ? 1 - smoothstep(1 - fadeOut, 1, progress) : 1;+ alpha = a * a * b * b;+ }+ }+ if (!inFrame) {+ if (s.shell) continue;+ respawn(s, f, live, accel, margin);+ s.fade = 0;+ stars[kept++] = s;+ continue;+ }+ stars[kept++] = s;+ if (s.fade > 0 && live) alpha *= smoothstep(0, s.fade, s.age);+ if (s.retire < 1) alpha *= smoothstep(0, 1, s.retire);+ if ((alpha *= s.gain * layer * layer) <= 1e-4) continue;+ const o = 12 * drawn;+ instances[o] = f.ox + ray.dx * s.r * f.unit;+ instances[o + 1] = f.oy + ray.dy * s.r * f.unit;+ instances[o + 2] = ray.dx;+ instances[o + 3] = ray.dy;+ instances[o + 4] = length * f.unit;+ instances[o + 5] = alpha;+ instances[o + 6] = (0.45 + 0.55 * layer) * (1 + 0.15 * s.glint) * (0.85 + 0.3 * ((7.31 * s.seed) % 1));+ instances[o + 7] = 0.55 + 0.45 * layer;+ instances[o + 8] = s.seed;+ instances[o + 9] = s.glint;+ instances[o + 10] = layer;+ instances[o + 11] = 0;+ drawn++;+ }+ stars.length = kept;+ if (hasBuffer) renderer.updateInstances(instances, 12 * Math.max(drawn, 1));+ instanceCount = drawn;+ };++ const burst = () => {+ if (destroyed || !running()) return;+ const n0 = Math.round(clamp(finite(props.burst, 64), 0, 256));+ if (!n0) return;+ let shells = 0;+ for (const s of stars) if (s.shell) shells++;+ const n = Math.min(n0, 4096 - shells);+ if (n <= 0) return;+ const f = fan();+ for (let k = 0; k < n; k++) {+ const s = newStar(true);+ s.angle = f.lo + ((f.hi - f.lo) * (k + 0.5 + (random() - 0.5) * 0.6)) / n;+ if (cast(f, s.angle)) {+ s.r = ray.enter + 0.003;+ s.seed = random();+ s.glint = 0.6;+ s.fade = 0.14;+ stars.push(s);+ }+ }+ request();+ };++ const updateColors = () => {+ const p = props;+ const [trail = "#5227FF", head = "#FF9FFC"] = p.colors ?? [];+ const key = [trail, head, p.backgroundColor, p.mode].join("|");+ if (key === colorKey) return;+ colorKey = key;+ const bg = parseColor(ctx2d, p.backgroundColor, [0.04, 0.04, 0.04]);+ const luminance = 0.2126 * bg[0] + 0.7152 * bg[1] + 0.0722 * bg[2];+ ink = p.mode === "ink" || (p.mode === "auto" && luminance > 0.5);+ let t = toOklab(parseColor(ctx2d, trail, [0.08, 0.72, 0.65]));+ let h = toOklab(parseColor(ctx2d, head, [0.8, 1, 0.96]));+ if (ink) {+ // on light backgrounds both colours are deepened into ink tones+ const mid = [t[0] + (h[0] - t[0]) * 0.35, t[1] + (h[1] - t[1]) * 0.35, t[2] + (h[2] - t[2]) * 0.35];+ t = [Math.min(t[0], 0.58), 1.08 * t[1], 1.08 * t[2]];+ h = [Math.min(mid[0], 0.4), 1.15 * mid[1], 1.15 * mid[2]];+ }+ shared.trailLab = t;+ shared.headLab = h;+ shared.background = [toLinear(bg[0]), toLinear(bg[1]), toLinear(bg[2])];+ };++ const render = () => {+ if (!lines || !downs.length || lost || destroyed) return;+ const p = props;+ updateColors();+ const common = (u) => {+ gl.uniform2f(u.uResolution, canvas.width, canvas.height);+ gl.uniform1f(u.uPixelRatio, canvas.width / width);+ gl.uniform3f(u.uTrailLab, ...shared.trailLab);+ gl.uniform3f(u.uHeadLab, ...shared.headLab);+ };+ renderer.bind(lines);+ renderer.clear();+ renderer.drawStars("trails", instanceCount, (u) => {+ common(u);+ gl.uniform1f(u.uLineWidth, clamp(finite(p.lineWidth, 1), 0.25, 4));+ gl.uniform1f(u.uTrailGain, ink ? 1 : 0.6);+ gl.uniform1f(u.uFade, clamp(finite(p.trailFade, 1.6), 0.2, 6));+ });+ renderer.drawStars("heads", instanceCount, (u) => {+ common(u);+ gl.uniform1f(u.uStarSize, clamp(finite(p.starSize, 2.2), 0, 8));+ gl.uniform1f(u.uTime, time);+ gl.uniform1f(u.uTwinkle, clamp(finite(p.twinkle, 0.35), 0, 1));+ gl.uniform1f(u.uHeadGain, ink ? 1.6 : 1.7);+ gl.uniform1f(u.uHalo, 0.04 * !ink);+ });+ // bloom: down the chain (the first step keeps only the bright parts), then back up+ let source = lines;+ for (const level of downs) {+ const first = source === lines;+ renderer.bind(level);+ renderer.drawPass("down", (u) => {+ gl.uniform2f(u.uTexel, 1 / source.width, 1 / source.height);+ gl.uniform1f(u.uThreshold, first && !ink ? 0.3 : 0);+ gl.uniform1f(u.uFloor, first && !ink ? 0.22 : 1);+ }, [["uSource", source]]);+ source = level;+ }+ let bloom = downs[downs.length - 1];+ for (let k = downs.length - 2; k >= 0; k--) {+ const from = bloom;+ renderer.bind(ups[k]);+ renderer.drawPass("up", (u) => gl.uniform2f(u.uTexel, 1 / from.width, 1 / from.height), [["uSource", from], ["uBase", downs[k]]]);+ bloom = ups[k];+ }+ renderer.bind(null);+ renderer.drawPass("composite", (u) => {+ gl.uniform3f(u.uBackground, ...shared.background);+ gl.uniform1f(u.uGlow, clamp(finite(p.glow, 0.45), 0, 3));+ gl.uniform1f(u.uExposure, (ink ? 1.8 : 1) * clamp(finite(p.intensity, 1), 0, 4));+ gl.uniform1f(u.uMode, +!!ink);+ gl.uniform1f(u.uGrain, clamp(finite(p.grain, 0.3), 0, 1));+ gl.uniform1f(u.uSeed, grainSeed);+ }, [["uLines", lines], ["uBloom", bloom]]);+ };++ const frame = (ts) => {+ rafId = 0;+ if (destroyed || lost) return;+ const dt = lastTs > 0 ? clamp((ts - lastTs) / 1e3, 0, 0.05) : 1 / 60;+ lastTs = ts;+ const live = running();+ if (live) {+ time += dt;+ grainSeed = (grainSeed + 0.618034) % 1;+ const p = props;+ const diagonal = Math.max(Math.hypot(width, height), 1);+ // pointer speed in frame diagonals per second+ const pointerSpeed = p.interactive ? pointerTravel / Math.max(dt, 1 / 240) / diagonal : 0;+ pointerTravel = 0;+ thrustTarget = Math.max(2 * clamp(finite(p.thrust, 1), 0, 3) * (1 - Math.exp(-pointerSpeed / 0.8)), thrustTarget * Math.exp(-dt / 0.25));+ boostVelocity += (42.25 * (thrustTarget - boost) - 13 * boostVelocity) * dt;+ if ((boost += boostVelocity * dt) < 0) {+ boost = 0;+ boostVelocity = Math.max(boostVelocity, 0);+ }+ step(dt);+ } else step(0);+ render();+ if (live && inView && !doc.hidden) rafId = win.requestAnimationFrame(frame);+ else lastTs = 0;+ };+ function request() {+ if (destroyed || lost || rafId || !inView) return;+ rafId = win.requestAnimationFrame(frame);+ }++ const currentPixelRatio = () => Math.min(win.devicePixelRatio || 1, 2) * clamp(finite(props.quality, 1), 0.25, 1);+ const resize = () => {+ if (destroyed) return;+ const rect = root.getBoundingClientRect();+ width = Math.max(1, root.clientWidth || rect.width);+ height = Math.max(1, root.clientHeight || rect.height);+ pixelRatio = currentPixelRatio();+ canvas.width = Math.floor(width * pixelRatio);+ canvas.height = Math.floor(height * pixelRatio);+ const w = canvas.width;+ const h = canvas.height;+ disposeTargets();+ lines = renderer.target(Math.max(1, w), Math.max(1, h));+ const levels = clamp(Math.floor(Math.log2(Math.min(w, h) / 8)), 3, 7);+ for (let k = 1; k <= levels; k++) {+ downs.push(renderer.target(Math.max(1, w >> k), Math.max(1, h >> k)));+ ups.push(renderer.target(Math.max(1, w >> k), Math.max(1, h >> k)));+ }+ step(0);+ render();+ request();+ };++ // pointer: moving speeds the flow up, a click (or a tap) launches a burst+ const onPointerMove = (e) => {+ if (e.pointerType === "touch" || !props.interactive || !running()) {+ lastPointer = null;+ return;+ }+ if (lastPointer) pointerTravel += Math.hypot(e.clientX - lastPointer.x, e.clientY - lastPointer.y);+ lastPointer = { x: e.clientX, y: e.clientY };+ request();+ };+ const onPointerLeave = () => {+ lastPointer = null;+ tap = null;+ };+ const onPointerDown = (e) => {+ tap = null;+ const t = e.target;+ if (!props.interactive || !e.isPrimary || (t && typeof t.closest === "function" && t.closest("a,button,input,textarea,select,label,summary,[role=button],[contenteditable=true]"))) return;+ if (e.pointerType === "touch") {+ tap = { id: e.pointerId, x: e.clientX, y: e.clientY, time: performance.now() };+ return;+ }+ if (e.button === 0) burst();+ };+ const onPointerUp = (e) => {+ const t = tap;+ tap = null;+ if (!t || t.id !== e.pointerId || Math.hypot(e.clientX - t.x, e.clientY - t.y) > 10 || performance.now() - t.time > 500) return;+ burst();+ };+ const onVisibility = () => {+ lastTs = 0;+ if (!doc.hidden) request();+ };+ const onLost = (e) => {+ e.preventDefault();+ lost = true;+ win.cancelAnimationFrame(rafId);+ rafId = 0;+ lastTs = 0;+ };+ // a restored context starts empty: rebuild programs, buffers and targets, keep the stars+ const onRestored = () => {+ let next = null;+ try {+ next = createRenderer(canvas);+ } catch {}+ if (!next || destroyed) return;+ renderer = next;+ gl = renderer.gl;+ lost = false;+ colorKey = "";+ lines = null;+ downs = [];+ ups = [];+ hasBuffer = false;+ capacity = 0;+ resize();+ };++ root.addEventListener("pointermove", onPointerMove);+ root.addEventListener("pointerleave", onPointerLeave);+ root.addEventListener("pointercancel", onPointerLeave);+ root.addEventListener("pointerdown", onPointerDown);+ root.addEventListener("pointerup", onPointerUp);+ doc.addEventListener("visibilitychange", onVisibility);+ canvas.addEventListener("webglcontextlost", onLost);+ canvas.addEventListener("webglcontextrestored", onRestored);+ const resizeObserver = new ResizeObserver(resize);+ resizeObserver.observe(root);+ const intersectionObserver = new IntersectionObserver(+ (entries) => {+ inView = entries.some((e) => e.isIntersecting);+ lastTs = 0;+ if (inView) request();+ },+ { rootMargin: "80px" },+ );+ intersectionObserver.observe(root);+ ensureCapacity(64);+ resize();++ return {+ sync(next = {}) {+ props = { ...props, ...next };+ if (destroyed || lost) return;+ if (Math.abs(currentPixelRatio() - pixelRatio) > 0.001) return void resize();+ if (!rafId) {+ step(0);+ render();+ }+ request();+ },+ burst,+ destroy() {+ destroyed = true;+ win.cancelAnimationFrame(rafId);+ rafId = 0;+ root.removeEventListener("pointermove", onPointerMove);+ root.removeEventListener("pointerleave", onPointerLeave);+ root.removeEventListener("pointercancel", onPointerLeave);+ root.removeEventListener("pointerdown", onPointerDown);+ root.removeEventListener("pointerup", onPointerUp);+ doc.removeEventListener("visibilitychange", onVisibility);+ canvas.removeEventListener("webglcontextlost", onLost);+ canvas.removeEventListener("webglcontextrestored", onRestored);+ resizeObserver.disconnect();+ intersectionObserver.disconnect();+ disposeTargets();+ renderer?.dispose();+ canvas.remove();+ },+ };+}diff --git a/site/public/examples/reactbits-fading-stars/src/main.js b/site/public/examples/reactbits-fading-stars/src/main.jsnew file mode 100644index 0000000..24d2bb4--- /dev/null+++ b/site/public/examples/reactbits-fading-stars/src/main.js@@ -0,0 +1,18 @@+// Mounts the stars in .fading-stars with the preview's props. Reduced-motion users get a still frame,+// as on pro.reactbits.dev. window.fadingStars.restart() mounts them again from the first frame (the+// captures use it to start both pages at the same moment).++import { createFadingStars } from "./fading-stars.js";++const root = document.querySelector(".fading-stars");+const motion = matchMedia("(prefers-reduced-motion: reduce)");+let stars = createFadingStars(root, { reduced: motion.matches });+motion.addEventListener("change", () => stars?.sync({ reduced: motion.matches }));++window.fadingStars = {+ burst: () => stars?.burst(),+ restart() {+ stars?.destroy();+ stars = createFadingStars(root, { reduced: motion.matches });+ },+};diff --git a/site/public/examples/reactbits-fading-stars/src/shaders.js b/site/public/examples/reactbits-fading-stars/src/shaders.jsnew file mode 100644index 0000000..40365f1--- /dev/null+++ b/site/public/examples/reactbits-fading-stars/src/shaders.js@@ -0,0 +1,265 @@+// Fading Stars shaders, verbatim from pro.reactbits.dev (FadingStars, three r181 ShaderMaterial, GLSL ES 3.00).+// three.js prepends "#version 300 es", highp precision and the built-in `position` / `uv` attributes;+// PREFIX below does the same for raw WebGL2.++export const VERTEX_PREFIX = `#version 300 es+precision highp float;+precision highp int;+precision highp sampler2D;+in vec3 position;+in vec2 uv;+`;++export const FRAGMENT_PREFIX = `#version 300 es+precision highp float;+precision highp int;+precision highp sampler2D;+`;++const LAB = `+vec3 labToLinear(vec3 lab) {+ float l = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;+ float m = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;+ float s = lab.x - 0.0894841775 * lab.y - 1.2914855480 * lab.z;+ l = l * l * l;+ m = m * m * m;+ s = s * s * s;+ return max(vec3(+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,+ -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s+ ), 0.0);+}+`;++// One instanced quad per star: the trail, a line from the head back along the ray.+export const trailVertex = `+in vec4 aHead;+in vec4 aShape;+in vec4 aLook;+uniform vec2 uResolution;+uniform float uPixelRatio;+uniform float uLineWidth;+uniform float uTrailGain;+out vec2 vLine;+out float vLength;+out float vHalf;+out float vGain;+out float vLayer;++void main() {+ float len = aShape.x * uPixelRatio;+ float width = uLineWidth * aShape.w * uPixelRatio;+ vLine = vec2(0.0);+ vLength = 1.0;+ vHalf = 0.0;+ vGain = 0.0;+ vLayer = aLook.z;+ if (aShape.y <= 0.0 || len < 0.05 || width <= 0.0) {+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);+ return;+ }+ float body = max(width, 1.0);+ float reach = body * 0.5 + 1.0;+ vec2 dir = aHead.zw;+ vec2 side = vec2(-dir.y, dir.x);+ float along = mix(-1.0, len + 1.0, position.x);+ float across = position.y * reach;+ vec2 point = aHead.xy * uPixelRatio - dir * (len - along) + side * across;+ vLine = vec2(along, across);+ vLength = len;+ vHalf = body * 0.5;+ vGain = aShape.y * uTrailGain * min(width, 1.0);+ gl_Position = vec4(point / uResolution * 2.0 - 1.0, 0.0, 1.0);+}+`;++export const trailFragment = `+precision highp float;+uniform vec3 uTrailLab;+uniform vec3 uHeadLab;+uniform float uFade;+in vec2 vLine;+in float vLength;+in float vHalf;+in float vGain;+in float vLayer;+out vec4 fragColor;+${LAB}++void main() {+ float t = clamp(vLine.x / vLength, 0.0, 1.0);+ float side = clamp(vHalf + 0.5 - abs(vLine.y), 0.0, 1.0);+ float cap = clamp(vLength + 0.5 - vLine.x, 0.0, 1.0);+ float e = pow(t, uFade * 2.2) * side * cap * vGain;+ vec3 color = labToLinear(mix(uTrailLab, uHeadLab, smoothstep(0.45, 1.0, t) * 0.45 * vLayer));+ fragColor = vec4(color * e, e);+}+`;++// One instanced quad per star: the head, a gaussian dot with a faint halo that twinkles.+export const headVertex = `+in vec4 aHead;+in vec4 aShape;+in vec4 aLook;+uniform vec2 uResolution;+uniform float uPixelRatio;+uniform float uStarSize;+uniform float uTime;+uniform float uTwinkle;+uniform float uHeadGain;+out vec2 vOffset;+out float vSigma;+out float vRadius;+out float vGain;+out float vLayer;++void main() {+ float wanted = uStarSize * aShape.z * uPixelRatio * 0.42;+ float sigma = max(wanted, 0.5);+ float radius = sigma * 4.5 + 1.0;+ vOffset = position.xy * radius;+ vSigma = sigma;+ vRadius = radius;+ vGain = 0.0;+ vLayer = aLook.z;+ if (aShape.y <= 0.0 || wanted <= 0.0) {+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);+ return;+ }+ float wave = 0.5 + 0.5 * sin(uTime * (0.6 + 1.5 * aLook.x) + aLook.x * 57.0);+ float shimmer = 1.0 - uTwinkle * 0.6 * wave * wave;+ vGain = aShape.y * uHeadGain * shimmer * (1.0 + aLook.y * 0.5) * (wanted * wanted) / (sigma * sigma);+ gl_Position = vec4((aHead.xy * uPixelRatio + vOffset) / uResolution * 2.0 - 1.0, 0.0, 1.0);+}+`;++export const headFragment = `+precision highp float;+uniform vec3 uTrailLab;+uniform vec3 uHeadLab;+uniform float uHalo;+in vec2 vOffset;+in float vSigma;+in float vRadius;+in float vGain;+in float vLayer;+out vec4 fragColor;+${LAB}++void main() {+ float d = length(vOffset);+ float x = d / vSigma;+ float body = exp(-0.5 * x * x) + uHalo * exp(-0.06 * x * x);+ float e = body * (1.0 - smoothstep(vRadius * 0.5, vRadius, d)) * vGain;+ vec3 color = labToLinear(mix(uTrailLab, uHeadLab, mix(0.5, 1.0, vLayer)));+ fragColor = vec4(color * e, e);+}+`;++// Full-screen passes.+export const screenVertex = `+out vec2 vUv;++void main() {+ vUv = uv;+ gl_Position = vec4(position.xy, 0.0, 1.0);+}+`;++// Bloom, down: a 5-tap filter at half size; the first level keeps only light above a soft threshold.+export const downFragment = `+precision highp float;+uniform sampler2D uSource;+uniform vec2 uTexel;+uniform float uThreshold;+uniform float uFloor;+in vec2 vUv;+out vec4 fragColor;++void main() {+ vec4 a = texture(uSource, vUv + uTexel * vec2(-1.0, -1.0));+ vec4 b = texture(uSource, vUv + uTexel * vec2(1.0, -1.0));+ vec4 c = texture(uSource, vUv + uTexel * vec2(-1.0, 1.0));+ vec4 d = texture(uSource, vUv + uTexel * vec2(1.0, 1.0));+ vec4 color = (a + b + c + d) * 0.125 + texture(uSource, vUv) * 0.5;+ float peak = max(color.r, max(color.g, color.b));+ float knee = uThreshold * 0.6 + 1e-4;+ float soft = clamp(peak - uThreshold + knee, 0.0, 2.0 * knee);+ float weight = max(soft * soft / (4.0 * knee), peak - uThreshold) / max(peak, 1e-4);+ color.rgb *= mix(uFloor, 1.0, clamp(weight, 0.0, 1.0));+ fragColor = color;+}+`;++// Bloom, up: a 9-tap tent of the smaller level added to the level above.+export const upFragment = `+precision highp float;+uniform sampler2D uSource;+uniform sampler2D uBase;+uniform vec2 uTexel;+in vec2 vUv;+out vec4 fragColor;++void main() {+ vec4 sum = texture(uSource, vUv) * 4.0;+ sum += texture(uSource, vUv + uTexel * vec2(-1.0, 0.0)) * 2.0;+ sum += texture(uSource, vUv + uTexel * vec2(1.0, 0.0)) * 2.0;+ sum += texture(uSource, vUv + uTexel * vec2(0.0, -1.0)) * 2.0;+ sum += texture(uSource, vUv + uTexel * vec2(0.0, 1.0)) * 2.0;+ sum += texture(uSource, vUv + uTexel * vec2(-1.0, -1.0));+ sum += texture(uSource, vUv + uTexel * vec2(1.0, -1.0));+ sum += texture(uSource, vUv + uTexel * vec2(-1.0, 1.0));+ sum += texture(uSource, vUv + uTexel * vec2(1.0, 1.0));+ fragColor = texture(uBase, vUv) + sum / 16.0;+}+`;++// To the screen: expose the light (glow) or lay down ink (light backgrounds), encode to sRGB, add grain.+export const compositeFragment = `+precision highp float;+uniform sampler2D uLines;+uniform sampler2D uBloom;+uniform vec3 uBackground;+uniform float uGlow;+uniform float uExposure;+uniform float uMode;+uniform float uGrain;+uniform float uSeed;+in vec2 vUv;+out vec4 fragColor;++float hash(vec2 p) {+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);+ p3 += dot(p3, p3.yzx + 33.33);+ return fract((p3.x + p3.y) * p3.z);+}++vec3 encode(vec3 c) {+ c = clamp(c, 0.0, 1.0);+ return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(vec3(0.0031308), c));+}++void main() {+ vec4 lines = texture(uLines, vUv);+ vec4 bloom = texture(uBloom, vUv);+ vec3 color;+ float amount;+ if (uMode < 0.5) {+ vec3 light = (lines.rgb + bloom.rgb * uGlow) * uExposure;+ vec3 exposed = 1.0 - exp(-light);+ float peak = max(exposed.r, max(exposed.g, exposed.b));+ exposed = mix(exposed, vec3(peak), smoothstep(0.7, 1.0, peak) * 0.4);+ color = uBackground + (1.0 - uBackground) * exposed;+ amount = peak;+ } else {+ float energy = lines.a + bloom.a * uGlow * 0.15;+ vec3 hue = (lines.rgb + bloom.rgb * uGlow * 0.15) / max(energy, 1e-4);+ float cover = clamp(1.0 - exp(-energy * uExposure), 0.0, 0.92);+ color = mix(uBackground, clamp(hue, 0.0, 1.0), cover);+ amount = cover;+ }+ float noise = hash(gl_FragCoord.xy + uSeed * 311.0) - 0.5;+ fragColor = vec4(encode(color) + noise * (1.0 / 255.0 + uGrain * 0.08 * sqrt(amount)), 1.0);+}+`;diff --git a/site/public/examples/resend-cube/assets/bg-floor.webp b/site/public/examples/resend-cube/assets/bg-floor.webpnew file mode 100644index 0000000..c572cccBinary files /dev/null and b/site/public/examples/resend-cube/assets/bg-floor.webp differdiff --git a/site/public/examples/resend-cube/assets/bg-light.avif b/site/public/examples/resend-cube/assets/bg-light.avifnew file mode 100644index 0000000..f6dd0d3Binary files /dev/null and b/site/public/examples/resend-cube/assets/bg-light.avif differdiff --git a/site/public/examples/resend-cube/assets/scene.json b/site/public/examples/resend-cube/assets/scene.jsonnew file mode 100644index 0000000..080e565--- /dev/null+++ b/site/public/examples/resend-cube/assets/scene.json@@ -0,0 +1 @@+{"note":"Ported from the reanimate trace of https://resend.com/ (Spline scene /static/cube.splinecode, three.js r149).","camera":{"matrixWorld":[0.7071067811865481,0,-0.707106781186547,0,-0.40824829046386274,0.816496580927726,-0.40824829046386335,0,0.5773502691896253,0.5773502691896258,0.5773502691896262,0,575.9999999999999,576,576.0000000000001,1],"near":49999.99999999999,"projection":[0.00308642,0,0,0,0,0.00363636,0,0,0,0,-2e-05,0,0,0,0,1]},"lights":{"spot":{"matrix":[1,0,0,0,0,0.6026492989873038,0.7980061543810996,0,0,-0.7980061543810996,0.6026492989873038,0,0,974.1102171230986,1381.2652884190875,1],"color":16777215,"intensity":10,"distance":2100,"angle":0.3839724354387525,"decay":1,"penumbra":0,"shadow":{"bias":0,"normalBias":1,"radius":2.022,"mapSize":[1024,1024],"near":100,"far":2100}},"directional":{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,850000,1300000,1000000,1],"color":16777215,"intensity":2},"hemisphere":{"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],"skyColor":13882323,"groundColor":8553090,"intensity":0.75}},"geometries":{"panel":{"position":"AADIQQAAT0PXRjhCAADIQQAAT0PXRjjCAADIQQAAT8PXRjhCAADIQQAAT8PXRjjCAADIwQAAT0PXRjjCAADIwQAAT0PXRjhCAADIwQAAT8PXRjjCAADIwQAAT8PX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CXHyUwabYVkPXRjjCAACIwQAAV0PXRjhCAACIwQAAV0PXRjjCAADIQQAAT0PXRjjCAADIQQAAT0PXRjhCMMXGQYyPUEPXRjjCMMXGQYyPUEPXRjhC2CDDQbwPUkPXRjjC2CDDQbwPUkPXRjhCzDa9Qc9xU0PXRjjCzDa9Qc9xU0PXRjhCPUG1QSioVEPXRjjCPUG1QSioVEPXRjhCdo6rQdqmVUPXRjjCdo6rQdqmVUPXRjhC432gQRtkVkPXRjjC432gQRtkVkPXRjhCXHyUQabYVkPXRjjCXHyUQabYVkPXRjhCAACIQQAAV0PXRjjCAACIQQAAV0PXRjhCAACIQQAAT8PXRljCAACIwQAAT8PXRljCAACIQYyPUMNvqVfCAACIwYyPUMNvqVfCAACIQbwPUsND11XCAACIwbwPUsND11XCAACIQc9xU8M94lLCAACIwc9xU8M94lLCAACIQSioVMN1507CAACIwSioVMN1507CAACIQdqmVcMSDkrCAACIwdqmVcMSDkrCAACIQRtkVsPIhUTCAACIwRtkVsPIhUTCAACIQabYVsMFhT7CAACIwabYVsMFhT7CAACIQQAAV8PXRjjCAACIwQAAV8PXRjjCAACIwQAAT8PXRlhCAACIQQAAT8PXRlhCAACIwYyPUMNvqVdCAACIQYyPUMNvqVdCAACIwbwPUsND11VCAACIQbwPUsND11VCAACIwc9xU8M94lJCAACIQc9xU8M94lJCAACIwSioVMN1505CAACIQSioVMN1505CAACIwdqmVcMSDkpCAACIQdqmVcMSDkpCAACIwRtkVsPIhURCAACIQRtkVsPIhURCAACIwabYVsMFhT5CAACIQabYVsMFhT5CAACIwQAAV8PXRjhCAACIQQAAV8PXRjhCAACIQQAAT0PXRlhCAACIwQAAT0PXRlhCAACIQYyPUENvqVdCAACIwYyPUENvqVdCAACIQbwPUkND11VCAACIwbwPUkND11VCAACIQc9xU0M94lJCAACIwc9xU0M94lJCAACIQSioVEN1505CAACIwSioVEN1505CAACIQdqmVUMSDkpCAACIwdqmVUMSDkpCAACIQRtkVkPIhURCAACIwRtkVkPIh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2AjcCMgI3AjMCMwI3AjgCMwI4AjQCNAI4AjkCNQI6AjsCNQI7AjYCNgI7AjwCNgI8AjcCNwI8Aj0CNwI9AjgCOAI9Aj4COAI+AjkCOQI+Aj8COgJAAkECOgJBAjsCOwJBAkICOwJCAjwCPAJCAkMCPAJDAj0CPQJDAkQCPQJEAj4CPgJEAkUCPgJFAj8CPwJFAkYCQAJHAkgCQAJIAkECQQJIAkkCQQJJAkICQgJJAkoCQgJKAkMCQwJKAksCQwJLAkQCRAJLAkwCRAJMAkUCRQJMAk0CRQJNAkYCRgJNAk4CRwJPAlACRwJQAkgCSAJQAlECSAJRAkkCSQJRAlICSQJSAkoCSgJSAlMCSgJTAksCSwJTAlQCSwJUAkwCTAJUAlUCTAJVAk0CTQJVAlYCTQJWAk4CTgJWAlcC","boundingSphere":{"center":[0,0,0],"radius":220.71822048702882}},"box":{"position":"AABIQgAAKEIAAChCAABIQgAAKEIAACjCAABIQgAAKMIAAChCAABIQgAAKMIAACjCAABIwgAAKEIAACjCAABIwgAAKEIAAChCAABIwgAAKMIAACjCAABIwgAAKMIAAChCAAAowgAASEIAACjCAAAoQgAASEIAACjCAAAowgAASEIAAChCAAAoQgAASEIAAChCAAAowgAASMIAAChCAAAoQgAASMIAAChCAAAowgAASMIAACjCAAAoQgAASMIAACjCAAAowgAAKEIAAEhCAAAoQgAAKEIAAEhCAAAowgAAKMIAAEhCAAAoQgAAKMIAAEhCAAAoQgAAKEIAAEjCAAAowgAAKEIAAEjCAAAoQgAAKMIAAEjCAAAowgAAKMIAAEjCAABIQgAAKMIAAChCAABIQgAAKMIAACjCmGJHQi4+LsIAAChCmGJHQi4+LsIAACjCbJBFQvE+NMIAAChCbJBFQvE+NMIAACjCZptCQjvHOcIAAChCZptCQjvHOcIAACjCnqA+Qp6gPsIAAChCnqA+Qp6gPsIAACjCO8c5QmabQsIAAChCO8c5QmabQsIAACjC8T40QmyQRcIAAChC8T40QmyQRcIAACjCLj4uQphiR8IAAChCLj4uQphiR8IAACjCAAAoQgAASMIAAChCAAAoQgAASMIAACjCAABIwgAAKMIAACjCAABIwgAAKMIAAChCmGJHwi4+LsIAACjCmGJHwi4+LsIAAChCbJBFwvE+NMIAACjCbJBFwvE+NMIAAChCZptCwjvHOcIAACjCZptCwjvHOcIAAChCnqA+wp6gPsIAACjCnqA+wp6gPsIAAChCO8c5wmabQsIAACjCO8c5wmabQsIAAChC8T40wmyQRcIAACjC8T40wmyQRcIAAChCLj4uwphiR8IAACjCLj4uwphiR8IAAChCAAAowgAASMIAACjCAAAowgAASMIAAChCAABIwgAAKEIAAChCAABIwgAAKEIAACjCmGJHwi4+LkIAAChCmGJHwi4+LkIAACjCbJBFwvE+NEIAAChCbJBFwvE+NEIAACjCZptCwjvHOUIAAChCZptCwjvHOUIAACjCnqA+wp6gPkIAAChCnqA+wp6gPkIAACjCO8c5wmabQkIAAChCO8c5wmabQkIAACjC8T40wmyQRUIAAChC8T40wmyQRUIAACjCLj4uwphiR0IAAChCLj4uwphiR0IAACjCAAAowgAASEIAAChCAAAowgAASEIAACjCAABIQgAAKEIAACjCAABIQgAAKEIAAChCmGJHQi4+LkIAACjCmGJHQi4+LkIAAChCbJBFQvE+NEIAACjCbJBFQvE+NEIAAChCZptCQjvHOUIAACjCZptCQjvHOUIAAChCnqA+Qp6gPkIAACjCnqA+Qp6gPkIAAChCO8c5QmabQkIAACjCO8c5QmabQkIAAChC8T40QmyQRUIAACjC8T40QmyQRUIAAChCLj4uQphiR0IAACjCLj4uQphiR0IAAChCAAAoQgAASEIAACjCAAAoQgAASEIAAChCAAAoQgAAKMIAAEjCAAAowgAAKMIAAEjCAAAoQi4+LsKYYkfCAAAowi4+LsKYYkfCAAAoQvE+NMJskEXCAAAowvE+NMJskEXCAAAoQjvHOcJmm0LCAAAowjvHOcJmm0LCAAAoQp6gPsKeoD7CAAAowp6gPsKeoD7CAAAoQmabQsI7xznCAAAowmabQsI7xznCAAAoQmyQRcLxPjTCAAAowmyQRcLxPjTCAAAoQphiR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335138077788}}},"textures":{"6ee68ea9":{"file":"textures/rubber-terrazzo.png","wrapS":1002,"wrapT":1002,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"19157261":{"file":"textures/rubber-terrazzo-mask.jpg","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"8c75e7ee":{"file":"textures/plastic-surface.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"aee34634":{"file":"textures/noise-200.png","wrapS":1002,"wrapT":1002,"minFilter":1006,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"ac376b47":{"file":"textures/metal.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"fbaf69cf":{"file":"textures/pattern-a.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"9672eb6e":{"file":"textures/pattern-b.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"95cda401":{"file":"textures/textured-plastic-a.png","wrapS":1000,"wrapT":1000,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"2ebde442":{"file":"textures/textured-plastic-b.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"9d76b7bd":{"file":"textures/studio-lighting.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4},"afe0bc61":{"file":"textures/plastic-surface.png","wrapS":1001,"wrapT":1001,"minFilter":1008,"magFilter":1006,"flipY":true,"generateMipmaps":true,"anisotropy":1,"unpackAlignment":4}},"programs":{"p1":{"vert":"shaders/p1.vert","frag":"shaders/p1.frag","uniforms":{},"samplers":{},"transparent":false,"materials":[],"state":"no-blend depth cull","zeroOnFirstFrame":[]},"p2":{"vert":"shaders/p2.vert","frag":"shaders/p2.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU7":{"type":"bool","value":false},"nodeU11":{"type":"bool","value":false},"nodeU19":{"type":"bool","value":false},"nodeU28":{"type":"bool","value":false},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0.0885993,0.0885993,0.0885993]},"nodeU1":{"type":"float","value":1},"nodeU2":{"type":"vec3","value":[0,0,0]},"nodeU3":{"type":"float","value":0.14},"nodeU4":{"type":"float","value":1},"nodeU5":{"type":"float","value":2},"nodeU6":{"type":"float","value":1},"nodeU8":{"type":"float","value":0.4},"nodeU9":{"type":"int","value":3},"nodeU12":{"type":"float","value":0.3},"nodeU13":{"type":"int","value":2},"nodeU14":{"type":"float","value":0},"nodeU15":{"type":"float","value":131},"nodeU16":{"type":"float","value":237.27},"nodeU17":{"type":"vec3","value":[73.6441,-126.558,30]},"nodeU18":{"type":"vec3","value":[1,0,0]},"nodeU20":{"type":"float","value":1},"nodeU21":{"type":"int","value":2},"nodeU23":{"type":"vec3","value":[200,200,0]},"nodeU24":{"type":"float","value":0},"nodeU25":{"type":"mat3","value":[1.66667,0,0,0,1.66667,0,0,0,1]},"nodeU26":{"type":"vec2","value":[120,120]},"nodeU27":{"type":"float","value":0},"nodeU29":{"type":"float","value":0.2},"nodeU30":{"type":"int","value":2},"nodeU31":{"type":"vec3","value":[0.0453011,0.0494764,0.194417]},"nodeU32":{"type":"float","value":-140},"nodeU33":{"type":"float","value":1},"nodeU34":{"type":"int","value":1},"nodeU35":{"type":"float","value":1},"nodeU36":{"type":"float","value":1},"nodeU37":{"type":"float","value":0.4},"nodeUA0":{"type":"vec4","value":[0.103929,0.103929,0.10699,1,0,0,0,1]},"nodeUA1":{"type":"float","value":[0,1]}},"samplers":{"aoMap":"@blank","nodeU10":"afe0bc61","nodeU22":"aee34634","spotShadowMap":"@shadow"},"transparent":false,"materials":["Plastic Surface 01"],"state":"no-blend depth cull","zeroOnFirstFrame":["nodeU23"]},"p3":{"vert":"shaders/p3.vert","frag":"shaders/p3.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU4":{"type":"bool","value":true},"nodeU8":{"type":"bool","value":false},"nodeU17":{"type":"bool","value":false},"emissive":{"type":"vec3","value":[0,0,0]},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0.0412531,0.0412531,0.0461925]},"nodeU1":{"type":"float","value":1},"nodeU2":{"type":"vec3","value":[0.2,0.2,0.2]},"nodeU3":{"type":"float","value":10},"nodeU5":{"type":"float","value":0.1},"nodeU6":{"type":"int","value":0},"nodeU9":{"type":"float","value":0.2},"nodeU10":{"type":"int","value":2},"nodeU11":{"type":"float","value":0},"nodeU12":{"type":"vec3","value":[0,0,0]},"nodeU13":{"type":"float","value":0.14},"nodeU14":{"type":"float","value":1},"nodeU15":{"type":"float","value":2},"nodeU16":{"type":"float","value":1},"nodeU18":{"type":"float","value":1},"nodeU19":{"type":"int","value":3},"nodeU20":{"type":"float","value":1},"nodeU21":{"type":"float","value":1}},"samplers":{"aoMap":"@blank","nodeU7":"9d76b7bd","spotShadowMap":"@shadow"},"transparent":false,"materials":["Studio Lighting 02_3"],"state":"no-blend depth cull","zeroOnFirstFrame":[]},"p4":{"vert":"shaders/p4.vert","frag":"shaders/p4.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU7":{"type":"bool","value":false},"nodeU11":{"type":"bool","value":false},"nodeU21":{"type":"bool","value":false},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0.0374994,0.037831,0.0403415]},"nodeU1":{"type":"float","value":1},"nodeU2":{"type":"vec3","value":[0,0,0]},"nodeU3":{"type":"float","value":0.14},"nodeU4":{"type":"float","value":1},"nodeU5":{"type":"float","value":2},"nodeU6":{"type":"float","value":1},"nodeU8":{"type":"float","value":0.4},"nodeU9":{"type":"int","value":3},"nodeU12":{"type":"float","value":0.8},"nodeU13":{"type":"int","value":2},"nodeU14":{"type":"float","value":0},"nodeU16":{"type":"vec3","value":[200,200,0]},"nodeU17":{"type":"float","value":0},"nodeU18":{"type":"mat3","value":[1.66667,0,0,0,1.66667,0,0,0,1]},"nodeU19":{"type":"vec2","value":[120,120]},"nodeU20":{"type":"float","value":0},"nodeU22":{"type":"float","value":0.2},"nodeU23":{"type":"int","value":2},"nodeU24":{"type":"vec3","value":[0.0453011,0.0494764,0.194417]},"nodeU25":{"type":"float","value":-140},"nodeU26":{"type":"float","value":1},"nodeU27":{"type":"int","value":1},"nodeU28":{"type":"float","value":1},"nodeU29":{"type":"float","value":1},"nodeU30":{"type":"float","value":0.4}},"samplers":{"aoMap":"@blank","nodeU10":"8c75e7ee","nodeU15":"aee34634","spotShadowMap":"@shadow"},"transparent":false,"materials":["Plastic Surface 02"],"state":"no-blend depth cull","zeroOnFirstFrame":["nodeU16"]},"p5":{"vert":"shaders/p5.vert","frag":"shaders/p5.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU8":{"type":"bool","value":false},"nodeU13":{"type":"bool","value":true},"nodeU17":{"type":"bool","value":false},"emissive":{"type":"vec3","value":[0,0,0]},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0,0,0]},"nodeU1":{"type":"float","value":1},"nodeU2":{"type":"float","value":20},"nodeU3":{"type":"float","value":0},"nodeU4":{"type":"vec3","value":[0,0,0]},"nodeU5":{"type":"float","value":0},"nodeU6":{"type":"float","value":1},"nodeU7":{"type":"vec3","value":[0,0,0]},"nodeU9":{"type":"float","value":0.1},"nodeU10":{"type":"int","value":0},"nodeU11":{"type":"vec3","value":[0.2,0.2,0.2]},"nodeU12":{"type":"float","value":5},"nodeU14":{"type":"float","value":0.8},"nodeU15":{"type":"int","value":0},"nodeU18":{"type":"float","value":1},"nodeU19":{"type":"int","value":3},"nodeU20":{"type":"float","value":0},"nodeU21":{"type":"float","value":1},"nodeU22":{"type":"float","value":1}},"samplers":{"aoMap":"@blank","nodeU16":"ac376b47","spotShadowMap":"@shadow"},"transparent":false,"materials":["Metal Color&Shinny "],"state":"no-blend depth cull","zeroOnFirstFrame":[]},"p6":{"vert":"shaders/p6.vert","frag":"shaders/p6.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU3":{"type":"bool","value":false},"nodeU13":{"type":"bool","value":false},"nodeU30":{"type":"bool","value":false},"nodeU35":{"type":"bool","value":true},"nodeU39":{"type":"bool","value":false},"nodeU59":{"type":"bool","value":false},"emissive":{"type":"vec3","value":[0,0,0]},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0.0226251,0.0226251,0.0226251]},"nodeU1":{"type":"float","value":1},"nodeU4":{"type":"float","value":0.15},"nodeU5":{"type":"int","value":0},"nodeU6":{"type":"float","value":0},"nodeU7":{"type":"float","value":21},"nodeU8":{"type":"float","value":0},"nodeU9":{"type":"vec3","value":[0,0,0]},"nodeU10":{"type":"float","value":0},"nodeU11":{"type":"float","value":1},"nodeU12":{"type":"vec3","value":[0,0,0]},"nodeU14":{"type":"float","value":1},"nodeU15":{"type":"int","value":1},"nodeU16":{"type":"float","value":0},"nodeU17":{"type":"int","value":0},"nodeU18":{"type":"vec2","value":[0,0]},"nodeU19":{"type":"vec4","value":[0,0,0,1]},"nodeU20":{"type":"vec4","value":[1,1,1,1]},"nodeU21":{"type":"vec2","value":[15,15]},"nodeU22":{"type":"float","value":0.8},"nodeU23":{"type":"float","value":0},"nodeU24":{"type":"float","value":0.5},"nodeU25":{"type":"float","value":0.5},"nodeU26":{"type":"float","value":0},"nodeU27":{"type":"vec2","value":[0,1]},"nodeU28":{"type":"vec2","value":[0,1]},"nodeU29":{"type":"int","value":6},"nodeU31":{"type":"float","value":1},"nodeU32":{"type":"int","value":3},"nodeU33":{"type":"vec3","value":[0.0720582,0.0720582,0.0720582]},"nodeU34":{"type":"float","value":5},"nodeU36":{"type":"float","value":0.6},"nodeU37":{"type":"int","value":0},"nodeU40":{"type":"float","value":0},"nodeU41":{"type":"int","value":2},"nodeU42":{"type":"float","value":0},"nodeU43":{"type":"float","value":1},"nodeU44":{"type":"vec3","value":[1,1,1]},"nodeU45":{"type":"float","value":1},"nodeU46":{"type":"vec2","value":[1.7,9.2]},"nodeU47":{"type":"vec2","value":[8.3,2.8]},"nodeU48":{"type":"vec2","value":[1,1]},"nodeU49":{"type":"vec4","value":[0.4,0.4,0.4,1]},"nodeU50":{"type":"vec4","value":[0.4,0.4,0.4,1]},"nodeU51":{"type":"vec4","value":[1,1,1,1]},"nodeU52":{"type":"vec4","value":[1,1,1,1]},"nodeU53":{"type":"int","value":0},"nodeU54":{"type":"float","value":1},"nodeU55":{"type":"float","value":0},"nodeU56":{"type":"float","value":0.3},"nodeU57":{"type":"float","value":0},"nodeU58":{"type":"int","value":1},"nodeU60":{"type":"float","value":0.2},"nodeU61":{"type":"int","value":3},"nodeU62":{"type":"float","value":1},"nodeU63":{"type":"float","value":1}},"samplers":{"aoMap":"@blank","nodeU2":"fbaf69cf","nodeU38":"9672eb6e","spotShadowMap":"@shadow"},"transparent":false,"materials":["Pattern Material"],"state":"no-blend depth cull","zeroOnFirstFrame":[]},"p7":{"vert":"shaders/p7.vert","frag":"shaders/p7.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU8":{"type":"bool","value":false},"nodeU12":{"type":"bool","value":false},"nodeU18":{"type":"bool","value":true},"nodeU27":{"type":"bool","value":false},"emissive":{"type":"vec3","value":[0,0,0]},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU0":{"type":"vec3","value":[0.0373859,0.0373859,0.0373859]},"nodeU1":{"type":"float","value":1},"nodeU3":{"type":"vec3","value":[1024,1024,0]},"nodeU4":{"type":"float","value":0},"nodeU5":{"type":"mat3","value":[10,0,0,0,10,0,0,0,1]},"nodeU6":{"type":"vec2","value":[128,128]},"nodeU7":{"type":"float","value":0.5},"nodeU9":{"type":"float","value":0},"nodeU10":{"type":"int","value":0},"nodeU13":{"type":"float","value":0.4},"nodeU14":{"type":"int","value":2},"nodeU15":{"type":"float","value":0},"nodeU16":{"type":"vec3","value":[0.0914339,0.0914339,0.0914339]},"nodeU17":{"type":"float","value":5},"nodeU19":{"type":"float","value":1},"nodeU20":{"type":"int","value":3},"nodeU21":{"type":"float","value":7},"nodeU22":{"type":"float","value":4},"nodeU23":{"type":"vec3","value":[0,0,0]},"nodeU24":{"type":"float","value":0},"nodeU25":{"type":"float","value":1},"nodeU26":{"type":"vec3","value":[0,0,0]},"nodeU28":{"type":"float","value":0.04},"nodeU29":{"type":"int","value":2},"nodeU30":{"type":"float","value":1},"nodeU31":{"type":"float","value":1},"nodeU32":{"type":"float","value":1}},"samplers":{"aoMap":"@blank","nodeU2":"95cda401","nodeU11":"2ebde442","spotShadowMap":"@shadow"},"transparent":false,"materials":["Textured Plastic"],"state":"no-blend depth cull","zeroOnFirstFrame":["nodeU3"]},"p8":{"vert":"shaders/p8.vert","frag":"shaders/p8.frag","uniforms":{"aoEnabled":{"type":"bool","value":false},"nodeU6":{"type":"bool","value":false},"nodeU14":{"type":"bool","value":true},"nodeU22":{"type":"bool","value":false},"nodeU26":{"type":"bool","value":false},"nodeU36":{"type":"bool","value":false},"emissive":{"type":"vec3","value":[0,0,0]},"penumbraSize":{"type":"float","value":[0.5,0.5,0.5,0.5,0.5]},"nodeU1":{"type":"vec3","value":[2000,2000,0]},"nodeU2":{"type":"float","value":0},"nodeU3":{"type":"mat3","value":[2.5,0,0,0,1.66667,0,0,0,1]},"nodeU4":{"type":"vec2","value":[128,128]},"nodeU5":{"type":"float","value":0},"nodeU7":{"type":"float","value":1},"nodeU8":{"type":"int","value":0},"nodeU9":{"type":"vec3","value":[0.0392157,0.0392157,0.0392157]},"nodeU10":{"type":"float","value":0.85},"nodeU11":{"type":"int","value":0},"nodeU12":{"type":"vec3","value":[0.2,0.2,0.2]},"nodeU13":{"type":"float","value":5},"nodeU15":{"type":"float","value":0.5},"nodeU16":{"type":"int","value":0},"nodeU17":{"type":"vec3","value":[0.847059,0.847059,0.847059]},"nodeU18":{"type":"float","value":0.1},"nodeU19":{"type":"float","value":1},"nodeU20":{"type":"float","value":2},"nodeU21":{"type":"float","value":1},"nodeU23":{"type":"float","value":0.4},"nodeU24":{"type":"int","value":3},"nodeU27":{"type":"float","value":0.2},"nodeU28":{"type":"int","value":3},"nodeU29":{"type":"float","value":0},"nodeU30":{"type":"float","value":5},"nodeU31":{"type":"float","value":7},"nodeU32":{"type":"vec3","value":[0,0,0]},"nodeU33":{"type":"float","value":1},"nodeU34":{"type":"float","value":1},"nodeU35":{"type":"vec3","value":[0,0,0]},"nodeU37":{"type":"float","value":1},"nodeU38":{"type":"int","value":3},"nodeU39":{"type":"float","value":1},"nodeU40":{"type":"float","value":1}},"samplers":{"aoMap":"@blank","nodeU0":"6ee68ea9","nodeU25":"19157261","spotShadowMap":"@shadow"},"transparent":true,"materials":["Rubber Terrazzo"],"state":"blend SRC_ALPHA,ONE_MINUS_SRC_ALPHA,ONE,ONE_MINUS_SRC_ALPHA depth cull","zeroOnFirstFrame":["nodeU1"]},"p9":{"vert":"shaders/p9.vert","frag":"shaders/p9.frag","uniforms":{"nodeU0":{"type":"vec3","value":[0.329412,0.329412,0.356863]},"nodeU1":{"type":"float","value":1},"nodeU2":{"type":"vec3","value":[0.329412,0.329412,0.356863]},"nodeU3":{"type":"float","value":0},"nodeU4":{"type":"int","value":0},"nodeU5":{"type":"float","value":1}},"samplers":{},"transparent":true,"materials":["Cube 6 Material","Cube 5 Material","Cube 4 Material","Cube 3 Material","Cube 2 Material"],"state":"blend SRC_ALPHA,ONE_MINUS_SRC_ALPHA,ONE,ONE_MINUS_SRC_ALPHA depth cull","zeroOnFirstFrame":[]},"p10":{"vert":"shaders/p10.vert","frag":"shaders/p10.frag","uniforms":{},"samplers":{"inputBuffer":"@input","historyBuffer":"@input","velocityBuffer":"@input","depthBuffer":"@input"},"transparent":false,"materials":[],"state":"no-blend cull no-depth-write","zeroOnFirstFrame":[]},"p11":{"vert":"shaders/p11.vert","frag":"shaders/p11.frag","uniforms":{},"samplers":{"inputBuffer":"@input"},"transparent":false,"materials":[],"state":"no-blend cull no-depth-write","zeroOnFirstFrame":[]},"p12":{"vert":"shaders/p12.vert","frag":"shaders/p12.frag","uniforms":{"threshold":{"type":"float","value":0.112},"smoothing":{"type":"float","value":1}},"samplers":{"inputBuffer":"@input"},"transparent":false,"materials":[],"state":"no-blend cull no-depth-write","zeroOnFirstFrame":[]},"p13":{"vert":"shaders/p13.vert","frag":"shaders/p13.frag","uniforms":{"texelSize":{"type":"vec2","value":[0.00308642,0.00363636]},"halfTexelSize":{"type":"vec2","value":[0.00154321,0.00181818]},"kernel":{"type":"float","value":10},"scale":{"type":"float","value":1}},"samplers":{"inputBuffer":"@input"},"transparent":false,"materials":[],"state":"no-blend cull no-depth-write","zeroOnFirstFrame":[]},"p14":{"vert":"shaders/p14.vert","frag":"shaders/p14.frag","uniforms":{"e0BlendOpacity":{"type":"float","value":1},"e0Intensity":{"type":"float","value":0.985}},"samplers":{"inputBuffer":"@input","e0Map":"@input"},"transparent":false,"materials":[],"state":"no-blend cull no-depth-write","zeroOnFirstFrame":[]}},"tree":{"name":"Scene","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"name":"Cube 6","type":"Mesh","matrix":[1,0,0,0,0,0.8241764710352262,-0.5663330686017916,0,0,0.5663330686017916,0.8241764710352262,0,134.3709941733303,338.429770468014,581.3809746842458,1],"geometry":"panel","program":"p9","material":"Cube 6 Material","castShadow":true,"receiveShadow":true},{"name":"Cube 5","type":"Mesh","matrix":[1,0,0,0,0,0.8241764710352263,-0.5663330686017917,0,0,0.5663330686017917,0.8241764710352263,0,66.6861599961709,338.42977046801406,581.3809746842458,1],"geometry":"panel","program":"p9","material":"Cube 5 Material","castShadow":true,"receiveShadow":true},{"name":"Cube 4","type":"Mesh","matrix":[1,0,0,0,0,0.8241764710352261,-0.5663330686017917,0,0,0.5663330686017917,0.8241764710352261,0,-8.603893813820498,336.5575545037732,578.6563653828088,1],"geometry":"panel","program":"p9","material":"Cube 4 Material","castShadow":true,"receiveShadow":true},{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,0.8241764710352258,-0.5663330686017916,0,0,0.5663330686017916,0.8241764710352258,0,-81.84115549942584,338.3830067114592,581.3129200535233,1],"geometry":"panel","program":"p9","material":"Cube 3 Material","castShadow":true,"receiveShadow":true},{"name":"Cube 2","type":"Mesh","matrix":[1,0,0,0,0,0.8241764710352258,-0.5663330686017916,0,0,0.5663330686017916,0.8241764710352258,0,-146.4214665580286,343.80989690904494,589.2105962792548,1],"geometry":"panel","program":"p9","material":"Cube 2 Material","castShadow":true,"receiveShadow":true},{"name":"Cube","type":"Group","matrix":[1,0,0,0,0,-0.832872945016062,0.5534642332264621,0,0,-0.5534642332264621,-0.832872945016062,0,0,0,0,1],"children":[{"name":"rotation","type":"Group","matrix":[-0.8328729450160622,0,-0.5534642332264622,0,0,1,0,0,0.5534642332264622,0,-0.8328729450160622,0,0,0,0,1],"children":[{"name":"section 3","type":"Group","matrix":[1,0,0,0,0,-1.000000000000006,-1.2246467991473606e-16,0,0,1.2246467991473606e-16,-1.000000000000006,0,-100,0,0,1],"children":[{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p8","material":"Rubber Terrazzo","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 2","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p4","material":"Plastic Surface 02","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p5","material":"Metal Color&Shinny ","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p6","material":"Pattern Material","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p8","material":"Rubber Terrazzo","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]}]},{"name":"section 2","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p6","material":"Pattern Material","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 2","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p4","material":"Plastic Surface 02","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p8","material":"Rubber Terrazzo","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p4","material":"Plastic Surface 02","castShadow":true,"receiveShadow":true}]}]},{"name":"section","type":"Group","matrix":[1,0,0,0,0,-1.000000000000006,-1.2246467991473606e-16,0,0,1.2246467991473606e-16,-1.000000000000006,0,100,0,0,1],"children":[{"name":"Cube","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p4","material":"Plastic Surface 02","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 2","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p6","material":"Pattern Material","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p8","material":"Rubber Terrazzo","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 3","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p3","material":"Studio Lighting 02_3","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,-100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p7","material":"Textured Plastic","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,0,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p5","material":"Metal Color&Shinny ","castShadow":true,"receiveShadow":true}]},{"name":"Cube Instance 4","type":"Group","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,-100,100,1],"children":[{"name":"Cube 3","type":"Mesh","matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"geometry":"box","program":"p2","material":"Plastic Surface 01","castShadow":true,"receiveShadow":true}]}]}]}]}]}}\ No newline at end of filediff --git a/site/public/examples/resend-cube/assets/shaders/p1.frag b/site/public/examples/resend-cube/assets/shaders/p1.fragnew file mode 100644index 0000000..aeb4f7d--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p1.frag@@ -0,0 +1,206 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define FLIP_SIDED+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#define DEPTH_PACKING 3201+#if DEPTH_PACKING == 3200+ uniform float opacity;+#endif+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )+ varying vec2 vUv;+#endif+#ifdef USE_MAP+ uniform sampler2D map;+#endif+#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif+#ifdef USE_ALPHATEST+ uniform float alphaTest;+#endif+#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )+ uniform float logDepthBufFC;+ varying float vFragDepth;+ varying float vIsPerspective;+#endif+#if 0 > 0+ varying vec3 vClipPosition;+ uniform vec4 clippingPlanes[ 0 ];+#endif+varying vec2 vHighPrecisionZW;+void main() {+#if 0 > 0+ vec4 plane;+ #if 0 < 0+ bool clipped = true;+ if ( clipped ) discard;+ #endif+#endif+ vec4 diffuseColor = vec4( 1.0 );+ #if DEPTH_PACKING == 3200+ diffuseColor.a = opacity;+ #endif+#ifdef USE_MAP+ vec4 sampledDiffuseColor = texture2D( map, vUv );+ #ifdef DECODE_VIDEO_TEXTURE+ 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+#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, vUv ).g;+#endif+#ifdef USE_ALPHATEST+ if ( diffuseColor.a < alphaTest ) discard;+#endif+#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )+ gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;+#endif+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;+ #if DEPTH_PACKING == 3200+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );+ #elif DEPTH_PACKING == 3201+ gl_FragColor = packDepthToRGBA( fragCoordZ );+ #endif+}diff --git a/site/public/examples/resend-cube/assets/shaders/p1.vert b/site/public/examples/resend-cube/assets/shaders/p1.vertnew file mode 100644index 0000000..8982df5--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p1.vert@@ -0,0 +1,290 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define VERTEX_TEXTURES+#define FLIP_SIDED+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+#ifdef USE_UV+ #ifdef UVS_VERTEX_ONLY+ vec2 vUv;+ #else+ varying vec2 vUv;+ #endif+ uniform mat3 uvTransform;+#endif+#ifdef USE_DISPLACEMENTMAP+ uniform sampler2D displacementMap;+ uniform float displacementScale;+ uniform float displacementBias;+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifdef USE_LOGDEPTHBUF+ #ifdef USE_LOGDEPTHBUF_EXT+ varying float vFragDepth;+ varying float vIsPerspective;+ #else+ uniform float logDepthBufFC;+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vHighPrecisionZW;+void main() {+#ifdef USE_UV+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+#endif+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+ #ifdef USE_DISPLACEMENTMAP+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#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+ #endif+vec3 transformed = vec3( position );+#ifdef USE_MORPHTARGETS+ 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+#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+#ifdef USE_DISPLACEMENTMAP+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#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+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vHighPrecisionZW = gl_Position.zw;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p10.frag b/site/public/examples/resend-cube/assets/shaders/p10.fragnew file mode 100644index 0000000..1cbf82f--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p10.frag@@ -0,0 +1,145 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#define GLSLIFY 1+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;+#define USE_YCOCG+#define USE_CATMULL_ROM+const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){+#ifdef USE_YCOCG+vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);+#else+return texture(tex,uv);+#endif+}vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){+#ifdef CHOOSE_LONGEST_MOTION_VECTOR+float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;+#else+float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;+#endif+}vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);+#ifdef USE_CATMULL_ROM+vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);+#else+vec4 previousColor=sample_color(historyBuffer,previousPixelPos);+#endif+#ifdef USE_YCOCG+previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);+#endif+vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);+#ifdef USE_YCOCG+vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;+#endif+vec4 previousColorClipped=clamp(previousColor,cmin,cmax);+#ifdef LUMINANCE_DIFFERENCES+#ifdef USE_YCOCG+float lum0=currentColor.r;float lum1=previousColorClipped.r;+#else+float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);+#endif+float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));+#else+const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);+#endif+#ifdef USE_YCOCG+gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);+#else+gl_FragColor=result;+#endif+}diff --git a/site/public/examples/resend-cube/assets/shaders/p10.vert b/site/public/examples/resend-cube/assets/shaders/p10.vertnew file mode 100644index 0000000..c9e50af--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p10.vert@@ -0,0 +1,55 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define VERTEX_TEXTURES+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#define GLSLIFY 1+varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}diff --git a/site/public/examples/resend-cube/assets/shaders/p11.frag b/site/public/examples/resend-cube/assets/shaders/p11.fragnew file mode 100644index 0000000..08c4e9c--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p11.frag@@ -0,0 +1,28 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#define GLSLIFY 1+layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}diff --git a/site/public/examples/resend-cube/assets/shaders/p11.vert b/site/public/examples/resend-cube/assets/shaders/p11.vertnew file mode 100644index 0000000..9bd129b--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p11.vert@@ -0,0 +1,55 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define VERTEX_TEXTURES+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#define GLSLIFY 1+varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}diff --git a/site/public/examples/resend-cube/assets/shaders/p12.frag b/site/public/examples/resend-cube/assets/shaders/p12.fragnew file mode 100644index 0000000..5cad73f--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p12.frag@@ -0,0 +1,127 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define THREE_REVISION 149+#define COLOR 1+#define THRESHOLD 1+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+#if THREE_REVISION < 143+#define luminance(v) linearToRelativeLuminance(v)+#endif+#ifdef FRAMEBUFFER_PRECISION_HIGH+uniform mediump sampler2D inputBuffer;+#else+uniform lowp sampler2D inputBuffer;+#endif+#ifdef RANGE+uniform vec2 range;+#elif defined(THRESHOLD)+uniform float threshold;uniform float smoothing;+#endif+varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);+#ifdef RANGE+float low=step(range.x,l);float high=step(l,range.y);l*=low*high;+#elif defined(THRESHOLD)+l=smoothstep(threshold,threshold+smoothing,l);+#endif+#ifdef COLOR+gl_FragColor=vec4(texel.rgb*l,l);+#else+gl_FragColor=vec4(l);+#endif+}diff --git a/site/public/examples/resend-cube/assets/shaders/p12.vert b/site/public/examples/resend-cube/assets/shaders/p12.vertnew file mode 100644index 0000000..63a94d4--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p12.vert@@ -0,0 +1,57 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define THREE_REVISION 149+#define COLOR 1+#define THRESHOLD 1+#define VERTEX_TEXTURES+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}diff --git a/site/public/examples/resend-cube/assets/shaders/p13.frag b/site/public/examples/resend-cube/assets/shaders/p13.fragnew file mode 100644index 0000000..828ccc7--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p13.frag@@ -0,0 +1,118 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+#ifdef FRAMEBUFFER_PRECISION_HIGH+uniform mediump sampler2D inputBuffer;+#else+uniform lowp sampler2D inputBuffer;+#endif+varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+}diff --git a/site/public/examples/resend-cube/assets/shaders/p13.vert b/site/public/examples/resend-cube/assets/shaders/p13.vertnew file mode 100644index 0000000..09e73fe--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p13.vert@@ -0,0 +1,54 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define VERTEX_TEXTURES+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}diff --git a/site/public/examples/resend-cube/assets/shaders/p14.frag b/site/public/examples/resend-cube/assets/shaders/p14.fragnew file mode 100644index 0000000..bfd7679--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p14.frag@@ -0,0 +1,200 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define THREE_REVISION 149+#define DEPTH_PACKING 0+#define ENCODE_OUTPUT 1+#define UV vUv+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+#define packFloatToRGBA(v) packDepthToRGBA(v)+#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)+#ifdef FRAMEBUFFER_PRECISION_HIGH+uniform mediump sampler2D inputBuffer;+#else+uniform lowp sampler2D inputBuffer;+#endif+#ifdef GL_FRAGMENT_PRECISION_HIGH+uniform highp sampler2D depthBuffer;+#else+uniform mediump sampler2D depthBuffer;+#endif+uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;+#if THREE_REVISION < 143+#define luminance(v) linearToRelativeLuminance(v)+#endif+#if THREE_REVISION >= 137+vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}+#endif+float readDepth(const in vec2 uv){+#if DEPTH_PACKING == 3201+return unpackRGBAToDepth(texture2D(depthBuffer,uv));+#else+return texture2D(depthBuffer,uv).r;+#endif+}float getViewZ(const in float depth){+#ifdef PERSPECTIVE_CAMERA+return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);+#else+return orthographicDepthToViewZ(depth,cameraNear,cameraFar);+#endif+}uniform float e0BlendOpacity;+#ifdef FRAMEBUFFER_PRECISION_HIGH+uniform mediump sampler2D e0Map;+#else+uniform lowp sampler2D e0Map;+#endif+uniform float e0Intensity;void e0MainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(e0Map,uv)*e0Intensity,0.0,1.0);}+vec4 blend16(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}void main(){vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);e0MainImage(color0, UV, color1);+ color0 = blend16(color0, color1, e0BlendOpacity);gl_FragColor=color0;+#ifdef ENCODE_OUTPUT+gl_FragColor = linearToOutputTexel( gl_FragColor );+#endif+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+}diff --git a/site/public/examples/resend-cube/assets/shaders/p14.vert b/site/public/examples/resend-cube/assets/shaders/p14.vertnew file mode 100644index 0000000..4beefce--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p14.vert@@ -0,0 +1,58 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define THREE_REVISION 149+#define DEPTH_PACKING 0+#define ENCODE_OUTPUT 1+#define UV vUv+#define VERTEX_TEXTURES+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}diff --git a/site/public/examples/resend-cube/assets/shaders/p2.frag b/site/public/examples/resend-cube/assets/shaders/p2.fragnew file mode 100644index 0000000..5bbaa64--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p2.frag@@ -0,0 +1,1253 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define TOON 1+#define g_uid42_MAX_COLORS 2+#define g_uid42_SMOOTH 1+#define g_uid42_IS_VECTOR 1+#define g_uid42_WORLDSPACE 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+varying vec3 vWPosition;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_GRADIENTMAP+ uniform sampler2D gradientMap;+#endif+vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {+ 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+ vec2 fw = fwidth( coord ) * 0.5;+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );+ #endif+}+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+ varying vec3 vViewPosition;+ struct ToonMaterial {+ vec3 diffuseColor;+ vec3 specularColor;+ float specularShininess;+ float specularStrength;+ };+ 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 );+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;+ }+ 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)+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef USE_BUMPMAP+ uniform sampler2D bumpMap;+ uniform float bumpScale;+ 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 ) {+ vec3 vSigmaX = dFdx( surf_pos.xyz );+ vec3 vSigmaY = dFdy( surf_pos.xyz );+ vec3 vN = surf_norm;+ 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+#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 ) )+ vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {+ vec3 q0 = dFdx( eye_pos.xyz );+ vec3 q1 = dFdy( eye_pos.xyz );+ vec2 st0 = dFdx( vUv.st );+ vec2 st1 = dFdy( vUv.st );+ vec3 N = surf_norm;+ 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+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform vec3 nodeU2;+uniform float nodeU3;+uniform float nodeU4;+uniform float nodeU5;+uniform float nodeU6;+uniform bool nodeU7;+uniform float nodeU8;+uniform int nodeU9;+uniform sampler2D nodeU10;+uniform bool nodeU11;+uniform float nodeU12;+uniform int nodeU13;+uniform float nodeU14;+uniform float nodeU15;+uniform float nodeU16;+uniform vec3 nodeU17;+uniform vec3 nodeU18;+uniform bool nodeU19;+uniform float nodeU20;+uniform int nodeU21;+uniform sampler2D nodeU22;+uniform vec3 nodeU23;+uniform float nodeU24;+uniform mat3 nodeU25;+uniform vec2 nodeU26;+uniform float nodeU27;+uniform bool nodeU28;+uniform float nodeU29;+uniform int nodeU30;+uniform vec3 nodeU31;+uniform float nodeU32;+uniform float nodeU33;+uniform int nodeU34;+uniform float nodeU35;+uniform float nodeU36;+uniform float nodeU37;+uniform vec4 nodeUA0[2];+uniform float nodeUA1[2];+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );+ float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return color;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {+ vec3 n = normalize(direction);+ float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));+ return ( dist - near ) / ( far - near );+ }+float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {+ vec3 n = normalize(direction);+ float dist = (n.x*(vPosition.x - origin.x) + n.y*(vPosition.y - origin.y) + n.z*(vPosition.z - origin.z));+ return ( dist - near ) / ( far - near );+ }+float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {+ float dist = length(vPosition - origin);+ return ( dist - near ) / ( far - near );+ }+float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {+ float dist = length(vWPosition - origin);+ return ( dist - near ) / ( far - near );+ }+vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {+ vec3 p = vPosition;+ vec2 uv0 = (1.0 + p.xy) / 2.0;+ vec2 uv1 = (1.0 + p.zy) / 2.0;+ vec2 vUv2 = (1.0 + p.xz) / 2.0;+ uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ vUv2 = (mat * vec3((vUv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ // Range from 3 to 128 seems to be good+ float exponent = (1.0 - blending) * 125.0 + 3.0;+ vec3 n = vObjectNormal;+ vec3 weights = abs(normalize(n));+ weights = pow(weights, vec3(exponent));+ weights /= dot(weights, vec3(1.0));+ // Write out all sets of UVs that we generated+ writeUvs0 = uv0;+ writeUvs1 = uv1;+ writeUvs2 = vUv2;+ writeWeights = weights;+ // Derivatives for LOD+ vec2 df0 = fwidth(uv0);+ vec2 df1 = fwidth(uv1);+ vec2 df2 = fwidth(vUv2);+ if (df0.x > 0.5) df0.x = 0.0;+ if (df1.x > 0.5) df1.x = 0.0;+ if (df2.x > 0.5) df2.x = 0.0;+ #ifdef GL_EXT_shader_texture_lod+ vec4 tmp =+ texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ texture2DLodEXT(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #else+ vec4 tmp =+ textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ textureLod(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #endif+ vec3 col = tmp.rgb;+ float lalpha = alpha * tmp.a;+ // Apply cropping across all 3 planes+ if ( crop > 0.5 ) {+ if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( vUv2.x < 0.0 || vUv2.x > 1.0 || vUv2.y < 0.0 || vUv2.y > 1.0 ) {+ lalpha = 0.0;+ }+ }+ lalpha *= mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return col;//n * 0.5 + 0.5;+ }+vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {+ // Gradient of UVs w.r.t. X coordinate (in screen-space)+ vec2 dSTdx = dFdx(bumpMapUv);+ // Gradient of UVs w.r.t. Y coordinate (in screen-space)+ vec2 dSTdy = dFdy(bumpMapUv);+ // Forward differencing+ float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);+ float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;+ float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;+ return vec2( dBx, dBy );+ }+vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {+ vec3 vSigmaX = dFdx( surf_pos.xyz );+ vec3 vSigmaY = dFdy( surf_pos.xyz );+ vec3 vN = surf_norm; // normalized+ vN = normalize(vN);+ vec3 R1 = cross( vSigmaY, vN );+ vec3 R2 = cross( vN, vSigmaX );+ R1 = normalize(R1);+ R2 = normalize(R2);+ float fDet = dot( vSigmaX, R1 ) * faceDirection;+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );+ return normalize( abs( fDet ) * vN - vGrad );+ }+vec3 g_uid42_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[g_uid42_MAX_COLORS], float steps[g_uid42_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {+ vec4 color = colors[0];+ #ifdef g_uid42_IS_VECTOR+ #ifdef g_uid42_LINEAR+ #ifdef g_uid42_WORLDSPACE+ float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);+ #else+ float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);+ #endif+ #else+ #ifdef g_uid42_WORLDSPACE+ float depth = vectorSphericalWorldSpaceDepth(origin, near, far);+ #else+ float depth = vectorSphericalObjectSpaceDepth(origin, near, far);+ #endif+ #endif+ #else+ float dist = length(vWPosition - cameraPosition);+ float depth = ( dist - near ) / ( far - near );+ #endif+ float p;+ #ifdef g_uid42_SMOOTH+ for ( int i = 1; i < g_uid42_MAX_COLORS; i++ ) {+ p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );+ color = mix(color, colors[i], smoothstep(0.0, 1.0, p));+ }+ #else+ for ( int i = 1; i < g_uid42_MAX_COLORS; i++ ) {+ p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);+ color = mix(color, colors[i], p);+ }+ #endif+ float lalpha = alpha * color.a * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return color.rgb;+ }+void main() {+float g_uid65_calpha;+float g_uid59_calpha;+float g_uid49_calpha;+float g_uid42_calpha;+float g_uid27_calpha;+vec2 g_uid27_writeUvs0;+vec2 g_uid27_writeUvs1;+vec2 g_uid27_writeUvs2;+vec3 g_uid27_triplanarWeights;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ ToonMaterial material;+// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates+ triplanarTexture(normal,nodeU22,nodeU23.xy,nodeU24,nodeU25,nodeU26,nodeU27,nodeU28,1.0,nodeU29,nodeU30,g_uid27_calpha,g_uid27_writeUvs0,g_uid27_writeUvs1,g_uid27_writeUvs2,g_uid27_triplanarWeights);+ vec3 bumpNormal = vec3(0.0);+ {+ vec2 uv0 = g_uid27_writeUvs0;+ vec2 uv1 = g_uid27_writeUvs1;+ vec2 uv2 = g_uid27_writeUvs2;+ vec3 weights = g_uid27_triplanarWeights;+ vec2 grad0 = dHdxy(nodeU22, uv0, nodeU37);+ vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);+ vec2 grad1 = dHdxy(nodeU22, uv1, nodeU37);+ vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);+ vec2 grad2 = dHdxy(nodeU22, uv2, nodeU37);+ vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);+ bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;+ bumpNormal = normalize(bumpNormal);+ }+ normal = bumpNormal;+ vec3 diffuseColor = spe_blend(spe_blend(spe_blend(spe_blend(customColor(nodeU0,1.0,nodeU1,g_uid65_calpha),fresnel(nodeU2,nodeU3,nodeU4,nodeU5,nodeU6,nodeU7,1.0,nodeU8,nodeU9,g_uid59_calpha),( g_uid59_calpha ),nodeU9),matcap(nodeU10,normal,nodeU11,1.0,nodeU12,nodeU13,g_uid49_calpha,nodeU14),( g_uid49_calpha ),nodeU13),g_uid42_sdepth(nodeU15,nodeU16,nodeU17,nodeU18,nodeUA0,nodeUA1,nodeU19,1.0,nodeU20,g_uid42_calpha),( g_uid42_calpha ),nodeU21),triplanarTexture(normal,nodeU22,nodeU23.xy,nodeU24,nodeU25,nodeU26,nodeU27,nodeU28,1.0,nodeU29,nodeU30,g_uid27_calpha,g_uid27_writeUvs0,g_uid27_writeUvs1,g_uid27_writeUvs2,g_uid27_triplanarWeights),( g_uid27_calpha ),nodeU30);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 specular = nodeU31;+ float shininess = max( 0.0001, nodeU32 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU35 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU33 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU33 * 1.0, nodeU34 );+ }+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU35 );+gl_FragColor.a *= nodeU36;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p2.vert b/site/public/examples/resend-cube/assets/shaders/p2.vertnew file mode 100644index 0000000..3c3c597--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p2.vert@@ -0,0 +1,506 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define TOON 1+#define g_uid42_MAX_COLORS 2+#define g_uid42_SMOOTH 1+#define g_uid42_IS_VECTOR 1+#define g_uid42_WORLDSPACE 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p3.frag b/site/public/examples/resend-cube/assets/shaders/p3.fragnew file mode 100644index 0000000..d3e6ddf--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p3.frag@@ -0,0 +1,1017 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+uniform vec3 emissive;+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+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+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec2 vUv;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform vec3 nodeU2;+uniform float nodeU3;+uniform bool nodeU4;+uniform float nodeU5;+uniform int nodeU6;+uniform sampler2D nodeU7;+uniform bool nodeU8;+uniform float nodeU9;+uniform int nodeU10;+uniform float nodeU11;+uniform vec3 nodeU12;+uniform float nodeU13;+uniform float nodeU14;+uniform float nodeU15;+uniform float nodeU16;+uniform bool nodeU17;+uniform float nodeU18;+uniform int nodeU19;+uniform float nodeU20;+uniform float nodeU21;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );+ float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return color;+ }+void main() {+float g_uid38_calpha;+float g_uid15_calpha;+float g_uid8_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ BlinnPhongMaterial material;+ vec3 diffuseColor = customColor(nodeU0,1.0,nodeU1,g_uid38_calpha);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ vec3 specular = nodeU2;+ float shininess = max( 0.0001, nodeU3 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU20 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled && nodeU4 ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU5 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU5 * 1.0, nodeU6 );+ outgoingLight *= ao;+ }+outgoingLight = spe_blend(outgoingLight, spe_blend(spe_blend(vec3( ( outgoingLight ) ),matcap(nodeU7,normal,nodeU8,1.0,nodeU9,nodeU10,g_uid15_calpha,nodeU11),( g_uid15_calpha ),nodeU10),fresnel(nodeU12,nodeU13,nodeU14,nodeU15,nodeU16,nodeU17,1.0,nodeU18,nodeU19,g_uid8_calpha),( g_uid8_calpha ),nodeU19), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU20);+gl_FragColor.a *= nodeU21;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p3.vert b/site/public/examples/resend-cube/assets/shaders/p3.vertnew file mode 100644index 0000000..85d7840--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p3.vert@@ -0,0 +1,497 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p4.frag b/site/public/examples/resend-cube/assets/shaders/p4.fragnew file mode 100644index 0000000..271416b--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p4.frag@@ -0,0 +1,1184 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define TOON 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+varying vec3 vWPosition;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_GRADIENTMAP+ uniform sampler2D gradientMap;+#endif+vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {+ 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+ vec2 fw = fwidth( coord ) * 0.5;+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );+ #endif+}+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+ varying vec3 vViewPosition;+ struct ToonMaterial {+ vec3 diffuseColor;+ vec3 specularColor;+ float specularShininess;+ float specularStrength;+ };+ 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 );+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;+ }+ 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)+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef USE_BUMPMAP+ uniform sampler2D bumpMap;+ uniform float bumpScale;+ 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 ) {+ vec3 vSigmaX = dFdx( surf_pos.xyz );+ vec3 vSigmaY = dFdy( surf_pos.xyz );+ vec3 vN = surf_norm;+ 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+#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 ) )+ vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {+ vec3 q0 = dFdx( eye_pos.xyz );+ vec3 q1 = dFdy( eye_pos.xyz );+ vec2 st0 = dFdx( vUv.st );+ vec2 st1 = dFdy( vUv.st );+ vec3 N = surf_norm;+ 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+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform vec3 nodeU2;+uniform float nodeU3;+uniform float nodeU4;+uniform float nodeU5;+uniform float nodeU6;+uniform bool nodeU7;+uniform float nodeU8;+uniform int nodeU9;+uniform sampler2D nodeU10;+uniform bool nodeU11;+uniform float nodeU12;+uniform int nodeU13;+uniform float nodeU14;+uniform sampler2D nodeU15;+uniform vec3 nodeU16;+uniform float nodeU17;+uniform mat3 nodeU18;+uniform vec2 nodeU19;+uniform float nodeU20;+uniform bool nodeU21;+uniform float nodeU22;+uniform int nodeU23;+uniform vec3 nodeU24;+uniform float nodeU25;+uniform float nodeU26;+uniform int nodeU27;+uniform float nodeU28;+uniform float nodeU29;+uniform float nodeU30;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );+ float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return color;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {+ vec3 p = vPosition;+ vec2 uv0 = (1.0 + p.xy) / 2.0;+ vec2 uv1 = (1.0 + p.zy) / 2.0;+ vec2 vUv2 = (1.0 + p.xz) / 2.0;+ uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ vUv2 = (mat * vec3((vUv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ // Range from 3 to 128 seems to be good+ float exponent = (1.0 - blending) * 125.0 + 3.0;+ vec3 n = vObjectNormal;+ vec3 weights = abs(normalize(n));+ weights = pow(weights, vec3(exponent));+ weights /= dot(weights, vec3(1.0));+ // Write out all sets of UVs that we generated+ writeUvs0 = uv0;+ writeUvs1 = uv1;+ writeUvs2 = vUv2;+ writeWeights = weights;+ // Derivatives for LOD+ vec2 df0 = fwidth(uv0);+ vec2 df1 = fwidth(uv1);+ vec2 df2 = fwidth(vUv2);+ if (df0.x > 0.5) df0.x = 0.0;+ if (df1.x > 0.5) df1.x = 0.0;+ if (df2.x > 0.5) df2.x = 0.0;+ #ifdef GL_EXT_shader_texture_lod+ vec4 tmp =+ texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ texture2DLodEXT(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #else+ vec4 tmp =+ textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ textureLod(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #endif+ vec3 col = tmp.rgb;+ float lalpha = alpha * tmp.a;+ // Apply cropping across all 3 planes+ if ( crop > 0.5 ) {+ if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( vUv2.x < 0.0 || vUv2.x > 1.0 || vUv2.y < 0.0 || vUv2.y > 1.0 ) {+ lalpha = 0.0;+ }+ }+ lalpha *= mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return col;//n * 0.5 + 0.5;+ }+vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {+ // Gradient of UVs w.r.t. X coordinate (in screen-space)+ vec2 dSTdx = dFdx(bumpMapUv);+ // Gradient of UVs w.r.t. Y coordinate (in screen-space)+ vec2 dSTdy = dFdy(bumpMapUv);+ // Forward differencing+ float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);+ float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;+ float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;+ return vec2( dBx, dBy );+ }+vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {+ vec3 vSigmaX = dFdx( surf_pos.xyz );+ vec3 vSigmaY = dFdy( surf_pos.xyz );+ vec3 vN = surf_norm; // normalized+ vN = normalize(vN);+ vec3 R1 = cross( vSigmaY, vN );+ vec3 R2 = cross( vN, vSigmaX );+ R1 = normalize(R1);+ R2 = normalize(R2);+ float fDet = dot( vSigmaX, R1 ) * faceDirection;+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );+ return normalize( abs( fDet ) * vN - vGrad );+ }+void main() {+float g_uid50_calpha;+float g_uid44_calpha;+float g_uid34_calpha;+float g_uid27_calpha;+vec2 g_uid27_writeUvs0;+vec2 g_uid27_writeUvs1;+vec2 g_uid27_writeUvs2;+vec3 g_uid27_triplanarWeights;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ ToonMaterial material;+// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates+ triplanarTexture(normal,nodeU15,nodeU16.xy,nodeU17,nodeU18,nodeU19,nodeU20,nodeU21,1.0,nodeU22,nodeU23,g_uid27_calpha,g_uid27_writeUvs0,g_uid27_writeUvs1,g_uid27_writeUvs2,g_uid27_triplanarWeights);+ vec3 bumpNormal = vec3(0.0);+ {+ vec2 uv0 = g_uid27_writeUvs0;+ vec2 uv1 = g_uid27_writeUvs1;+ vec2 uv2 = g_uid27_writeUvs2;+ vec3 weights = g_uid27_triplanarWeights;+ vec2 grad0 = dHdxy(nodeU15, uv0, nodeU30);+ vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);+ vec2 grad1 = dHdxy(nodeU15, uv1, nodeU30);+ vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);+ vec2 grad2 = dHdxy(nodeU15, uv2, nodeU30);+ vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);+ bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;+ bumpNormal = normalize(bumpNormal);+ }+ normal = bumpNormal;+ vec3 diffuseColor = spe_blend(spe_blend(spe_blend(customColor(nodeU0,1.0,nodeU1,g_uid50_calpha),fresnel(nodeU2,nodeU3,nodeU4,nodeU5,nodeU6,nodeU7,1.0,nodeU8,nodeU9,g_uid44_calpha),( g_uid44_calpha ),nodeU9),matcap(nodeU10,normal,nodeU11,1.0,nodeU12,nodeU13,g_uid34_calpha,nodeU14),( g_uid34_calpha ),nodeU13),triplanarTexture(normal,nodeU15,nodeU16.xy,nodeU17,nodeU18,nodeU19,nodeU20,nodeU21,1.0,nodeU22,nodeU23,g_uid27_calpha,g_uid27_writeUvs0,g_uid27_writeUvs1,g_uid27_writeUvs2,g_uid27_triplanarWeights),( g_uid27_calpha ),nodeU23);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 specular = nodeU24;+ float shininess = max( 0.0001, nodeU25 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU28 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU26 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU26 * 1.0, nodeU27 );+ }+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU28 );+gl_FragColor.a *= nodeU29;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p4.vert b/site/public/examples/resend-cube/assets/shaders/p4.vertnew file mode 100644index 0000000..1f8586f--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p4.vert@@ -0,0 +1,502 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define TOON 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p5.frag b/site/public/examples/resend-cube/assets/shaders/p5.fragnew file mode 100644index 0000000..129c07e--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p5.frag@@ -0,0 +1,1069 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+uniform vec3 emissive;+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+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+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform float nodeU2;+uniform float nodeU3;+uniform vec3 nodeU4;+uniform float nodeU5;+uniform float nodeU6;+uniform vec3 nodeU7;+uniform bool nodeU8;+uniform float nodeU9;+uniform int nodeU10;+uniform vec3 nodeU11;+uniform float nodeU12;+uniform bool nodeU13;+uniform float nodeU14;+uniform int nodeU15;+uniform sampler2D nodeU16;+uniform bool nodeU17;+uniform float nodeU18;+uniform int nodeU19;+uniform float nodeU20;+uniform float nodeU21;+uniform float nodeU22;+const float F3 = 0.3333333;+const float G3 = 0.1666667;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 random3(vec3 c) {+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));+ vec3 r;+ r.z = fract(512.0*j);+ j *= .125;+ r.x = fract(512.0*j);+ j *= .125;+ r.y = fract(512.0*j);+ return r-0.5;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+float simplexFast(vec3 p) {+ vec3 s = floor(p + dot(p, vec3(F3)));+ mediump vec3 x = p - s + dot(s, vec3(G3));+ mediump vec3 hs = s;+ mediump vec3 e = step(vec3(0.0), x - x.yzx);+ mediump vec3 i1 = e*(1.0 - e.zxy);+ mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);+ mediump vec3 x1 = x - i1 + G3;+ mediump vec3 x2 = x - i2 + 2.0*G3;+ mediump vec3 x3 = x - 1.0 + 3.0*G3;+ mediump vec4 w, d;+ w.x = dot(x, x);+ w.y = dot(x1, x1);+ w.z = dot(x2, x2);+ w.w = dot(x3, x3);+ w = max(0.6 - w, 0.0);+ d.x = dot(random3(hs), x);+ d.y = dot(random3(hs + i1), x1);+ d.z = dot(random3(hs + i2), x2);+ d.w = dot(random3(hs + 1.0), x3);+ w *= w;+ w *= w;+ d *= w;+ return dot(d, vec4(52.0));+ }+vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {+ float f = 0.0;+ if (noiseStrength != 0.0) {+ vec3 st = vPosition / noiseScale;+ float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));+ f = noise * noiseStrength;+ }+ vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;+ float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));+ mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);+ return .5 + .5 * color;+ }+vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {+ mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);+ float lalpha = alpha * rainbowContribution * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return res;+ }+void main() {+float g_uid39_calpha;+float g_uid33_calpha;+float g_uid5_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ BlinnPhongMaterial material;+ vec3 diffuseColor = spe_blend(customColor(nodeU0,1.0,nodeU1,g_uid39_calpha),rainbow(nodeU2,nodeU3,nodeU4,nodeU5,nodeU6,nodeU7,nodeU8,1.0,nodeU9,g_uid33_calpha),( g_uid33_calpha ),nodeU10);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ vec3 specular = nodeU11;+ float shininess = max( 0.0001, nodeU12 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU21 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled && nodeU13 ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU14 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU14 * 1.0, nodeU15 );+ outgoingLight *= ao;+ }+outgoingLight = spe_blend(outgoingLight, spe_blend(vec3( ( outgoingLight ) ),matcap(nodeU16,normal,nodeU17,1.0,nodeU18,nodeU19,g_uid5_calpha,nodeU20),( g_uid5_calpha ),nodeU19), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU21);+gl_FragColor.a *= nodeU22;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p5.vert b/site/public/examples/resend-cube/assets/shaders/p5.vertnew file mode 100644index 0000000..1f560e2--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p5.vert@@ -0,0 +1,499 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p6.frag b/site/public/examples/resend-cube/assets/shaders/p6.fragnew file mode 100644index 0000000..8101085--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p6.frag@@ -0,0 +1,1628 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+uniform vec3 emissive;+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+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+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform sampler2D nodeU2;+uniform bool nodeU3;+uniform float nodeU4;+uniform int nodeU5;+uniform float nodeU6;+uniform float nodeU7;+uniform float nodeU8;+uniform vec3 nodeU9;+uniform float nodeU10;+uniform float nodeU11;+uniform vec3 nodeU12;+uniform bool nodeU13;+uniform float nodeU14;+uniform int nodeU15;+uniform float nodeU16;+uniform int nodeU17;+uniform vec2 nodeU18;+uniform vec4 nodeU19;+uniform vec4 nodeU20;+uniform vec2 nodeU21;+uniform float nodeU22;+uniform float nodeU23;+uniform float nodeU24;+uniform float nodeU25;+uniform float nodeU26;+uniform vec2 nodeU27;+uniform vec2 nodeU28;+uniform int nodeU29;+uniform bool nodeU30;+uniform float nodeU31;+uniform int nodeU32;+uniform vec3 nodeU33;+uniform float nodeU34;+uniform bool nodeU35;+uniform float nodeU36;+uniform int nodeU37;+uniform sampler2D nodeU38;+uniform bool nodeU39;+uniform float nodeU40;+uniform int nodeU41;+uniform float nodeU42;+uniform float nodeU43;+uniform vec3 nodeU44;+uniform float nodeU45;+uniform vec2 nodeU46;+uniform vec2 nodeU47;+uniform vec2 nodeU48;+uniform vec4 nodeU49;+uniform vec4 nodeU50;+uniform vec4 nodeU51;+uniform vec4 nodeU52;+uniform int nodeU53;+uniform float nodeU54;+uniform float nodeU55;+uniform float nodeU56;+uniform float nodeU57;+uniform int nodeU58;+uniform bool nodeU59;+uniform float nodeU60;+uniform int nodeU61;+uniform float nodeU62;+uniform float nodeU63;+const float F3 = 0.3333333;+const float G3 = 0.1666667;+const int NUM_OCTAVES = 5;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+vec3 random3(vec3 c) {+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));+ vec3 r;+ r.z = fract(512.0*j);+ j *= .125;+ r.x = fract(512.0*j);+ j *= .125;+ r.y = fract(512.0*j);+ return r-0.5;+ }+vec2 rotate_uv(in vec2 uv, float a, bool repeat)+ {+ const float mid = 0.5;+ float radians = a * (PI / 180.0);+ vec2 rotated = vec2(+ cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,+ cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid+ );+ return repeat ? fract(rotated): rotated;+ }+float hashwithoutsine12(vec2 p)+ {+ vec3 p3 = fract(vec3(p.xyx) * .1031);+ p3 += dot(p3, p3.yzx + 33.33);+ return fract((p3.x + p3.y) * p3.z);+ }+float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ uv *= frequency;+ vec2 i = floor(uv);+ float offset = mod(i.y, 2.0);+ uv.x += offset + zigzag * offset;+ float x = floor(uv.x);+ return mod(x, 2.0);+ }+// Uses bisection+ float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {+ // Convert all data to a primitive cosine wave+ p = c * (p - vec2(d, a));+ const float TWO_PI = PI * 2.0;+ // Reduce to principal half cycle+ p.x = mod(p.x, TWO_PI);+ if (p.x > PI) {+ p.x = TWO_PI - p.x;+ }+ // Find zero of derivative (minimize distance)+ float xa = 0.0;+ float xb = TWO_PI;+ // 24 bit precision+ for (int i = 0; i < 24; i++) {+ float x = 0.5 * (xa + xb);+ float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));+ if (y < 0.0) xa = x;+ else xb = x;+ }+ float x = 0.5 * (xa + xb);+ // Compute distance+ vec2 q = vec2(x, b * c * cos(x));+ return length(p - q) / c;+ }+ float wave(in vec2 vUv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ float repeat = frequency.x;+ vUv *= repeat;+ vec2 i = floor(vUv);+ float row_offset = mod(i.y, 2.0);+ vUv.x += row_offset * zigzag;+ vec2 f = vec2(vUv.x, fract(vUv.y));+ // Generalized cosine: y(x) = a + b * cos(cx + d)+ const float amplitude = 0.125;+ float wave_frequency = frequency.y * 0.1;+ float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);+ // Different approach for variation param here+ float rand = hashwithoutsine12(vec2(i.y));+ float s = mix(size, size * rand, variation);+ return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);+ }+vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}+vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}+vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}+vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}+float hashwithoutsine13(vec3 p3)+ {+ p3 = fract(p3 * .1031);+ p3 += dot(p3, p3.yzx + 33.33);+ return fract((p3.x + p3.y) * p3.z);+ }+vec3 hashwithoutsine33(vec3 p3)+ {+ p3 = fract(p3 * vec3(.1031, .1030, .0973));+ p3 += dot(p3, p3.yxz+33.33);+ return fract((p3.xxy + p3.yxx)*p3.zyx);+ }+float metric(in vec3 p)+ {+ // L2+ return length(p);+ // Chebyshev+ // vec3 a = abs(p);+ // return max(a.x, max(a.y, a.z));+ }+float smin( float a, float b, float k )+ {+ float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);+ float correction = k * h * (1.0 - h);+ return mix(b, a, h) - correction;+ }+float smax( float a, float b, float k )+ {+ float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);+ float correction = k * h * (1.0 - h);+ return mix(a, b, h) + correction;+ }+float remap(float value, float input_min, float input_max, float output_min, float output_max) {+ // Compute width of each interval+ float input_width = input_max - input_min;+ float output_width = output_max - output_min;+ // Convert input range into a 0-1 range+ float scaled = (value - input_min) / input_width;+ // Convert the 0-1 range into a value in output range+ return output_min + (scaled * output_width);+ }+float simplexFast(vec3 p) {+ vec3 s = floor(p + dot(p, vec3(F3)));+ mediump vec3 x = p - s + dot(s, vec3(G3));+ mediump vec3 hs = s;+ mediump vec3 e = step(vec3(0.0), x - x.yzx);+ mediump vec3 i1 = e*(1.0 - e.zxy);+ mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);+ mediump vec3 x1 = x - i1 + G3;+ mediump vec3 x2 = x - i2 + 2.0*G3;+ mediump vec3 x3 = x - 1.0 + 3.0*G3;+ mediump vec4 w, d;+ w.x = dot(x, x);+ w.y = dot(x1, x1);+ w.z = dot(x2, x2);+ w.w = dot(x3, x3);+ w = max(0.6 - w, 0.0);+ d.x = dot(random3(hs), x);+ d.y = dot(random3(hs + i1), x1);+ d.z = dot(random3(hs + i2), x2);+ d.w = dot(random3(hs + 1.0), x3);+ w *= w;+ w *= w;+ d *= w;+ return dot(d, vec4(52.0));+ }+vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {+ // Create tiles in UV-space+ uv *= frequency;+ // Integer coords+ vec2 i = floor(uv);+ // Offset every other row based on zigzag param, then compute fractional coords+ float row_offset = mod(i.y, 2.0);+ uv.x += row_offset * zigzag;+ vec2 f = fract(uv);+ // Rotate the tile itself:+ // const float mid = 0.5;+ // f = vec2(+ // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid,+ // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid+ // );+ // f = fract(f);+ f = f * 2.0 - 1.0;+ // Recompute integer coords after shifting - then, random value per tile+ i = floor(uv);+ float rand = (hashwithoutsine12(i) * 5.0 + 1.0);+ float jitter = mix(1.0, rand, variation);+ f *= jitter;+ return f;+ }+vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}+vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {+ float f = 0.0;+ if (noiseStrength != 0.0) {+ vec3 st = vPosition / noiseScale;+ float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));+ f = noise * noiseStrength;+ }+ vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;+ float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));+ mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);+ return .5 + .5 * color;+ }+float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);+ return smoothstep(+ -smoothness,+ smoothness,+ length(f) - size+ );+ }+float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);+ float d = length(f);+ const float inner_width = 0.5;+ float outer = smoothstep(-smoothness, smoothness, d - size);+ float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);+ return outer + (1.0 - inner);+ }+float sdf_ngon(in vec2 p, in float r, in int n) {+ float an = (PI * 2.0) / float(n);+ float he = r * tan(0.5 * an);+ // Rotate to first sector+ p = -p.yx;+ float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);+ vec2 cs = vec2(cos(bn), sin(bn));+ p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;+ // Side of polygon+ return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);+ }+ float polygon(in vec2 vUv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {+ vec2 f = tile_and_center(vUv, frequency, variation, zigzag, rotation);+ return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));+ }+float sdf_cross(in vec2 p, in vec2 b, float r ) {+ p = abs(p);+ p = (p.y > p.x) ? p.yx : p.xy;+ vec2 q = p - b;+ float k = max(q.y, q.x);+ vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);+ return sign(k) * length(max(w, 0.0)) + r;+ }+ // Avoid namespace conflicts+ float xcross(in vec2 vUv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ vec2 f = tile_and_center(vUv, frequency, variation, zigzag, rotation);+ return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));+ }+float ndot(vec2 a, vec2 b) {+ return a.x*b.x - a.y*b.y;+ }+ float sdf_diamond(in vec2 p, in vec2 b) {+ p = abs(p);+ float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);+ float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));+ return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);+ }+ float diamond(in vec2 vUv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ vec2 f = tile_and_center(vUv, frequency, variation, zigzag, rotation);+ return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));+ }+float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {+ vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);+ // Different approach for variation param here+ float row = floor(uv * frequency).y;+ float rand = hashwithoutsine12(vec2(row));+ float s = mix(size, size * rand, variation);+ return smoothstep(+ s - smoothness,+ s + smoothness,+ abs(f.y)+ );+ }+float simplexFractal(vec3 m) {+ mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);+ mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);+ mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);+ return 0.5333333 * simplexFast(m * rot1)+ + 0.2666667 * simplexFast(2.0 * m * rot2)+ + 0.1333333 * simplexFast(4.0 * m * rot3)+ + 0.0666667 * simplexFast(8.0 * m);+ }+float simplexAshima(vec3 v) {+ const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);+ vec3 i = floor(v + dot(v, C.yyy) );+ vec3 x0 = v - i + dot(i, C.xxx) ;+ vec3 g = step(x0.yzx, x0.xyz);+ vec3 l = 1.0 - g;+ vec3 i1 = min( g.xyz, l.zxy );+ vec3 i2 = max( g.xyz, l.zxy );+ vec3 x1 = x0 - i1 + 1.0 * C.xxx;+ vec3 x2 = x0 - i2 + 2.0 * C.xxx;+ vec3 x3 = x0 - 1. + 3.0 * C.xxx;+ i = mod(i, 289.0 );+ vec4 p = permute( permute( permute(+ i.z + vec4(0.0, i1.z, i2.z, 1.0 ))+ + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))+ + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));+ float n_ = 1.0/7.0; // N=7+ vec3 ns = n_ * D.wyz - D.xzx;+ vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)+ vec4 x_ = floor(j * ns.z);+ vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)+ vec4 x = x_ *ns.x + ns.yyyy;+ vec4 y = y_ *ns.x + ns.yyyy;+ vec4 h = 1.0 - abs(x) - abs(y);+ vec4 b0 = vec4( x.xy, y.xy );+ vec4 b1 = vec4( x.zw, y.zw );+ vec4 s0 = floor(b0)*2.0 + 1.0;+ vec4 s1 = floor(b1)*2.0 + 1.0;+ vec4 sh = -step(h, vec4(0.0));+ vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;+ vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;+ vec3 p0 = vec3(a0.xy,h.x);+ vec3 p1 = vec3(a0.zw,h.y);+ vec3 p2 = vec3(a1.xy,h.z);+ vec3 p3 = vec3(a1.zw,h.w);+ vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));+ p0 *= norm.x;+ p1 *= norm.y;+ p2 *= norm.z;+ p3 *= norm.w;+ vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);+ m = m * m;+ return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),+ dot(p2,x2), dot(p3,x3) ) );+ }+float noise(vec3 p){+ vec3 a = floor(p);+ vec3 d = p - a;+ d = d * d * (3.0 - 2.0 * d);+ vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);+ vec4 k1 = perm(b.xyxy);+ vec4 k2 = perm(k1.xyxy + b.zzww);+ vec4 c = k2 + a.zzzz;+ vec4 k3 = perm(c);+ vec4 k4 = perm(c + 1.0);+ vec4 o1 = fract(k3 * (1.0 / 41.0));+ vec4 o2 = fract(k4 * (1.0 / 41.0));+ vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);+ vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);+ return o4.y * d.y + o4.x * (1.0 - d.y);+ }+vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {+ mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);+ float lalpha = alpha * rainbowContribution * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return res;+ }+float fbm(vec3 x) {+ float v = 0.0;+ float a = 0.5;+ vec3 shift = vec3(100);+ for (int i = 0; i < NUM_OCTAVES; ++i) {+ v += a * noise(x);+ x = x * 2.0 + shift;+ a *= 0.5;+ }+ return v;+ }+float perlin(vec3 P){+ vec3 Pi0 = floor(P);+ vec3 Pi1 = Pi0 + vec3(1.0);+ Pi0 = mod(Pi0, 289.0);+ Pi1 = mod(Pi1, 289.0);+ vec3 Pf0 = fract(P);+ vec3 Pf1 = Pf0 - vec3(1.0);+ vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);+ vec4 iy = vec4(Pi0.yy, Pi1.yy);+ vec4 iz0 = Pi0.zzzz;+ vec4 iz1 = Pi1.zzzz;+ vec4 ixy = permute(permute(ix) + iy);+ vec4 ixy0 = permute(ixy + iz0);+ vec4 ixy1 = permute(ixy + iz1);+ vec4 gx0 = ixy0 / 7.0;+ vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;+ gx0 = fract(gx0);+ vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);+ vec4 sz0 = step(gz0, vec4(0.0));+ gx0 -= sz0 * (step(0.0, gx0) - 0.5);+ gy0 -= sz0 * (step(0.0, gy0) - 0.5);+ vec4 gx1 = ixy1 / 7.0;+ vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;+ gx1 = fract(gx1);+ vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);+ vec4 sz1 = step(gz1, vec4(0.0));+ gx1 -= sz1 * (step(0.0, gx1) - 0.5);+ gy1 -= sz1 * (step(0.0, gy1) - 0.5);+ vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);+ vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);+ vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);+ vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);+ vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);+ vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);+ vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);+ vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);+ vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));+ g000 *= norm0.x;+ g010 *= norm0.y;+ g100 *= norm0.z;+ g110 *= norm0.w;+ vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));+ g001 *= norm1.x;+ g011 *= norm1.y;+ g101 *= norm1.z;+ g111 *= norm1.w;+ float n000 = dot(g000, Pf0);+ float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));+ float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));+ float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));+ float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));+ float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));+ float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));+ float n111 = dot(g111, Pf1);+ vec3 fade_xyz = fade(Pf0);+ vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);+ vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);+ float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);+ return 2.2 * n_xyz;+ }+float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)+ {+ // Integer and fractional parts of this point's coordinates+ ivec3 p = ivec3(floor(x));+ vec3 f = fract(x);+ // Different variables that we will use to construct noise:+ //+ // f1: distance to the closest feature point+ // f2: distance to the second closest feature point+ // e: distance to the closest edge (cell boundary)+ //+ // We also compute "smooth" versions of all of the above quantites, essentially+ // replacing "hard" minimums with "smooth" minimums (described by IQ)+ float f1_smooth = 8.0;+ float f1 = 8.0;+ float f2_smooth = 8.0;+ float f2 = 8.0;+ float e_smooth = 8.0;+ float e = 8.0;+ // Variables stored from closest cell+ ivec3 mb;+ vec3 mr;+ int steps = quality;+ for (int x = -steps; x <= steps; x++)+ for (int y = -steps; y <= steps; y++)+ for (int z = -steps; z <= steps; z++)+ {+ ivec3 b = ivec3(x, y, z);+ vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;+ float d = length(r);+ f1_smooth = smin(d, f1_smooth, smoothness);+ // Store un-smoothed distances too+ if (d < f1)+ {+ f2 = f1;+ f1 = d;+ mb = ivec3(x, y, z);+ mr = r;+ }+ else if (d < f2)+ {+ f2 = d;+ }+ }+ // Second pass for edge distance+ // skip for styles don't need+ if (style != 0 && style != 5 && style != 7)+ for (int x = -steps; x <= steps; x++)+ for (int y = -steps; y <= steps; y++)+ for (int z = -steps; z <= steps; z++)+ {+ // Start search at the cell that contains the closest point to "x" (found in 1st pass)+ ivec3 b = mb + ivec3(x, y, z);+ vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;+ float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version?+ float d2 = dot(0.5 * (mr + r), normalize(r - mr));+ e_smooth = smin(d1, e_smooth, smoothness);+ e = min(e, d2);+ // Also compute a smooth version of F2 in this pass+ {+ ivec3 b = ivec3(x, y, z);+ if (b != mb)+ {+ vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;+ float d = length(r);+ f2_smooth = smin(d, f2_smooth, smoothness);+ }+ }+ }+ // Different visualization modes+ if (style == 0)+ {+ return f1_smooth;+ }+ if (style == 1)+ {+ return f2_smooth;+ }+ if (style == 2)+ {+ return f2_smooth - f1_smooth;+ // "Pebbles" also cool+ //return step(0.2, f2_smooth - f1_smooth);+ }+ if (style == 3)+ {+ // This one is really good for rock / stone effects+ float a = f1;+ float b = f2;+ float k = 3.0;+ float h = max(k - abs(a - b), 0.0) / k;+ float final = min(a, b) - h * h * k * (1.0 / 4.0);+ return final;+ }+ if (style == 4)+ {+ // Some random adjustments to make this style stand out more+ return exp(5.0 * e_smooth);+ }+ if (style == 5)+ {+ return pow(f1_smooth, 3.0);+ }+ if (style == 6)+ {+ const float eps = 0.0125;+ // Thicker lines as the user increases the smoothness slider+ float thickness = smoothness * 0.25 + eps;+ // Blurrier lines as the user increases the smoothness slider+ float blur = pow(smoothness, 3.0) * 0.25 + eps;+ return smoothstep(+ thickness - thickness * blur,+ thickness + thickness * blur,+ e+ );+ }+ if (style == 7)+ {+ return hashwithoutsine13(vec3(p + mb) + seed);+ }+ }+vec3 g_uid65_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {+ const float TWO_PI = PI * 2.0;+ float smoothness_remapped = pow(smoothness, 5.0);+ vec2 custom_uv;+ custom_uv = vUv.st;+ custom_uv += offset;+ custom_uv = fract(custom_uv);+ custom_uv = rotate_uv(custom_uv, rotation, true);+ float draw = circle(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation);+ // Construct final output color+ vec4 color = mix(colorA, colorB, draw);+ color.a = clamp(color.a, 0.0, 1.0);+ // Apply cuts+ color.a *=+ step(vertical.x, custom_uv.y) *+ step(custom_uv.y, vertical.y);+ color.a *=+ step(horizontal.x, abs(custom_uv.x)) *+ step(abs(custom_uv.x), horizontal.y);+ // Accumulate alpha+ float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return clamp(color, 0.0, 1.0).rgb;+ }+vec3 simplexFastcustomNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)+ {+ // Prevent scale of zero+ scale = max(abs(scale), 0.001);+ vec3 st = vPosition / size;+ st /= scale;+ vec3 q = vec3(simplexFast(st),+ simplexFast(st + vec3(1.0)),+ simplexFast(st + vec3(1.0)));+ vec3 r = vec3(simplexFast(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),+ simplexFast(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),+ simplexFast(st * q));+ float f = simplexFast(st + r);+ vec4 color;+ color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));+ color = mix(color, colorC, clamp(length(q), 0.0, 1.0));+ color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));+ float lalpha = alpha * color.a * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return clamp(color, 0.0, 1.0).rgb;+ }+void main() {+float g_uid89_calpha;+float g_uid83_calpha;+float g_uid76_calpha;+float g_uid65_calpha;+float g_uid27_calpha;+float g_uid20_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ BlinnPhongMaterial material;+ vec3 diffuseColor = spe_blend(spe_blend(spe_blend(customColor(nodeU0,1.0,nodeU1,g_uid89_calpha),matcap(nodeU2,normal,nodeU3,1.0,nodeU4,nodeU5,g_uid83_calpha,nodeU6),( g_uid83_calpha ),nodeU5),rainbow(nodeU7,nodeU8,nodeU9,nodeU10,nodeU11,nodeU12,nodeU13,1.0,nodeU14,g_uid76_calpha),( g_uid76_calpha ),nodeU15),g_uid65_pattern(normal,nodeU16,nodeU17,nodeU18,nodeU19,nodeU20,nodeU21,nodeU22,nodeU23,nodeU24,nodeU25,nodeU26,nodeU27,nodeU28,nodeU29,nodeU30,1.0,nodeU31,g_uid65_calpha),( g_uid65_calpha ),nodeU32);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ vec3 specular = nodeU33;+ float shininess = max( 0.0001, nodeU34 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU62 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled && nodeU35 ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU36 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU36 * 1.0, nodeU37 );+ outgoingLight *= ao;+ }+outgoingLight = spe_blend(outgoingLight, spe_blend(spe_blend(vec3( ( outgoingLight ) ),matcap(nodeU38,normal,nodeU39,1.0,nodeU40,nodeU41,g_uid27_calpha,nodeU42),( g_uid27_calpha ),nodeU41),simplexFastcustomNoise(nodeU43,nodeU44,nodeU45,nodeU46,nodeU47,nodeU48,nodeU49,nodeU50,nodeU51,nodeU52,nodeU53,nodeU54,nodeU55,nodeU56,nodeU57,nodeU58,nodeU59,1.0,nodeU60,g_uid20_calpha),( g_uid20_calpha ),nodeU61), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU62);+gl_FragColor.a *= nodeU63;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p6.vert b/site/public/examples/resend-cube/assets/shaders/p6.vertnew file mode 100644index 0000000..1f560e2--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p6.vert@@ -0,0 +1,499 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p7.frag b/site/public/examples/resend-cube/assets/shaders/p7.fragnew file mode 100644index 0000000..0ebbdea--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p7.frag@@ -0,0 +1,1182 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+#define OPAQUE+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+uniform vec3 emissive;+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+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+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform vec3 nodeU0;+uniform float nodeU1;+uniform sampler2D nodeU2;+uniform vec3 nodeU3;+uniform float nodeU4;+uniform mat3 nodeU5;+uniform vec2 nodeU6;+uniform float nodeU7;+uniform bool nodeU8;+uniform float nodeU9;+uniform int nodeU10;+uniform sampler2D nodeU11;+uniform bool nodeU12;+uniform float nodeU13;+uniform int nodeU14;+uniform float nodeU15;+uniform vec3 nodeU16;+uniform float nodeU17;+uniform bool nodeU18;+uniform float nodeU19;+uniform int nodeU20;+uniform float nodeU21;+uniform float nodeU22;+uniform vec3 nodeU23;+uniform float nodeU24;+uniform float nodeU25;+uniform vec3 nodeU26;+uniform bool nodeU27;+uniform float nodeU28;+uniform int nodeU29;+uniform float nodeU30;+uniform float nodeU31;+uniform float nodeU32;+const float F3 = 0.3333333;+const float G3 = 0.1666667;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {+ vec3 p = vPosition;+ vec2 uv0 = (1.0 + p.xy) / 2.0;+ vec2 uv1 = (1.0 + p.zy) / 2.0;+ vec2 vUv2 = (1.0 + p.xz) / 2.0;+ uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ vUv2 = (mat * vec3((vUv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;+ // Range from 3 to 128 seems to be good+ float exponent = (1.0 - blending) * 125.0 + 3.0;+ vec3 n = vObjectNormal;+ vec3 weights = abs(normalize(n));+ weights = pow(weights, vec3(exponent));+ weights /= dot(weights, vec3(1.0));+ // Write out all sets of UVs that we generated+ writeUvs0 = uv0;+ writeUvs1 = uv1;+ writeUvs2 = vUv2;+ writeWeights = weights;+ // Derivatives for LOD+ vec2 df0 = fwidth(uv0);+ vec2 df1 = fwidth(uv1);+ vec2 df2 = fwidth(vUv2);+ if (df0.x > 0.5) df0.x = 0.0;+ if (df1.x > 0.5) df1.x = 0.0;+ if (df2.x > 0.5) df2.x = 0.0;+ #ifdef GL_EXT_shader_texture_lod+ vec4 tmp =+ texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ texture2DLodEXT(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #else+ vec4 tmp =+ textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z ++ textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x ++ textureLod(tex, vUv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;+ #endif+ vec3 col = tmp.rgb;+ float lalpha = alpha * tmp.a;+ // Apply cropping across all 3 planes+ if ( crop > 0.5 ) {+ if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {+ lalpha = 0.0;+ }+ if ( vUv2.x < 0.0 || vUv2.x > 1.0 || vUv2.y < 0.0 || vUv2.y > 1.0 ) {+ lalpha = 0.0;+ }+ }+ lalpha *= mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return col;//n * 0.5 + 0.5;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+vec3 random3(vec3 c) {+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));+ vec3 r;+ r.z = fract(512.0*j);+ j *= .125;+ r.x = fract(512.0*j);+ j *= .125;+ r.y = fract(512.0*j);+ return r-0.5;+ }+vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {+ // Gradient of UVs w.r.t. X coordinate (in screen-space)+ vec2 dSTdx = dFdx(bumpMapUv);+ // Gradient of UVs w.r.t. Y coordinate (in screen-space)+ vec2 dSTdy = dFdy(bumpMapUv);+ // Forward differencing+ float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);+ float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;+ float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;+ return vec2( dBx, dBy );+ }+vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {+ vec3 vSigmaX = dFdx( surf_pos.xyz );+ vec3 vSigmaY = dFdy( surf_pos.xyz );+ vec3 vN = surf_norm; // normalized+ vN = normalize(vN);+ vec3 R1 = cross( vSigmaY, vN );+ vec3 R2 = cross( vN, vSigmaX );+ R1 = normalize(R1);+ R2 = normalize(R2);+ float fDet = dot( vSigmaX, R1 ) * faceDirection;+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );+ return normalize( abs( fDet ) * vN - vGrad );+ }+float simplexFast(vec3 p) {+ vec3 s = floor(p + dot(p, vec3(F3)));+ mediump vec3 x = p - s + dot(s, vec3(G3));+ mediump vec3 hs = s;+ mediump vec3 e = step(vec3(0.0), x - x.yzx);+ mediump vec3 i1 = e*(1.0 - e.zxy);+ mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);+ mediump vec3 x1 = x - i1 + G3;+ mediump vec3 x2 = x - i2 + 2.0*G3;+ mediump vec3 x3 = x - 1.0 + 3.0*G3;+ mediump vec4 w, d;+ w.x = dot(x, x);+ w.y = dot(x1, x1);+ w.z = dot(x2, x2);+ w.w = dot(x3, x3);+ w = max(0.6 - w, 0.0);+ d.x = dot(random3(hs), x);+ d.y = dot(random3(hs + i1), x1);+ d.z = dot(random3(hs + i2), x2);+ d.w = dot(random3(hs + 1.0), x3);+ w *= w;+ w *= w;+ d *= w;+ return dot(d, vec4(52.0));+ }+vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {+ float f = 0.0;+ if (noiseStrength != 0.0) {+ vec3 st = vPosition / noiseScale;+ float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));+ f = noise * noiseStrength;+ }+ vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;+ float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));+ mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);+ return .5 + .5 * color;+ }+vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {+ mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);+ float lalpha = alpha * rainbowContribution * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return res;+ }+void main() {+float g_uid53_calpha;+float g_uid47_calpha;+vec2 g_uid47_writeUvs0;+vec2 g_uid47_writeUvs1;+vec2 g_uid47_writeUvs2;+vec3 g_uid47_triplanarWeights;+float g_uid33_calpha;+float g_uid9_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ BlinnPhongMaterial material;+// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates+ triplanarTexture(normal,nodeU2,nodeU3.xy,nodeU4,nodeU5,nodeU6,nodeU7,nodeU8,1.0,nodeU9,nodeU10,g_uid47_calpha,g_uid47_writeUvs0,g_uid47_writeUvs1,g_uid47_writeUvs2,g_uid47_triplanarWeights);+ vec3 bumpNormal = vec3(0.0);+ {+ vec2 uv0 = g_uid47_writeUvs0;+ vec2 uv1 = g_uid47_writeUvs1;+ vec2 uv2 = g_uid47_writeUvs2;+ vec3 weights = g_uid47_triplanarWeights;+ vec2 grad0 = dHdxy(nodeU2, uv0, nodeU32);+ vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);+ vec2 grad1 = dHdxy(nodeU2, uv1, nodeU32);+ vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);+ vec2 grad2 = dHdxy(nodeU2, uv2, nodeU32);+ vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);+ bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;+ bumpNormal = normalize(bumpNormal);+ }+ normal = bumpNormal;+ vec3 diffuseColor = spe_blend(spe_blend(customColor(nodeU0,1.0,nodeU1,g_uid53_calpha),triplanarTexture(normal,nodeU2,nodeU3.xy,nodeU4,nodeU5,nodeU6,nodeU7,nodeU8,1.0,nodeU9,nodeU10,g_uid47_calpha,g_uid47_writeUvs0,g_uid47_writeUvs1,g_uid47_writeUvs2,g_uid47_triplanarWeights),( g_uid47_calpha ),nodeU10),matcap(nodeU11,normal,nodeU12,1.0,nodeU13,nodeU14,g_uid33_calpha,nodeU15),( g_uid33_calpha ),nodeU14);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ vec3 specular = nodeU16;+ float shininess = max( 0.0001, nodeU17 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU30 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled && nodeU18 ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU19 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU19 * 1.0, nodeU20 );+ outgoingLight *= ao;+ }+outgoingLight = spe_blend(outgoingLight, spe_blend(vec3( ( outgoingLight ) ),rainbow(nodeU21,nodeU22,nodeU23,nodeU24,nodeU25,nodeU26,nodeU27,1.0,nodeU28,g_uid9_calpha),( g_uid9_calpha ),nodeU29), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU30);+gl_FragColor.a *= nodeU31;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p7.vert b/site/public/examples/resend-cube/assets/shaders/p7.vertnew file mode 100644index 0000000..1f560e2--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p7.vert@@ -0,0 +1,499 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p8.frag b/site/public/examples/resend-cube/assets/shaders/p8.fragnew file mode 100644index 0000000..1f82af0--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p8.frag@@ -0,0 +1,1122 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+uniform vec3 emissive;+uniform float penumbraSize[5];+uniform sampler2D aoMap;+uniform bool aoEnabled;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+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 );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+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 );+ 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 );+}+#ifdef USE_IRIDESCENCE+ vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {+ float alpha = pow2( 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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+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 ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ 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 );+ 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 ] ) {+ 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 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ 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 );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ 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 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+float G_BlinnPhong_Implicit( ) {+ 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( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ 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+uniform bool receiveShadow;+uniform vec3 ambientLightColor;+uniform vec3 lightProbe[ 9 ];+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ 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 )+ 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 1 > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ 1 ];+ 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 0 > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ 0 ];+ 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 1 > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ 1 ];+ 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 0 > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ 0 ];+#endif+#if 1 > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ 1 ];+ 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+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+// PCSS implementation based on:+// https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/+// NOTE: This number affects how big the shadow blur can+// possibly get. Bigger number == bigger blur, but less precise results+const float gPenumbraFilterSize = 80.0;+const int gPenumbraSamples = 16;+const int gShadowSamples = 16;+const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform sampler2D directionalShadowMap[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ uniform sampler2D spotShadowMap[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform sampler2D pointShadowMap[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+ /*+ #if 0 > 0+ // TODO (abelnation): create uniforms for area light shadows+ #endif+ */+float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)+{+ float penumbra = 1.0;+ float blockerDepthAvg = 0.0;+ float blockerCount = 0.0;+ #pragma unroll_loop_start+ for(int i = 0; i < gPenumbraSamples; i ++)+ {+ vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;+ float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );+ if(depth < compare + 0.0001)+ {+ blockerDepthAvg += depth;+ blockerCount++;+ }+ }+ #pragma unroll_loop_end+ if (blockerCount > 0.0)+ {+ blockerDepthAvg /= blockerCount;+ // Compute penumbra+ penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);+ penumbra *= penumbra;+ penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows+ return clamp(penumbra, 0.00, 1.0);+ }+ return 0.0;+}+float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)+{+ float shadow = 0.0f;+ // NOTE: When using TAA, we should use screen space interleaved gradient noise+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);+ float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);+ if (penumbra == -1.0) {+ return 1.0;+ }+ #pragma unroll_loop_start+ for (int i = 0; i < gShadowSamples; i++)+ {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec2 offset = vogelSample * (shadowRadius * 2.);+ // Penumbra offset+ offset += vogelSample * (penumbra * texelScalar);+ shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );+ }+ #pragma unroll_loop_end+ return shadow * gShadowSamplesRpc;+}+ 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( int i, 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;+ return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );+ #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 ) {+ float shadow = 1.0;+ 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 compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?+ compare += shadowBias;+ // bd3D = base direction 3D+ vec3 bd3D = normalize( lightToPosition );+ vec2 halton = haltonSequence[frameIndex];+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);+ float temporalAngle = temporalOffset * PI2;+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )+ for (int i = 0; i < gShadowSamples; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ // NOTE: Removed for now+ // Penumbra offset+ //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * gShadowSamplesRpc;+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ for (int i = 0; i < 16; i++) {+ vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;+ // Overall blurring offset+ vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);+ shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );+ }+ return shadow * (1.0 / 16.0);+ #else // no percentage-closer filtering+ return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );+ #endif+ }+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+uniform sampler2D nodeU0;+uniform vec3 nodeU1;+uniform float nodeU2;+uniform mat3 nodeU3;+uniform vec2 nodeU4;+uniform float nodeU5;+uniform bool nodeU6;+uniform float nodeU7;+uniform int nodeU8;+uniform vec3 nodeU9;+uniform float nodeU10;+uniform int nodeU11;+uniform vec3 nodeU12;+uniform float nodeU13;+uniform bool nodeU14;+uniform float nodeU15;+uniform int nodeU16;+uniform vec3 nodeU17;+uniform float nodeU18;+uniform float nodeU19;+uniform float nodeU20;+uniform float nodeU21;+uniform bool nodeU22;+uniform float nodeU23;+uniform int nodeU24;+uniform sampler2D nodeU25;+uniform bool nodeU26;+uniform float nodeU27;+uniform int nodeU28;+uniform float nodeU29;+uniform float nodeU30;+uniform float nodeU31;+uniform vec3 nodeU32;+uniform float nodeU33;+uniform float nodeU34;+uniform vec3 nodeU35;+uniform bool nodeU36;+uniform float nodeU37;+uniform int nodeU38;+uniform float nodeU39;+uniform float nodeU40;+const float F3 = 0.3333333;+const float G3 = 0.1666667;+vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {+ vec3 posN = normalize(vPosition);+ float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);+ float v = 0.5 + asin(posN.y) / 3.1415;+ vec2 calculatedUv = vec2(u,v);+ vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;+ writeUv = uvs;+ vec2 df = fwidth(uvs);+ if(df.x > 0.5) df.x = 0.;+ #ifdef GL_EXT_shader_texture_lod+ vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));+ #else+ vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));+ #endif+ vec3 col = tmp.rgb;+ float lalpha = alpha * tmp.a;+ if ( crop > 0.5 ) {+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {+ lalpha = 0.0;+ }+ }+ lalpha *= mask;+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return col;+ }+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );+ float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return color;+ }+vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 vUv = vec2( dot( x, normal ), dot( y, normal ) );+ vUv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * vUv;+ vUv = vUv * 0.495 + 0.5;+ vec4 matcapColor = texture2D( matcapTex, vUv );+ float lalpha = alpha * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return matcapColor.rgb;+ }+vec3 random3(vec3 c) {+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));+ vec3 r;+ r.z = fract(512.0*j);+ j *= .125;+ r.x = fract(512.0*j);+ j *= .125;+ r.y = fract(512.0*j);+ return r-0.5;+ }+float simplexFast(vec3 p) {+ vec3 s = floor(p + dot(p, vec3(F3)));+ mediump vec3 x = p - s + dot(s, vec3(G3));+ mediump vec3 hs = s;+ mediump vec3 e = step(vec3(0.0), x - x.yzx);+ mediump vec3 i1 = e*(1.0 - e.zxy);+ mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);+ mediump vec3 x1 = x - i1 + G3;+ mediump vec3 x2 = x - i2 + 2.0*G3;+ mediump vec3 x3 = x - 1.0 + 3.0*G3;+ mediump vec4 w, d;+ w.x = dot(x, x);+ w.y = dot(x1, x1);+ w.z = dot(x2, x2);+ w.w = dot(x3, x3);+ w = max(0.6 - w, 0.0);+ d.x = dot(random3(hs), x);+ d.y = dot(random3(hs + i1), x1);+ d.z = dot(random3(hs + i2), x2);+ d.w = dot(random3(hs + 1.0), x3);+ w *= w;+ w *= w;+ d *= w;+ return dot(d, vec4(52.0));+ }+vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {+ float f = 0.0;+ if (noiseStrength != 0.0) {+ vec3 st = vPosition / noiseScale;+ float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));+ f = noise * noiseStrength;+ }+ vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;+ float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));+ mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);+ return .5 + .5 * color;+ }+vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {+ mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);+ float lalpha = alpha * rainbowContribution * mask;+ calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));+ accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));+ return res;+ }+void main() {+float g_uid63_calpha;+vec2 g_uid63_writeUvs;+float g_uid49_calpha;+float g_uid26_calpha;+float g_uid16_calpha;+float g_uid9_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+ // NOTE: gl_FrontFacing alternative using face normal estimation.+ vec3 viewdx = dFdx(vViewPosition);+ vec3 viewdy = dFdy(vViewPosition);+ vec3 faceNormal = normalize(cross(viewdx,viewdy));+ if (dot(normal, faceNormal) < 0.0) {+ normal *= -1.0;+ }+ BlinnPhongMaterial material;+ vec3 diffuseColor = spe_blend(sphericalTexture(normal,nodeU0,nodeU1.xy,nodeU2,nodeU3,nodeU4,nodeU5,nodeU6,1.0,nodeU7,nodeU8,g_uid63_calpha,g_uid63_writeUvs),customColor(nodeU9,1.0,nodeU10,g_uid49_calpha),( g_uid49_calpha ),nodeU11);+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ vec3 specular = nodeU12;+ float shininess = max( 0.0001, nodeU13 );+ float specularStrength = 1.0;+#ifdef ALPHATEST+if ( nodeU39 <= ALPHATEST ) discard;+#endif+material.diffuseColor = diffuseColor;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;+GeometricContext geometry;+geometry.position = - vViewPosition;+geometry.normal = normal;+geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+#ifdef USE_CLEARCOAT+ geometry.clearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometry.viewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( 0 > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ PointLightShadow pointLightShadow;+ #endif+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && 1 > 0+ SpotLightShadow spotLightShadow;+ #endif+ spotLight = spotLights[ 0 ];+ getSpotLightInfo( spotLight, geometry, directLight );+ #if ( 0 < 0 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #elif ( 0 < 1 )+ #define SPOT_LIGHT_MAP_INDEX 0+ #else+ #define SPOT_LIGHT_MAP_INDEX ( 0 - 1 + 0 )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < 0 )+ spotLightCoord = vSpotLightCoord[ 0 ].xyz / vSpotLightCoord[ 0 ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( 0 < 1 )+ spotLightShadow = spotLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0 + 3, spotShadowMap[ 0 ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 1 > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && 0 > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ directionalLight = directionalLights[ 0 ];+ getDirectionalLightInfo( directionalLight, geometry, directLight );+ #if defined( USE_SHADOWMAP ) && ( 0 < 0 )+ directionalLightShadow = directionalLightShadows[ 0 ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( 0, directionalShadowMap[ 0 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 0 ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometry, material, reflectedLight );+#endif+#if ( 0 > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );+ #if ( 1 > 0 )+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ 0 ], geometry.normal );+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif+#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );+#endif+vec3 ao = aoEnabled && nodeU14 ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);+vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ if (outgoingLight != diffuseColor) {+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );+ accumAlpha += ( 1.0 - accumAlpha ) * nodeU15 * 1.0 * lightAccu;+ outgoingLight = spe_blend( diffuseColor, outgoingLight, nodeU15 * 1.0, nodeU16 );+ outgoingLight *= ao;+ }+outgoingLight = spe_blend(outgoingLight, spe_blend(spe_blend(spe_blend(vec3( ( outgoingLight ) ),fresnel(nodeU17,nodeU18,nodeU19,nodeU20,nodeU21,nodeU22,1.0,nodeU23,nodeU24,g_uid26_calpha),( g_uid26_calpha ),nodeU24),matcap(nodeU25,normal,nodeU26,1.0,nodeU27,nodeU28,g_uid16_calpha,nodeU29),( g_uid16_calpha ),nodeU28),rainbow(nodeU30,nodeU31,nodeU32,nodeU33,nodeU34,nodeU35,nodeU36,1.0,nodeU37,g_uid9_calpha),( g_uid9_calpha ),nodeU38), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( outgoingLight, accumAlpha * nodeU39);+gl_FragColor.a *= nodeU40;+gl_FragColor = linearToOutputTexel( gl_FragColor );+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p8.vert b/site/public/examples/resend-cube/assets/shaders/p8.vertnew file mode 100644index 0000000..1f560e2--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p8.vert@@ -0,0 +1,499 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define PHONG 1+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+#if 1 > 0+ uniform mat4 spotLightMatrix[ 1 ];+ varying vec4 vSpotLightCoord[ 1 ];+#endif+#ifdef USE_SHADOWMAP+ #if 0 > 0+ uniform mat4 directionalShadowMatrix[ 0 ];+ varying vec4 vDirectionalShadowCoord[ 0 ];+ struct DirectionalLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ 0 ];+ #endif+ #if 1 > 0+ struct SpotLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ 1 ];+ #endif+ #if 0 > 0+ uniform mat4 pointShadowMatrix[ 0 ];+ varying vec4 vPointShadowCoord[ 0 ];+ struct PointLightShadow {+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ 0 ];+ #endif+#endif+#if 0 > 0+ varying vec3 vClipPosition;+#endif+varying vec2 vUv;+varying vec3 vPosition;+varying vec3 vObjectNormal;+varying vec3 vWNormal;+varying vec3 vWorldViewDir;+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #ifndef USE_LAYER_DISPLACE+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = objectNormal;+ #ifdef USE_LAYER_DISPLACE+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #ifndef USE_LAYER_DISPLACE+vec3 transformed = vec3( position );+ #endif+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+#if ( defined( USE_SHADOWMAP ) && ( 0 > 0 || 0 > 0 ) ) || ( 1 > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if 0 > 0+ #endif+ #if 0 > 0+ #endif+#endif+#if 1 > 0+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && 0 < 1 )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ 0 ].shadowNormalBias;+ #endif+ vSpotLightCoord[ 0 ] = spotLightMatrix[ 0 ] * shadowWorldPosition;+#endif+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+vUv = uv;+vPosition = transformed;+ #ifndef SHAPEBLEND+ vObjectNormal = normal;+ #else+ vObjectNormal = objectNormal;+ #endif+vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;+vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/shaders/p9.frag b/site/public/examples/resend-cube/assets/shaders/p9.fragnew file mode 100644index 0000000..6b3ae9d--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p9.frag@@ -0,0 +1,314 @@+#define varying in+layout(location = 0) out highp vec4 pc_fragColor;+#define gl_FragColor pc_fragColor+#define gl_FragDepthEXT gl_FragDepth+#define texture2D texture+#define textureCube texture+#define texture2DProj textureProj+#define texture2DLodEXT textureLod+#define texture2DProjLodEXT textureProjLod+#define textureCubeLodEXT textureLod+#define texture2DGradEXT textureGrad+#define texture2DProjGradEXT textureProjGrad+#define textureCubeGradEXT textureGrad+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 viewMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#define DITHERING+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 );+}+vec4 linearToOutputTexel( vec4 value ) { return LinearToLinear( value ); }+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float accumAlpha = 0.0;+void accumulateAlpha(float alpha) {+ accumAlpha += (1.0 - accumAlpha) * alpha;+ }+layout(location = 1) out vec4 gVelocity;+uniform int frameIndex;+uniform vec2 resolution;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {+ const float goldenAngle = 2.399963f; // radians+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));+ float theta = float(sampleIndex) * goldenAngle + angle;+ float sine = sin(theta);+ float cosine = cos(theta);+ return vec2(cosine, sine) * r;+}+// Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso+float getNoiseInterleavedGradient(vec2 screenPos) {+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);+ return fract(magic.z * fract(dot(screenPos, magic.xy)));+}+varying vec3 vWPosition;+#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif+#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif+varying vec3 vViewPosition;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+uniform vec3 nodeU0;+uniform float nodeU1;+uniform vec3 nodeU2;+uniform float nodeU3;+uniform int nodeU4;+uniform float nodeU5;+vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {+ float lalpha = alpha * mask;+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);+ accumAlpha += (1.0 - accumAlpha) * lalpha;+ return color;+ }+void main() {+float g_uid4_calpha;+float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ 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+vec3 geometryNormal = normal;+#ifdef ALPHATEST+ if ( nodeU1 <= ALPHATEST ) discard;+#endif+vec3 outgoingLight = nodeU0;+vec3 finalColor = spe_blend(outgoingLight, spe_blend(vec3( ( outgoingLight ) ),customColor(nodeU2,1.0,nodeU3,g_uid4_calpha),( g_uid4_calpha ),nodeU4), 1.0, SPE_BLENDING_NORMAL);+gl_FragColor = vec4( finalColor, accumAlpha * nodeU1 * 1.0 );+gl_FragColor.a *= nodeU5;+#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+#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif+vec2 oldPos = vPreviousPosition.xy;+ oldPos /= vPreviousPosition.w;+ oldPos.xy = (oldPos.xy+1.)/2.0;+vec2 newPos = vCurrentPosition.xy;+ newPos /= vCurrentPosition.w;+ newPos.xy = (newPos.xy+1.)/2.0;+vec2 velocity = (newPos - oldPos);+// Discard fully transparent pixels+if (gl_FragColor.a <= 0.0) discard;+gVelocity = vec4(velocity, 0.0, 1.0);+}diff --git a/site/public/examples/resend-cube/assets/shaders/p9.vert b/site/public/examples/resend-cube/assets/shaders/p9.vertnew file mode 100644index 0000000..ad5124f--- /dev/null+++ b/site/public/examples/resend-cube/assets/shaders/p9.vert@@ -0,0 +1,425 @@+precision mediump sampler2DArray;+#define attribute in+#define varying out+#define texture2D texture+precision highp float;+precision highp int;+#define HIGH_PRECISION+#define VERTEX_TEXTURES+#define USE_COLOR+#define USE_SHADOWMAP+#define SHADOWMAP_TYPE_PCF+uniform mat4 modelMatrix;+uniform mat4 modelViewMatrix;+uniform mat4 projectionMatrix;+uniform mat4 viewMatrix;+uniform mat3 normalMatrix;+uniform vec3 cameraPosition;+uniform bool isOrthographic;+#ifdef USE_INSTANCING+ attribute mat4 instanceMatrix;+#endif+#ifdef USE_INSTANCING_COLOR+ attribute vec3 instanceColor;+#endif+attribute vec3 position;+attribute vec3 normal;+attribute vec2 uv;+#ifdef USE_TANGENT+ attribute vec4 tangent;+#endif+#if defined( USE_COLOR_ALPHA )+ attribute vec4 color;+#elif defined( USE_COLOR )+ attribute vec3 color;+#endif+#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )+ attribute vec3 morphTarget0;+ attribute vec3 morphTarget1;+ attribute vec3 morphTarget2;+ attribute vec3 morphTarget3;+ #ifdef USE_MORPHNORMALS+ attribute vec3 morphNormal0;+ attribute vec3 morphNormal1;+ attribute vec3 morphNormal2;+ attribute vec3 morphNormal3;+ #else+ attribute vec3 morphTarget4;+ attribute vec3 morphTarget5;+ attribute vec3 morphTarget6;+ attribute vec3 morphTarget7;+ #endif+#endif+#ifdef USE_SKINNING+ attribute vec4 skinIndex;+ attribute vec4 skinWeight;+#endif+#ifdef TEXTURE_LOD_EXT+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)+#else+ #define texCube(a, b) textureCube(a, b)+ #define texCubeBias(a, b, c) textureCube(a, b, c)+ #define tex2D(a, b) texture2D(a, b)+ #define tex2DBias(a, b, c) texture2D(a, b, c)+#endif+ // NOTE: Include Spline's blending modes. This could be part of BlendNode+ #define SPE_BLENDING_NORMAL 0+ #define SPE_BLENDING_MULTIPLY 1+ #define SPE_BLENDING_SCREEN 2+ #define SPE_BLENDING_OVERLAY 3+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, b, alpha );+ }+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {+ return mix( a, a * b, alpha );+ }+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );+ return mix( a, tmp, alpha );+ }+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );+ }+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );+ return vec3( 1.0 );+ }+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.;const float UnpackDownscale = 255. / 256.;+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; return r * PackUpscale;+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors );+}+vec2 packDepthToRG( in highp float v ) {+ return packDepthToRGBA( v ).yx;+}+float unpackRGToDepth( const in highp vec2 v ) {+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );+}+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 ) );+}+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;+}+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 );+}+#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+#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; }+vec3 pow2( const in vec3 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 v ) { return dot( v, vec3( 0.3333333 ) ); }+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 ) {+ 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;+}+float luminance( const in vec3 rgb ) {+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );+ return dot( weights, rgb );+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ 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 );+}+float neighbor_offset = 0.0001;+uniform int frameIndex;+uniform vec2 resolution;+uniform mat4 previousModelViewMatrix;+uniform mat4 previousProjectionMatrix;+varying vec4 vCurrentPosition;+varying vec4 vPreviousPosition;+varying vec3 vViewPosition;+varying vec3 vWPosition;+#ifdef USE_FOG+ varying float vFogDepth;+#endif+#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ 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;+ }+#endif+#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif+#ifdef USE_MORPHTARGETS+ uniform float morphTargetBaseInfluence;+ #ifdef MORPHTARGETS_TEXTURE+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+ #else+ #ifndef USE_MORPHNORMALS+ uniform float morphTargetInfluences[ 8 ];+ #else+ uniform float morphTargetInfluences[ 4 ];+ #endif+ #endif+#endif+void main() {+vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif+#ifdef USE_MORPHNORMALS+ 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+#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif+#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+ #if !defined( USE_LAYER_DISPLACE )+vec3 transformedNormal = objectNormal;+#ifdef USE_INSTANCING+ 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+ #endif+ vec3 displaced_position = position;+ vec3 displaced_normal = normal;+ #if defined( USE_LAYER_DISPLACE )+ vec3 transformed;+ vec3 transformedNormal;+ #endif+#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif+ #if !defined( USE_LAYER_DISPLACE )+vec3 transformed = vec3( position );+ #endif /* !USE_LAYER_DISPLACE */+transformed = displaced_position;+#ifdef USE_MORPHTARGETS+ 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+#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+transformedNormal = normalMatrix * displaced_normal;+#ifndef FLAT_SHADED+ vNormal = transformedNormal;+#endif+vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;+#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif+#if 0 > 0+ vClipPosition = - mvPosition.xyz;+#endif+ vViewPosition = - mvPosition.xyz;+#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 1 > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif+vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;+// TODO: This could be generated CPU side and passed to the shader every frame+const vec2 haltonSequence[16] = vec2[16](+vec2( 0.000000,-0.333334),+vec2(-0.500000, 0.333334),+vec2( 0.500000,-0.777778),+vec2(-0.750000,-0.111112),+vec2( 0.250000, 0.555556),+vec2(-0.250000,-0.555556),+vec2( 0.750000, 0.111112),+vec2(-0.875000, 0.777778),+vec2(0.125000, -0.925926),+vec2(-0.375000, -0.259260),+vec2(0.625000, 0.407408),+vec2(-0.625000, -0.703704),+vec2(0.375000, -0.037038),+vec2(-0.125000, 0.629630),+vec2(0.875000, -0.481482),+vec2(-0.937500, 0.185186));+// TODO: Pass correct view size+vec2 offset = haltonSequence[frameIndex];+offset.x /= resolution.x;+offset.y /= resolution.y;+vec4 currentPosition = gl_Position;+vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);+// We want to calculate the velocity with unjittered positions+// so that things that are not moving get a velocity = 0+vCurrentPosition = currentPosition;+vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);+#ifdef OUTLINE_COMPENSATION+vPreviousPosition.xy += OUTLINE_COMPENSATION;+#endif+gl_Position = currentPositionJittered;+}diff --git a/site/public/examples/resend-cube/assets/textures/metal.png b/site/public/examples/resend-cube/assets/textures/metal.pngnew file mode 100644index 0000000..6baf1fcBinary files /dev/null and b/site/public/examples/resend-cube/assets/textures/metal.png differdiff --git a/site/public/examples/resend-cube/assets/textures/noise-200.png b/site/public/examples/resend-cube/assets/textures/noise-200.pngnew file mode 100644index 0000000..136ac27Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/noise-200.png differdiff --git a/site/public/examples/resend-cube/assets/textures/pattern-a.png b/site/public/examples/resend-cube/assets/textures/pattern-a.pngnew file mode 100644index 0000000..50e00aaBinary files /dev/null and b/site/public/examples/resend-cube/assets/textures/pattern-a.png differdiff --git a/site/public/examples/resend-cube/assets/textures/pattern-b.png b/site/public/examples/resend-cube/assets/textures/pattern-b.pngnew file mode 100644index 0000000..c653e81Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/pattern-b.png differdiff --git a/site/public/examples/resend-cube/assets/textures/plastic-surface.png b/site/public/examples/resend-cube/assets/textures/plastic-surface.pngnew file mode 100644index 0000000..b7aed3cBinary files /dev/null and b/site/public/examples/resend-cube/assets/textures/plastic-surface.png differdiff --git a/site/public/examples/resend-cube/assets/textures/rubber-terrazzo-mask.jpg b/site/public/examples/resend-cube/assets/textures/rubber-terrazzo-mask.jpgnew file mode 100644index 0000000..b10ea32Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/rubber-terrazzo-mask.jpg differdiff --git a/site/public/examples/resend-cube/assets/textures/rubber-terrazzo.png b/site/public/examples/resend-cube/assets/textures/rubber-terrazzo.pngnew file mode 100644index 0000000..930485fBinary files /dev/null and b/site/public/examples/resend-cube/assets/textures/rubber-terrazzo.png differdiff --git a/site/public/examples/resend-cube/assets/textures/studio-lighting.png b/site/public/examples/resend-cube/assets/textures/studio-lighting.pngnew file mode 100644index 0000000..1c51d34Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/studio-lighting.png differdiff --git a/site/public/examples/resend-cube/assets/textures/textured-plastic-a.png b/site/public/examples/resend-cube/assets/textures/textured-plastic-a.pngnew file mode 100644index 0000000..f96d811Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/textured-plastic-a.png differdiff --git a/site/public/examples/resend-cube/assets/textures/textured-plastic-b.png b/site/public/examples/resend-cube/assets/textures/textured-plastic-b.pngnew file mode 100644index 0000000..d68c178Binary files /dev/null and b/site/public/examples/resend-cube/assets/textures/textured-plastic-b.png differdiff --git a/site/public/examples/resend-cube/index.html b/site/public/examples/resend-cube/index.htmlnew file mode 100644index 0000000..015f950--- /dev/null+++ b/site/public/examples/resend-cube/index.html@@ -0,0 +1,31 @@+<!doctype html>+<!--+ resend.com hero cube, rebuilt with reanimate.+ A Rubik's-style cube of 27 rounded cubies turns slowly on two axes while its outer slices make+ half-turns. On resend.com it is a Spline scene; here it is plain three.js r178 running the scene,+ the shaders and the post-processing recorded from that page (see src/cube.js).+-->+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <title>resend.com hero cube, rebuilt with reanimate</title>+ <meta name="robots" content="noindex">+ <script type="importmap">+ { "imports": { "three": "./vendor/three/three.module.js" } }+ </script>+ <link rel="stylesheet" href="./src/cube.css">+ <script type="module" src="./src/cube.js"></script>+</head>+<body>+ <main class="hero">+ <img class="hero__floor" alt="" src="./assets/bg-floor.webp" width="1920" height="1080" decoding="async">+ <img class="hero__rays" alt="" src="./assets/bg-light.avif" width="1920" height="1080" decoding="async">+ <div class="resend-cube" role="img" aria-label="A dark Rubik's cube turning slowly while its outer slices make half-turns">+ <div class="animate-webgl-scale-in-fade">+ <canvas></canvas>+ </div>+ </div>+ </main>+</body>+</html>diff --git a/site/public/examples/resend-cube/src/cube.css b/site/public/examples/resend-cube/src/cube.cssnew file mode 100644index 0000000..4d04af7--- /dev/null+++ b/site/public/examples/resend-cube/src/cube.css@@ -0,0 +1,85 @@+/* resend.com hero, as laid out at a 1440×900 viewport: the two images behind the hero (the floor,+ /static/landing-page/bg-hero-1.jpg as Next serves it (WebP), at 0,58, 80 % opacity; the light rays,+ bg-light.avif, at 0,−22; both 1440×900 and masked off at the bottom) and the cube's box at+ 688,193, 648×550, greyscale, with the two entrance animations of resend.com. */++html, body { margin: 0; background: #000; }+body { overflow-x: hidden; }++.hero {+ position: relative;+ width: 1440px;+ height: 900px;+ margin: 0 auto;+}++/* narrower windows: keep the cube (centre x = 1012) in the middle rather than off to the right */+@media (max-width: 1439px) {+ .hero { margin-left: calc(50vw - 1012px); }+}++.hero__floor,+.hero__rays {+ position: absolute;+ left: 0;+ width: 1440px;+ height: 900px;+ pointer-events: none;+ user-select: none;+ color: transparent;+ -webkit-mask-image: linear-gradient(to top, transparent 15%, black 25%);+ mask-image: linear-gradient(to top, transparent 15%, black 25%);+}++.hero__floor { top: 58px; opacity: 0.8; }+.hero__rays { top: -22px; }++/* the visual: resend's `relative transform-gpu grayscale lg:flex lg:animate-[open-scale-up-fade_1.5s_ease-in-out]` */+.resend-cube {+ position: absolute;+ left: 688px;+ top: 193px;+ width: 648px;+ height: 550px;+ display: flex;+ align-items: center;+ justify-content: center;+ transform: translateZ(0);+ filter: grayscale(100%);+ animation: 1.5s ease-in-out open-scale-up-fade;+}++/* Spline's wrapper: `relative animate-webgl-scale-in-fade` with width/height 100%, overflow hidden */+.animate-webgl-scale-in-fade {+ position: relative;+ width: 100%;+ height: 100%;+ overflow: hidden;+ animation: webgl-scale-in-fade 1s ease-in-out;+}++.animate-webgl-scale-in-fade canvas {+ display: block;+ width: 100%;+ height: 100%;+}++@keyframes open-scale-up-fade {+ 0% { opacity: 0; transform: scale(0.98) translateY(5px); }+ 100% { opacity: 1; transform: scale(1) translateY(0px); }+}++@keyframes webgl-scale-in-fade {+ 0% { opacity: 0; transform: scale(0.7); }+ 100% { opacity: 1; transform: scale(1); }+}++@keyframes fade-in {+ 0% { opacity: 0; }+ 100% { opacity: 1; }+}++/* as on resend.com: with reduced motion the cube fades in instead of scaling in */+@media (prefers-reduced-motion: reduce) {+ .animate-webgl-scale-in-fade { animation-name: fade-in !important; }+}diff --git a/site/public/examples/resend-cube/src/cube.js b/site/public/examples/resend-cube/src/cube.jsnew file mode 100644index 0000000..4a3d272--- /dev/null+++ b/site/public/examples/resend-cube/src/cube.js@@ -0,0 +1,321 @@+// resend.com's hero cube, ported from a reanimate trace of the Spline scene (/static/cube.splinecode,+// rendered there by Spline's runtime on three.js r149) to plain three.js r178.+//+// assets/scene.json holds what the trace recorded: the scene graph (27 rounded cubies in three+// slices, five shadow-casting bars), the two geometries, every constant uniform of every program, the+// texture settings, lights and camera. assets/shaders/ holds the programs exactly as Spline compiled+// them (its node materials, three's depth material, and the postprocessing passes). This file rebuilds+// Spline's frame: spot-light shadow map → scene into colour + velocity + depth → TAA resolve →+// luminance → 10 Kawase blur passes → bloom composite onto the transparent canvas.++import * as THREE from "three";+import { createMotion } from "./motion.js";++const ASSETS = new URL("../assets/", import.meta.url);+const KAWASE_KERNELS = [0, 1, 2, 3, 4, 5, 7, 8, 9, 10];+const BLUR_SCALE = 0.5;++const root = document.querySelector(".resend-cube");+const canvas = root.querySelector("canvas");++const fetchText = (path) => fetch(new URL(path, ASSETS)).then((r) => r.text());++function loadTexture(def) {+ return new Promise((resolve, reject) => {+ new THREE.ImageLoader().load(new URL(def.file, ASSETS).href, (image) => {+ const t = new THREE.Texture(image);+ t.wrapS = def.wrapS;+ t.wrapT = def.wrapT;+ t.minFilter = def.minFilter;+ t.magFilter = def.magFilter;+ t.flipY = def.flipY;+ t.generateMipmaps = def.generateMipmaps;+ t.anisotropy = def.anisotropy;+ t.unpackAlignment = def.unpackAlignment;+ t.needsUpdate = true;+ resolve(t);+ }, undefined, reject);+ });+}++function decode(b64, Type) {+ const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));+ return new Type(bytes.buffer);+}++function buildGeometry(def) {+ const g = new THREE.BufferGeometry();+ g.setAttribute("position", new THREE.BufferAttribute(decode(def.position, Float32Array), 3));+ g.setAttribute("normal", new THREE.BufferAttribute(decode(def.normal, Float32Array), 3));+ g.setAttribute("uv", new THREE.BufferAttribute(decode(def.uv, Float32Array), 2));+ g.setIndex(new THREE.BufferAttribute(decode(def.index, Uint16Array), 1));+ const s = def.boundingSphere;+ g.boundingSphere = new THREE.Sphere(new THREE.Vector3().fromArray(s.center), s.radius);+ return g;+}++function constUniforms(defs) {+ const u = {};+ for (const [name, { value }] of Object.entries(defs)) u[name] = { value };+ return u;+}++// The light uniforms three.js r149 computed for Spline (WebGLLights.setup / setupView, legacy light+// units: colour × intensity × π), from the lights' own matrices in the scene file.+function lightUniforms(L, camera, shadowCamera) {+ const view = camera.matrixWorldInverse;+ const pos = (m) => new THREE.Vector3().setFromMatrixPosition(m);+ const hex = (h, k) => new THREE.Vector3(((h >> 16) & 255) / 255, ((h >> 8) & 255) / 255, (h & 255) / 255).multiplyScalar(k);++ const spotM = new THREE.Matrix4().fromArray(L.spot.matrix);+ const spotPos = pos(spotM);+ const spotTarget = spotPos.clone().sub(new THREE.Vector3().setFromMatrixColumn(spotM, 1)); // Spline lights shine along −y+ const dirM = new THREE.Matrix4().multiplyMatrices(camera.matrixWorld, new THREE.Matrix4().fromArray(L.directional.matrix));+ const hemiM = new THREE.Matrix4().fromArray(L.hemisphere.matrix);++ // spot shadow camera (SpotLightShadow.updateMatrices)+ const sh = L.spot.shadow;+ shadowCamera.fov = THREE.MathUtils.RAD2DEG * 2 * L.spot.angle;+ shadowCamera.aspect = sh.mapSize[0] / sh.mapSize[1];+ shadowCamera.near = sh.near;+ shadowCamera.far = L.spot.distance || sh.far;+ shadowCamera.updateProjectionMatrix();+ shadowCamera.position.copy(spotPos);+ shadowCamera.lookAt(spotTarget);+ shadowCamera.updateMatrixWorld();+ const shadowMatrix = new THREE.Matrix4()+ .set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1)+ .multiply(shadowCamera.projectionMatrix)+ .multiply(shadowCamera.matrixWorldInverse);++ return {+ directionalLights: { value: [{+ direction: pos(dirM).transformDirection(view),+ color: hex(L.directional.color, L.directional.intensity * Math.PI),+ }] },+ spotLights: { value: [{+ position: spotPos.clone().applyMatrix4(view),+ direction: spotPos.clone().sub(spotTarget).transformDirection(view),+ color: hex(L.spot.color, L.spot.intensity * Math.PI),+ distance: L.spot.distance,+ decay: L.spot.decay,+ coneCos: Math.cos(L.spot.angle),+ penumbraCos: Math.cos(L.spot.angle * (1 - L.spot.penumbra)),+ }] },+ spotLightShadows: { value: [{+ shadowBias: sh.bias, shadowNormalBias: sh.normalBias, shadowRadius: sh.radius,+ shadowMapSize: new THREE.Vector2(sh.mapSize[0], sh.mapSize[1]),+ }] },+ spotLightMatrix: { value: [shadowMatrix] }, // mat4[1]+ hemisphereLights: { value: [{+ direction: pos(hemiM).transformDirection(view),+ skyColor: hex(L.hemisphere.skyColor, L.hemisphere.intensity * Math.PI),+ groundColor: hex(L.hemisphere.groundColor, L.hemisphere.intensity * Math.PI),+ }] },+ ambientLightColor: { value: [0, 0, 0] },+ lightProbe: { value: new Array(27).fill(0) },+ };+}++async function main() {+ const data = await (await fetch(new URL("scene.json", ASSETS))).json();+ const shaderFiles = [...new Set(Object.values(data.programs).flatMap((p) => [p.vert, p.frag]))];+ const shaderSrc = Object.fromEntries(await Promise.all(shaderFiles.map(async (f) => [f, await fetchText(f)])));+ const textureList = Object.entries(data.textures);+ const textures = Object.fromEntries(await Promise.all(textureList.map(async ([id, def]) => [id, await loadTexture(def)])));++ // Spline's context: no antialias, no depth or stencil on the canvas, transparent, premultiplied.+ const renderer = new THREE.WebGLRenderer({ canvas, antialias: false, alpha: true, depth: false, stencil: false, powerPreference: "high-performance" });+ // three r178 uploads textures with UNPACK_COLORSPACE_CONVERSION = NONE; r149 (Spline) left the browser+ // default, which converts the one Display-P3-tagged texture (rubber terrazzo) to sRGB. Keep r149's.+ const gl = renderer.getContext();+ const pixelStorei = gl.pixelStorei.bind(gl);+ gl.pixelStorei = (pname, value) => pixelStorei(pname, pname === gl.UNPACK_COLORSPACE_CONVERSION_WEBGL ? gl.BROWSER_DEFAULT_WEBGL : value);++ renderer.autoClear = false;+ renderer.outputColorSpace = THREE.LinearSRGBColorSpace;+ renderer.setPixelRatio(window.devicePixelRatio);+ const cssW = canvas.clientWidth, cssH = canvas.clientHeight;+ renderer.setSize(cssW, cssH, false);+ const size = renderer.getDrawingBufferSize(new THREE.Vector2());+ const W = size.x, H = size.y;++ // camera: Spline's orthographic "Default Camera", one world unit per CSS pixel+ const camera = new THREE.OrthographicCamera(-cssW / 2, cssW / 2, cssH / 2, -cssH / 2, -50000, 50000);+ camera.matrixAutoUpdate = false;+ camera.matrixWorldAutoUpdate = false;+ camera.matrixWorld.fromArray(data.camera.matrixWorld);+ camera.matrixWorldInverse.copy(camera.matrixWorld).invert();+ const shadowCamera = new THREE.PerspectiveCamera();++ const blank = new THREE.DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1);+ blank.needsUpdate = true;++ // render targets, as Spline's composer made them+ const shadowRT = new THREE.WebGLRenderTarget(1024, 1024, { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, depthBuffer: true, stencilBuffer: false });+ // r149 gives a render target without a depth texture a 16-bit depth renderbuffer (r178: 24-bit);+ // the shadow casters are depth-tested at that precision there, so here too.+ shadowRT.depthTexture = new THREE.DepthTexture(1024, 1024, THREE.UnsignedShortType);+ const sceneRT = new THREE.WebGLRenderTarget(W, H, { count: 2, minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, depthBuffer: true, stencilBuffer: false });+ sceneRT.textures[1].type = THREE.HalfFloatType; // velocity+ sceneRT.depthTexture = new THREE.DepthTexture(W, H, THREE.FloatType);+ const rt = (w, h) => new THREE.WebGLRenderTarget(w, h, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, depthBuffer: false, stencilBuffer: false });+ const taaResult = rt(W, H), taaHistory = rt(W, H), bloomRT = rt(W, H);+ const bw = Math.max(1, Math.round(W * BLUR_SCALE)), bh = Math.max(1, Math.round(H * BLUR_SCALE));+ const blurA = rt(bw, bh), blurB = rt(bw, bh);++ // shared dynamic uniforms of the node materials+ const shared = {+ frameIndex: { value: 0 },+ resolution: { value: new THREE.Vector2(W, H) },+ previousProjectionMatrix: { value: new THREE.Matrix4() },+ spotShadowMap: { value: [shadowRT.texture] }, // sampler2D[1]+ aoMap: { value: blank },+ ...lightUniforms(data.lights, camera, shadowCamera),+ };++ // Spline's materials (one program each; the five light bars share one), created in the trace's+ // draw order so three sorts the opaque ones the same way+ const materials = {};+ // Spline sets the size inputs of its image layers once each image has loaded, after the first frame+ const firstFrameOnly = [];+ for (const id of ["p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9"]) {+ const p = data.programs[id];+ for (const name of p.materials) {+ const uniforms = { ...constUniforms(p.uniforms), previousModelViewMatrix: { value: new THREE.Matrix4() } };+ for (const u of ["frameIndex", "resolution", "previousProjectionMatrix", "directionalLights", "spotLights", "spotLightShadows", "spotLightMatrix", "hemisphereLights", "ambientLightColor", "lightProbe"]) uniforms[u] = shared[u];+ for (const [u, src] of Object.entries(p.samplers)) uniforms[u] = src === "@shadow" ? shared.spotShadowMap : src === "@blank" ? shared.aoMap : { value: textures[src] };+ materials[name] = new THREE.RawShaderMaterial({+ name, glslVersion: THREE.GLSL3,+ vertexShader: shaderSrc[p.vert], fragmentShader: shaderSrc[p.frag],+ uniforms, transparent: p.transparent,+ });+ for (const u of p.zeroOnFirstFrame) firstFrameOnly.push({ uniform: uniforms[u], value: uniforms[u].value });+ }+ }+ const depthMaterial = new THREE.RawShaderMaterial({+ name: "p1", glslVersion: THREE.GLSL3,+ vertexShader: shaderSrc[data.programs.p1.vert], fragmentShader: shaderSrc[data.programs.p1.frag],+ side: THREE.BackSide, blending: THREE.NoBlending,+ });++ // scene graph+ const geometries = Object.fromEntries(Object.entries(data.geometries).map(([k, v]) => [k, buildGeometry(v)]));+ const scene = new THREE.Scene();+ const nodes = new Map();+ const meshes = [];+ let mainPass = false;+ const build = (def, parent, path) => {+ let o;+ if (def.type === "Mesh") {+ o = new THREE.Mesh(geometries[def.geometry], materials[def.material]);+ o.castShadow = def.castShadow;+ o.receiveShadow = def.receiveShadow;+ const prev = new THREE.Matrix4();+ o.userData.prev = prev;+ o.onBeforeRender = (_r, _s, _c, _g, material) => {+ if (!mainPass) return;+ material.uniforms.previousModelViewMatrix.value = prev;+ material.uniformsNeedUpdate = true;+ };+ meshes.push(o);+ } else o = new THREE.Group();+ o.name = def.name;+ o.matrix.fromArray(def.matrix);+ o.matrix.decompose(o.position, o.quaternion, o.scale);+ parent.add(o);+ nodes.set(path, o);+ for (const c of def.children ?? []) build(c, o, path ? `${path}/${c.name}` : c.name);+ };+ for (const c of data.tree.children) build(c, scene, c.name);+ const motion = createMotion(nodes);++ // fullscreen passes (postprocessing's single triangle)+ const quad = new THREE.BufferGeometry();+ quad.setAttribute("position", new THREE.BufferAttribute(new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]), 3));+ quad.boundingSphere = new THREE.Sphere(new THREE.Vector3(), Infinity);+ const quadMesh = new THREE.Mesh(quad);+ quadMesh.frustumCulled = false;+ const quadScene = new THREE.Scene().add(quadMesh);+ const quadCamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);+ const pass = (id, uniforms) => new THREE.RawShaderMaterial({+ name: id, glslVersion: THREE.GLSL3,+ vertexShader: shaderSrc[data.programs[id].vert], fragmentShader: shaderSrc[data.programs[id].frag],+ uniforms: { ...constUniforms(data.programs[id].uniforms), ...uniforms },+ depthTest: false, depthWrite: false, blending: THREE.NoBlending,+ });+ const taa = pass("p10", {+ resolution: { value: new THREE.Vector2(W, H) },+ inputBuffer: { value: sceneRT.textures[0] }, historyBuffer: { value: taaHistory.texture },+ velocityBuffer: { value: sceneRT.textures[1] }, depthBuffer: { value: sceneRT.depthTexture },+ });+ const copy = pass("p11", { inputBuffer: { value: taaResult.texture } });+ const luminance = pass("p12", { inputBuffer: { value: sceneRT.textures[0] } });+ const kawase = pass("p13", {+ inputBuffer: { value: null }, kernel: { value: 0 },+ texelSize: { value: new THREE.Vector2(1 / bw, 1 / bh) }, halfTexelSize: { value: new THREE.Vector2(0.5 / bw, 0.5 / bh) },+ });+ const composite = pass("p14", { inputBuffer: { value: sceneRT.textures[0] }, e0Map: { value: bloomRT.texture } });+ const draw = (material, target) => {+ quadMesh.material = material;+ renderer.setRenderTarget(target);+ renderer.render(quadScene, quadCamera);+ };++ renderer.compile(scene, camera);+ let frame = 0;+ const render = (now) => {+ motion.step(now);+ scene.updateMatrixWorld();+ shared.frameIndex.value = frame % 16;+ for (const f of firstFrameOnly) f.uniform.value = frame === 0 ? [0, 0, f.value[2]] : f.value;++ // 1. spot-light shadow map (three's RGBA-packed depth, back faces, drawn in scene order as+ // r149's WebGLShadowMap does)+ mainPass = false;+ scene.overrideMaterial = depthMaterial;+ renderer.sortObjects = false;+ renderer.setRenderTarget(shadowRT);+ renderer.setClearColor(0xffffff, 1);+ renderer.clear(true, true, false);+ renderer.render(scene, shadowCamera);+ renderer.sortObjects = true;+ scene.overrideMaterial = null;++ // 2. scene → colour + velocity + depth+ mainPass = true;+ renderer.setRenderTarget(sceneRT);+ renderer.setClearColor(0x000000, 0);+ renderer.clear(true, true, false);+ renderer.render(scene, camera);+ mainPass = false;+ for (const m of meshes) m.userData.prev.copy(m.modelViewMatrix);+ shared.previousProjectionMatrix.value = camera.projectionMatrix;++ // 3. TAA resolve, history copy, result back into the scene buffer+ draw(taa, taaResult);+ draw(copy, taaHistory);+ draw(copy, sceneRT);++ // 4. bloom: luminance, Kawase blur (ping-pong at half size, last pass back to full size)+ draw(luminance, bloomRT);+ let input = bloomRT;+ KAWASE_KERNELS.forEach((k, i) => {+ const last = i === KAWASE_KERNELS.length - 1;+ const target = last ? bloomRT : i % 2 === 0 ? blurA : blurB;+ kawase.uniforms.kernel.value = k;+ kawase.uniforms.inputBuffer.value = input.texture;+ draw(kawase, target);+ input = target;+ });++ // 5. screen-blend the bloom over the scene, onto the canvas+ draw(composite, null);+ frame++;+ requestAnimationFrame(render);+ };+ // Spline draws its first frame as soon as the scene is ready, then keeps going on rAF.+ render(performance.now());+}++main();diff --git a/site/public/examples/resend-cube/src/motion.js b/site/public/examples/resend-cube/src/motion.jsnew file mode 100644index 0000000..f8c6399--- /dev/null+++ b/site/public/examples/resend-cube/src/motion.js@@ -0,0 +1,101 @@+// The cube's motion, as read from the trace of resend.com's Spline scene (per-frame values of+// Cube.rotation.x, rotation.rotation.y, section_3.rotation.x and section.rotation.x over 25 s).+//+// - The whole cube turns 359° in 10 s, linearly, and loops: the outer group "Cube" about its x axis+// and the inner group "rotation" about its y axis, by the same angle.+// - The left slice ("section 3") turns half a revolution about x in 2 s, 1.5 s after the start and+// then every 5 s, alternately to −π and back to 0.+// - The right slice ("section") does the same in 3 s, 2.5 s after the start and then every 8 s.+// - Both slice turns ease with cubic-bezier(0.42, 0, 0.58, 1) (fits the trace to 3e-5 of a turn).+// - Everything starts on the third rendered frame. Spline advances its clock by the frame delta in+// milliseconds and wraps the loop with `t -= duration`; both are copied here, which reproduces the+// frame on which resend.com's loop shows its end pose.++import { Euler } from "three";++const DEG = Math.PI / 180;+const SPIN_MS = 10000;+const SPIN_END = -359 * DEG;++const SLICES = [+ { path: "Cube/rotation/section 3", delay: 1500, every: 5000, duration: 2000 },+ { path: "Cube/rotation/section", delay: 2500, every: 8000, duration: 3000 },+];++// cubic-bezier solver (Newton–Raphson with a bisection fallback, as in the common bezier-easing code).+function bezier(x1, y1, x2, y2) {+ const ax = 1 - 3 * x2 + 3 * x1, bx = 3 * x2 - 6 * x1, cx = 3 * x1;+ const ay = 1 - 3 * y2 + 3 * y1, by = 3 * y2 - 6 * y1, cy = 3 * y1;+ const sx = (t) => ((ax * t + bx) * t + cx) * t;+ const sy = (t) => ((ay * t + by) * t + cy) * t;+ const dx = (t) => (3 * ax * t + 2 * bx) * t + cx;+ return (x) => {+ if (x <= 0) return 0;+ if (x >= 1) return 1;+ let t = x;+ for (let i = 0; i < 8; i++) {+ const e = sx(t) - x;+ if (Math.abs(e) < 1e-12) return sy(t);+ const d = dx(t);+ if (Math.abs(d) < 1e-9) break;+ t -= e / d;+ }+ let lo = 0, hi = 1;+ t = x;+ for (let i = 0; i < 64 && hi - lo > 1e-14; i++) {+ if (sx(t) < x) lo = t; else hi = t;+ t = (lo + hi) / 2;+ }+ return sy(t);+ };+}+const easeInOut = bezier(0.42, 0, 0.58, 1);++// Half-turn legs: 0 → −π, hold, −π → 0, hold, …+function slice(t, { delay, every, duration }) {+ if (t < delay) return 0;+ const n = Math.floor((t - delay) / every);+ const local = t - delay - n * every;+ const p = local < duration ? easeInOut(local / duration) : 1;+ const from = n % 2 === 0 ? 0 : -Math.PI;+ const to = n % 2 === 0 ? -Math.PI : 0;+ return from + (to - from) * p;+}++export function createMotion(nodes) {+ const cube = nodes.get("Cube");+ const inner = nodes.get("Cube/rotation");+ const slices = SLICES.map((s) => ({ ...s, node: nodes.get(s.path) }));+ let frame = 0;+ let last = null;+ let elapsed = 0; // ms since the motion started+ let spin = 0; // ms into the current spin loop++ // Spline writes rotations through the quaternion, so three re-derives the Euler angles from it+ // (they wrap at ±π, and the y spin shows up as x = z = ±π past a quarter turn), as in the trace.+ const euler = new Euler();+ const turn = (node, x, y) => node.quaternion.setFromEuler(euler.set(x, y, 0));+ const apply = (angle) => {+ turn(cube, angle, 0);+ turn(inner, 0, angle);+ for (const s of slices) turn(s.node, slice(elapsed, s), 0);+ };+ apply(0);++ return {+ // Call once per rendered frame with the rAF timestamp (ms).+ step(now) {+ const dt = last === null ? 0 : now - last;+ last = now;+ if (frame++ < 3) return apply(0); // frames 0–2 show the start pose+ elapsed += dt;+ spin += dt;+ let angle;+ if (spin >= SPIN_MS) {+ angle = SPIN_END;+ spin -= SPIN_MS;+ } else angle = (SPIN_END * spin) / SPIN_MS;+ apply(angle);+ },+ };+}diff --git a/site/public/media/liveblocks-comments/compare.mp4 b/site/public/media/liveblocks-comments/compare.mp4new file mode 100644index 0000000..4f4d847Binary files /dev/null and b/site/public/media/liveblocks-comments/compare.mp4 differdiff --git a/site/public/media/liveblocks-comments/poster.webp b/site/public/media/liveblocks-comments/poster.webpnew file mode 100644index 0000000..d5434a1Binary files /dev/null and b/site/public/media/liveblocks-comments/poster.webp differdiff --git a/site/public/media/reactbits-fading-stars/compare.mp4 b/site/public/media/reactbits-fading-stars/compare.mp4new file mode 100644index 0000000..8fcb2d8Binary files /dev/null and b/site/public/media/reactbits-fading-stars/compare.mp4 differdiff --git a/site/public/media/reactbits-fading-stars/poster.webp b/site/public/media/reactbits-fading-stars/poster.webpnew file mode 100644index 0000000..5b09c74Binary files /dev/null and b/site/public/media/reactbits-fading-stars/poster.webp differdiff --git a/site/public/media/resend-cube/compare.mp4 b/site/public/media/resend-cube/compare.mp4new file mode 100644index 0000000..12c5285Binary files /dev/null and b/site/public/media/resend-cube/compare.mp4 differdiff --git a/site/public/media/resend-cube/poster.webp b/site/public/media/resend-cube/poster.webpnew file mode 100644index 0000000..3001fb1Binary files /dev/null and b/site/public/media/resend-cube/poster.webp differdiff --git a/site/scripts/record-media.ts b/site/scripts/record-media.tsindex 4388688..7057b08 100644--- a/site/scripts/record-media.ts+++ b/site/scripts/record-media.ts@@ -22,6 +22,7 @@ type Clip = {select: string[]; // what to film: the crop is these elements' union plus PAD, on both pagestrigger: "scroll" | "hover"; // scroll: the entrance as they scroll into view; hover: HOVER_PATH over the firstpin?: number; // Math.random returns this from just before the trigger, so random picks come out the same on both pages+ sync?: boolean; // the motion is a loop each page starts when its scene is ready, not on the trigger: line the takes up by their frames};const bento = (card: string) => `.modular-solutions-bento__card-${card}`;@@ -31,6 +32,10 @@ const CLIPS: Clip[] = [{ slug: "stripe-issuing", reference: "https://stripe.com/", clone: "/examples/stripe-bento/", select: [bento("issuing")], trigger: "hover" },{ slug: "stripe-crypto", reference: "https://stripe.com/", clone: "/examples/stripe-bento/", select: [bento("crypto")], trigger: "hover" },{ slug: "workos-atlas", reference: "https://workos.com/atlas", clone: "/examples/workos-atlas/", select: ['[aria-label^="Atlas reaching out"]'], trigger: "scroll", pin: 0.37 },+ { slug: "liveblocks-comments", reference: "https://liveblocks.io/comments", clone: "/examples/liveblocks-comments/", select: ['.select-none[class*="aspect-1208/770"]'], trigger: "scroll", sync: true },+ { slug: "resend-cube", reference: "https://resend.com/", clone: "/examples/resend-cube/", select: [".animate-webgl-scale-in-fade"], trigger: "scroll", sync: true },+ // the preview is an iframe on the original; one selector list finds it there and the copy's canvas here+ { slug: "reactbits-fading-stars", reference: "https://pro.reactbits.dev/docs/components/fading-stars?browse=components", clone: "/examples/reactbits-fading-stars/", select: ['iframe[title="Preview"], .fading-stars'], trigger: "hover" },];const { values: args } = parseArgs({@@ -56,6 +61,7 @@ const HOVER_MS = 5000;const COMPARE_WIDTH = 1120; // compare.mp4, in px: 2x the page columnconst COMPARE_GAP = 24;const COMPARE_HOLD_MS = 1000; // the last frame is held this long before the loop starts again+const SYNC_MS = 4000; // with `sync`, how far apart the two loops may be; the takes run this much longer// Pointer path, as fractions of the element's box: in from the left, hold, across, hold, out to the// right. Times in ms from the start of the clip.const HOVER_PATH: [number, number, number][] = [@@ -189,7 +195,7 @@ async function film(browser: Browser, clip: Clip, side: Side): Promise<Take> {await scrollIn();await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));start = Date.now(); // the elements are on screen, not yet mounted- ms = ENTRANCE_MS + 2500;+ ms = ENTRANCE_MS + 2500 + (clip.sync ? SYNC_MS : 0);await sleep(ms);} else {// Mouse input lands in the zoomed window's coordinates, so CSS px are scaled up to match.@@ -257,6 +263,33 @@ function contentAppears(file: string): number {throw new Error(`no content appeared in ${file}`);}+// For `sync` clips: how many ms the reference's loop runs behind the clone's, found by sliding one take+// along the other and keeping the shift where the frames differ least. Negative when the clone is behind.+function loopOffset(reference: string, clone: string): number {+ const [w, h] = dims(reference);+ const sw = 96;+ const sh = Math.round((h / w) * sw / 2) * 2;+ const gray = (file: string) => run("ffmpeg", ["-v", "error", "-i", file, "-vf", `scale=${sw}:${sh},format=gray`, "-f", "rawvideo", "-"]);+ const ref = gray(reference);+ const cl = gray(clone);+ const size = sw * sh;+ const n = Math.min(ref.length, cl.length) / size;+ const max = Math.round((SYNC_MS / 1000) * FPS);+ const from = Math.round(0.5 * FPS);+ const span = n - from - max; // frames compared at every shift+ let best = { k: 0, d: Infinity };+ for (let k = -max; k <= max; k++) {+ let d = 0;+ for (let i = from; i < from + span; i += 2) {+ const a = (i + Math.max(0, k)) * size;+ const b = (i + Math.max(0, -k)) * size;+ for (let p = 0; p < size; p += 3) d += Math.abs(ref[a + p] - cl[b + p]);+ }+ if (d < best.d) best = { k, d };+ }+ return (best.k / FPS) * 1000;+}+// The original and the clone in one file, so the page never has to keep two videos in step: side by// side, or stacked when the recordings are wider than tall.function compareMp4(panels: { file: string; from: number }[], ms: number, out: string) {@@ -338,14 +371,22 @@ for (const clip of CLIPS) {if (take!.small) throw new Error(`${clip.slug} ${side}: frames kept coming out at 1x`);const file = join(WORK, `${clip.slug}-${side}.mkv`);master(take!, file);- takes[side] = { file, appear: clip.trigger === "scroll" ? contentAppears(file) : 0 };+ takes[side] = { file, appear: clip.trigger === "scroll" && !clip.sync ? contentAppears(file) : 0 };}const lead = Math.min(ENTRANCE_LEAD_MS, ...SIDES.map((s) => takes[s].appear));const ms = clip.trigger === "scroll" ? ENTRANCE_MS : HOVER_MS;for (const side of SIDES) masters[`${clip.slug}-${side}`] = { file: takes[side].file, from: takes[side].appear - lead };+ if (clip.sync) {+ // start the take that runs behind later, by as much as it runs behind+ const behind = loopOffset(takes.reference.file, takes.clone.file);+ masters[`${clip.slug}-reference`].from += Math.max(0, behind);+ masters[`${clip.slug}-clone`].from += Math.max(0, -behind);+ console.log(`${clip.slug}: the original's loop runs ${behind.toFixed(0)} ms behind the copy's`);+ }compareMp4(SIDES.map((side) => masters[`${clip.slug}-${side}`]), ms, join(out, "compare.mp4"));// At rest: the end of an entrance, the start of a hover.- poster(takes.clone.file, clip.trigger === "scroll" ? takes.clone.appear - lead + ms - 100 : 0, join(out, "poster.webp"));+ const cloneFrom = masters[`${clip.slug}-clone`].from;+ poster(takes.clone.file, clip.trigger === "scroll" ? cloneFrom + ms - 100 : cloneFrom, join(out, "poster.webp"));}if (masters["stripe-bento-reference"]) {diff --git a/site/scripts/vendor-examples.mjs b/site/scripts/vendor-examples.mjsindex 0896216..7656a2d 100644--- a/site/scripts/vendor-examples.mjs+++ b/site/scripts/vendor-examples.mjs@@ -17,3 +17,11 @@ cpSync(nm("three", "LICENSE"), join(vendor, "three", "LICENSE"));cpSync(nm("@fontsource-variable", "inter", "files", "inter-latin-wght-normal.woff2"), join(vendor, "fonts", "inter-latin-wght-normal.woff2"));cpSync(nm("@fontsource-variable", "inter", "LICENSE"), join(vendor, "fonts", "LICENSE-inter.txt"));console.log("vendored three.js + Inter into", vendor);++// resend-cube: three.js only (no addons, no fonts).+const resendVendor = join(root, "public", "examples", "resend-cube", "vendor");+rmSync(resendVendor, { recursive: true, force: true });+mkdirSync(join(resendVendor, "three"), { recursive: true });+for (const f of ["three.module.js", "three.core.js"]) cpSync(nm("three", "build", f), join(resendVendor, "three", f));+cpSync(nm("three", "LICENSE"), join(resendVendor, "three", "LICENSE"));+console.log("vendored three.js into", resendVendor);diff --git a/site/src/app/page.tsx b/site/src/app/page.tsxindex de2c15e..9c9d390 100644--- a/site/src/app/page.tsx+++ b/site/src/app/page.tsx@@ -195,8 +195,8 @@ export default function Home() {<Section id="examples" n={5} title="Examples"><p>- Hover a clerk.com card to play it, or on a phone just scroll to it. The copies use the free Geist font, so only the lettering differs. For stripe.com and workos.com, the original plays on the left and the copy on the- right.+ Hover a clerk.com card to play it, or on a phone just scroll to it. The copies use the free Geist font, so only the lettering differs. For the others, the original plays on the left or on top, and the copy next to it or+ below.</p><nav className="strip" aria-label="Examples">{examples.map((e) => (@@ -214,7 +214,16 @@ export default function Home() {</h3><Details e={e} /></div>- {e.show.kind === "video" ? (+ {e.show.kind === "video" && e.show.height > e.show.width ? (+ // wider than tall: the two takes are stacked+ <figure className="figure">+ <CompareVideo src={media(e.slug, "compare.mp4")} width={e.show.width} height={e.show.height} label={`${e.title}: ${e.source.name} on top, the copy below`} />+ <figcaption className="figure__caption">+ <span>{e.source.name} on top, the copy below</span>+ <a href={e.live} target="_blank" rel="noreferrer">try it live ↗</a>+ </figcaption>+ </figure>+ ) : e.show.kind === "video" ? (<figure className="figure"><CompareVideo src={media(e.slug, "compare.mp4")} width={e.show.width} height={e.show.height} label={`${e.title}: ${e.source.name} on the left, the copy on the right`} /><figcaption className="figure__caption figure__caption--pair">@@ -247,7 +256,10 @@ export default function Home() {<span><a href={REPO}>GitHub</a> · MIT licence · built with reanimate</span>- <span>The examples recreate parts of stripe.com, workos.com and clerk.com as a study of the technique. Not affiliated with or endorsed by Stripe, WorkOS or Clerk. All trademarks belong to their owners.</span>+ <span>+ The examples recreate parts of stripe.com, workos.com, clerk.com, liveblocks.io, resend.com and pro.reactbits.dev as a study of the technique. Not affiliated with or endorsed by Stripe, WorkOS, Clerk, Liveblocks, Resend or React Bits. All trademarks belong+ to their owners.+ </span></footer></main></div>diff --git a/site/src/examples.ts b/site/src/examples.tsindex dd28dc4..5dae8c6 100644--- a/site/src/examples.ts+++ b/site/src/examples.ts@@ -83,6 +83,51 @@ export const examples: Example[] = [["Links", "draw-in, ring and fade of each connection", "≤ 10 ms"],],},+ {+ slug: "liveblocks-comments",+ title: "Comments in any app",+ source: { name: "liveblocks.io", url: "https://liveblocks.io/comments" },+ about:+ "An app window switches every 6 s between a text editor, a media player, a whiteboard, a website and a video editor. Each time, the drawing blurs away and the next one springs in. A second later the comment thread fades over, the panel glides to its new spot and the colours change.",+ note: "liveblocks.io sets its text in Suisse Int’l, a paid font, so the copy uses Inter spaced to the same widths. Lines break in the same places; the letters differ.",+ show: { kind: "video", width: 560, height: 732 },+ live: "/examples/liveblocks-comments/",+ results: [+ ["Frame match", "pixels that differ over the 30 s loop", "0.55 %"],+ ["Panel glide", "position and size, all five changes", "≤ 0.7 px"],+ ["Timing", "start and end of every change", "0 ms"],+ ],+ },+ {+ slug: "resend-cube",+ title: "Hero cube",+ source: { name: "resend.com", url: "https://resend.com/" },+ about:+ "A dark Rubik’s cube fades in and turns slowly on two axes, once every 10 s. Its left slice makes a half-turn every 5 s and its right slice every 8 s, while bars of light leave striped shadows across the faces.",+ note: "This is resend.com’s own Spline scene, read from the page and drawn with plain three.js: the same geometry, textures, shaders and post-processing, so it draws the same pixels.",+ show: { kind: "video", width: 560, height: 968 },+ live: "/examples/resend-cube/",+ results: [+ ["Motion", "every rotation, frame by frame over 25 s", "0 differ"],+ ["Frame match", "pixels that differ over 6 s, entrance included", "0.11 %"],+ ["Same pixels", "frames after the entrance, within one frame", "265 of 266"],+ ],+ },+ {+ slug: "reactbits-fading-stars",+ title: "Fading stars",+ source: { name: "pro.reactbits.dev", url: "https://pro.reactbits.dev/docs/components/fading-stars" },+ about:+ "Violet stars rise from below the frame in a wide fan, each on a trail that fades behind it, and speed up as they climb. Move the pointer over them and the flow surges, then settles over about a second. Click and 64 stars lift off together as an arc.",+ note: "The stars come from the component’s own random generator with a fixed seed, so they are the same on every load. The copy uses the same generator: started on the same frame, it draws the same pixels.",+ show: { kind: "video", width: 560, height: 640 },+ live: "/examples/reactbits-fading-stars/",+ results: [+ ["Frame match", "canvas pixels that differ over 4 s, at 1x and 2x", "0 px"],+ ["Pointer", "pixels that differ during a click burst and a fast drag", "0.014 %"],+ ["Timing", "star clock and film grain, every rendered frame", "0 ms"],+ ],+ },{slug: "clerk-mfa",title: "Multifactor authentication",