@kingsy/viewer 2.25.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IViewer.d.ts +157 -0
- package/dist/helpers/flatten.d.ts +11 -0
- package/dist/helpers/typeHelper.d.ts +2 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +42 -0
- package/dist/modules/Assets.d.ts +15 -0
- package/dist/modules/EventEmitter.d.ts +7 -0
- package/dist/modules/Helpers.d.ts +3 -0
- package/dist/modules/Intersections.d.ts +20 -0
- package/dist/modules/KingSyRenderer.d.ts +168 -0
- package/dist/modules/LegacyViewer.d.ts +77 -0
- package/dist/modules/Shadowcatcher.d.ts +25 -0
- package/dist/modules/ShadowcatcherConfig.d.ts +14 -0
- package/dist/modules/UrlHelper.d.ts +1 -0
- package/dist/modules/Utils.d.ts +10 -0
- package/dist/modules/Viewer.d.ts +74 -0
- package/dist/modules/WebXrViewer.d.ts +10 -0
- package/dist/modules/World.d.ts +31 -0
- package/dist/modules/batching/Batch.d.ts +62 -0
- package/dist/modules/batching/BatchObject.d.ts +53 -0
- package/dist/modules/batching/Batcher.d.ts +60 -0
- package/dist/modules/batching/DrawRanges.d.ts +6 -0
- package/dist/modules/batching/InstancedBatchObject.d.ts +8 -0
- package/dist/modules/batching/InstancedMeshBatch.d.ts +60 -0
- package/dist/modules/batching/LineBatch.d.ts +52 -0
- package/dist/modules/batching/MeshBatch.d.ts +35 -0
- package/dist/modules/batching/PointBatch.d.ts +29 -0
- package/dist/modules/batching/PrimitiveBatch.d.ts +57 -0
- package/dist/modules/batching/TextBatch.d.ts +41 -0
- package/dist/modules/converter/Geometry.d.ts +38 -0
- package/dist/modules/converter/MeshTriangulationHelper.d.ts +50 -0
- package/dist/modules/converter/Units.d.ts +12 -0
- package/dist/modules/extensions/CameraController.d.ts +95 -0
- package/dist/modules/extensions/Controls.d.ts +91 -0
- package/dist/modules/extensions/DiffExtension.d.ts +50 -0
- package/dist/modules/extensions/ExplodeExtension.d.ts +17 -0
- package/dist/modules/extensions/Extension.d.ts +15 -0
- package/dist/modules/extensions/FilteringExtension.d.ts +55 -0
- package/dist/modules/extensions/HybridCameraController.d.ts +14 -0
- package/dist/modules/extensions/SelectionExtension.d.ts +53 -0
- package/dist/modules/extensions/TransformControls.d.ts +157 -0
- package/dist/modules/extensions/ViewModes.d.ts +32 -0
- package/dist/modules/extensions/controls/FlyControls.d.ts +82 -0
- package/dist/modules/extensions/controls/KingSyControls.d.ts +25 -0
- package/dist/modules/extensions/controls/SmoothOrbitControls.d.ts +222 -0
- package/dist/modules/extensions/measurements/AreaMeasurement.d.ts +64 -0
- package/dist/modules/extensions/measurements/Measurement.d.ts +34 -0
- package/dist/modules/extensions/measurements/MeasurementPointGizmo.d.ts +42 -0
- package/dist/modules/extensions/measurements/MeasurementsExtension.d.ts +71 -0
- package/dist/modules/extensions/measurements/PerpendicularMeasurement.d.ts +19 -0
- package/dist/modules/extensions/measurements/PointMeasurement.d.ts +25 -0
- package/dist/modules/extensions/measurements/PointToPointMeasurement.d.ts +15 -0
- package/dist/modules/extensions/sections/SectionOutlines.d.ts +45 -0
- package/dist/modules/extensions/sections/SectionTool.d.ts +219 -0
- package/dist/modules/filtering/PropertyManager.d.ts +55 -0
- package/dist/modules/input/Input.d.ts +47 -0
- package/dist/modules/loaders/GeometryConverter.d.ts +32 -0
- package/dist/modules/loaders/KingSy/KingSyConverter.d.ts +118 -0
- package/dist/modules/loaders/KingSy/KingSyGeometryConverter.d.ts +127 -0
- package/dist/modules/loaders/KingSy/KingSyLoader.d.ts +18 -0
- package/dist/modules/loaders/KingSy/KingSyOfflineLoader.d.ts +8 -0
- package/dist/modules/loaders/Loader.d.ts +35 -0
- package/dist/modules/loaders/OBJ/ObjConverter.d.ts +18 -0
- package/dist/modules/loaders/OBJ/ObjGeometryConverter.d.ts +14 -0
- package/dist/modules/loaders/OBJ/ObjLoader.d.ts +16 -0
- package/dist/modules/materials/KingSyBasicMaterial.d.ts +26 -0
- package/dist/modules/materials/KingSyDepthMaterial.d.ts +22 -0
- package/dist/modules/materials/KingSyDepthNormalIdMaterial.d.ts +11 -0
- package/dist/modules/materials/KingSyDepthNormalMaterial.d.ts +6 -0
- package/dist/modules/materials/KingSyDisplaceMaterial.d.ts +11 -0
- package/dist/modules/materials/KingSyGhostMaterial.d.ts +8 -0
- package/dist/modules/materials/KingSyLineMaterial.d.ts +20 -0
- package/dist/modules/materials/KingSyMatcapMaterial.d.ts +19 -0
- package/dist/modules/materials/KingSyMaterial.d.ts +65 -0
- package/dist/modules/materials/KingSyNormalMaterial.d.ts +18 -0
- package/dist/modules/materials/KingSyPointColouredMaterial.d.ts +12 -0
- package/dist/modules/materials/KingSyPointMaterial.d.ts +18 -0
- package/dist/modules/materials/KingSyShadowcatcherMaterial.d.ts +10 -0
- package/dist/modules/materials/KingSyStandardColoredMaterial.d.ts +11 -0
- package/dist/modules/materials/KingSyStandardMaterial.d.ts +22 -0
- package/dist/modules/materials/KingSyTextMaterial.d.ts +26 -0
- package/dist/modules/materials/KingSyViewportMaterial.d.ts +13 -0
- package/dist/modules/materials/MaterialOptions.d.ts +6 -0
- package/dist/modules/materials/Materials.d.ts +111 -0
- package/dist/modules/materials/shaders/kingsy-apply-ao-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-apply-ao-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-basic-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-basic-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-copy-output-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-copy-output-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-normal-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-normal-id-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-normal-id-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-normal-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-depth-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-displace-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-displace.vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-edges-generator-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-edges-generator-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-ghost-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-ghost-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-line-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-line-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-normal-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-normal-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-point-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-point-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-sao-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-sao-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-shadowcatche-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-shadowcatcher-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-standard-colored-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-standard-colored-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-standard-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-standard-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-static-ao-accumulate-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-static-ao-accumulate-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-static-ao-generate-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-static-ao-generate-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-temporal-supersampling-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-temporal-supersampling-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-text-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-text-vert.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-viewport-frag.d.ts +1 -0
- package/dist/modules/materials/shaders/kingsy-viewport-vert.d.ts +1 -0
- package/dist/modules/objects/AccelerationStructure.d.ts +72 -0
- package/dist/modules/objects/ExtendedInstancedMesh.d.ts +6 -0
- package/dist/modules/objects/JitterQuad.d.ts +10 -0
- package/dist/modules/objects/KingSyCamera.d.ts +31 -0
- package/dist/modules/objects/KingSyInstancedMesh.d.ts +44 -0
- package/dist/modules/objects/KingSyMesh.d.ts +43 -0
- package/dist/modules/objects/KingSyRaycaster.d.ts +42 -0
- package/dist/modules/objects/KingSyText.d.ts +39 -0
- package/dist/modules/objects/KingSyWebGLRenderer.d.ts +24 -0
- package/dist/modules/objects/RotatablePMREMGenerator.d.ts +5 -0
- package/dist/modules/objects/TopLevelAccelerationStructure.d.ts +41 -0
- package/dist/modules/pipeline/Passes/BlendPass.d.ts +17 -0
- package/dist/modules/pipeline/Passes/DepthNormalIdPass.d.ts +12 -0
- package/dist/modules/pipeline/Passes/DepthNormalPass.d.ts +25 -0
- package/dist/modules/pipeline/Passes/DepthPass.d.ts +23 -0
- package/dist/modules/pipeline/Passes/EdgesPass.d.ts +25 -0
- package/dist/modules/pipeline/Passes/GPass.d.ts +88 -0
- package/dist/modules/pipeline/Passes/GeometryPass.d.ts +7 -0
- package/dist/modules/pipeline/Passes/NormalsPass.d.ts +8 -0
- package/dist/modules/pipeline/Passes/OutputPass.d.ts +23 -0
- package/dist/modules/pipeline/Passes/ProgressiveAOPass.d.ts +30 -0
- package/dist/modules/pipeline/Passes/ShadedPass.d.ts +26 -0
- package/dist/modules/pipeline/Passes/ShadowcatcherPass.d.ts +43 -0
- package/dist/modules/pipeline/Passes/StencilMaskPass.d.ts +9 -0
- package/dist/modules/pipeline/Passes/StencilPass.d.ts +9 -0
- package/dist/modules/pipeline/Passes/TAAPass.d.ts +15 -0
- package/dist/modules/pipeline/Passes/ViewportPass.d.ts +22 -0
- package/dist/modules/pipeline/Pipelines/ArcticViewPipeline.d.ts +7 -0
- package/dist/modules/pipeline/Pipelines/DefaultPipeline.d.ts +6 -0
- package/dist/modules/pipeline/Pipelines/EdgesPipeline.d.ts +28 -0
- package/dist/modules/pipeline/Pipelines/PenViewPipeline.d.ts +6 -0
- package/dist/modules/pipeline/Pipelines/Pipeline.d.ts +43 -0
- package/dist/modules/pipeline/Pipelines/ProgressivePipeline.d.ts +24 -0
- package/dist/modules/pipeline/Pipelines/ShadedViewPipeline.d.ts +7 -0
- package/dist/modules/pipeline/Pipelines/SolidViewPipeline.d.ts +6 -0
- package/dist/modules/pipeline/Pipelines/TAAPipeline.d.ts +7 -0
- package/dist/modules/queries/IntersectionQuerySolver.d.ts +11 -0
- package/dist/modules/queries/PointQuerySolver.d.ts +9 -0
- package/dist/modules/queries/Queries.d.ts +9 -0
- package/dist/modules/queries/Query.d.ts +51 -0
- package/dist/modules/three/stats.d.ts +4 -0
- package/dist/modules/tree/NodeMap.d.ts +20 -0
- package/dist/modules/tree/NodeRenderView.d.ts +51 -0
- package/dist/modules/tree/RenderTree.d.ts +36 -0
- package/dist/modules/tree/WorldTree.d.ts +52 -0
- package/dist/modules/utils/AngleDamper.d.ts +18 -0
- package/dist/modules/utils/Damper.d.ts +17 -0
- package/dist/modules/utils/Logger.d.ts +2 -0
- package/dist/type-augmentations/three-extensions.d.ts +1 -0
- package/package.json +99 -0
- package/readme.md +30 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type IUniform, Vector2, Material, type MeshBasicMaterialParameters, Scene, Camera, BufferGeometry, Object3D } from 'three';
|
|
2
|
+
import { Matrix4 } from 'three';
|
|
3
|
+
import { ExtendedMeshBasicMaterial, type Uniforms } from './KingSyMaterial.js';
|
|
4
|
+
import type { KingSyWebGLRenderer } from '../objects/KingSyWebGLRenderer.js';
|
|
5
|
+
declare class KingSyTextMaterial extends ExtendedMeshBasicMaterial {
|
|
6
|
+
protected static readonly matBuff: Matrix4;
|
|
7
|
+
protected static readonly vecBuff: Vector2;
|
|
8
|
+
private _billboardPixelHeight;
|
|
9
|
+
protected get vertexProgram(): string;
|
|
10
|
+
protected get fragmentProgram(): string;
|
|
11
|
+
protected get baseUniforms(): {
|
|
12
|
+
[uniform: string]: IUniform;
|
|
13
|
+
};
|
|
14
|
+
protected get uniformsDef(): Uniforms;
|
|
15
|
+
set billboardPixelHeight(value: number);
|
|
16
|
+
get billboardPixelHeight(): number;
|
|
17
|
+
constructor(parameters: MeshBasicMaterialParameters, defines?: Array<string>);
|
|
18
|
+
/** We need a unique key per program */
|
|
19
|
+
customProgramCacheKey(): string;
|
|
20
|
+
copy(source: Material): this;
|
|
21
|
+
getDerivedMaterial(): any;
|
|
22
|
+
fastCopy(from: Material, to: Material): void;
|
|
23
|
+
/** Called by three.js render loop */
|
|
24
|
+
onBeforeRender(_this: KingSyWebGLRenderer, _scene: Scene, camera: Camera, _geometry: BufferGeometry, _object: Object3D): void;
|
|
25
|
+
}
|
|
26
|
+
export default KingSyTextMaterial;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import KingSyBasicMaterial from './KingSyBasicMaterial.js';
|
|
2
|
+
import { Material, MeshBasicMaterialParameters, Texture } from 'three';
|
|
3
|
+
import { Uniforms } from './KingSyMaterial.js';
|
|
4
|
+
declare class KingSyViewportMaterial extends KingSyBasicMaterial {
|
|
5
|
+
protected get vertexProgram(): string;
|
|
6
|
+
protected get fragmentProgram(): string;
|
|
7
|
+
protected get uniformsDef(): Uniforms;
|
|
8
|
+
constructor(parameters: MeshBasicMaterialParameters, defines?: never[]);
|
|
9
|
+
set minIntensity(value: number);
|
|
10
|
+
set matcapTexture(value: Texture | null);
|
|
11
|
+
fastCopy(from: Material, to: Material): void;
|
|
12
|
+
}
|
|
13
|
+
export default KingSyViewportMaterial;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Color, Material, Texture } from 'three';
|
|
2
|
+
import { GeometryType } from '../batching/Batch.js';
|
|
3
|
+
import { type TreeNode } from '../tree/WorldTree.js';
|
|
4
|
+
import { NodeRenderView } from '../tree/NodeRenderView.js';
|
|
5
|
+
import { KingSyMaterial } from './KingSyMaterial.js';
|
|
6
|
+
import { type MaterialOptions } from '../../IViewer.js';
|
|
7
|
+
export interface RenderMaterial extends MinimalMaterial {
|
|
8
|
+
id: string;
|
|
9
|
+
emissive: number;
|
|
10
|
+
opacity: number;
|
|
11
|
+
roughness: number;
|
|
12
|
+
metalness: number;
|
|
13
|
+
vertexColors: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DisplayStyle extends MinimalMaterial {
|
|
16
|
+
id: string;
|
|
17
|
+
lineWeight: number;
|
|
18
|
+
opacity?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface MinimalMaterial {
|
|
21
|
+
color: number;
|
|
22
|
+
}
|
|
23
|
+
export declare enum FilterMaterialType {
|
|
24
|
+
GHOST = 0,
|
|
25
|
+
GRADIENT = 1,
|
|
26
|
+
COLORED = 2,
|
|
27
|
+
HIDDEN = 3
|
|
28
|
+
}
|
|
29
|
+
/** TO DO: This still sucks */
|
|
30
|
+
export interface FilterMaterial {
|
|
31
|
+
filterType: FilterMaterialType;
|
|
32
|
+
rampIndex?: number;
|
|
33
|
+
rampIndexColor?: Color;
|
|
34
|
+
rampTexture?: Texture;
|
|
35
|
+
}
|
|
36
|
+
export interface FilterMaterialOptions {
|
|
37
|
+
rampIndex?: number;
|
|
38
|
+
rampIndexColor?: Color;
|
|
39
|
+
rampTexture?: Texture;
|
|
40
|
+
rampWidth?: number;
|
|
41
|
+
}
|
|
42
|
+
export default class Materials {
|
|
43
|
+
static readonly UNIFORM_VECTORS_USED = 33;
|
|
44
|
+
static readonly DEFAULT_ARTIFICIAL_ROUGHNESS = 0.6; /** The inverse of "shininess" */
|
|
45
|
+
private readonly materialMap;
|
|
46
|
+
private meshGhostMaterial;
|
|
47
|
+
private meshGradientMaterial;
|
|
48
|
+
private meshTransparentGradientMaterial;
|
|
49
|
+
private meshColoredMaterial;
|
|
50
|
+
private meshTransparentColoredMaterial;
|
|
51
|
+
private meshHiddenMaterial;
|
|
52
|
+
private lineGhostMaterial;
|
|
53
|
+
private lineColoredMaterial;
|
|
54
|
+
private lineHiddenMaterial;
|
|
55
|
+
private pointGhostMaterial;
|
|
56
|
+
private pointCloudColouredMaterial;
|
|
57
|
+
private pointCloudGradientMaterial;
|
|
58
|
+
private textGhostMaterial;
|
|
59
|
+
private textColoredMaterial;
|
|
60
|
+
private textHiddenMaterial;
|
|
61
|
+
private defaultGradientTextureData;
|
|
62
|
+
private static readonly NullRenderMaterialHash;
|
|
63
|
+
private static readonly NullRenderMaterialVertexColorsHash;
|
|
64
|
+
private static readonly NullDisplayStyleHash;
|
|
65
|
+
private static readonly NullTextDisplayStyle;
|
|
66
|
+
private static readonly NullPointMaterialHash;
|
|
67
|
+
private static readonly NullPointCloudMaterialHash;
|
|
68
|
+
private static readonly NullPointCloudVertexColorsMaterialHash;
|
|
69
|
+
private static readonly NullRenderMaterialInstancedHash;
|
|
70
|
+
private static readonly NullRenderMaterialInstancedVertexColorHash;
|
|
71
|
+
static renderMaterialFromNode(materialNode: TreeNode | null, geometryNode: TreeNode | null): RenderMaterial | null;
|
|
72
|
+
static displayStyleFromNode(node: TreeNode | null): DisplayStyle | null;
|
|
73
|
+
static colorMaterialFromNode(node: TreeNode | null): MinimalMaterial | null;
|
|
74
|
+
static fastCopy(from: Material, to: Material): void;
|
|
75
|
+
private static renderMaterialToString;
|
|
76
|
+
private static displayStyleToString;
|
|
77
|
+
private static minimalMaterialToString;
|
|
78
|
+
private static hashCode;
|
|
79
|
+
static isMaterialInstance(material: Material | FilterMaterial | RenderMaterial | DisplayStyle): material is Material;
|
|
80
|
+
static isFilterMaterial(material: Material | FilterMaterial | RenderMaterial | DisplayStyle): material is FilterMaterial;
|
|
81
|
+
static isRenderMaterial(materialData: Material | FilterMaterial | RenderMaterial | DisplayStyle | MaterialOptions): materialData is RenderMaterial;
|
|
82
|
+
static isDisplayStyle(materialData: Material | FilterMaterial | RenderMaterial | DisplayStyle | MaterialOptions): materialData is DisplayStyle;
|
|
83
|
+
static getMaterialHash(renderView: NodeRenderView, materialData?: RenderMaterial | DisplayStyle | MaterialOptions | null): number;
|
|
84
|
+
static isTransparent(material: Material): boolean;
|
|
85
|
+
static isOpaque(material: Material): boolean;
|
|
86
|
+
static isKingSyMaterial(material: Material): material is KingSyMaterial & Material;
|
|
87
|
+
private createDefaultMeshMaterials;
|
|
88
|
+
private createLineDefaultMaterials;
|
|
89
|
+
private createDefaultPointMaterials;
|
|
90
|
+
private createDefaultTextMaterials;
|
|
91
|
+
private createDefaultNullMaterials;
|
|
92
|
+
createDefaultMaterials(): Promise<void>;
|
|
93
|
+
private makeMeshMaterial;
|
|
94
|
+
private makeLineMaterial;
|
|
95
|
+
private makePointMaterial;
|
|
96
|
+
private makeTextMaterial;
|
|
97
|
+
getMaterial(hash: number, material: RenderMaterial | DisplayStyle | MinimalMaterial | null, type: GeometryType): Material;
|
|
98
|
+
private getMeshMaterial;
|
|
99
|
+
private getLineMaterial;
|
|
100
|
+
private getPointMaterial;
|
|
101
|
+
private getPointCloudMaterial;
|
|
102
|
+
private getTextMaterial;
|
|
103
|
+
getGhostMaterial(renderView: NodeRenderView, filterMaterial?: FilterMaterial): Material | null;
|
|
104
|
+
getGradientMaterial(renderView: NodeRenderView, filterMaterial?: FilterMaterial): Material | null;
|
|
105
|
+
getColoredMaterial(renderView: NodeRenderView, filterMaterial?: FilterMaterial): Material | null;
|
|
106
|
+
getHiddenMaterial(renderView: NodeRenderView, filterMaterial?: FilterMaterial): Material | null;
|
|
107
|
+
getFilterMaterial(renderView: NodeRenderView, filterMaterial: FilterMaterial): Material | null;
|
|
108
|
+
getDataMaterial(renderView: NodeRenderView, materialData: RenderMaterial & DisplayStyle & MaterialOptions): Material;
|
|
109
|
+
getFilterMaterialOptions(filterMaterial: FilterMaterial): FilterMaterialOptions | null;
|
|
110
|
+
purge(): void;
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyApplyAoFrag = "\n\n #if BLEND_AO == 1\n\t\t uniform sampler2D tAo;\n #endif\n #if BLEND_EDGES == 1\n uniform sampler2D tEdges;\n #endif\n\t\tvarying vec2 vUv;\n\n #define ONE3 vec3(1.,1.,1.)\n\n\t\tvoid main() {\n vec3 ao = ONE3;\n vec3 edges = ONE3;\n \n #if BLEND_AO == 1\n ao = texture2D( tAo, vUv ).rgb;\n #endif\n\n #if BLEND_EDGES == 1\n edges = texture2D (tEdges, vUv).rgb;\n #endif\n \n gl_FragColor.rgb = min(ao, edges);\n\t\t\tgl_FragColor.a = 1.;\n\t\t}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyApplyAoVert = "\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyBasicFrag = "\nuniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t// modulation\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t// #include <output_fragment> COMMENTED CHUNK\n\t#ifdef OPAQUE\n\t\tdiffuseColor.a = 1.0;\n\t#endif\n\n\t// https://github.com/mrdoob/three.js/pull/22425\n\t#ifdef USE_TRANSMISSION\n\t\tdiffuseColor.a *= transmissionAlpha + 0.1;\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight * diffuseColor.a, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyBasicVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n } \n#endif\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n#endif\n\n#if defined(BILLBOARD) || defined(BILLBOARD_FIXED)\n uniform vec3 billboardPos;\n uniform mat4 invProjection;\n#endif\n#ifdef BILLBOARD_FIXED\n uniform vec2 billboardSize;\n uniform vec2 billboardOffset;\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n mvPosition = modelViewMatrix * mvPosition;\n \n #if defined(BILLBOARD)\n float div = 1.;\n gl_Position = projectionMatrix * (viewMatrix * vec4(billboardPos, 1.0) + vec4(position.x, position.y, 0., 0.0));\n #elif defined(BILLBOARD_FIXED)\n gl_Position = projectionMatrix * (viewMatrix * vec4(billboardPos, 1.0));\n float div = gl_Position.w;\n gl_Position /= gl_Position.w;\n gl_Position.xy += (position.xy + billboardOffset) * billboardSize;\n #else\n gl_Position = projectionMatrix * mvPosition;\n #endif\n\n\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex> COMMENTED CHUNK\n #if NUM_CLIPPING_PLANES > 0\n #if defined(BILLBOARD) || defined(BILLBOARD_FIXED)\n vec4 movelViewProjection = gl_Position * div;\n vClipPosition = - (invProjection * movelViewProjection).xyz;\n #else\n\t vClipPosition = - mvPosition.xyz;\n #endif\n #endif\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyCopyOutputFrag = "\n uniform float opacity;\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n\n const float UnpackDownscale = 255. / 256.;\n const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\n const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\n float unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors );\n }\n\n vec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n }\n\n void main() {\n vec4 inSample = texture2D( tDiffuse, vUv );\n vec3 outSample = inSample.rgb;\n #if INPUT_TYPE == 0\n /** \n Un-premultiply alpha\n */\n inSample.rgb /= inSample.a;\n outSample = LinearTosRGB( inSample ).rgb;\n #elif INPUT_TYPE == 1\n outSample.rgb = vec3(unpackRGBAToDepth(inSample));\n #elif INPUT_TYPE == 2\n outSample.rgb = unpackRGBToNormal(inSample.rgb);\n #endif\n\n gl_FragColor.rgb = outSample;\n gl_FragColor.a = inSample.a;\n }";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyCopyOutputVert = "\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthFrag = "\n#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n\tuniform float near;\n\tuniform float far;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t// #include <alphatest_fragment>\n\t#ifdef USE_ALPHATEST\n\t\tif ( diffuseColor.a < alphaTest ) discard;\n\t\t/** This is a workaround for rejecting shadows for certain materials, since three.js gave me no choice*/\n\t\t#ifdef ALPHATEST_REJECTION\n\t\t\tif (alphaTest > 0. ) discard;\n\t\t#endif\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\t#ifdef LINEAR_DEPTH\n\t\t/** View z is negative moving away from the camera */\n\t\tgl_FragColor = packDepthToRGBA((vViewPosition.z + near) / (near - far));\n\t#else\n\t\tfloat fragCoordZ = (0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5);\n\t\t#if DEPTH_PACKING == 3200\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t\t#elif DEPTH_PACKING == 3201\n\t\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t\t#endif\n\t#endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthNormalFrag = "\n#if __VERSION__ == 100\n #extension GL_EXT_draw_buffers : require\n#endif\n\n#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n\tuniform float near;\n\tuniform float far;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvarying vec3 vNormal;\n\n#if __VERSION__ == 300\n layout(location = 1) out vec4 gNormal;\n#endif\n\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t// #include <alphatest_fragment>\n\t#ifdef USE_ALPHATEST\n\t\tif ( diffuseColor.a < alphaTest ) discard;\n\t\t/** This is a workaround for rejecting shadows for certain materials, since three.js gave me no choice*/\n\t\t#ifdef ALPHATEST_REJECTION\n\t\t\tif (alphaTest > 0. ) discard;\n\t\t#endif\n\t#endif\n\t#include <logdepthbuf_fragment>\n vec3 normal = normalize( vNormal );\n\n /** Output view space normals*/\n \n vec4 outNormal = vec4( packNormalToRGB( normal ), 1.0 );\n vec4 outDepth;\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\t#ifdef LINEAR_DEPTH\n\t\t/** View z is negative moving away from the camera */\n\t\toutDepth = packDepthToRGBA((vViewPosition.z + near) / (near - far));\n\t#else\n\t\tfloat fragCoordZ = (0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5);\n\t\t#if DEPTH_PACKING == 3200\n\t\t\toutDepth = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t\t#elif DEPTH_PACKING == 3201\n\t\t\toutDepth = packDepthToRGBA( fragCoordZ );\n\t\t#endif\n\t#endif\n #if __VERSION__ == 300\n pc_fragColor = outDepth;\n gNormal = outNormal;\n #else\n gl_FragData[0] = outDepth;\n gl_FragData[1] = outNormal;\n #endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthNormalIdFrag = "\n#if __VERSION__ == 100\n #extension GL_EXT_draw_buffers : require\n#endif\n\n#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n\tuniform float near;\n\tuniform float far;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvarying vec3 vNormal;\n\nvarying vec3 vIdColor;\n\n#if __VERSION__ == 300\n layout(location = 1) out vec4 gNormal;\n layout(location = 2) out vec4 gId;\n#endif\n\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t// #include <alphatest_fragment>\n\t#ifdef USE_ALPHATEST\n\t\tif ( diffuseColor.a < alphaTest ) discard;\n\t\t/** This is a workaround for rejecting shadows for certain materials, since three.js gave me no choice*/\n\t\t#ifdef ALPHATEST_REJECTION\n\t\t\tif (alphaTest > 0. ) discard;\n\t\t#endif\n\t#endif\n\t#include <logdepthbuf_fragment>\n vec3 normal = normalize( vNormal );\n\n /** Output view space normals*/\n \n vec4 outNormal = vec4( packNormalToRGB( normal ), 1.0 );\n vec4 outDepth;\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\t#ifdef LINEAR_DEPTH\n\t\t/** View z is negative moving away from the camera */\n\t\toutDepth = packDepthToRGBA((vViewPosition.z + near) / (near - far));\n\t#else\n\t\tfloat fragCoordZ = (0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5);\n\t\t#if DEPTH_PACKING == 3200\n\t\t\toutDepth = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t\t#elif DEPTH_PACKING == 3201\n\t\t\toutDepth = packDepthToRGBA( fragCoordZ );\n\t\t#endif\n\t#endif\n #if __VERSION__ == 300\n pc_fragColor = outDepth;\n gNormal = outNormal;\n gId = vec4(vIdColor, 1.0);\n #else\n gl_FragData[0] = outDepth;\n gl_FragData[1] = outNormal;\n gl_FragData[2] = vec4(vIdColor, 1.0);\n #endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthNormalIdVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#if defined( TRANSFORM_STORAGE ) || ( defined( USE_INSTANCING ) && __VERSION__ == 100)\n attribute float objIndex;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\nvarying vec3 vIdColor;\nuniform int batchIndex;\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\n/** Original glsl100 and glsl300 hash functions. Good outputs but maybe a bit slow? */\n/*\n#if __VERSION__ == 300\n vec3 hashColor(uint id) {\n // A simple integer hash function\n id = (id ^ 61u) ^ (id >> 16u);\n id = id * 9u;\n id = id ^ (id >> 4u);\n id = id * 0x27d4eb2du;\n id = id ^ (id >> 15u);\n\n return vec3(\n float((id >> 16u) & 0xFFu) / 255.0,\n float((id >> 8u) & 0xFFu) / 255.0,\n float(id & 0xFFu) / 255.0\n );\n }\n#elif __VERSION__ == 100\n vec3 hashColor(float id) {\n // Step 1: Simulate XOR by using mod and floating-point arithmetic\n id = mod(id + 61.0, 4294967296.0);\n id = mod(id - floor(id / 65536.0), 4294967296.0); // Approximate id ^ (id >> 16)\n // Step 2: Multiply by 9 (same as original)\n id = mod(id * 9.0, 4294967296.0);\n // Step 3: Simulate XOR with division/mod trick\n id = mod(id - floor(id / 16.0), 4294967296.0); // Approximate id ^ (id >> 4)\n // Step 4: Multiply by large prime\n id = mod(id * 666083407.0, 4294967296.0); // Approximate * 0x27d4eb2dU\n // Step 5: Simulate final XOR\n id = mod(id - floor(id / 32768.0), 4294967296.0); // Approximate id ^ (id >> 15)\n // Convert hash to RGB by extracting \"fake\" bit shifts\n return vec3(\n mod(floor(id / 65536.0), 256.0) / 255.0, // Simulates (id >> 16) & 0xFF\n mod(floor(id / 256.0), 256.0) / 255.0, // Simulates (id >> 8) & 0xFF\n mod(id, 256.0) / 255.0 // Simulates id & 0xFF\n );\n }\n#endif\n*/\n\n/** Simpler hash function works on both glsl versions */\nhighp vec3 hashColor(float id) {\n // Large prime multipliers\n highp float r = mod(id * 127.1, 256.0) / 255.0;\n highp float g = mod(id * 987.654, 256.0) / 255.0;\n highp float b = mod(id * 4321.123, 256.0) / 255.0;\n \n return vec3(r, g, b);\n}\n\nint szudzikHash(int x, int y) {\n return (x >= y) ? (x * x + x + y) : (y * y + x);\n}\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n #include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n\n vNormal = normalize( transformedNormal );\n \n #ifdef TRANSFORM_STORAGE\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #else\n #if defined( USE_INSTANCING ) \n #if __VERSION__ == 300\n vIdColor = hashColor(float(szudzikHash(int(gl_InstanceID), batchIndex)));\n #elif __VERSION__ == 100\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #endif\n #else\n vIdColor = vec3(0.);\n #endif\n #endif\n\n\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthNormalVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n #include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n vNormal = normalize( transformedNormal );\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDepthVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n \n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n \n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDisplaceFrag = "\nuniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t// modulation\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyDisplaceVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\nuniform vec2 size;\nuniform float displacement;\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n \n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n mvPosition = modelViewMatrix * mvPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n \n // Transform normal vector from object space to clip space.\n vec3 normalHCS = mat3(projectionMatrix) * normalMatrix * normal;\n\n // Move vertex along normal vector in clip space.\n gl_Position.xy += normalize(normalHCS.xy) / size * gl_Position.w * displacement * 2.;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyEdgesGeneratorFrag = "\n#include <common>\nvarying vec2 vUv;\nuniform sampler2D tDepth;\nuniform sampler2D tNormal;\nuniform sampler2D tId;\nuniform float uDepthMultiplier;\nuniform float uDepthBias;\nuniform float uNormalMultiplier;\nuniform float uNormalBias;\nuniform float uOutlineThickness;\nuniform float uOutlineDensity;\nuniform vec3 uOutlineColor;\nuniform vec3 uBackgroundColor;\nuniform vec2 size;\n\nuniform float cameraNear;\nuniform float cameraFar;\nuniform mat4 cameraProjectionMatrix;\nuniform mat4 cameraInverseProjectionMatrix;\n\n#define ID_GRADIENT_THRESHOLD 1e-4\n#include <packing>\n\n\nfloat getDepth( const in ivec2 screenPosition ) {\n #if __VERSION__ == 300\n\t return unpackRGBAToDepth( texelFetch( tDepth, clamp(screenPosition, ivec2(0,0), ivec2(size)), 0 ) );\n #else\n vec2 cUv = vec2(0.5/size.x, 0.5/size.y);\n return unpackRGBAToDepth( texture2D( tDepth, vec2(min(screenPosition, ivec2(size)))/size + cUv ) );\n #endif\n}\n\n\n\nvec3 SobelSample(sampler2D t, vec2 uv, vec3 offset){\n\tvec3 pixelCenter = texture2D(t, uv).rgb;\n\tvec3 pixelLeft = texture2D(t, uv - offset.xz).rgb;\n\tvec3 pixelRight = texture2D(t, uv + offset.xz).rgb;\n\tvec3 pixelUp = texture2D(t, uv + offset.zy).rgb;\n\tvec3 pixelDown = texture2D(t, uv - offset.zy).rgb;\n\n\treturn abs(pixelLeft - pixelCenter) +\n\t\t\tabs(pixelRight - pixelCenter) +\n\t\t\tabs(pixelUp - pixelCenter) +\n\t\t\tabs(pixelDown - pixelCenter);\n}\n\n\nfloat GetTolerance(float d, float k)\n{\n // -------------------------------------------\n // Find a tolerance for depth that is constant\n // in view space (k in view space).\n //\n // tol = k*ddx(ZtoDepth(z))\n // -------------------------------------------\n \n float A=- (cameraFar+cameraNear)/(cameraFar - cameraNear);\n float B=-2.0*cameraFar*cameraNear /(cameraFar -cameraNear);\n \n d = d*2.0-1.0;\n \n return -k*(d+A)*(d+A)/B; \n}\n\nfloat DetectSilho(ivec2 fragCoord, ivec2 dir, float tolerance)\n{\n // -------------------------------------------\n // x0 ___ x1----o \n // : : \n // r0 : : r1\n // : : \n // o---x2 ___ x3\n //\n // r0 and r1 are the differences between actual\n // and expected (as if x0..3 where on the same\n // plane) depth values.\n // -------------------------------------------\n float x0 = abs(getDepth(fragCoord + dir*-2));\n float x1 = abs(getDepth(fragCoord + dir*-1));\n float x2 = abs(getDepth(fragCoord + dir* 0));\n float x3 = abs(getDepth(fragCoord + dir* 1));\n \n float d0 = (x1-x0);\n float d1 = (x2-x3);\n \n float r0 = x1 + d0 - x2;\n float r1 = x2 + d1 - x1;\n \n float tol = GetTolerance(x2, tolerance);\n \n return smoothstep(0.0, tol*tol, max( - r0*r1, 0.0));\n\n}\n\n// Source: https://www.shadertoy.com/view/DslXz2\nfloat DepthEdge(ivec2 fragCoord, float tolerance)\n{\n return max(\n DetectSilho(fragCoord, ivec2(1,0), tolerance), // Horizontal\n DetectSilho(fragCoord, ivec2(0,1), tolerance) // Vertical\n );\n}\n\nfloat NormalEdge(float scale)\n{\n\tfloat halfScaleFloor = floor(scale * 0.5);\n\tfloat halfScaleCeil = ceil(scale * 0.5);\n\n\tvec2 pixelSize = vec2(1.0 / size.x, 1.0 / size.y);\n\n\tvec2 bottomLeftUV = vUv - pixelSize * halfScaleFloor;\n\tvec2 topRightUV = vUv + pixelSize * halfScaleCeil; \n\tvec2 bottomRightUV = vUv + vec2(pixelSize.x * halfScaleCeil, -pixelSize.y * halfScaleFloor);\n\tvec2 topLeftUV = vUv + vec2(-pixelSize.x * halfScaleFloor, pixelSize.y * halfScaleCeil);\n\n\tvec3 centerNormal = unpackRGBToNormal(texture2D(tNormal, vUv).rgb);\n\tvec3 normal0 = unpackRGBToNormal(texture2D(tNormal, bottomLeftUV).rgb);\n\tvec3 normal1 = unpackRGBToNormal(texture2D(tNormal, topRightUV).rgb);\n\tvec3 normal2 = unpackRGBToNormal(texture2D(tNormal, bottomRightUV).rgb);\n\tvec3 normal3 = unpackRGBToNormal(texture2D(tNormal, topLeftUV).rgb);\n\n\tvec3 normalFiniteDifference0 = normal1 - normal0;\n\tvec3 normalFiniteDifference1 = normal3 - normal2;\n\n\treturn sqrt(dot(normalFiniteDifference0, normalFiniteDifference0) + dot(normalFiniteDifference1, normalFiniteDifference1));\n}\n\n/** Alternative to NormalEdge. */\nvec3 SobelSampleNormal(vec2 uv){\n\tfloat w = 1.0 / size.x;\n\tfloat h = 1.0 / size.y;\n\tvec3 n[9];\n\tn[0] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( -w, -h)).rgb);\n\tn[1] = unpackRGBToNormal(texture2D(tNormal, uv + vec2(0.0, -h)).rgb);\n\tn[2] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( w, -h)).rgb);\n\tn[3] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( -w, 0.0)).rgb);\n\tn[4] = unpackRGBToNormal(texture2D(tNormal, uv).rgb);\n\tn[5] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( w, 0.0)).rgb);\n\tn[6] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( -w, h)).rgb);\n\tn[7] = unpackRGBToNormal(texture2D(tNormal, uv + vec2(0.0, h)).rgb);\n\tn[8] = unpackRGBToNormal(texture2D(tNormal, uv + vec2( w, h)).rgb);\n\n\tvec3 sobel_edge_h = n[2] + (2.0*n[5]) + n[8] - (n[0] + (2.0*n[3]) + n[6]);\n \tvec3 sobel_edge_v = n[0] + (2.0*n[1]) + n[2] - (n[6] + (2.0*n[7]) + n[8]);\n\tvec3 sobel = sqrt((sobel_edge_h * sobel_edge_h) + (sobel_edge_v * sobel_edge_v));\n\treturn sobel;\n}\n\n\nvoid main() {\n\t// Depth edge\n float depthEdge = DepthEdge(ivec2(gl_FragCoord), uDepthBias) * uDepthMultiplier; \n // Normal edge\n\tfloat normalEdge = pow(NormalEdge(uOutlineThickness) * uNormalMultiplier, uNormalBias);\n // Id edge\n\tvec3 offset = vec3((1.0 / size.x), (1.0 / size.y), 0.0) * uOutlineThickness;\n\tvec3 sobelIdVec = abs(SobelSample(tId, vUv, offset));\n // This is the branchless equivalent of sobelIdVec.x + sobelIdVec.y + sobelIdVec.z > ID_GRADIENT_THRESHOLD ? 1. : 0.\n\tfloat sobelIdEdge = step(ID_GRADIENT_THRESHOLD, sobelIdVec.x + sobelIdVec.y + sobelIdVec.z);\n\n // Combine the three edges by taking the minimum\n float maxOutline = saturate(max(sobelIdEdge, max(depthEdge, normalEdge)));\n\tfloat sobelOutline = maxOutline * uOutlineDensity;\n\n \n vec3 color = mix(uBackgroundColor, uOutlineColor, sobelOutline);\n float alpha = mix(0., uOutlineDensity, sobelOutline);\n // vec3 color = vec3(depthEdge, normalEdge, sobelIdEdge); // Debug\n\tgl_FragColor = vec4(color, alpha);\n\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyEdgesGeneratorVert = "\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyGhostFrag = "\nuniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n // We're disabling alpha testing because we need to use it for shadow rejection. Three.js gave me no choice\n\t// #include <alphatest_fragment> \n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t// modulation\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyGhostVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n mvPosition = modelViewMatrix * mvPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyLineFrag = "\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\t\tvarying float vAlpha;\n\t\t// varying vec3 debugColor;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\t\t\tvarying float correctedLineWidth;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha;\n\t\t\t#ifdef UNIFORM_OPACITY\n\t\t\t\talpha = opacity;\n\t\t\t#else\n\t\t\t\talpha = vAlpha;\n\t\t\t#endif\n\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / correctedLineWidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t// #include <color_fragment> COMMENTED CHUNK\n\t\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\t\tdiffuseColor *= vColor;\n\t\t\t#elif defined( USE_COLOR )\n\t\t\t\tdiffuseColor.rgb = vColor;\n\t\t\t#endif\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyLineVert = "\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\t\tuniform float pixelThreshold;\n\n\t\tvarying float vAlpha;\n\n\t\t#define SEARCH_STEPS 10\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec4 instanceColorStart;\n\t\tattribute vec4 instanceColorEnd;\n\t\t// varying vec3 debugColor;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\t\t\tvarying float correctedLineWidth;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n #ifdef USE_RTE\n\t\t\tattribute vec3 instanceStartLow;\n\t\t\tattribute vec3 instanceEndLow;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n #endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tfloat screenSpaceDistance(vec4 p0, vec4 p1) {\n\t\t\tp0 = projectionMatrix * p0;\n\t\t\tp0 /= p0.w;\n\t\t\tp1 = projectionMatrix * p1;\n\t\t\tp1 /= p1.w;\n\t\t\treturn length(p1.xy - p0.xy);\n\t\t}\n\n\t\thighp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n\t\t\t/* \n\t\t\tSource https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n\t\t\tNote here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n\t\t\t*/\n\t\t\thighp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n\t\t\thighp vec3 e = t1 - position_low.xyz;\n\t\t\t/** This is redunant, but necessary as a workaround for Apple platforms */\n\t\t\thighp float x = position_high.x - relativeTo_high.x;\n\t\t\thighp float y = position_high.y - relativeTo_high.y;\n\t\t\thighp float z = position_high.z - relativeTo_high.z;\n\t\t\thighp vec3 v = vec3(x, y, z);\n\t\t\t/** End of redundant part */\n\t\t\thighp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n\t\t\thighp vec3 highDifference = t1 + t2;\n\t\t\thighp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n\t\t\t\n\t\t\thighp vec3 position = highDifference.xyz + lowDifference.xyz;\n\t\t\treturn vec4(position, 1.);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tif(instanceColorStart.w == 0.) {\n\t\t\t\tgl_Position = vec4(0.);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tvAlpha = instanceColorStart.w;\n\n vec3 computedPosition = position;\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( computedPosition.y < 0.5 ) ? instanceColorStart.xyz : instanceColorEnd.xyz;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( computedPosition.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n #ifdef USE_RTE\n\t\t\t/** Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl */\n\t\t\t\t// vec3 t1 = instanceStartLow.xyz - uViewer_low;\n\t\t\t\t// vec3 e = t1 - instanceStartLow.xyz;\n\t\t\t\t// vec3 t2 = ((-uViewer_low - e) + (instanceStartLow.xyz - (t1 - e))) + instanceStart.xyz - uViewer_high;\n\t\t\t\t// vec3 highDifference = t1 + t2;\n\t\t\t\t// vec3 lowDifference = t2 - (highDifference - t1);\n\t\t\t\t// vec4 start = modelViewMatrix * vec4(highDifference.xyz + lowDifference.xyz , 1.);\n\t\t\t\tvec4 start = modelViewMatrix * computeRelativePosition(instanceStartLow.xyz, instanceStart.xyz, uViewer_low, uViewer_high);\n\t\t\t\t\n\t\t\t\t// t1 = instanceEndLow.xyz - uViewer_low;\n\t\t\t\t// e = t1 - instanceEndLow.xyz;\n\t\t\t\t// t2 = ((-uViewer_low - e) + (instanceEndLow.xyz - (t1 - e))) + instanceEnd.xyz - uViewer_high;\n\t\t\t\t// highDifference = t1 + t2;\n\t\t\t\t// lowDifference = t2 - (highDifference - t1);\n\t\t\t\t// vec4 end = modelViewMatrix * vec4(highDifference.xyz + lowDifference.xyz , 1.);\n\t\t\t\tvec4 end = modelViewMatrix * computeRelativePosition(instanceEndLow.xyz, instanceEnd.xyz, uViewer_low, uViewer_high);\n #else\n vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n #endif\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// get the offset direction as perpendicular to the view vector\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 offset;\n\t\t\t\tif ( computedPosition.y < 0.5 ) {\n\n\t\t\t\t\toffset = normalize( cross( start.xyz, worldDir ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\toffset = normalize( cross( end.xyz, worldDir ) );\n\n\t\t\t\t}\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( computedPosition.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\tfloat forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// extend the line bounds to encompass endcaps\n\t\t\t\t\tstart.xyz += - worldDir * linewidth * 0.5;\n\t\t\t\t\tend.xyz += worldDir * linewidth * 0.5;\n\n\t\t\t\t\t// shift the position of the quad so it hugs the forward edge of the line\n\t\t\t\t\toffset.xy -= dir * forwardOffset;\n\t\t\t\t\toffset.z += 0.5;\n\n\t\t\t\t#endif\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( computedPosition.y > 1.0 || computedPosition.y < 0.0 ) {\n\n\t\t\t\t\toffset.xy += dir * 2.0 * forwardOffset;\n\n\t\t\t\t}\n\n\t\t\t\t// debugColor = vec3(0., 0., 1.);\n\t\t\t\tcorrectedLineWidth = linewidth;\n\t\t\t\tvec3 cOffset = offset;\n\t\t\t\t\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth * 0.5;\n\n\t\t\t\t// set the world position\n\t\t\t\tworldPos = ( computedPosition.y < 0.5 ) ? start : end;\n\n\t\t\t\t/*\n\t\t\t\tNot great, not terrible\n\t\t\t\t*/\n\t\t\t\tfloat pixelSize = length(vec2(pixelThreshold/resolution.x + pixelThreshold/resolution.y));\n\t\t\t\tfloat offsetStep = linewidth;\n\t\t\t\tfloat d = screenSpaceDistance(worldPos, worldPos + vec4(cOffset * offsetStep, 0.));\n\t\t\t\t/* We're trying to start off with a step closer to the initial difference between SS distance and the pixel size we want\n\t\t\t\t*/\n\t\t\t\t// offsetStep += pixelSize - d;\n\t\t\t\tvec3 move = offset;\n\t\t\t\t\n\t\t\t\tfor(int i = 0; i < SEARCH_STEPS; i++){\n\t\t\t\t\tmove = cOffset * offsetStep;\n\t\t\t\t\td = screenSpaceDistance(worldPos, worldPos + vec4(move, 0.));\n\t\t\t\t\tif(d > pixelSize) {\n\t\t\t\t\t\tcorrectedLineWidth = offsetStep;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\toffsetStep += offsetStep;\n\t\t\t\t}\n\n\t\t\t\tworldPos.xyz += move;\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( computedPosition.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( computedPosition.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( computedPosition.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( computedPosition.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( computedPosition.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( computedPosition.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyNormalFrag = "\n#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyNormalVert = "\n#define NORMAL\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n //#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n\n mvPosition = modelViewMatrix * mvPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\t vViewPosition = - mvPosition.xyz;\n #endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyPointFrag = "\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n#ifdef USE_GRADIENT_RAMP\n\tvarying float vGradientIndex;\n\tuniform sampler2D gradientRamp;\n#endif\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\n\t#ifdef USE_GRADIENT_RAMP\n\t\tvec4 diffuseColor = vec4( texture2D(gradientRamp, vec2(vGradientIndex, 0.)).rgb, opacity );\n\t#else\n\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#endif\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\n\toutgoingLight = diffuseColor.rgb;\n\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyPointVert = "\nuniform float size;\nuniform float scale;\n\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\nhighp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n}\n\n#ifdef USE_GRADIENT_RAMP\n attribute float gradientIndex;\n varying float vGradientIndex;\n#endif\n\nvoid main() {\n\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n\t#ifdef USE_RTE\n vec4 mvPosition = computeRelativePosition(position_low.xyz, position.xyz, uViewer_low, uViewer_high);\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #endif\n \n #ifdef USE_INSTANCING\n\n mvPosition = instanceMatrix * mvPosition;\n\n #endif\n mvPosition = modelViewMatrix * mvPosition;\n\n #ifdef USE_GRADIENT_RAMP\n vGradientIndex = gradientIndex;\n #endif\n\n gl_Position = projectionMatrix * mvPosition;\n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsySaoFrag = "\n\t\t#include <common>\n\t\tvarying vec2 vUv;\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\t\tuniform sampler2D tDepth;\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\t\t// RGBA depth\n\t\t#include <packing>\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\t//https://wickedengine.net/2019/09/22/improved-normal-reconstruction-from-depth/\n\t\tvec3 viewNormalImproved(in vec2 uv, in vec3 origin)\n\t\t{\t\n\t\t\thighp vec2 dd = abs(vec2(1./size.x, 1./size.y));\n\t\t\thighp vec2 ddx = vec2(dd.x, 0.);\n\t\t\thighp vec2 ddy = vec2(0., dd.y);\n\n\t\t\tfloat sampleDepth = getDepth( uv - ddy );\n\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 top = getViewPosition( uv - ddy, sampleDepth, sampleViewZ );\n\n\t\t\tsampleDepth = getDepth( uv + ddy );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 bottom = getViewPosition( uv + ddy, sampleDepth, sampleViewZ );\n\n\t\t\thighp vec3 center = origin;\n\t\t\t\n\t\t\tsampleDepth = getDepth( uv - ddx );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 left = getViewPosition( uv - ddx, sampleDepth, sampleViewZ );\n\n\t\t\tsampleDepth = getDepth( uv + ddx );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 right = getViewPosition( uv + ddx, sampleDepth, sampleViewZ );\n\n\t\t\t // get the difference between the current and each offset position\n\t\t\tvec3 l = center - left;\n\t\t\tvec3 r = right - center;\n\t\t\tvec3 d = center - top;\n\t\t\tvec3 u = bottom - center;\n\n\t\t\t// pick horizontal and vertical diff with the smallest z difference\n\t\t\tvec3 hDeriv = abs(l.z) < abs(r.z) ? l : r;\n\t\t\tvec3 vDeriv = abs(d.z) < abs(u.z) ? d : u;\n\n\t\t\t// get view space normal from the cross product of the two smallest offsets\n\t\t\tvec3 viewNormal = normalize(cross(hDeriv, vDeriv));\n\n\t\t\treturn viewNormal;\n\t\t}\n\n\t\tvec3 viewNormalAccurate(in vec2 uv, in vec3 origin, in float centerDepth) {\n\t\t\thighp vec2 dd = abs(vec2(1./size.x, 1./size.y));\n\t\t\thighp vec2 ddx = vec2(dd.x, 0.);\n\t\t\thighp vec2 ddy = vec2(0., dd.y);\n\n\t\t\tfloat sampleDepth = getDepth( uv - ddy );\n\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 top = getViewPosition( uv - ddy, sampleDepth, sampleViewZ );\n\n\t\t\tsampleDepth = getDepth( uv + ddy );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 bottom = getViewPosition( uv + ddy, sampleDepth, sampleViewZ );\n\n\t\t\thighp vec3 center = origin;\n\t\t\t\n\t\t\tsampleDepth = getDepth( uv - ddx );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 left = getViewPosition( uv - ddx, sampleDepth, sampleViewZ );\n\n\t\t\tsampleDepth = getDepth( uv + ddx );\n\t\t\tsampleViewZ = getViewZ( sampleDepth );\n\t\t\thighp vec3 right = getViewPosition( uv + ddx, sampleDepth, sampleViewZ );\n\n\t\t\t // get the difference between the current and each offset position\n\t\t\tvec3 l = center - left;\n\t\t\tvec3 r = right - center;\n\t\t\tvec3 d = center - top;\n\t\t\tvec3 u = bottom - center;\n\n\t\t\t// get depth values at 1 & 2 pixels offsets from current along the horizontal axis\n\t\t\tvec4 H = vec4(\n\t\t\t\tgetDepth(uv - ddx),\n\t\t\t\tgetDepth(uv + ddx),\n\t\t\t\tgetDepth(uv - 2. * ddx),\n\t\t\t\tgetDepth(uv + 2. * ddx)\n\t\t\t);\n\n\t\t\t// get depth values at 1 & 2 pixels offsets from current along the vertical axis\n\t\t\tvec4 V = vec4(\n\t\t\t\tgetDepth(uv - ddy),\n\t\t\t\tgetDepth(uv + ddy),\n\t\t\t\tgetDepth(uv - 2. * ddy),\n\t\t\t\tgetDepth(uv + 2. * ddy)\n\t\t\t);\n\n\t\t\t// current pixel's depth difference from slope of offset depth samples\n\t\t\t// differs from original article because we're using non-linear depth values\n\t\t\t// see article's comments\n\t\t\tvec2 he = abs((2. * H.xy - H.zw) - centerDepth);\n\t\t\tvec2 ve = abs((2. * V.xy - V.zw) - centerDepth);\n\n\t\t\t// pick horizontal and vertical diff with the smallest depth difference from slopes\n\t\t\tvec3 hDeriv = he.x < he.y ? l : r;\n\t\t\tvec3 vDeriv = ve.x < ve.y ? d : u;\n\n\t\t\t// get view space normal from the cross product of the best derivatives\n\t\t\tvec3 viewNormal = normalize(cross(hDeriv, vDeriv));\n\n\t\t\treturn viewNormal;\n\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition, in float centerDepth ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#elif IMPROVED_NORMAL_RECONSTRUCTION == 1\n\t\t\t\treturn viewNormalImproved(screenPosition, viewPosition);\n\t\t\t#elif ACCURATE_NORMAL_RECONSTRUCTION == 1\n\t\t\t\treturn viewNormalAccurate(screenPosition, viewPosition, centerDepth);\n\t\t\t#else\n\t\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition, in float centerDepth ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv, centerDepth );\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\t\t\tif( weightSum == 0.0 ) discard;\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\t#ifdef OUTPUT_RECONSTRUCTED_NORMALS\n\t\t\t\tvec3 normal;\n\t\t\t\t#if IMPROVED_NORMAL_RECONSTRUCTION == 1\n\t\t\t\t\tnormal = viewNormalImproved(vUv, viewPosition);\n\t\t\t\t#elif ACCURATE_NORMAL_RECONSTRUCTION == 1\n\t\t\t\t\tnormal = viewNormalAccurate(vUv, viewPosition, centerDepth);\n\t\t\t\t#else\n\t\t\t\t\tnormal = normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t\t#endif\n\t\t\t\tgl_FragColor.rgb = packNormalToRGB(normal);\n\t\t\t\tgl_FragColor.a = 1.;\n\t\t\t\treturn;\n\t\t\t#endif\n\t\t\t\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition, centerDepth );\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1. - ambientOcclusion;\n\t\t}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsySaoVert = "\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyShadowcatcherFrag = "\nvarying vec2 vUv;\n\nuniform sampler2D tex0;\nuniform sampler2D tex1;\nuniform sampler2D tex2;\nuniform sampler2D tex3;\nuniform vec4 weights;\nuniform float sigmoidRange;\nuniform float sigmoidStrength;\n\nvoid main() {\n\tfloat color0 = texture2D(tex0, vUv).r * weights.x;\n\tfloat color1 = texture2D(tex1, vUv).r * weights.y;\n\tfloat color2 = texture2D(tex2, vUv).r * weights.z;\n\tfloat color3 = texture2D(tex3, vUv).r * weights.w;\n\n\t// float c0 = mix(color0, 0., color1);\n\t// float c1 = mix(color1, 0., color0);\n\t// float c2 = mix(color3, 0., color0 * 0.5 + color1 * 0.5);\n\t// float sum = c0 + c1 + c2;\n\n\tfloat sum = color0 + color1 + color3 + color2;\n\n\tfloat a = sigmoidRange;//2.;\n\tfloat b = 0.03;\n\tfloat c = sigmoidStrength;//2.43;\n\tfloat d = 0.59;\n\tfloat e = 0.14;\n\tsum = clamp((sum*(a*sum+b))/(sum*(c*sum+d)+e), 0., 1.);\n\n\tvec2 sUv = vUv * 2. - 1.;\n\tsum *= 1. - pow(abs(sUv.x), 6.);\n\tsum *= 1. - pow(abs(sUv.y), 6.);\n\n\tgl_FragColor = vec4( vec3(sum), sum );\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyShadowcatcherVert = "\n\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = vec2(1. - uv.x, uv.y);\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyStandardColoredFrag = "\n#define STANDARD\n\n#ifdef PHYSICAL\n #define IOR\n #define SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\n uniform float ior;\n#endif\n\n#ifdef SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n\n #ifdef USE_SPECULARINTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n\n #ifdef USE_SPECULARCOLORMAP\n uniform sampler2D specularColorMap;\n #endif\n#endif\n\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n\n #ifdef USE_SHEENCOLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n\n #ifdef USE_SHEENROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n\nvarying vec3 vViewPosition;\n\nvarying float vGradientIndex;\nuniform sampler2D gradientRamp;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n\n vec4 diffuseColor = vec4( texture2D(gradientRamp, vec2(vGradientIndex, 0.)).rgb, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n\n // accumulation\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n #include <transmission_fragment>\n\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n #ifdef USE_SHEEN\n\n // Sheen energy compensation approximation calculation can be found at the end of\n // https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\n float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\n outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\n #endif\n\n #ifdef USE_CLEARCOAT\n\n float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\n #endif\n\n #include <output_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyStandardColoredVert = "\n#define STANDARD\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteShadowMatrix;\n uniform vec3 uShadowViewer_high;\n uniform vec3 uShadowViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifdef USE_TRANSMISSION\n\n varying vec3 vWorldPosition;\n\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n#endif\n\nattribute float gradientIndex;\nvarying float vGradientIndex;\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\nvoid main() {\n\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n //#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n\n\n mvPosition = modelViewMatrix * mvPosition;\n\n vGradientIndex = gradientIndex;\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n #include <worldpos_vertex>\n // #include <shadowmap_vertex>// EDITED CHUNK\n #ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\t// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n highp vec4 shadowPosition = vec4(transformed, 1.0);\n mat4 shadowMatrix = directionalShadowMatrix[ i ];\n\n #ifdef USE_RTE\n shadowPosition = computeRelativePosition(position_low.xyz, position.xyz, uShadowViewer_low, uShadowViewer_high);\n shadowMatrix = rteShadowMatrix;\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivotShadow = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uShadowViewer_low, uShadowViewer_high);\n shadowPosition.xyz = rotate_scaled_vertex_position_delta(shadowPosition, rtePivotShadow, tScale, tQuaternion) + rtePivotShadow.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 rtePivotShadow = computeRelativePosition(ZERO3, ZERO3, uShadowViewer_low, uShadowViewer_high);\n shadowPosition.xyz = (mat3(instanceMatrix) * (shadowPosition - rtePivotShadow).xyz) + rtePivotShadow.xyz + instanceMatrix[3].xyz;\n #endif\n #else\n #ifdef TRANSFORM_STORAGE\n shadowPosition.xyz = rotate_vertex_position(shadowPosition.xyz * tScale.xyz, tQuaternion) + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n shadowPosition = instanceMatrix * shadowPosition;\n #endif\n #endif\n shadowWorldPosition = modelMatrix * shadowPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = shadowMatrix * shadowWorldPosition;\n \n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\t#endif\n\t*/\n #endif\n #include <fog_vertex>\n\n#ifdef USE_TRANSMISSION\n\n vWorldPosition = worldPosition.xyz;\n\n#endif\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kingsyStandardFrag = "\n#define STANDARD\n\n#ifdef PHYSICAL\n #define IOR\n #define SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\n uniform float ior;\n#endif\n\n#ifdef SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n\n #ifdef USE_SPECULARINTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n\n #ifdef USE_SPECULARCOLORMAP\n uniform sampler2D specularColorMap;\n #endif\n#endif\n\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n\n #ifdef USE_SHEENCOLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n\n #ifdef USE_SHEENROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n\nvarying vec3 vViewPosition;\n/** We're disabling color grading for now until we want to properly offer it to the users */\n//#define CUSTOM_TONEMAPPING \n\n#ifdef CUSTOM_TONEMAPPING\n\n\tuniform float contrast;\n\tuniform float saturation;\n\tuniform float whitescale;\n\tvec3 EvalLogContrastFunc(vec3 col, float eps, float logMidpoint, float contrastFactor)\n\t{\n\t\tvec3 x = max(vec3(0.), col);\n\t\tvec3 logX = log2(x+vec3(eps));\n\t\tvec3 adjX = vec3(logMidpoint) + (logX - vec3(logMidpoint)) * contrastFactor;\n\t\tvec3 ret = max(vec3(0.0), exp2(adjX) - vec3(eps));\n\t\treturn ret;\n\t}\n\n\tvec3 evalSaturation(vec3 rgbVal, float saturationFactor){\n\t\tvec3 lumaWeights = vec3(.25,.50,.25);\n\t\tvec3 grey = vec3(dot(lumaWeights,rgbVal));\n\t\treturn grey + saturationFactor*(rgbVal-grey);\n\t}\n\n\tvec3 evalExposure(vec3 rgbVal, float exposureFactor){\n\t\treturn rgbVal * exp2(exposureFactor);\n\t}\n\n\tvec3 filmicTonemap(vec3 x) {\n\t\tfloat A = 0.15;\n\t\tfloat B = 0.50;\n\t\tfloat C = 0.10;\n\t\tfloat D = 0.20;\n\t\tfloat E = 0.02;\n\t\tfloat F = 0.30;\n\t\tfloat W = 11.2;\n\t\treturn ((x*(A*x+C*B)+D*E) / (x*(A*x+B)+D*F))- E / F;\n\t}\n\n\n\tvec3 applyFilmicToneMap( vec3 color) \n\t{\n\t\tcolor = 2.0 * filmicTonemap( color);\n\t\tvec3 whiteScale = 1.0 / filmicTonemap(vec3(11.2));\n\t\tcolor *= whiteScale;\n\t\treturn color;\n\t}\n\n\tvec3 postProcess(in vec3 _color, float exposureFactor, float contrastFactor, float saturationFactor){\n\t\tvec3 color = _color;\n\n\t\t// color.rgb *= exposureFactor;\n\t\tcolor.rgb = evalSaturation(color.rgb, saturationFactor);\n\t\tcolor = EvalLogContrastFunc(color, 0.0001, 0.18, contrastFactor);\n\t\tcolor.rgb = ACESFilmicToneMapping( color );//applyFilmicToneMap(color.rgb);\n\t\treturn color;\n\t}\n#endif\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n\n // accumulation\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n #include <transmission_fragment>\n\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n #ifdef USE_SHEEN\n\n // Sheen energy compensation approximation calculation can be found at the end of\n // https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\n float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\n outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\n #endif\n\n #ifdef USE_CLEARCOAT\n\n float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\n #endif\n\n // #include <output_fragment> COMMENTED CHUNK\n #ifdef OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n // https://github.com/mrdoob/three.js/pull/22425\n #ifdef USE_TRANSMISSION\n diffuseColor.a *= transmissionAlpha + 0.1;\n #endif\n\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n // #include <tonemapping_fragment> // COMMENTED OUT\n #ifdef TONE_MAPPING\n\t\t#ifdef CUSTOM_TONEMAPPING\n\t\t\tgl_FragColor.rgb = postProcess(gl_FragColor.rgb, toneMappingExposure, contrast, saturation);\n\t\t#else\n \n\t\t\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\t\t#endif\n\t#endif\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n\n}\n";
|