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

TSL: Improve fog approach 2 #30092

Merged
merged 5 commits into from
Dec 12, 2024
Merged
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
Binary file modified examples/screenshots/webgpu_compute_birds.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_instance_sprites.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_postprocessing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_postprocessing_afterimage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/materials/nodes/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,9 @@ class NodeMaterial extends Material {

if ( fogNode ) {

const fog = vec4( fogNode );
output.assign( outputNode );

outputNode = vec4( fog.a.mix( outputNode.rgb, fog.rgb ), outputNode.a );
outputNode = vec4( fogNode );

}

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/fog/Fog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { positionView } from '../accessors/Position.js';
import { smoothstep } from '../math/MathNode.js';
import { Fn, vec4 } from '../tsl/TSLBase.js';
import { Fn, output, vec4 } from '../tsl/TSLBase.js';

/** @module Fog **/

Expand Down Expand Up @@ -69,7 +69,7 @@ export const densityFogFactor = Fn( ( [ density ], builder ) => {
*/
export const fog = Fn( ( [ color, factor ] ) => {

return vec4( color.toVec3(), factor.toFloat() );
return vec4( factor.toFloat().mix( output.rgb, color.toVec3() ), output.a );

} );

Expand Down
Loading