Skip to content

Commit 0639f2f

Browse files
authored
Rename SparkRenderer.renderScale to focalAdjustment. Add to constructor options and to docs. (#113)
1 parent 00e3edb commit 0639f2f

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

docs/docs/spark-renderer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const spark = new SparkRenderer({
3939
apertureAngle?: number;
4040
falloff?: number;
4141
clipXY?: number;
42+
focalAdjustment?: number;
4243
view?: SparkViewpointOptions;
4344
});
4445
```
@@ -63,6 +64,7 @@ const spark = new SparkRenderer({
6364
| **apertureAngle** | Full-width angle of aperture opening from pinhole camera origin in radians (default: `0.0` to disable)
6465
| **falloff** | Modulate Gaussian kernel falloff. 0 means "no falloff, flat shading", while 1 is the normal Gaussian kernel. (default: `1.0`)
6566
| **clipXY** | X/Y clipping boundary factor for splat centers against view frustum. 1.0 clips any centers that are exactly out of bounds (but the splat's entire projection may still be in bounds), while 1.4 clips centers that are 40% beyond the bounds. (default: `1.4`)
67+
| **focalAdjustment** | Parameter to adjust projected splat scale calculation to match other renderers, similar to the same parameter in the MKellogg 3DGS renderer. Higher values will tend to sharpen the splats. A value 2.0 can be used to match the behavior of the PlayCanvas renderer. (default: `1.0`)
6668
| **view** | Configures the `SparkViewpointOptions` for the default `SparkViewpoint` associated with this `SparkRenderer`. Notable option: `sortRadial` (sort by radial distance or Z-depth)
6769

6870
## `newViewpoint(options: SparkViewpointOptions)`

examples/editor/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@
512512
spark.blurAmount = 0.3;
513513
},
514514
}, "AA").name("AA preset");
515-
debugFolder.add(spark, "renderScale", 0.1, 2.0, 0.1).name("Render scale");
515+
debugFolder.add(spark, "focalAdjustment", 0.1, 2.0, 0.1).name("Tweak focalAdjustment");
516516

517517
const splatsFolder = secondGui.addFolder("Files");
518518

src/SparkRenderer.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ export type SparkRendererOptions = {
126126
// 1.0 clips any centers that are exactly out of bounds, while 1.4 clips
127127
// centers that are 40% beyond the bounds. (default: 1.4)
128128
clipXY?: number;
129+
// Parameter to adjust projected splat scale calculation to match other renderers,
130+
// similar to the same parameter in the MKellogg 3DGS renderer. Higher values will
131+
// tend to sharpen the splats. A value 2.0 can be used to match the behavior of
132+
// the PlayCanvas renderer. (default: 1.0)
133+
focalAdjustment?: number;
129134
// Configures the SparkViewpointOptions for the default SparkViewpoint
130135
// associated with this SparkRenderer. Notable option: sortRadial (sort by
131136
// radial distance or Z-depth)
@@ -148,7 +153,7 @@ export class SparkRenderer extends THREE.Mesh {
148153
apertureAngle: number;
149154
falloff: number;
150155
clipXY: number;
151-
renderScale = 1.0;
156+
focalAdjustment: number;
152157

153158
splatTexture: null | {
154159
enable?: boolean;
@@ -264,6 +269,7 @@ export class SparkRenderer extends THREE.Mesh {
264269
this.apertureAngle = options.apertureAngle ?? 0.0;
265270
this.falloff = options.falloff ?? 1.0;
266271
this.clipXY = options.clipXY ?? 1.4;
272+
this.focalAdjustment = options.focalAdjustment ?? 1.0;
267273

268274
this.active = new SplatAccumulator();
269275
this.accumulatorCount = 1;
@@ -321,7 +327,7 @@ export class SparkRenderer extends THREE.Mesh {
321327
// Clip Gsplats that are clipXY times beyond the +-1 frustum bounds
322328
clipXY: { value: 1.4 },
323329
// Debug renderSize scale factor
324-
renderScale: { value: 1.0 },
330+
focalAdjustment: { value: 1.0 },
325331
// Enable splat texture rendering
326332
splatTexEnable: { value: false },
327333
// Splat texture to render
@@ -479,7 +485,7 @@ export class SparkRenderer extends THREE.Mesh {
479485
this.uniforms.apertureAngle.value = this.apertureAngle;
480486
this.uniforms.falloff.value = this.falloff;
481487
this.uniforms.clipXY.value = this.clipXY;
482-
this.uniforms.renderScale.value = this.renderScale;
488+
this.uniforms.focalAdjustment.value = this.focalAdjustment;
483489

484490
if (this.splatTexture) {
485491
const { enable, texture, multiply, add, near, far, mid } =

src/shaders/splatVertex.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ uniform float preBlurAmount;
2525
uniform float focalDistance;
2626
uniform float apertureAngle;
2727
uniform float clipXY;
28-
uniform float renderScale;
28+
uniform float focalAdjustment;
2929

3030
uniform usampler2DArray packedSplats;
3131

@@ -112,7 +112,7 @@ void main() {
112112
mat3 cov3D = RS * transpose(RS);
113113

114114
// Compute the Jacobian of the splat's projection at its center
115-
vec2 scaledRenderSize = renderSize * renderScale;
115+
vec2 scaledRenderSize = renderSize * focalAdjustment;
116116
vec2 focal = 0.5 * scaledRenderSize * vec2(projectionMatrix[0][0], projectionMatrix[1][1]);
117117
float invZ = 1.0 / viewCenter.z;
118118
vec2 J1 = focal * invZ;

0 commit comments

Comments
 (0)