Skip to content

Commit

Permalink
Examples: Fixed webgpu_tsl_vfx_flames smoothstep usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Aug 30, 2024
1 parent 480092d commit 9a0ae53
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/webgpu_tsl_vfx_flames.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script type="module">

import * as THREE from 'three';
import { PI2, spherizeUV, sin, step, texture, timerLocal, Fn, uv, vec2, vec3, vec4, mix, billboarding } from 'three/tsl';
import { PI2, oneMinus, spherizeUV, sin, step, texture, timerLocal, Fn, uv, vec2, vec3, vec4, mix, billboarding } from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

Expand Down Expand Up @@ -78,14 +78,14 @@
const progress = i / ( gradient.colors.length - 1 );
const color = gradient.colors[ i ];
fillGradient.addColorStop( progress, color );

}

gradient.context.fillStyle = fillGradient;
gradient.context.fillRect( 0, 0, gradient.element.width, gradient.element.height );

gradient.texture.needsUpdate = true;

};

gradient.update();
Expand Down Expand Up @@ -125,7 +125,7 @@
const color = mix( gradientColor, vec3( 1 ), shape.step( 0.8 ).oneMinus() );
const alpha = shape.smoothstep( 0, 0.3 );
return vec4( color.rgb, alpha );

} )();

// flame 2 material
Expand All @@ -150,7 +150,7 @@
// gradients
const gradient1 = sin( time.mul( 10 ).sub( mainUv.y.mul( PI2 ).mul( 2 ) ) );
const gradient2 = mainUv.y.smoothstep( 0, 1 );
const gradient3 = mainUv.y.smoothstep( 1, 0.7 );
const gradient3 = oneMinus( mainUv.y ).smoothstep( 0, 0.3 );
mainUv.x.addAssign( gradient1.mul( gradient2 ).mul( 0.2 ) );

// displaced perlin noise
Expand All @@ -172,7 +172,7 @@

// output
return vec4( vec3( 1 ), shape );

} )();

// billboarding - follow the camera rotation only horizontally
Expand Down

0 comments on commit 9a0ae53

Please sign in to comment.