@synchronized-console/viewer 2.26.0-rev.1 → 2.31.14
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 +8 -2
- package/dist/index.d.ts +10 -6
- package/dist/index.js +4 -4
- package/dist/modules/EventEmitter.d.ts +5 -4
- package/dist/modules/LegacyViewer.d.ts +1 -1
- package/dist/modules/SynchronizedRenderer.d.ts +9 -1
- package/dist/modules/Viewer.d.ts +2 -1
- package/dist/modules/batching/Batch.d.ts +7 -0
- package/dist/modules/batching/BatchObject.d.ts +2 -1
- package/dist/modules/batching/Batcher.d.ts +3 -0
- package/dist/modules/batching/LineBatch.d.ts +7 -3
- package/dist/modules/batching/MeshBatch.d.ts +1 -1
- package/dist/modules/batching/PointBatch.d.ts +1 -1
- package/dist/modules/batching/TextBatch.d.ts +27 -8
- package/dist/modules/batching/TextBatchObject.d.ts +9 -0
- package/dist/modules/converter/Geometry.d.ts +18 -6
- package/dist/modules/converter/MeshTriangulationHelper.d.ts +2 -41
- package/dist/modules/converter/VirtualArray.d.ts +30 -0
- package/dist/modules/extensions/ExplodeExtension.d.ts +4 -0
- package/dist/modules/extensions/controls/FlyControls.d.ts +6 -3
- package/dist/modules/extensions/measurements/AreaMeasurement.d.ts +8 -2
- package/dist/modules/extensions/measurements/Measurement.d.ts +6 -0
- package/dist/modules/extensions/measurements/MeasurementPointGizmo.d.ts +8 -6
- package/dist/modules/extensions/measurements/MeasurementsExtension.d.ts +22 -16
- package/dist/modules/extensions/measurements/PerpendicularMeasurement.d.ts +4 -1
- package/dist/modules/extensions/measurements/PointMeasurement.d.ts +6 -4
- package/dist/modules/extensions/measurements/PointToPointMeasurement.d.ts +2 -0
- package/dist/modules/extensions/sections/SectionTool.d.ts +49 -2
- package/dist/modules/input/Input.d.ts +6 -2
- package/dist/modules/loaders/Synchronized/SynchronizedConverter.d.ts +7 -1
- package/dist/modules/loaders/Synchronized/SynchronizedGeometryConverter.d.ts +7 -3
- package/dist/modules/loaders/Synchronized/SynchronizedLoader.d.ts +5 -3
- package/dist/modules/materials/Materials.d.ts +1 -0
- package/dist/modules/materials/SynchronizedBasicMaterial.d.ts +8 -7
- package/dist/modules/materials/SynchronizedTextColoredMaterial.d.ts +8 -0
- package/dist/modules/materials/SynchronizedTextMaterial.d.ts +9 -17
- package/dist/modules/materials/shaders/synchronized-basic-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-depth-normal-id-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-depth-normal-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-displace.vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-ghost-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-normal-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-standard-colored-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-standard-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-text-frag.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-text-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-viewport-vert.d.ts +1 -1
- package/dist/modules/objects/AccelerationStructure.d.ts +1 -1
- package/dist/modules/objects/SynchronizedBatchedText.d.ts +59 -0
- package/dist/modules/objects/TextLabel.d.ts +51 -0
- package/dist/modules/pipeline/Passes/GPass.d.ts +9 -3
- package/dist/modules/pipeline/Pipelines/EdgesPipeline.d.ts +2 -0
- package/dist/modules/tree/NodeMap.d.ts +9 -0
- package/dist/modules/tree/NodeRenderView.d.ts +13 -5
- package/dist/modules/tree/RenderTree.d.ts +5 -1
- package/dist/modules/tree/WorldTree.d.ts +6 -0
- package/package.json +9 -7
- package/dist/modules/objects/SynchronizedText.d.ts +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedDisplaceVert = "\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
|
|
1
|
+
export declare const synchronizedDisplaceVert = "\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 // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedGhostVert = "\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
|
|
1
|
+
export declare const synchronizedGhostVert = "\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 // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedNormalVert = "\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
|
|
1
|
+
export declare const synchronizedNormalVert = "\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 // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedStandardColoredVert = "\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";
|
|
1
|
+
export declare const synchronizedStandardColoredVert = "\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> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedStandardVert = "\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 #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\n highp vec3 rotate_vertex_position(highp vec3 position, highp 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\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 \n #ifdef TRANSFORM_STORAGE\n highp 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\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n #include <worldpos_vertex>\n // #include <shadowmap_vertex> COMMENTED 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\t}\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\n #include <fog_vertex>\n\n#ifdef USE_TRANSMISSION\n\n vWorldPosition = worldPosition.xyz;\n\n#endif\n}\n";
|
|
1
|
+
export declare const synchronizedStandardVert = "\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 #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\n highp vec3 rotate_vertex_position(highp vec3 position, highp 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\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> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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 \n #ifdef TRANSFORM_STORAGE\n highp 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\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n #include <worldpos_vertex>\n // #include <shadowmap_vertex> COMMENTED 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\t}\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\n #include <fog_vertex>\n\n#ifdef USE_TRANSMISSION\n\n vWorldPosition = worldPosition.xyz;\n\n#endif\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedTextFrag = "\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(
|
|
1
|
+
export declare const synchronizedTextFrag = "\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>\n\n#ifdef BATCHED_TEXT\n\tuniform sampler2D gradientRamp;\n\tvarying float vGradientIndex;\n#endif\n\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor_RGB = vec4(diffuse, opacity);\n\tvec4 diffuseColor = diffuseColor_RGB;\n\t#ifdef BATCHED_TEXT\n\t\tvec4 diffuseColor_Tex = vec4( texture2D(gradientRamp, vec2(vGradientIndex, 0.)).rgb, opacity );\n\t\tdiffuseColor = mix(diffuseColor_RGB, diffuseColor_Tex, float(vGradientIndex > 0.));\n\t#endif\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedTextVert = "\n#include <common>\n#ifdef USE_RTE\n
|
|
1
|
+
export declare const synchronizedTextVert = "\n#include <common>\n#ifdef USE_RTE\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#if defined(BILLBOARD) || defined(BILLBOARD_SCREEN)\n uniform mat4 invProjection;\n#endif\n\n#ifdef BILLBOARD_SCREEN\n uniform vec4 billboardPixelOffsetSize;\n#endif\n\n\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\n#ifdef BATCHED_TEXT\n varying float vGradientIndex;\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 // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\n vec4 mvPosition;\n mat4 matrix;\n\n #ifdef BATCHED_TEXT\n matrix = mat4(\n troikaBatchTexel(0.0), \n troikaBatchTexel(1.0), \n troikaBatchTexel(2.0), \n troikaBatchTexel(3.0)\n );\n #else\n matrix = modelMatrix;\n #endif\n\n #ifdef USE_RTE\n /* We store the high part normally as the translation component */\n vec3 translationHigh = matrix[3].xyz;\n /** We store the low part of the translation in row4 ofthe matrix */\n vec3 translationLow = vec3(matrix[0][3], matrix[1][3], matrix[2][3]);\n highp vec4 rteTranslation = computeRelativePosition(translationLow, translationHigh, uViewer_low, uViewer_high);\n #if defined(BILLBOARD)\n mvPosition = (modelViewMatrix * rteTranslation + vec4(position.x, position.y, 0., 0.0));\n #else\n mvPosition = vec4(mat3(matrix) * transformed + rteTranslation.xyz, 1.);\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n #else\n #if defined(BILLBOARD) || defined(BILLBOARD_SCREEN)\n vec3 billboardPosition = matrix[3].xyz;\n #if defined(BILLBOARD_SCREEN)\n mvPosition = projectionMatrix * (viewMatrix * vec4(billboardPosition, 1.0));\n float div = mvPosition.w;\n mvPosition /= mvPosition.w;\n // Pixel values are computed like so\n // windowX = ((ndc.x + 1) / 2) * width;\n // windowY = ((ndc.y + 1) / 2) * height;\n // That's why we multiply by 2.\n mvPosition.xy += position.xy * billboardPixelOffsetSize.zw * 2. + billboardPixelOffsetSize.xy * 2.;\n /** Back to view space for convenience */\n mvPosition *= div;\n mvPosition = invProjection * mvPosition;\n #else\n mvPosition = (viewMatrix * vec4(billboardPosition, 1.) + vec4(position.x, position.y, 0., 0.0));\n #endif\n #else\n mvPosition = viewMatrix * matrix * vec4(transformed, 1.);\n #endif\n #endif\n\n #ifdef BATCHED_TEXT\n vGradientIndex = troikaBatchTexel(6.).w;\n #endif\n\n gl_Position = projectionMatrix * mvPosition;\n\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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedViewportVert = "\n#define USE_ENVMAP\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\nvarying vec3 vNormal;\nvarying vec3 vViewPosition;\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#endif\nvarying float dotValue;\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 vNormal = normalize( transformedNormal );\n vViewPosition = -mvPosition.xyz;\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 * 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";
|
|
1
|
+
export declare const synchronizedViewportVert = "\n#define USE_ENVMAP\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\nvarying vec3 vNormal;\nvarying vec3 vViewPosition;\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#endif\nvarying float dotValue;\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 // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\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 vNormal = normalize( transformedNormal );\n vViewPosition = -mvPosition.xyz;\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 * 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";
|
|
@@ -52,7 +52,7 @@ export declare class AccelerationStructure {
|
|
|
52
52
|
outputOriginTransfom: Matrix4;
|
|
53
53
|
get geometry(): BufferGeometry;
|
|
54
54
|
get bvh(): MeshBVH;
|
|
55
|
-
static buildBVH(indices:
|
|
55
|
+
static buildBVH(indices: Uint16Array | Uint32Array | undefined, position: Float32Array | Float64Array | undefined, options?: BVHOptions, transform?: Matrix4): MeshBVH;
|
|
56
56
|
constructor(bvh: MeshBVH);
|
|
57
57
|
raycast(ray: Ray, materialOrSide?: Side | Material | Material[]): MeshIntersection[];
|
|
58
58
|
raycastFirst(ray: Ray, materialOrSide?: Side | Material | Material[]): MeshIntersection;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Text } from 'troika-three-text';
|
|
2
|
+
import { BatchedText } from 'troika-three-text';
|
|
3
|
+
import { TopLevelAccelerationStructure } from './TopLevelAccelerationStructure.js';
|
|
4
|
+
import { BufferGeometry, Camera, Intersection, Material, Scene, Texture } from 'three';
|
|
5
|
+
import { BatchObject } from '../batching/BatchObject.js';
|
|
6
|
+
import { SynchronizedRaycaster } from './SynchronizedRaycaster.js';
|
|
7
|
+
import { DrawGroup } from '../batching/Batch.js';
|
|
8
|
+
import SynchronizedTextMaterial from '../materials/SynchronizedTextMaterial.js';
|
|
9
|
+
import { SynchronizedWebGLRenderer } from '../../index.js';
|
|
10
|
+
export declare class SynchronizedBatchedText extends BatchedText {
|
|
11
|
+
material: SynchronizedTextMaterial;
|
|
12
|
+
private tas;
|
|
13
|
+
private _batchMaterial;
|
|
14
|
+
private _batchObjects;
|
|
15
|
+
private _textObjects;
|
|
16
|
+
private _dirty;
|
|
17
|
+
groups: Array<DrawGroup>;
|
|
18
|
+
materials: Material[];
|
|
19
|
+
private materialCache;
|
|
20
|
+
private materialCacheLUT;
|
|
21
|
+
private readonly DEBUG_BILLBOARDS;
|
|
22
|
+
private debugMeshes;
|
|
23
|
+
get TAS(): TopLevelAccelerationStructure;
|
|
24
|
+
get batchObjects(): BatchObject[];
|
|
25
|
+
get batchMaterial(): Material;
|
|
26
|
+
set dirty(value: boolean);
|
|
27
|
+
get isBillboarded(): any;
|
|
28
|
+
setBatchMaterial(material: Material): void;
|
|
29
|
+
setBatchObjects(batchObjects: BatchObject[], textObjects: Text[]): void;
|
|
30
|
+
private lookupMaterial;
|
|
31
|
+
getCachedMaterial(material: Material, copy?: boolean): Material;
|
|
32
|
+
buildTAS(): void;
|
|
33
|
+
/** This could be made faster. BUT, as this point in time it's not worth the effort */
|
|
34
|
+
updateTransformsUniform(): void;
|
|
35
|
+
updateMaterialTransformsUniform(material: Material): void;
|
|
36
|
+
setGradientTexture(texture: Texture): void;
|
|
37
|
+
getBatchObjectMaterial(batchObject: BatchObject): Material | null;
|
|
38
|
+
private convertRaycastIntersect;
|
|
39
|
+
private initDebugBox;
|
|
40
|
+
/** Debug purposes only */
|
|
41
|
+
onBeforeRender(renderer: SynchronizedWebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: unknown): void;
|
|
42
|
+
raycast(raycaster: SynchronizedRaycaster, intersects: Array<Intersection>): void;
|
|
43
|
+
/**
|
|
44
|
+
* Update the batched geometry bounds to hold all members
|
|
45
|
+
*/
|
|
46
|
+
updateBounds(): void;
|
|
47
|
+
/**
|
|
48
|
+
* @param {Text} text
|
|
49
|
+
*/
|
|
50
|
+
addText(text: Text): void;
|
|
51
|
+
private setTexData;
|
|
52
|
+
/**
|
|
53
|
+
* @override
|
|
54
|
+
* Patched version that allows:
|
|
55
|
+
* - Individual text opacities
|
|
56
|
+
* - Coordinate inside gradient/ramp texture <27>
|
|
57
|
+
*/
|
|
58
|
+
_prepareForRender(material: SynchronizedTextMaterial): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Box3, BufferGeometry, Color, Material, Mesh, Raycaster, Vector2, type Intersection } from 'three';
|
|
2
|
+
import { AnchorX, AnchorY, Text } from 'troika-three-text';
|
|
3
|
+
import SynchronizedBasicMaterial, { BillboardingType } from '../materials/SynchronizedBasicMaterial.js';
|
|
4
|
+
import SynchronizedTextMaterial from '../materials/SynchronizedTextMaterial.js';
|
|
5
|
+
import { ObjectLayers } from '../../index.js';
|
|
6
|
+
export interface TextLabelParams {
|
|
7
|
+
text?: string;
|
|
8
|
+
fontSize?: number;
|
|
9
|
+
maxWidth?: number;
|
|
10
|
+
anchorX?: AnchorX;
|
|
11
|
+
anchorY?: AnchorY;
|
|
12
|
+
billboard?: BillboardingType | null;
|
|
13
|
+
backgroundColor?: Color | null;
|
|
14
|
+
backgroundCornerRadius?: number;
|
|
15
|
+
backgroundMargins?: Vector2;
|
|
16
|
+
textColor?: Color;
|
|
17
|
+
textOpacity?: number;
|
|
18
|
+
objectLayer?: ObjectLayers;
|
|
19
|
+
}
|
|
20
|
+
/** Screen */
|
|
21
|
+
export declare const DefaultTextLabelParams: Required<TextLabelParams>;
|
|
22
|
+
export declare class TextLabel extends Text {
|
|
23
|
+
/** Needs a raycast to start rendering */
|
|
24
|
+
private readonly DEBUG_BILLBOARDS;
|
|
25
|
+
material: SynchronizedTextMaterial;
|
|
26
|
+
private _background;
|
|
27
|
+
private _backgroundMaterial;
|
|
28
|
+
private _params;
|
|
29
|
+
private _textBounds;
|
|
30
|
+
private _collisionMesh;
|
|
31
|
+
get textMesh(): this;
|
|
32
|
+
get backgroundMesh(): Mesh<BufferGeometry, Material | Material[]>;
|
|
33
|
+
get textBounds(): Box3;
|
|
34
|
+
get backgroundMaterial(): SynchronizedBasicMaterial;
|
|
35
|
+
constructor(params?: TextLabelParams);
|
|
36
|
+
updateParams(params: TextLabelParams, onUpdateComplete?: () => void): Promise<void>;
|
|
37
|
+
raycast(raycaster: Raycaster, intersects: Array<Intersection>): void;
|
|
38
|
+
/** Gets the current bounds reported by troika taking `fontSize` into account */
|
|
39
|
+
private textBoundsToBox;
|
|
40
|
+
/** Text's blockBounds, the one we're working with bounds-wise is not a unit quad
|
|
41
|
+
When using BILLBOARD_SCREEN we store the desired pixel size in the text's `fontSize` property
|
|
42
|
+
This makes troika compute a large text since it thinks our pixels are world units.
|
|
43
|
+
So we divide the text bounds by the font size to get the size of the unit text bounds, or
|
|
44
|
+
another way of putting it, to compute the text bounds value as if fontSize = 1
|
|
45
|
+
From the unit box, we get it's size and compute a world->pixel ratio which we send to the shader
|
|
46
|
+
*/
|
|
47
|
+
private updateBillboarding;
|
|
48
|
+
private updateBackground;
|
|
49
|
+
/** Improved version of https://discourse.threejs.org/t/roundedrectangle-squircle/28645 by way of the vibe */
|
|
50
|
+
private RectangleRounded;
|
|
51
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Camera, Material, OrthographicCamera, PerspectiveCamera, Plane, Scene, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
2
|
import { ObjectLayers } from '../../../IViewer.js';
|
|
3
|
+
import { BatchUpdateRange } from '../../batching/Batch.js';
|
|
4
|
+
import SynchronizedRenderer from '../../SynchronizedRenderer.js';
|
|
3
5
|
export declare enum ObjectVisibility {
|
|
4
6
|
OPAQUE = "opaque",
|
|
5
7
|
TRANSPARENT = "transparent",
|
|
6
8
|
DEPTH = "depth",
|
|
7
|
-
STENCIL = "stencil"
|
|
9
|
+
STENCIL = "stencil",
|
|
10
|
+
CUSTOM = "custom"
|
|
8
11
|
}
|
|
9
12
|
export declare enum ClearFlags {
|
|
10
13
|
COLOR = 256,
|
|
@@ -27,6 +30,7 @@ export interface GPass {
|
|
|
27
30
|
get clearColor(): number | undefined;
|
|
28
31
|
get clearAlpha(): number | undefined;
|
|
29
32
|
get clearFlags(): number | undefined;
|
|
33
|
+
get visibilityFunction(): ((renderer: SynchronizedRenderer) => Record<string, BatchUpdateRange>) | undefined;
|
|
30
34
|
setSize?(width: number, height: number): void;
|
|
31
35
|
onBeforeRender?: () => void;
|
|
32
36
|
onAferRender?: () => void;
|
|
@@ -36,7 +40,7 @@ export interface GPass {
|
|
|
36
40
|
setClearFlags(flags: number): void;
|
|
37
41
|
setClippingPlanes?(planes: Plane[]): void;
|
|
38
42
|
setLayers?(layers: ObjectLayers[]): void;
|
|
39
|
-
setVisibility?(objectVisibility: ObjectVisibility): void;
|
|
43
|
+
setVisibility?(objectVisibility: ObjectVisibility, visibilityFunction?: (renderer: SynchronizedRenderer) => Record<string, BatchUpdateRange>): void;
|
|
40
44
|
setJitter(value: boolean): void;
|
|
41
45
|
}
|
|
42
46
|
export declare abstract class BaseGPass implements GPass {
|
|
@@ -52,6 +56,7 @@ export declare abstract class BaseGPass implements GPass {
|
|
|
52
56
|
protected _outputTarget: WebGLRenderTarget | null;
|
|
53
57
|
onBeforeRender: (() => void) | undefined;
|
|
54
58
|
onAfterRender: (() => void) | undefined;
|
|
59
|
+
protected _visibilityFunction: ((renderer: SynchronizedRenderer) => Record<string, BatchUpdateRange>) | undefined;
|
|
55
60
|
get enabledLayers(): ObjectLayers[];
|
|
56
61
|
get displayName(): string;
|
|
57
62
|
get outputTarget(): WebGLRenderTarget | null;
|
|
@@ -66,11 +71,12 @@ export declare abstract class BaseGPass implements GPass {
|
|
|
66
71
|
get clearColor(): number | undefined;
|
|
67
72
|
get clearAlpha(): number | undefined;
|
|
68
73
|
get clearFlags(): number | undefined;
|
|
74
|
+
get visibilityFunction(): ((renderer: SynchronizedRenderer) => Record<string, BatchUpdateRange>) | undefined;
|
|
69
75
|
setClearColor(color: number, alpha: number): void;
|
|
70
76
|
setClearFlags(flags: number): void;
|
|
71
77
|
setLayers(layers: ObjectLayers[]): void;
|
|
72
78
|
enableLayer(layer: ObjectLayers, value: boolean): void;
|
|
73
|
-
setVisibility(objectVisibility: ObjectVisibility | null): void;
|
|
79
|
+
setVisibility(objectVisibility: ObjectVisibility | null, visibilityFunction?: (renderer: SynchronizedRenderer) => Record<string, BatchUpdateRange>): void;
|
|
74
80
|
setJitter(value: boolean): void;
|
|
75
81
|
protected applyLayers(camera: Camera | null): void;
|
|
76
82
|
protected clear(renderer: WebGLRenderer): void;
|
|
@@ -5,6 +5,7 @@ import { DepthNormalIdPass } from '../Passes/DepthNormalIdPass.js';
|
|
|
5
5
|
import { Texture } from 'three';
|
|
6
6
|
import { DepthPass } from '../Passes/DepthPass.js';
|
|
7
7
|
import { BasePipelineOptions } from './Pipeline.js';
|
|
8
|
+
import { BatchUpdateRange } from '../../batching/Batch.js';
|
|
8
9
|
export interface EdgesPipelineOptions extends BasePipelineOptions {
|
|
9
10
|
outlineThickness?: number;
|
|
10
11
|
outlineColor?: number;
|
|
@@ -23,6 +24,7 @@ export declare class EdgesPipeline extends ProgressivePipeline {
|
|
|
23
24
|
outputTexture?: Texture;
|
|
24
25
|
outputTextureDynamic?: Texture;
|
|
25
26
|
constructor(synchronizedRenderer: SynchronizedRenderer, options?: EdgesPipelineOptions);
|
|
27
|
+
protected depthNormalIdPassVisibility(renderer: SynchronizedRenderer): Record<string, BatchUpdateRange>;
|
|
26
28
|
protected MRTPipeline(options: EdgesPipelineOptions): void;
|
|
27
29
|
protected SRTPipeline(options: EdgesPipelineOptions): void;
|
|
28
30
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { type TreeNode } from './WorldTree.js';
|
|
2
2
|
export declare class NodeMap {
|
|
3
3
|
static readonly COMPOUND_ID_CHAR = "~";
|
|
4
|
+
static readonly DUPLICATE_ID_CHAR = "#";
|
|
4
5
|
private all;
|
|
5
6
|
instances: {
|
|
6
7
|
[id: string]: {
|
|
7
8
|
[id: string]: TreeNode;
|
|
8
9
|
};
|
|
9
10
|
};
|
|
11
|
+
duplicates: {
|
|
12
|
+
[id: string]: {
|
|
13
|
+
[id: string]: TreeNode;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
10
16
|
get nodeCount(): number;
|
|
11
17
|
constructor(subtreeRoot: TreeNode);
|
|
12
18
|
addNode(node: TreeNode): boolean;
|
|
@@ -14,7 +20,10 @@ export declare class NodeMap {
|
|
|
14
20
|
getNodeById(id: string): TreeNode[] | null;
|
|
15
21
|
getSubtreeById(id: string): TreeNode;
|
|
16
22
|
hasId(id: string): boolean;
|
|
23
|
+
hasNodeId(id: string): boolean;
|
|
24
|
+
hasInstanceId(id: string): boolean;
|
|
17
25
|
private registerInstance;
|
|
26
|
+
private registerDuplicate;
|
|
18
27
|
private registerNode;
|
|
19
28
|
purge(): void;
|
|
20
29
|
}
|