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

FilmShader: Fix deterioration. #26908

Merged
merged 3 commits into from Oct 7, 2023
Merged

FilmShader: Fix deterioration. #26908

merged 3 commits into from Oct 7, 2023

Conversation

kaisavi
Copy link
Contributor

@kaisavi kaisavi commented Oct 6, 2023

No Related Issue

Description
Incorrect usage of the rand function causes the film effect to deteriorate with large time values. This is fixed by applying a modulus to the time value, restraining it to the expected [0,1]x[0,1] range of the rand function

highp float rand( const in vec2 uv ) {

Incorrect usage of the ``rand`` function causes the film effect to deteriorate with large time values. This is fixed by applying a modulus to the time value, restraining it to the expected [0,1]x[0,1] range of the ``rand`` function

https://github.com/mrdoob/three.js/blob/76e1fb171af400afebbfb851ef7d7297625c5f0a/src/renderers/shaders/ShaderChunk/common.glsl.js#L24
Copy link
Collaborator

@gkjohnson gkjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide screenshots showing what the "deterioration" looks like before and after this change.

examples/jsm/shaders/FilmShader.js Outdated Show resolved Hide resolved
@kaisavi
Copy link
Contributor Author

kaisavi commented Oct 6, 2023

Noise function at 0 seconds
0sec

Noise function at 300 seconds
300sec

The noise also becomes highly correlated between frames at high time values
You can view a demonstration of this effect on Shadertoy

@kaisavi kaisavi marked this pull request as draft October 6, 2023 22:34
Addresses mrdoob#26908 (comment)
the constraining function is now fract() instead of mod(n,1.0), and wraps vUv + time instead of only time
@kaisavi kaisavi marked this pull request as ready for review October 6, 2023 22:58
@Mugen87 Mugen87 added this to the r158 milestone Oct 7, 2023
@Mugen87 Mugen87 changed the title Fix FilmShader Deterioration FilmShader: Fix deterioration. Oct 7, 2023
@Mugen87 Mugen87 merged commit f7b0c24 into mrdoob:dev Oct 7, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants