Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling jitter #628

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/core/PathTracingRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@

}

set jitterEnabled( v ) {

this._ptMaterial.jitterEnabled = v;

};

Check warning on line 202 in src/core/PathTracingRenderer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary semicolon

get jitterEnabled() {

return this._ptMaterial.jitterEnabled;

};

Check warning on line 208 in src/core/PathTracingRenderer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary semicolon

constructor( renderer ) {

this.camera = null;
Expand All @@ -208,7 +220,8 @@
this._opacityFactor = 1.0;
this._renderer = renderer;
this._alpha = false;
this._fsQuad = new FullScreenQuad( new PhysicalPathTracingMaterial() );
this._ptMaterial = new PhysicalPathTracingMaterial();
this._fsQuad = new FullScreenQuad( this._ptMaterial );
this._blendQuad = new FullScreenQuad( new BlendMaterial() );
this._task = null;
this._currentTile = 0;
Expand Down
12 changes: 12 additions & 0 deletions src/core/WebGLPathTracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@

}

set jitterEnabled( v ) {

this._pathTracer.jitterEnabled = v;

};

Check warning on line 88 in src/core/WebGLPathTracer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary semicolon

get jitterEnabled() {

return this._pathTracer.jitterEnabled;

Check failure on line 93 in src/core/WebGLPathTracer.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Trailing spaces not allowed
}

constructor( renderer ) {

// members
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class WebGLPathTracer {
rasterizeScene: boolean;
renderToCanvas: boolean;
textureSize: Vector2;
jitterEnabled: boolean

rasterizeSceneCallback: ( scene: Scene, camera: Camera ) => void;
renderToCanvasCallback: ( target: WebGLRenderTarget, renderer: WebGLRenderer, quad: FullScreenQuad ) => void;
Expand Down
15 changes: 15 additions & 0 deletions src/materials/pathtracing/PhysicalPathTracingMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@

}

set jitterEnabled( v ) {

this.uniforms.jitterEnabled.value = v ? 1 : 0;

Check failure on line 42 in src/materials/pathtracing/PhysicalPathTracingMaterial.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Trailing spaces not allowed
}

get jitterEnabled() {

return this.uniforms.jitterEnabled.value > 1;

Check failure on line 48 in src/materials/pathtracing/PhysicalPathTracingMaterial.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Trailing spaces not allowed
}

constructor( parameters ) {

super( {
Expand Down Expand Up @@ -112,6 +124,7 @@
sobolTexture: { value: null },
stratifiedTexture: { value: new StratifiedSamplesTexture() },
stratifiedOffsetTexture: { value: new BlueNoiseTexture( 64, 1 ) },
jitterEnabled: { value: 1 }
},

vertexShader: /* glsl */`
Expand Down Expand Up @@ -293,6 +306,8 @@
${ RenderGLSL.direct_light_contribution_function }
${ RenderGLSL.get_surface_record_function }

uniform float jitterEnabled;

void main() {

// init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const camera_util_functions = /* glsl */`
// Jitter the camera ray by finding a uv coordinate at a random sample
// around this pixel's UV coordinate for AA
vec2 ruv = rand2( 0 );
vec2 jitteredUv = vUv + vec2( tentFilter( ruv.x ) * ssd.x, tentFilter( ruv.y ) * ssd.y );
vec2 jitteredUv = vUv + ( (jitterEnabled > 0.5) ? vec2( tentFilter( ruv.x ) * ssd.x, tentFilter( ruv.y ) * ssd.y ) : vec2(0.0, 0.0) );
Ray ray;

#if CAMERA_TYPE == 2
Expand Down
Loading