angular-three-postprocessing 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, Component, input, Directive, computed, viewChild, effect, untracked } from '@angular/core';
|
|
3
|
-
import { injectStore, pick, extend, getInstanceState, beforeRender, NgtArgs, vector2, omit, resolveRef,
|
|
2
|
+
import { inject, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, Component, input, Directive, computed, viewChild, effect, DestroyRef, untracked } from '@angular/core';
|
|
3
|
+
import { injectStore, pick, extend, getInstanceState, beforeRender, NgtArgs, vector3, vector2, omit, resolveRef, is, NgtSelectionApi, loaderResource } from 'angular-three';
|
|
4
4
|
import { createNoopInjectionToken } from 'ngxtension/create-injection-token';
|
|
5
5
|
import { mergeInputs } from 'ngxtension/inject-inputs';
|
|
6
|
-
import { EffectAttribute, EffectComposer, RenderPass, NormalPass, DepthDownsamplingPass, Effect, EffectPass, Pass, BloomEffect, BlendFunction, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect,
|
|
6
|
+
import { EffectAttribute, EffectComposer, RenderPass, NormalPass, DepthDownsamplingPass, Effect, EffectPass, Pass, DepthPickingPass, CopyPass, DepthOfFieldEffect, BloomEffect, BlendFunction, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, MaskFunction, DotScreenEffect, FXAAEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, LUT3DEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, SSAOEffect, ShockWaveEffect, SMAAEffect, TextureEffect, TiltShiftEffect, ToneMappingEffect, VignetteEffect } from 'postprocessing';
|
|
7
7
|
import * as THREE from 'three';
|
|
8
8
|
import { Group } from 'three';
|
|
9
9
|
import { isWebGL2Available } from 'three-stdlib';
|
|
@@ -107,7 +107,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
107
107
|
type: Directive
|
|
108
108
|
}], propDecorators: { blendFunction: [{ type: i0.Input, args: [{ isSignal: true, alias: "blendFunction", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }] } });
|
|
109
109
|
|
|
110
|
-
const defaultOptions$
|
|
110
|
+
const defaultOptions$6 = {
|
|
111
111
|
enabled: true,
|
|
112
112
|
renderPriority: 1,
|
|
113
113
|
autoClear: true,
|
|
@@ -153,7 +153,7 @@ class NgtpEffectComposer {
|
|
|
153
153
|
* Configuration options for the effect composer.
|
|
154
154
|
* @see NgtpEffectComposerOptions
|
|
155
155
|
*/
|
|
156
|
-
this.options = input(defaultOptions$
|
|
156
|
+
this.options = input(defaultOptions$6, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$6) });
|
|
157
157
|
this.store = injectStore();
|
|
158
158
|
this.depthBuffer = pick(this.options, 'depthBuffer');
|
|
159
159
|
this.stencilBuffer = pick(this.options, 'stencilBuffer');
|
|
@@ -230,6 +230,8 @@ class NgtpEffectComposer {
|
|
|
230
230
|
* Can be used to access the composer directly for advanced use cases.
|
|
231
231
|
*/
|
|
232
232
|
this.effectComposer = pick(this.composerData, 'composer');
|
|
233
|
+
this.normalPass = pick(this.composerData, 'normalPass');
|
|
234
|
+
this.downSamplingPass = pick(this.composerData, 'downSamplingPass');
|
|
233
235
|
extend({ Group });
|
|
234
236
|
// NOTE: Disable tone mapping because threejs disallows tonemapping on render targets
|
|
235
237
|
effect((onCleanup) => {
|
|
@@ -447,7 +449,7 @@ class ASCIIEffect extends Effect {
|
|
|
447
449
|
return texture;
|
|
448
450
|
}
|
|
449
451
|
}
|
|
450
|
-
const defaultOptions$
|
|
452
|
+
const defaultOptions$5 = {
|
|
451
453
|
font: 'arial',
|
|
452
454
|
characters: ` .:,'-^=*+?!|0#X%WM@`,
|
|
453
455
|
fontSize: 54,
|
|
@@ -474,7 +476,7 @@ class NgtpASCII {
|
|
|
474
476
|
* Configuration options for the ASCII effect.
|
|
475
477
|
* @see ASCIIEffectOptions
|
|
476
478
|
*/
|
|
477
|
-
this.options = input(defaultOptions$
|
|
479
|
+
this.options = input(defaultOptions$5, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$5) });
|
|
478
480
|
/** The underlying ASCIIEffect instance */
|
|
479
481
|
this.effect = computed(() => new ASCIIEffect(this.options()), ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
480
482
|
effect((onCleanup) => {
|
|
@@ -500,6 +502,139 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
500
502
|
}]
|
|
501
503
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
502
504
|
|
|
505
|
+
const defaultOptions$4 = {
|
|
506
|
+
mouse: false,
|
|
507
|
+
manual: false,
|
|
508
|
+
smoothTime: 0.25,
|
|
509
|
+
};
|
|
510
|
+
class NgtpAutofocus {
|
|
511
|
+
constructor() {
|
|
512
|
+
this.options = input(defaultOptions$4, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions$4) });
|
|
513
|
+
this.effectComposer = inject(NgtpEffectComposer);
|
|
514
|
+
this.store = injectStore();
|
|
515
|
+
this.hitpoint = new THREE.Vector3(0, 0, 0);
|
|
516
|
+
this.ndc = new THREE.Vector3(0, 0, 0);
|
|
517
|
+
this.depthPickingPass = new DepthPickingPass();
|
|
518
|
+
this.copyPass = new CopyPass();
|
|
519
|
+
this.debugSize = pick(this.options, 'debug');
|
|
520
|
+
this.hitpointMeshRef = viewChild('hitpointMesh', ...(ngDevMode ? [{ debugName: "hitpointMeshRef" }] : []));
|
|
521
|
+
this.targetMeshRef = viewChild('targetMesh', ...(ngDevMode ? [{ debugName: "targetMeshRef" }] : []));
|
|
522
|
+
this.target = vector3(this.options, 'target', true);
|
|
523
|
+
this.dofEffect = computed(() => {
|
|
524
|
+
const [camera, options] = [this.effectComposer.camera(), this.options()];
|
|
525
|
+
const { target: _, mouse: __, debug: ___, manual: ____, smoothTime: _____, ...dofOptions } = options;
|
|
526
|
+
const dof = new DepthOfFieldEffect(camera, dofOptions);
|
|
527
|
+
dof.target = new THREE.Vector3().copy(this.hitpoint);
|
|
528
|
+
return dof;
|
|
529
|
+
}, ...(ngDevMode ? [{ debugName: "dofEffect" }] : []));
|
|
530
|
+
// add passes to composer
|
|
531
|
+
effect((onCleanup) => {
|
|
532
|
+
const composer = this.effectComposer.effectComposer();
|
|
533
|
+
if (!composer)
|
|
534
|
+
return;
|
|
535
|
+
composer.addPass(this.depthPickingPass);
|
|
536
|
+
composer.addPass(this.copyPass);
|
|
537
|
+
onCleanup(() => {
|
|
538
|
+
composer.removePass(this.depthPickingPass);
|
|
539
|
+
composer.removePass(this.copyPass);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
inject(DestroyRef).onDestroy(() => {
|
|
543
|
+
this.depthPickingPass.dispose();
|
|
544
|
+
this.copyPass.dispose();
|
|
545
|
+
});
|
|
546
|
+
// cleanup dof effect
|
|
547
|
+
effect((onCleanup) => {
|
|
548
|
+
const dof = this.dofEffect();
|
|
549
|
+
onCleanup(() => dof.dispose());
|
|
550
|
+
});
|
|
551
|
+
beforeRender(({ delta }) => {
|
|
552
|
+
const dof = this.dofEffect();
|
|
553
|
+
if (!dof?.target)
|
|
554
|
+
return;
|
|
555
|
+
const { mouse: followMouse, smoothTime, manual } = this.options();
|
|
556
|
+
if (manual)
|
|
557
|
+
return;
|
|
558
|
+
const target = this.target();
|
|
559
|
+
const camera = this.effectComposer.camera();
|
|
560
|
+
if (target) {
|
|
561
|
+
this.hitpoint.copy(target);
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
const { x, y } = followMouse ? this.store.snapshot.pointer : { x: 0, y: 0 };
|
|
565
|
+
this.ndc.x = x;
|
|
566
|
+
this.ndc.y = y;
|
|
567
|
+
this.depthPickingPass.readDepth(this.ndc).then((depth) => {
|
|
568
|
+
this.ndc.z = depth * 2.0 - 1.0;
|
|
569
|
+
const hit = 1 - this.ndc.z > 0.0000001;
|
|
570
|
+
if (hit) {
|
|
571
|
+
const unprojected = this.ndc.clone().unproject(camera);
|
|
572
|
+
this.hitpoint.copy(unprojected);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if (smoothTime && smoothTime > 0 && delta > 0) {
|
|
577
|
+
easing.damp3(dof.target, this.hitpoint, smoothTime, delta);
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
dof.target.copy(this.hitpoint);
|
|
581
|
+
}
|
|
582
|
+
const hitpointMesh = this.hitpointMeshRef()?.nativeElement;
|
|
583
|
+
if (hitpointMesh)
|
|
584
|
+
hitpointMesh.position.copy(this.hitpoint);
|
|
585
|
+
const targetMesh = this.targetMeshRef()?.nativeElement;
|
|
586
|
+
if (targetMesh)
|
|
587
|
+
targetMesh.position.copy(dof.target);
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpAutofocus, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
591
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: NgtpAutofocus, isStandalone: true, selector: "ngtp-autofocus", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "hitpointMeshRef", first: true, predicate: ["hitpointMesh"], descendants: true, isSignal: true }, { propertyName: "targetMeshRef", first: true, predicate: ["targetMesh"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
592
|
+
<ngt-primitive *args="[dofEffect()]" [dispose]="null" />
|
|
593
|
+
@if (debugSize(); as debugSize) {
|
|
594
|
+
<ngt-mesh #hitpointMesh>
|
|
595
|
+
<ngt-sphere-geometry *args="[debugSize, 16, 16]" />
|
|
596
|
+
<ngt-mesh-basic-material [color]="'#00ff00'" [opacity]="1" [transparent]="true" [depthWrite]="false" />
|
|
597
|
+
</ngt-mesh>
|
|
598
|
+
<ngt-mesh #targetMesh>
|
|
599
|
+
<ngt-sphere-geometry *args="[debugSize / 2, 16, 16]" />
|
|
600
|
+
<ngt-mesh-basic-material
|
|
601
|
+
[color]="'#00ff00'"
|
|
602
|
+
[opacity]="0.5"
|
|
603
|
+
[transparent]="true"
|
|
604
|
+
[depthWrite]="false"
|
|
605
|
+
/>
|
|
606
|
+
</ngt-mesh>
|
|
607
|
+
}
|
|
608
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
609
|
+
}
|
|
610
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpAutofocus, decorators: [{
|
|
611
|
+
type: Component,
|
|
612
|
+
args: [{
|
|
613
|
+
selector: 'ngtp-autofocus',
|
|
614
|
+
template: `
|
|
615
|
+
<ngt-primitive *args="[dofEffect()]" [dispose]="null" />
|
|
616
|
+
@if (debugSize(); as debugSize) {
|
|
617
|
+
<ngt-mesh #hitpointMesh>
|
|
618
|
+
<ngt-sphere-geometry *args="[debugSize, 16, 16]" />
|
|
619
|
+
<ngt-mesh-basic-material [color]="'#00ff00'" [opacity]="1" [transparent]="true" [depthWrite]="false" />
|
|
620
|
+
</ngt-mesh>
|
|
621
|
+
<ngt-mesh #targetMesh>
|
|
622
|
+
<ngt-sphere-geometry *args="[debugSize / 2, 16, 16]" />
|
|
623
|
+
<ngt-mesh-basic-material
|
|
624
|
+
[color]="'#00ff00'"
|
|
625
|
+
[opacity]="0.5"
|
|
626
|
+
[transparent]="true"
|
|
627
|
+
[depthWrite]="false"
|
|
628
|
+
/>
|
|
629
|
+
</ngt-mesh>
|
|
630
|
+
}
|
|
631
|
+
`,
|
|
632
|
+
imports: [NgtArgs],
|
|
633
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
634
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
635
|
+
}]
|
|
636
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], hitpointMeshRef: [{ type: i0.ViewChild, args: ['hitpointMesh', { isSignal: true }] }], targetMeshRef: [{ type: i0.ViewChild, args: ['targetMesh', { isSignal: true }] }] } });
|
|
637
|
+
|
|
503
638
|
/**
|
|
504
639
|
* Angular component that applies a bloom postprocessing effect to the scene.
|
|
505
640
|
*
|
|
@@ -1272,49 +1407,376 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
1272
1407
|
*/
|
|
1273
1408
|
const LensFlareShader = {
|
|
1274
1409
|
fragmentShader: /* language=glsl glsl */ `
|
|
1410
|
+
uniform float time;
|
|
1411
|
+
uniform vec2 lensPosition;
|
|
1412
|
+
uniform vec2 screenRes;
|
|
1413
|
+
uniform vec3 colorGain;
|
|
1414
|
+
uniform float starPoints;
|
|
1415
|
+
uniform float glareSize;
|
|
1416
|
+
uniform float flareSize;
|
|
1417
|
+
uniform float flareSpeed;
|
|
1418
|
+
uniform float flareShape;
|
|
1419
|
+
uniform float haloScale;
|
|
1420
|
+
uniform float opacity;
|
|
1421
|
+
uniform bool animated;
|
|
1422
|
+
uniform bool anamorphic;
|
|
1423
|
+
uniform bool enabled;
|
|
1424
|
+
uniform bool secondaryGhosts;
|
|
1425
|
+
uniform bool starBurst;
|
|
1426
|
+
uniform float ghostScale;
|
|
1427
|
+
uniform bool aditionalStreaks;
|
|
1428
|
+
uniform sampler2D lensDirtTexture;
|
|
1429
|
+
vec2 vTexCoord;
|
|
1430
|
+
|
|
1431
|
+
float rand(float n){return fract(sin(n) * 43758.5453123);}
|
|
1432
|
+
|
|
1433
|
+
float noise(float p){
|
|
1434
|
+
float fl = floor(p);
|
|
1435
|
+
float fc = fract(p);
|
|
1436
|
+
return mix(rand(fl),rand(fl + 1.0), fc);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
vec3 hsv2rgb(vec3 c)
|
|
1440
|
+
{
|
|
1441
|
+
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
1442
|
+
vec3 p = abs(fract(c.xxx + k.xyz) * 6.0 - k.www);
|
|
1443
|
+
return c.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
float saturate(float x)
|
|
1447
|
+
{
|
|
1448
|
+
return clamp(x, 0.,1.);
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
vec2 rotateUV(vec2 uv, float rotation)
|
|
1452
|
+
{
|
|
1453
|
+
return vec2(
|
|
1454
|
+
cos(rotation) * uv.x + sin(rotation) * uv.y,
|
|
1455
|
+
cos(rotation) * uv.y - sin(rotation) * uv.x
|
|
1456
|
+
);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
vec3 drawflare(vec2 p, float intensity, float rnd, float speed, int id)
|
|
1460
|
+
{
|
|
1461
|
+
float flarehueoffset = (1. / 32.) * float(id) * 0.1;
|
|
1462
|
+
float lingrad = distance(vec2(0.), p);
|
|
1463
|
+
float expgrad = 1. / exp(lingrad * (fract(rnd) * 0.66 + 0.33));
|
|
1464
|
+
vec3 colgrad = hsv2rgb(vec3( fract( (expgrad * 8.) + speed * flareSpeed + flarehueoffset), pow(1.-abs(expgrad*2.-1.), 0.45), 20.0 * expgrad * intensity));
|
|
1465
|
+
|
|
1466
|
+
float internalStarPoints;
|
|
1467
|
+
|
|
1468
|
+
if(anamorphic){
|
|
1469
|
+
internalStarPoints = 1.0;
|
|
1470
|
+
} else{
|
|
1471
|
+
internalStarPoints = starPoints;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
float blades = length(p * flareShape * sin(internalStarPoints * atan(p.x, p.y)));
|
|
1475
|
+
|
|
1476
|
+
float comp = pow(1.-saturate(blades), ( anamorphic ? 100. : 12.));
|
|
1477
|
+
comp += saturate(expgrad-0.9) * 3.;
|
|
1478
|
+
comp = pow(comp * expgrad, 8. + (1.-intensity) * 5.);
|
|
1479
|
+
|
|
1480
|
+
if(flareSpeed > 0.0){
|
|
1481
|
+
return vec3(comp) * colgrad;
|
|
1482
|
+
} else{
|
|
1483
|
+
return vec3(comp) * flareSize * 15.;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
float dist(vec3 a, vec3 b) { return abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z); }
|
|
1488
|
+
|
|
1489
|
+
vec3 saturate(vec3 x)
|
|
1490
|
+
{
|
|
1491
|
+
return clamp(x, vec3(0.0), vec3(1.0));
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
float glare(vec2 uv, vec2 pos, float size)
|
|
1495
|
+
{
|
|
1496
|
+
vec2 main;
|
|
1497
|
+
|
|
1498
|
+
if(animated){
|
|
1499
|
+
main = rotateUV(uv-pos, time * 0.1);
|
|
1500
|
+
} else{
|
|
1501
|
+
main = uv-pos;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
float ang = atan(main.y, main.x) * (anamorphic ? 1.0 : starPoints);
|
|
1505
|
+
float dist = length(main);
|
|
1506
|
+
dist = pow(dist, .9);
|
|
1507
|
+
|
|
1508
|
+
float f0 = 1.0/(length(uv-pos)*(1.0/size*16.0)+.2);
|
|
1509
|
+
|
|
1510
|
+
return f0+f0*(sin((ang))*.2 +.3);
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
float sdHex(vec2 p){
|
|
1514
|
+
p = abs(p);
|
|
1515
|
+
vec2 q = vec2(p.x*2.0*0.5773503, p.y + p.x*0.5773503);
|
|
1516
|
+
return dot(step(q.xy,q.yx), 1.0-q.yx);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
float fpow(float x, float k){
|
|
1520
|
+
return x > k ? pow((x-k)/(1.0-k),2.0) : 0.0;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
vec3 renderhex(vec2 uv, vec2 p, float s, vec3 col){
|
|
1524
|
+
uv -= p;
|
|
1525
|
+
if (abs(uv.x) < 0.2*s && abs(uv.y) < 0.2*s){
|
|
1526
|
+
return mix(vec3(0),mix(vec3(0),col,0.1 + fpow(length(uv/s),0.1)*10.0),smoothstep(0.0,0.1,sdHex(uv*20.0/s)));
|
|
1527
|
+
}
|
|
1528
|
+
return vec3(0);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
vec3 LensFlare(vec2 uv, vec2 pos)
|
|
1532
|
+
{
|
|
1533
|
+
vec2 main = uv-pos;
|
|
1534
|
+
vec2 uvd = uv*(length(uv));
|
|
1535
|
+
|
|
1536
|
+
float ang = atan(main.x,main.y);
|
|
1537
|
+
|
|
1538
|
+
float f0 = .3/(length(uv-pos)*16.0+1.0);
|
|
1539
|
+
|
|
1540
|
+
f0 = f0*(sin(noise(sin(ang*3.9-(animated ? time : 0.0) * 0.3) * starPoints))*.2 );
|
|
1541
|
+
|
|
1542
|
+
float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0;
|
|
1543
|
+
|
|
1544
|
+
float f2 = max(.9/(10.0+32.0*pow(length(uvd+0.99*pos),2.0)),.0)*0.35;
|
|
1545
|
+
float f22 = max(.9/(11.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*0.23;
|
|
1546
|
+
float f23 = max(.9/(12.0+32.0*pow(length(uvd+0.95*pos),2.0)),.0)*0.6;
|
|
1547
|
+
|
|
1548
|
+
vec2 uvx = mix(uv,uvd, 0.1);
|
|
1549
|
+
|
|
1550
|
+
float f4 = max(0.01-pow(length(uvx+0.4*pos),2.9),.0)*4.02;
|
|
1551
|
+
float f42 = max(0.0-pow(length(uvx+0.45*pos),2.9),.0)*4.1;
|
|
1552
|
+
float f43 = max(0.01-pow(length(uvx+0.5*pos),2.9),.0)*4.6;
|
|
1553
|
+
|
|
1554
|
+
uvx = mix(uv,uvd,-.4);
|
|
1555
|
+
|
|
1556
|
+
float f5 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;
|
|
1557
|
+
float f52 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
|
|
1558
|
+
float f53 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;
|
|
1559
|
+
|
|
1560
|
+
uvx = mix(uv,uvd, 2.1);
|
|
1561
|
+
|
|
1562
|
+
float f6 = max(0.01-pow(length(uvx-0.3*pos),1.61),.0)*3.159;
|
|
1563
|
+
float f62 = max(0.01-pow(length(uvx-0.325*pos),1.614),.0)*3.14;
|
|
1564
|
+
float f63 = max(0.01-pow(length(uvx-0.389*pos),1.623),.0)*3.12;
|
|
1565
|
+
|
|
1566
|
+
vec3 c = vec3(glare(uv,pos, glareSize));
|
|
1567
|
+
|
|
1568
|
+
vec2 prot;
|
|
1569
|
+
|
|
1570
|
+
if(animated){
|
|
1571
|
+
prot = rotateUV(uv - pos, (time * 0.1));
|
|
1572
|
+
} else if(anamorphic){
|
|
1573
|
+
prot = rotateUV(uv - pos, 1.570796);
|
|
1574
|
+
} else {
|
|
1575
|
+
prot = uv - pos;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
c += drawflare(prot, (anamorphic ? flareSize * 10. : flareSize), 0.1, time, 1);
|
|
1579
|
+
|
|
1580
|
+
c.r+=f1+f2+f4+f5+f6; c.g+=f1+f22+f42+f52+f62; c.b+=f1+f23+f43+f53+f63;
|
|
1581
|
+
c = c*1.3 * vec3(length(uvd)+.09);
|
|
1582
|
+
c+=vec3(f0);
|
|
1583
|
+
|
|
1584
|
+
return c;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
vec3 cc(vec3 color, float factor,float factor2)
|
|
1588
|
+
{
|
|
1589
|
+
float w = color.x+color.y+color.z;
|
|
1590
|
+
return mix(color,vec3(w)*factor,w*factor2);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
float rnd(vec2 p)
|
|
1594
|
+
{
|
|
1595
|
+
float f = fract(sin(dot(p, vec2(12.1234, 72.8392) )*45123.2));
|
|
1596
|
+
return f;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
float rnd(float w)
|
|
1600
|
+
{
|
|
1601
|
+
float f = fract(sin(w)*1000.);
|
|
1602
|
+
return f;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
float regShape(vec2 p, int N)
|
|
1606
|
+
{
|
|
1607
|
+
float f;
|
|
1608
|
+
|
|
1609
|
+
float a=atan(p.x,p.y)+.2;
|
|
1610
|
+
float b=6.28319/float(N);
|
|
1611
|
+
f=smoothstep(.5,.51, cos(floor(.5+a/b)*b-a)*length(p.xy)* 2.0 -ghostScale);
|
|
1612
|
+
|
|
1613
|
+
return f;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
vec3 circle(vec2 p, float size, float decay, vec3 color, vec3 color2, float dist, vec2 position)
|
|
1617
|
+
{
|
|
1618
|
+
float l = length(p + position*(dist*2.))+size/2.;
|
|
1619
|
+
float l2 = length(p + position*(dist*4.))+size/3.;
|
|
1620
|
+
|
|
1621
|
+
float c = max(0.01-pow(length(p + position*dist), size*ghostScale), 0.0)*10.;
|
|
1622
|
+
float c1 = max(0.001-pow(l-0.3, 1./40.)+sin(l*20.), 0.0)*3.;
|
|
1623
|
+
float c2 = max(0.09/pow(length(p-position*dist/.5)*1., .95), 0.0)/20.;
|
|
1624
|
+
float s = max(0.02-pow(regShape(p*5. + position*dist*5. + decay, 6) , 1.), 0.0)*1.5;
|
|
1625
|
+
|
|
1626
|
+
color = cos(vec3(0.44, .24, .2)*16. + dist/8.)*0.5+.5;
|
|
1627
|
+
vec3 f = c*color;
|
|
1628
|
+
f += c1*color;
|
|
1629
|
+
f += c2*color;
|
|
1630
|
+
f += s*color;
|
|
1631
|
+
return f;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
vec4 getLensColor(float x){
|
|
1635
|
+
return vec4(vec3(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(vec3(0., 0., 0.),
|
|
1636
|
+
vec3(0., 0., 0.), smoothstep(0.0, 0.063, x)),
|
|
1637
|
+
vec3(0., 0., 0.), smoothstep(0.063, 0.125, x)),
|
|
1638
|
+
vec3(0.0, 0., 0.), smoothstep(0.125, 0.188, x)),
|
|
1639
|
+
vec3(0.188, 0.131, 0.116), smoothstep(0.188, 0.227, x)),
|
|
1640
|
+
vec3(0.31, 0.204, 0.537), smoothstep(0.227, 0.251, x)),
|
|
1641
|
+
vec3(0.192, 0.106, 0.286), smoothstep(0.251, 0.314, x)),
|
|
1642
|
+
vec3(0.102, 0.008, 0.341), smoothstep(0.314, 0.392, x)),
|
|
1643
|
+
vec3(0.086, 0.0, 0.141), smoothstep(0.392, 0.502, x)),
|
|
1644
|
+
vec3(1.0, 0.31, 0.0), smoothstep(0.502, 0.604, x)),
|
|
1645
|
+
vec3(.1, 0.1, 0.1), smoothstep(0.604, 0.643, x)),
|
|
1646
|
+
vec3(1.0, 0.929, 0.0), smoothstep(0.643, 0.761, x)),
|
|
1647
|
+
vec3(1.0, 0.086, 0.424), smoothstep(0.761, 0.847, x)),
|
|
1648
|
+
vec3(1.0, 0.49, 0.0), smoothstep(0.847, 0.89, x)),
|
|
1649
|
+
vec3(0.945, 0.275, 0.475), smoothstep(0.89, 0.941, x)),
|
|
1650
|
+
vec3(0.251, 0.275, 0.796), smoothstep(0.941, 1.0, x))),
|
|
1651
|
+
1.0);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
float dirtNoise(vec2 p){
|
|
1655
|
+
vec2 f = fract(p);
|
|
1656
|
+
f = (f * f) * (3.0 - (2.0 * f));
|
|
1657
|
+
float n = dot(floor(p), vec2(1.0, 157.0));
|
|
1658
|
+
vec4 a = fract(sin(vec4(n + 0.0, n + 1.0, n + 157.0, n + 158.0)) * 43758.5453123);
|
|
1659
|
+
return mix(mix(a.x, a.y, f.x), mix(a.z, a.w, f.x), f.y);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
float fbm(vec2 p){
|
|
1663
|
+
const mat2 m = mat2(0.80, -0.60, 0.60, 0.80);
|
|
1664
|
+
float f = 0.0;
|
|
1665
|
+
f += 0.5000*dirtNoise(p); p = m*p*2.02;
|
|
1666
|
+
f += 0.2500*dirtNoise(p); p = m*p*2.03;
|
|
1667
|
+
f += 0.1250*dirtNoise(p); p = m*p*2.01;
|
|
1668
|
+
f += 0.0625*dirtNoise(p);
|
|
1669
|
+
return f/0.9375;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
vec4 getLensStar(vec2 p){
|
|
1673
|
+
vec2 pp = (p - vec2(0.5)) * 2.0;
|
|
1674
|
+
float a = atan(pp.y, pp.x);
|
|
1675
|
+
vec4 cp = vec4(sin(a * 1.0), length(pp), sin(a * 13.0), sin(a * 53.0));
|
|
1676
|
+
float d = sin(clamp(pow(length(vec2(0.5) - p) * 0.5 + haloScale /2., 5.0), 0.0, 1.0) * 3.14159);
|
|
1677
|
+
vec3 c = vec3(d) * vec3(fbm(cp.xy * 16.0) * fbm(cp.zw * 9.0) * max(max(max(max(0.5, sin(a * 1.0)), sin(a * 3.0) * 0.8), sin(a * 7.0) * 0.8), sin(a * 9.0) * 10.6));
|
|
1678
|
+
c *= vec3(mix(2.0, (sin(length(pp.xy) * 256.0) * 0.5) + 0.5, sin((clamp((length(pp.xy) - 0.875) / 0.1, 0.0, 1.0) + 0.0) * 2.0 * 3.14159) * 1.5) + 0.5) * 0.3275;
|
|
1679
|
+
return vec4(vec3(c * 1.0), d);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
vec4 getLensDirt(vec2 p){
|
|
1683
|
+
p.xy += vec2(fbm(p.yx * 3.0), fbm(p.yx * 2.0)) * 0.0825;
|
|
1684
|
+
vec3 o = vec3(mix(0.125, 0.25, max(max(smoothstep(0.1, 0.0, length(p - vec2(0.25))),
|
|
1685
|
+
smoothstep(0.4, 0.0, length(p - vec2(0.75)))),
|
|
1686
|
+
smoothstep(0.8, 0.0, length(p - vec2(0.875, 0.125))))));
|
|
1687
|
+
o += vec3(max(fbm(p * 1.0) - 0.5, 0.0)) * 0.5;
|
|
1688
|
+
o += vec3(max(fbm(p * 2.0) - 0.5, 0.0)) * 0.5;
|
|
1689
|
+
o += vec3(max(fbm(p * 4.0) - 0.5, 0.0)) * 0.25;
|
|
1690
|
+
o += vec3(max(fbm(p * 8.0) - 0.75, 0.0)) * 1.0;
|
|
1691
|
+
o += vec3(max(fbm(p * 16.0) - 0.75, 0.0)) * 0.75;
|
|
1692
|
+
o += vec3(max(fbm(p * 64.0) - 0.75, 0.0)) * 0.5;
|
|
1693
|
+
return vec4(clamp(o, vec3(0.15), vec3(1.0)), 1.0);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
vec4 textureLimited(sampler2D tex, vec2 texCoord){
|
|
1697
|
+
if(((texCoord.x < 0.) || (texCoord.y < 0.)) || ((texCoord.x > 1.) || (texCoord.y > 1.))){
|
|
1698
|
+
return vec4(0.0);
|
|
1699
|
+
}else{
|
|
1700
|
+
return texture(tex, texCoord);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
vec4 textureDistorted(sampler2D tex, vec2 texCoord, vec2 direction, vec3 distortion) {
|
|
1705
|
+
return vec4(textureLimited(tex, (texCoord + (direction * distortion.r))).r,
|
|
1706
|
+
textureLimited(tex, (texCoord + (direction * distortion.g))).g,
|
|
1707
|
+
textureLimited(tex, (texCoord + (direction * distortion.b))).b,
|
|
1708
|
+
1.0);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
vec4 getStartBurst(){
|
|
1712
|
+
vec2 aspectTexCoord = vec2(1.0) - (((vTexCoord - vec2(0.5)) * vec2(1.0)) + vec2(0.5));
|
|
1713
|
+
vec2 texCoord = vec2(1.0) - vTexCoord;
|
|
1714
|
+
vec2 ghostVec = (vec2(0.5) - texCoord) * 0.3 - lensPosition;
|
|
1715
|
+
vec2 ghostVecAspectNormalized = normalize(ghostVec * vec2(1.0)) * vec2(1.0);
|
|
1716
|
+
vec2 haloVec = normalize(ghostVec) * 0.6;
|
|
1717
|
+
vec2 haloVecAspectNormalized = ghostVecAspectNormalized * 0.6;
|
|
1718
|
+
vec2 texelSize = vec2(1.0) / vec2(screenRes.xy);
|
|
1719
|
+
vec3 distortion = vec3(-(texelSize.x * 1.5), 0.2, texelSize.x * 1.5);
|
|
1720
|
+
vec4 c = vec4(0.0);
|
|
1721
|
+
for (int i = 0; i < 8; i++) {
|
|
1722
|
+
vec2 offset = texCoord + (ghostVec * float(i));
|
|
1723
|
+
c += textureDistorted(lensDirtTexture, offset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - offset) / length(vec2(0.5)))), 10.0);
|
|
1724
|
+
}
|
|
1725
|
+
vec2 haloOffset = texCoord + haloVecAspectNormalized;
|
|
1726
|
+
return (c * getLensColor((length(vec2(0.5) - aspectTexCoord) / length(vec2(haloScale))))) +
|
|
1727
|
+
(textureDistorted(lensDirtTexture, haloOffset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - haloOffset) / length(vec2(0.5)))), 10.0));
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
void mainImage(vec4 inputColor, vec2 uv, out vec4 outputColor)
|
|
1731
|
+
{
|
|
1732
|
+
vec2 myUV = uv -0.5;
|
|
1733
|
+
myUV.y *= screenRes.y/screenRes.x;
|
|
1734
|
+
vec2 finalLensPosition = lensPosition * 0.5;
|
|
1735
|
+
finalLensPosition.y *= screenRes.y/screenRes.x;
|
|
1736
|
+
|
|
1737
|
+
vec3 finalColor = LensFlare(myUV, finalLensPosition) * 20.0 * colorGain / 256.;
|
|
1738
|
+
|
|
1739
|
+
if(aditionalStreaks){
|
|
1740
|
+
vec3 circColor = vec3(0.9, 0.2, 0.1);
|
|
1741
|
+
vec3 circColor2 = vec3(0.3, 0.1, 0.9);
|
|
1742
|
+
|
|
1743
|
+
for(float i=0.;i<10.;i++){
|
|
1744
|
+
finalColor += circle(myUV, pow(rnd(i*2000.)*2.8, .1)+1.41, 0.0, circColor+i , circColor2+i, rnd(i*20.)*3.+0.2-.5, lensPosition);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
if(secondaryGhosts){
|
|
1749
|
+
vec3 altGhosts = vec3(0);
|
|
1750
|
+
altGhosts += renderhex(myUV, -lensPosition*0.25, ghostScale * 1.4, vec3(0.25,0.35,0));
|
|
1751
|
+
altGhosts += renderhex(myUV, lensPosition*0.25, ghostScale * 0.5, vec3(1,0.5,0.5));
|
|
1752
|
+
altGhosts += renderhex(myUV, lensPosition*0.1, ghostScale * 1.6, vec3(1,1,1));
|
|
1753
|
+
altGhosts += renderhex(myUV, lensPosition*1.8, ghostScale * 2.0, vec3(0,0.5,0.75));
|
|
1754
|
+
altGhosts += renderhex(myUV, lensPosition*1.25, ghostScale * 0.8, vec3(1,1,0.5));
|
|
1755
|
+
altGhosts += renderhex(myUV, -lensPosition*1.25, ghostScale * 5.0, vec3(0.5,0.5,0.25));
|
|
1756
|
+
|
|
1757
|
+
altGhosts += fpow(1.0 - abs(distance(lensPosition*0.8,myUV) - 0.7),0.985)*colorGain / 2100.;
|
|
1758
|
+
finalColor += altGhosts;
|
|
1759
|
+
}
|
|
1275
1760
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
vec2 vxtC;
|
|
1296
|
-
|
|
1297
|
-
float rndf(float n){return fract(sin(n) * 43758.5453123);}float niz(float p){float fl = floor(p);float fc = fract(p);return mix(rndf(fl),rndf(fl + 1.0), fc);}
|
|
1298
|
-
vec3 hsv2rgb(vec3 c){vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);vec3 p = abs(fract(c.xxx + k.xyz) * 6.0 - k.www);return c.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y);}
|
|
1299
|
-
float satU(float x){return clamp(x, 0.,1.);}vec2 rtU(vec2 naz, float rtn){return vec2(cos(rtn) * naz.x + sin(rtn) * naz.y,cos(rtn) * naz.y - sin(rtn) * naz.x);}
|
|
1300
|
-
vec3 drwF(vec2 p, float intensity, float rnd, float speed, int id){float flhos = (1. / 32.) * float(id) * 0.1;float lingrad = distance(vec2(0.), p);float expg = 1. / exp(lingrad * (fract(rnd) * 0.66 + 0.33));vec3 qzTg = hsv2rgb(vec3( fract( (expg * 8.) + speed * flareSpeed + flhos), pow(1.-abs(expg*2.-1.), 0.45), 20.0 * expg * intensity));float internalStarPoints;if(anamorphic){internalStarPoints = 1.0;} else{internalStarPoints = starPoints;}float ams = length(p * flareShape * sin(internalStarPoints * atan(p.x, p.y)));float kJhg = pow(1.-satU(ams), ( anamorphic ? 100. : 12.));kJhg += satU(expg-0.9) * 3.;kJhg = pow(kJhg * expg, 8. + (1.-intensity) * 5.);if(flareSpeed > 0.0){return vec3(kJhg) * qzTg;} else{return vec3(kJhg) * flareSize * 15.;}}
|
|
1301
|
-
float ams2(vec3 a, vec3 b) { return abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z);}vec3 satU(vec3 x){return clamp(x, vec3(0.0), vec3(1.0));}
|
|
1302
|
-
float glR(vec2 naz, vec2 pos, float zsi){vec2 mni;if(animated){mni = rtU(naz-pos, iTime * 0.1);} else{mni = naz-pos;}float ang = atan(mni.y, mni.x) * (anamorphic ? 1.0 : starPoints);float ams2 = length(mni);ams2 = pow(ams2, .9);float f0 = 1.0/(length(naz-pos)*(1.0/zsi*16.0)+.2);return f0+f0*(sin((ang))*.2 +.3);}
|
|
1303
|
-
float sdHex(vec2 p){p = abs(p);vec2 q = vec2(p.x*2.0*0.5773503, p.y + p.x*0.5773503);return dot(step(q.xy,q.yx), 1.0-q.yx);}float fpow(float x, float k){return x > k ? pow((x-k)/(1.0-k),2.0) : 0.0;}
|
|
1304
|
-
vec3 rHx(vec2 naz, vec2 p, float s, vec3 col){naz -= p;if (abs(naz.x) < 0.2*s && abs(naz.y) < 0.2*s){return mix(vec3(0),mix(vec3(0),col,0.1 + fpow(length(naz/s),0.1)*10.0),smoothstep(0.0,0.1,sdHex(naz*20.0/s)));}return vec3(0);}
|
|
1305
|
-
vec3 mLs(vec2 naz, vec2 pos){vec2 mni = naz-pos;vec2 zxMp = naz*(length(naz));float ang = atan(mni.x,mni.y);float f0 = .3/(length(naz-pos)*16.0+1.0);f0 = f0*(sin(niz(sin(ang*3.9-(animated ? iTime : 0.0) * 0.3) * starPoints))*.2 );float f1 = max(0.01-pow(length(naz+1.2*pos),1.9),.0)*7.0;float f2 = max(.9/(10.0+32.0*pow(length(zxMp+0.99*pos),2.0)),.0)*0.35;float f22 = max(.9/(11.0+32.0*pow(length(zxMp+0.85*pos),2.0)),.0)*0.23;float f23 = max(.9/(12.0+32.0*pow(length(zxMp+0.95*pos),2.0)),.0)*0.6;vec2 ztX = mix(naz,zxMp, 0.1);float f4 = max(0.01-pow(length(ztX+0.4*pos),2.9),.0)*4.02;float f42 = max(0.0-pow(length(ztX+0.45*pos),2.9),.0)*4.1;float f43 = max(0.01-pow(length(ztX+0.5*pos),2.9),.0)*4.6;ztX = mix(naz,zxMp,-.4);float f5 = max(0.01-pow(length(ztX+0.1*pos),5.5),.0)*2.0;float f52 = max(0.01-pow(length(ztX+0.2*pos),5.5),.0)*2.0;float f53 = max(0.01-pow(length(ztX+0.1*pos),5.5),.0)*2.0;ztX = mix(naz,zxMp, 2.1);float f6 = max(0.01-pow(length(ztX-0.3*pos),1.61),.0)*3.159;float f62 = max(0.01-pow(length(ztX-0.325*pos),1.614),.0)*3.14;float f63 = max(0.01-pow(length(ztX-0.389*pos),1.623),.0)*3.12;vec3 c = vec3(glR(naz,pos, glareSize));vec2 prot;if(animated){prot = rtU(naz - pos, (iTime * 0.1));} else if(anamorphic){prot = rtU(naz - pos, 1.570796);} else {prot = naz - pos;}c += drwF(prot, (anamorphic ? flareSize * 10. : flareSize), 0.1, iTime, 1);c.r+=f1+f2+f4+f5+f6; c.g+=f1+f22+f42+f52+f62; c.b+=f1+f23+f43+f53+f63;c = c*1.3 * vec3(length(zxMp)+.09);c+=vec3(f0);return c;}
|
|
1306
|
-
vec3 cc(vec3 clr, float fct,float fct2){float w = clr.x+clr.y+clr.z;return mix(clr,vec3(w)*fct,w*fct2);}float rnd(vec2 p){float f = fract(sin(dot(p, vec2(12.1234, 72.8392) )*45123.2));return f;}float rnd(float w){float f = fract(sin(w)*1000.);return f;}
|
|
1307
|
-
float rShp(vec2 p, int N){float f;float a=atan(p.x,p.y)+.2;float b=6.28319/float(N);f=smoothstep(.5,.51, cos(floor(.5+a/b)*b-a)*length(p.xy)* 2.0 -ghostScale);return f;}
|
|
1308
|
-
vec3 drC(vec2 p, float zsi, float dCy, vec3 clr, vec3 clr2, float ams2, vec2 esom){float l = length(p + esom*(ams2*2.))+zsi/2.;float l2 = length(p + esom*(ams2*4.))+zsi/3.;float c = max(0.01-pow(length(p + esom*ams2), zsi*ghostScale), 0.0)*10.;float c1 = max(0.001-pow(l-0.3, 1./40.)+sin(l*20.), 0.0)*3.;float c2 = max(0.09/pow(length(p-esom*ams2/.5)*1., .95), 0.0)/20.;float s = max(0.02-pow(rShp(p*5. + esom*ams2*5. + dCy, 6) , 1.), 0.0)*1.5;clr = cos(vec3(0.44, .24, .2)*8. + ams2*4.)*0.5+.5;vec3 f = c*clr;f += c1*clr;f += c2*clr;f += s*clr;return f-0.01;}
|
|
1309
|
-
vec4 geLC(float x){return vec4(vec3(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(vec3(0., 0., 0.),vec3(0., 0., 0.), smoothstep(0.0, 0.063, x)),vec3(0., 0., 0.), smoothstep(0.063, 0.125, x)),vec3(0.0, 0., 0.), smoothstep(0.125, 0.188, x)),vec3(0.188, 0.131, 0.116), smoothstep(0.188, 0.227, x)),vec3(0.31, 0.204, 0.537), smoothstep(0.227, 0.251, x)),vec3(0.192, 0.106, 0.286), smoothstep(0.251, 0.314, x)),vec3(0.102, 0.008, 0.341), smoothstep(0.314, 0.392, x)),vec3(0.086, 0.0, 0.141), smoothstep(0.392, 0.502, x)),vec3(1.0, 0.31, 0.0), smoothstep(0.502, 0.604, x)),vec3(.1, 0.1, 0.1), smoothstep(0.604, 0.643, x)),vec3(1.0, 0.929, 0.0), smoothstep(0.643, 0.761, x)),vec3(1.0, 0.086, 0.424), smoothstep(0.761, 0.847, x)),vec3(1.0, 0.49, 0.0), smoothstep(0.847, 0.89, x)),vec3(0.945, 0.275, 0.475), smoothstep(0.89, 0.941, x)),vec3(0.251, 0.275, 0.796), smoothstep(0.941, 1.0, x))),1.0);}
|
|
1310
|
-
float diTN(vec2 p){vec2 f = fract(p);f = (f * f) * (3.0 - (2.0 * f));float n = dot(floor(p), vec2(1.0, 157.0));vec4 a = fract(sin(vec4(n + 0.0, n + 1.0, n + 157.0, n + 158.0)) * 43758.5453123);return mix(mix(a.x, a.y, f.x), mix(a.z, a.w, f.x), f.y);}
|
|
1311
|
-
float fbm(vec2 p){const mat2 m = mat2(0.80, -0.60, 0.60, 0.80);float f = 0.0;f += 0.5000*diTN(p); p = m*p*2.02;f += 0.2500*diTN(p); p = m*p*2.03;f += 0.1250*diTN(p); p = m*p*2.01;f += 0.0625*diTN(p);return f/0.9375;}
|
|
1312
|
-
vec4 geLS(vec2 p){vec2 pp = (p - vec2(0.5)) * 2.0;float a = atan(pp.y, pp.x);vec4 cp = vec4(sin(a * 1.0), length(pp), sin(a * 13.0), sin(a * 53.0));float d = sin(clamp(pow(length(vec2(0.5) - p) * 0.5 + haloScale /2., 5.0), 0.0, 1.0) * 3.14159);vec3 c = vec3(d) * vec3(fbm(cp.xy * 16.0) * fbm(cp.zw * 9.0) * max(max(max(max(0.5, sin(a * 1.0)), sin(a * 3.0) * 0.8), sin(a * 7.0) * 0.8), sin(a * 9.0) * 10.6));c *= vec3(mix(2.0, (sin(length(pp.xy) * 256.0) * 0.5) + 0.5, sin((clamp((length(pp.xy) - 0.875) / 0.1, 0.0, 1.0) + 0.0) * 2.0 * 3.14159) * 1.5) + 0.5) * 0.3275;return vec4(vec3(c * 1.0), d);}
|
|
1313
|
-
vec4 geLD(vec2 p){p.xy += vec2(fbm(p.yx * 3.0), fbm(p.yx * 2.0)) * 0.0825;vec3 o = vec3(mix(0.125, 0.25, max(max(smoothstep(0.1, 0.0, length(p - vec2(0.25))),smoothstep(0.4, 0.0, length(p - vec2(0.75)))),smoothstep(0.8, 0.0, length(p - vec2(0.875, 0.125))))));o += vec3(max(fbm(p * 1.0) - 0.5, 0.0)) * 0.5;o += vec3(max(fbm(p * 2.0) - 0.5, 0.0)) * 0.5;o += vec3(max(fbm(p * 4.0) - 0.5, 0.0)) * 0.25;o += vec3(max(fbm(p * 8.0) - 0.75, 0.0)) * 1.0;o += vec3(max(fbm(p * 16.0) - 0.75, 0.0)) * 0.75;o += vec3(max(fbm(p * 64.0) - 0.75, 0.0)) * 0.5;return vec4(clamp(o, vec3(0.15), vec3(1.0)), 1.0);}
|
|
1314
|
-
vec4 txL(sampler2D tex, vec2 xtC){if(((xtC.x < 0.) || (xtC.y < 0.)) || ((xtC.x > 1.) || (xtC.y > 1.))){return vec4(0.0);}else{return texture(tex, xtC); }}
|
|
1315
|
-
vec4 txD(sampler2D tex, vec2 xtC, vec2 dir, vec3 ditn) {return vec4(txL(tex, (xtC + (dir * ditn.r))).r,txL(tex, (xtC + (dir * ditn.g))).g,txL(tex, (xtC + (dir * ditn.b))).b,1.0);}
|
|
1316
|
-
vec4 strB(){vec2 aspXtc = vec2(1.0) - (((vxtC - vec2(0.5)) * vec2(1.0)) + vec2(0.5)); vec2 xtC = vec2(1.0) - vxtC; vec2 ghvc = (vec2(0.5) - xtC) * 0.3 - lensPosition; vec2 ghNm = normalize(ghvc * vec2(1.0)) * vec2(1.0);vec2 haloVec = normalize(ghvc) * 0.6;vec2 hlNm = ghNm * 0.6;vec2 texelSize = vec2(1.0) / vec2(iResolution.xy);vec3 ditn = vec3(-(texelSize.x * 1.5), 0.2, texelSize.x * 1.5);vec4 c = vec4(0.0);for (int i = 0; i < 8; i++) {vec2 offset = xtC + (ghvc * float(i));c += txD(lensDirtTexture, offset, ghNm, ditn) * pow(max(0.0, 1.0 - (length(vec2(0.5) - offset) / length(vec2(0.5)))), 10.0);}vec2 uyTrz = xtC + hlNm; return (c * geLC((length(vec2(0.5) - aspXtc) / length(vec2(haloScale))))) +(txD(lensDirtTexture, uyTrz, ghNm, ditn) * pow(max(0.0, 1.0 - (length(vec2(0.5) - uyTrz) / length(vec2(0.5)))), 10.0));}
|
|
1317
|
-
void mainImage(vec4 v,vec2 r,out vec4 i){vec2 g=r-.5;g.y*=iResolution.y/iResolution.x;vec2 l=lensPosition*.5;l.y*=iResolution.y/iResolution.x;vec3 f=mLs(g,l)*20.*colorGain/256.;if(aditionalStreaks){vec3 o=vec3(.9,.2,.1),p=vec3(.3,.1,.9);for(float n=0.;n<10.;n++)f+=drC(g,pow(rnd(n*2e3)*2.8,.1)+1.41,0.,o+n,p+n,rnd(n*20.)*3.+.2-.5,lensPosition);}if(secondaryGhosts){vec3 n=vec3(0);n+=rHx(g,-lensPosition*.25,ghostScale*1.4,vec3(.25,.35,0));n+=rHx(g,lensPosition*.25,ghostScale*.5,vec3(1,.5,.5));n+=rHx(g,lensPosition*.1,ghostScale*1.6,vec3(1));n+=rHx(g,lensPosition*1.8,ghostScale*2.,vec3(0,.5,.75));n+=rHx(g,lensPosition*1.25,ghostScale*.8,vec3(1,1,.5));n+=rHx(g,-lensPosition*1.25,ghostScale*5.,vec3(.5,.5,.25));n+=fpow(1.-abs(distance(lensPosition*.8,g)-.7),.985)*colorGain/2100.;f+=n;}if(starBurst){vxtC=g+.5;vec4 n=geLD(g);float o=1.-clamp(0.5,0.,.5)*2.;n+=mix(n,pow(n*2.,vec4(2))*.5,o);float s=(g.x+g.y)*(1./6.);vec2 d=mat2(cos(s),-sin(s),sin(s),cos(s))*vxtC;n+=geLS(d)*2.;f+=clamp(n.xyz*strB().xyz,.01,1.);}i=enabled?vec4(mix(f,vec3(0),opacity)+v.xyz,v.w):vec4(v);}
|
|
1761
|
+
if(starBurst){
|
|
1762
|
+
vTexCoord = myUV + 0.5;
|
|
1763
|
+
vec4 lensMod = getLensDirt(myUV);
|
|
1764
|
+
float tooBright = 1.0 - (clamp(0.5, 0.0, 0.5) * 2.0);
|
|
1765
|
+
float tooDark = clamp(0.5 - 0.5, 0.0, 0.5) * 2.0;
|
|
1766
|
+
lensMod += mix(lensMod, pow(lensMod * 2.0, vec4(2.0)) * 0.5, tooBright);
|
|
1767
|
+
float lensStarRotationAngle = ((myUV.x + myUV.y)) * (1.0 / 6.0);
|
|
1768
|
+
vec2 lensStarTexCoord = (mat2(cos(lensStarRotationAngle), -sin(lensStarRotationAngle), sin(lensStarRotationAngle), cos(lensStarRotationAngle)) * vTexCoord);
|
|
1769
|
+
lensMod += getLensStar(lensStarTexCoord) * 2.;
|
|
1770
|
+
|
|
1771
|
+
finalColor += clamp((lensMod.rgb * getStartBurst().rgb ), 0.01, 1.0);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
if(enabled){
|
|
1775
|
+
outputColor = vec4(mix(finalColor, vec3(.0), opacity) + inputColor.rgb, inputColor.a);
|
|
1776
|
+
} else {
|
|
1777
|
+
outputColor = vec4(inputColor);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1318
1780
|
`,
|
|
1319
1781
|
};
|
|
1320
1782
|
/**
|
|
@@ -1341,7 +1803,7 @@ class LensFlareEffect extends Effect {
|
|
|
1341
1803
|
* @param options.enabled - Whether the effect is enabled
|
|
1342
1804
|
* @param options.glareSize - Size of the glare
|
|
1343
1805
|
* @param options.lensPosition - Position of the lens on screen
|
|
1344
|
-
* @param options.
|
|
1806
|
+
* @param options.screenRes - Resolution of the effect
|
|
1345
1807
|
* @param options.starPoints - Number of points in the star pattern
|
|
1346
1808
|
* @param options.flareSize - Size of individual flares
|
|
1347
1809
|
* @param options.flareSpeed - Animation speed of flares
|
|
@@ -1357,15 +1819,15 @@ class LensFlareEffect extends Effect {
|
|
|
1357
1819
|
* @param options.opacity - Opacity of the effect
|
|
1358
1820
|
* @param options.starBurst - Enable star burst effect
|
|
1359
1821
|
*/
|
|
1360
|
-
constructor({ blendFunction = BlendFunction.NORMAL, enabled = true, glareSize = 0.2, lensPosition = [0.01, 0.01],
|
|
1822
|
+
constructor({ blendFunction = BlendFunction.NORMAL, enabled = true, glareSize = 0.2, lensPosition = [0.01, 0.01], screenRes = [0, 0], starPoints = 6, flareSize = 0.01, flareSpeed = 0.01, flareShape = 0.01, animated = true, anamorphic = false, colorGain = new THREE.Color(20, 20, 20), lensDirtTexture = null, haloScale = 0.5, secondaryGhosts = true, aditionalStreaks = true, ghostScale = 0.0, opacity = 1.0, starBurst = false, } = {}) {
|
|
1361
1823
|
super('LensFlareEffect', LensFlareShader.fragmentShader, {
|
|
1362
1824
|
blendFunction,
|
|
1363
1825
|
uniforms: new Map([
|
|
1364
1826
|
['enabled', new THREE.Uniform(enabled)],
|
|
1365
1827
|
['glareSize', new THREE.Uniform(glareSize)],
|
|
1366
1828
|
['lensPosition', new THREE.Uniform(lensPosition)],
|
|
1367
|
-
['
|
|
1368
|
-
['
|
|
1829
|
+
['time', new THREE.Uniform(0)],
|
|
1830
|
+
['screenRes', new THREE.Uniform(screenRes)],
|
|
1369
1831
|
['starPoints', new THREE.Uniform(starPoints)],
|
|
1370
1832
|
['flareSize', new THREE.Uniform(flareSize)],
|
|
1371
1833
|
['flareSpeed', new THREE.Uniform(flareSpeed)],
|
|
@@ -1391,9 +1853,9 @@ class LensFlareEffect extends Effect {
|
|
|
1391
1853
|
* @param deltaTime - Time elapsed since last frame
|
|
1392
1854
|
*/
|
|
1393
1855
|
update(_renderer, _inputBuffer, deltaTime) {
|
|
1394
|
-
const
|
|
1395
|
-
if (
|
|
1396
|
-
|
|
1856
|
+
const time = this.uniforms.get('time');
|
|
1857
|
+
if (time) {
|
|
1858
|
+
time.value += deltaTime;
|
|
1397
1859
|
}
|
|
1398
1860
|
}
|
|
1399
1861
|
}
|
|
@@ -1447,10 +1909,10 @@ class NgtpLensFlare {
|
|
|
1447
1909
|
this.store.viewport.width(),
|
|
1448
1910
|
this.store.viewport.height(),
|
|
1449
1911
|
];
|
|
1450
|
-
const
|
|
1451
|
-
if (
|
|
1452
|
-
|
|
1453
|
-
|
|
1912
|
+
const screenRes = lensFlareEffect.uniforms.get('screenRes');
|
|
1913
|
+
if (screenRes) {
|
|
1914
|
+
screenRes.value.x = width;
|
|
1915
|
+
screenRes.value.y = height;
|
|
1454
1916
|
}
|
|
1455
1917
|
});
|
|
1456
1918
|
effect((onCleanup) => {
|
|
@@ -1885,6 +2347,125 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
1885
2347
|
}]
|
|
1886
2348
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
1887
2349
|
|
|
2350
|
+
const RampShader = {
|
|
2351
|
+
fragmentShader: /* language=glsl glsl */ `
|
|
2352
|
+
uniform int rampType;
|
|
2353
|
+
|
|
2354
|
+
uniform vec2 rampStart;
|
|
2355
|
+
uniform vec2 rampEnd;
|
|
2356
|
+
|
|
2357
|
+
uniform vec4 startColor;
|
|
2358
|
+
uniform vec4 endColor;
|
|
2359
|
+
|
|
2360
|
+
uniform float rampBias;
|
|
2361
|
+
uniform float rampGain;
|
|
2362
|
+
|
|
2363
|
+
uniform bool rampMask;
|
|
2364
|
+
uniform bool rampInvert;
|
|
2365
|
+
|
|
2366
|
+
float getBias(float time, float bias) {
|
|
2367
|
+
return time / (((1.0 / bias) - 2.0) * (1.0 - time) + 1.0);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
float getGain(float time, float gain) {
|
|
2371
|
+
if (time < 0.5)
|
|
2372
|
+
return getBias(time * 2.0, gain) / 2.0;
|
|
2373
|
+
else
|
|
2374
|
+
return getBias(time * 2.0 - 1.0, 1.0 - gain) / 2.0 + 0.5;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
|
|
2378
|
+
vec2 centerPixel = uv * resolution;
|
|
2379
|
+
vec2 startPixel = rampStart * resolution;
|
|
2380
|
+
vec2 endPixel = rampEnd * resolution;
|
|
2381
|
+
|
|
2382
|
+
float rampAlpha;
|
|
2383
|
+
|
|
2384
|
+
if (rampType == 1) {
|
|
2385
|
+
vec2 fuv = centerPixel / resolution.y;
|
|
2386
|
+
vec2 suv = startPixel / resolution.y;
|
|
2387
|
+
vec2 euv = endPixel / resolution.y;
|
|
2388
|
+
|
|
2389
|
+
float radius = length(suv - euv);
|
|
2390
|
+
float falloff = length(fuv - suv);
|
|
2391
|
+
rampAlpha = smoothstep(0.0, radius, falloff);
|
|
2392
|
+
} else {
|
|
2393
|
+
float radius = length(startPixel - endPixel);
|
|
2394
|
+
vec2 direction = normalize(vec2(endPixel.x - startPixel.x, -(startPixel.y - endPixel.y)));
|
|
2395
|
+
|
|
2396
|
+
float fade = dot(centerPixel - startPixel, direction);
|
|
2397
|
+
if (rampType == 2) fade = abs(fade);
|
|
2398
|
+
|
|
2399
|
+
rampAlpha = smoothstep(0.0, 1.0, fade / radius);
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
rampAlpha = abs((rampInvert ? 1.0 : 0.0) - getBias(rampAlpha, rampBias) * getGain(rampAlpha, rampGain));
|
|
2403
|
+
|
|
2404
|
+
if (rampMask) {
|
|
2405
|
+
vec4 inputBuff = texture2D(inputBuffer, uv);
|
|
2406
|
+
outputColor = mix(inputBuff, inputColor, rampAlpha);
|
|
2407
|
+
} else {
|
|
2408
|
+
outputColor = mix(startColor, endColor, rampAlpha);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
`,
|
|
2412
|
+
};
|
|
2413
|
+
var RampType;
|
|
2414
|
+
(function (RampType) {
|
|
2415
|
+
RampType[RampType["Linear"] = 0] = "Linear";
|
|
2416
|
+
RampType[RampType["Radial"] = 1] = "Radial";
|
|
2417
|
+
RampType[RampType["MirroredLinear"] = 2] = "MirroredLinear";
|
|
2418
|
+
})(RampType || (RampType = {}));
|
|
2419
|
+
class RampEffect extends Effect {
|
|
2420
|
+
constructor({ rampType = RampType.Linear, rampStart = [0.5, 0.5], rampEnd = [1, 1], startColor = [0, 0, 0, 1], endColor = [1, 1, 1, 1], rampBias = 0.5, rampGain = 0.5, rampMask = false, rampInvert = false, ...params } = {}) {
|
|
2421
|
+
super('RampEffect', RampShader.fragmentShader, {
|
|
2422
|
+
...params,
|
|
2423
|
+
uniforms: new Map([
|
|
2424
|
+
['rampType', new THREE.Uniform(rampType)],
|
|
2425
|
+
['rampStart', new THREE.Uniform(rampStart)],
|
|
2426
|
+
['rampEnd', new THREE.Uniform(rampEnd)],
|
|
2427
|
+
['startColor', new THREE.Uniform(startColor)],
|
|
2428
|
+
['endColor', new THREE.Uniform(endColor)],
|
|
2429
|
+
['rampBias', new THREE.Uniform(rampBias)],
|
|
2430
|
+
['rampGain', new THREE.Uniform(rampGain)],
|
|
2431
|
+
['rampMask', new THREE.Uniform(rampMask)],
|
|
2432
|
+
['rampInvert', new THREE.Uniform(rampInvert)],
|
|
2433
|
+
]),
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
extend({ RampEffect });
|
|
2438
|
+
class NgtpRamp {
|
|
2439
|
+
constructor() {
|
|
2440
|
+
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2441
|
+
this.hostEffect = inject(NgtpEffect, { host: true });
|
|
2442
|
+
this.effectRef = viewChild('effect', ...(ngDevMode ? [{ debugName: "effectRef" }] : []));
|
|
2443
|
+
}
|
|
2444
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpRamp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2445
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: NgtpRamp, isStandalone: true, selector: "ngtp-ramp", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "effectRef", first: true, predicate: ["effect"], descendants: true, isSignal: true }], hostDirectives: [{ directive: NgtpEffect, inputs: ["blendFunction", "blendFunction", "opacity", "opacity"] }], ngImport: i0, template: `
|
|
2446
|
+
<ngt-ramp-effect #effect *args="[options()]" [camera]="hostEffect.camera()">
|
|
2447
|
+
<ngtp-effect-blend-mode />
|
|
2448
|
+
<ng-content />
|
|
2449
|
+
</ngt-ramp-effect>
|
|
2450
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }, { kind: "component", type: NgtpEffectBlendMode, selector: "ngtp-effect-blend-mode" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2451
|
+
}
|
|
2452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpRamp, decorators: [{
|
|
2453
|
+
type: Component,
|
|
2454
|
+
args: [{
|
|
2455
|
+
selector: 'ngtp-ramp',
|
|
2456
|
+
template: `
|
|
2457
|
+
<ngt-ramp-effect #effect *args="[options()]" [camera]="hostEffect.camera()">
|
|
2458
|
+
<ngtp-effect-blend-mode />
|
|
2459
|
+
<ng-content />
|
|
2460
|
+
</ngt-ramp-effect>
|
|
2461
|
+
`,
|
|
2462
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
2463
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2464
|
+
imports: [NgtArgs, NgtpEffectBlendMode],
|
|
2465
|
+
hostDirectives: [{ directive: NgtpEffect, inputs: ['blendFunction', 'opacity'] }],
|
|
2466
|
+
}]
|
|
2467
|
+
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], effectRef: [{ type: i0.ViewChild, args: ['effect', { isSignal: true }] }] } });
|
|
2468
|
+
|
|
1888
2469
|
const defaultOptions$1 = {
|
|
1889
2470
|
density: 1.25,
|
|
1890
2471
|
};
|
|
@@ -2176,6 +2757,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
2176
2757
|
}]
|
|
2177
2758
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], effectRef: [{ type: i0.ViewChild, args: ['effect', { isSignal: true }] }] } });
|
|
2178
2759
|
|
|
2760
|
+
class NgtpSSAO {
|
|
2761
|
+
constructor() {
|
|
2762
|
+
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2763
|
+
this.effectComposer = inject(NgtpEffectComposer);
|
|
2764
|
+
this.effect = computed(() => {
|
|
2765
|
+
const [normalPass, downSamplingPass] = [
|
|
2766
|
+
this.effectComposer.normalPass(),
|
|
2767
|
+
this.effectComposer.downSamplingPass(),
|
|
2768
|
+
];
|
|
2769
|
+
if (normalPass === null && downSamplingPass === null) {
|
|
2770
|
+
console.error('[NGT Postprocessing] Please enable the NormalPass in the EffectComposer in order to use SSAO.');
|
|
2771
|
+
return null;
|
|
2772
|
+
}
|
|
2773
|
+
const [camera, options] = [this.effectComposer.camera(), this.options()];
|
|
2774
|
+
return new SSAOEffect(camera, normalPass && !downSamplingPass ? normalPass.texture : null, {
|
|
2775
|
+
blendFunction: BlendFunction.MULTIPLY,
|
|
2776
|
+
samples: 30,
|
|
2777
|
+
rings: 4,
|
|
2778
|
+
distanceThreshold: 1.0,
|
|
2779
|
+
distanceFalloff: 0.0,
|
|
2780
|
+
rangeThreshold: 0.5,
|
|
2781
|
+
rangeFalloff: 0.1,
|
|
2782
|
+
luminanceInfluence: 0.9,
|
|
2783
|
+
radius: 20,
|
|
2784
|
+
bias: 0.5,
|
|
2785
|
+
intensity: 1.0,
|
|
2786
|
+
color: undefined,
|
|
2787
|
+
// @ts-expect-error - normalDepthBuffer is not in the types but is supported
|
|
2788
|
+
normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,
|
|
2789
|
+
resolutionScale: 1,
|
|
2790
|
+
depthAwareUpsampling: true,
|
|
2791
|
+
...options,
|
|
2792
|
+
});
|
|
2793
|
+
}, ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
2794
|
+
effect((onCleanup) => {
|
|
2795
|
+
const ssaoEffect = this.effect();
|
|
2796
|
+
if (!ssaoEffect)
|
|
2797
|
+
return;
|
|
2798
|
+
onCleanup(() => ssaoEffect.dispose());
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpSSAO, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2802
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.6", type: NgtpSSAO, isStandalone: true, selector: "ngtp-ssao", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
2803
|
+
<ngt-primitive *args="[effect()]" [dispose]="null" />
|
|
2804
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2805
|
+
}
|
|
2806
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpSSAO, decorators: [{
|
|
2807
|
+
type: Component,
|
|
2808
|
+
args: [{
|
|
2809
|
+
selector: 'ngtp-ssao',
|
|
2810
|
+
template: `
|
|
2811
|
+
<ngt-primitive *args="[effect()]" [dispose]="null" />
|
|
2812
|
+
`,
|
|
2813
|
+
imports: [NgtArgs],
|
|
2814
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
2815
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2816
|
+
}]
|
|
2817
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
2818
|
+
|
|
2179
2819
|
/**
|
|
2180
2820
|
* Angular component that applies a shock wave distortion effect.
|
|
2181
2821
|
*
|
|
@@ -2287,6 +2927,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
2287
2927
|
}]
|
|
2288
2928
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], effectRef: [{ type: i0.ViewChild, args: ['effect', { isSignal: true }] }] } });
|
|
2289
2929
|
|
|
2930
|
+
class NgtpTexture {
|
|
2931
|
+
constructor() {
|
|
2932
|
+
this.options = input({}, ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2933
|
+
this.textureSrc = pick(this.options, 'textureSrc');
|
|
2934
|
+
this.texture = pick(this.options, 'texture');
|
|
2935
|
+
this.opacity = pick(this.options, 'opacity');
|
|
2936
|
+
this.store = injectStore();
|
|
2937
|
+
this.loadedTexture = loaderResource(() => THREE.TextureLoader, () => this.textureSrc() || '', {
|
|
2938
|
+
onLoad: (texture) => {
|
|
2939
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
2940
|
+
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
|
2941
|
+
},
|
|
2942
|
+
});
|
|
2943
|
+
this.effect = computed(() => {
|
|
2944
|
+
const { textureSrc: _, texture, opacity: __, ...options } = this.options();
|
|
2945
|
+
const loaded = this.loadedTexture.value();
|
|
2946
|
+
const t = loaded || texture;
|
|
2947
|
+
if (!t)
|
|
2948
|
+
return null;
|
|
2949
|
+
return new TextureEffect({ ...options, texture: t });
|
|
2950
|
+
}, ...(ngDevMode ? [{ debugName: "effect" }] : []));
|
|
2951
|
+
effect(() => {
|
|
2952
|
+
const effect = this.effect();
|
|
2953
|
+
if (!effect)
|
|
2954
|
+
return;
|
|
2955
|
+
const opacity = this.opacity();
|
|
2956
|
+
if (opacity === undefined)
|
|
2957
|
+
return;
|
|
2958
|
+
const invalidate = this.store.invalidate();
|
|
2959
|
+
effect.blendMode.opacity.value = opacity;
|
|
2960
|
+
invalidate();
|
|
2961
|
+
});
|
|
2962
|
+
effect(() => {
|
|
2963
|
+
const effect = this.effect();
|
|
2964
|
+
if (!effect)
|
|
2965
|
+
return;
|
|
2966
|
+
const texture = this.texture();
|
|
2967
|
+
if (!texture)
|
|
2968
|
+
return;
|
|
2969
|
+
const invalidate = this.store.invalidate();
|
|
2970
|
+
effect.texture = texture;
|
|
2971
|
+
invalidate();
|
|
2972
|
+
});
|
|
2973
|
+
effect((onCleanup) => {
|
|
2974
|
+
const effect = this.effect();
|
|
2975
|
+
if (!effect)
|
|
2976
|
+
return;
|
|
2977
|
+
onCleanup(() => effect.dispose());
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpTexture, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2981
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.6", type: NgtpTexture, isStandalone: true, selector: "ngtp-texture", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
2982
|
+
<ngt-primitive *args="[effect()]" [dispose]="null" />
|
|
2983
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "ng-template[args]", inputs: ["args"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2984
|
+
}
|
|
2985
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: NgtpTexture, decorators: [{
|
|
2986
|
+
type: Component,
|
|
2987
|
+
args: [{
|
|
2988
|
+
selector: 'ngtp-texture',
|
|
2989
|
+
template: `
|
|
2990
|
+
<ngt-primitive *args="[effect()]" [dispose]="null" />
|
|
2991
|
+
`,
|
|
2992
|
+
imports: [NgtArgs],
|
|
2993
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
2994
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2995
|
+
}]
|
|
2996
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
2997
|
+
|
|
2290
2998
|
/**
|
|
2291
2999
|
* Angular component that applies a tilt-shift blur effect.
|
|
2292
3000
|
*
|
|
@@ -2716,5 +3424,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
|
|
|
2716
3424
|
* Generated bundle index. Do not edit.
|
|
2717
3425
|
*/
|
|
2718
3426
|
|
|
2719
|
-
export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpOutline, NgtpPixelation, NgtpSMAA, NgtpScanline, NgtpSelectiveBloom, NgtpSepia, NgtpShockWave, NgtpTiltShift, NgtpTiltShift2, NgtpToneMapping, NgtpVignette, NgtpWater, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
|
|
3427
|
+
export { ASCIIEffect, LensFlareEffect, NgtpASCII, NgtpAutofocus, NgtpBloom, NgtpBrightnessContrast, NgtpChromaticAberration, NgtpColorAverage, NgtpColorDepth, NgtpDepth, NgtpDepthOfField, NgtpDotScreen, NgtpEffect, NgtpEffectBlendMode, NgtpEffectComposer, NgtpFXAA, NgtpGlitch, NgtpGodRays, NgtpGrid, NgtpHueSaturation, NgtpLUT, NgtpLensFlare, NgtpNoise, NgtpOutline, NgtpPixelation, NgtpRamp, NgtpSMAA, NgtpSSAO, NgtpScanline, NgtpSelectiveBloom, NgtpSepia, NgtpShockWave, NgtpTexture, NgtpTiltShift, NgtpTiltShift2, NgtpToneMapping, NgtpVignette, NgtpWater, RampEffect, RampType, TiltShift2Effect, WaterEffect, injectDefaultEffectOptions, provideDefaultEffectOptions };
|
|
2720
3428
|
//# sourceMappingURL=angular-three-postprocessing.mjs.map
|