Skip to content
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_tsl_galaxy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/webgpu_tsl_galaxy.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
sin( angle )
).mul( radius );

const randomOffset = range( vec3( - 1 ), vec3( 1 ) ).pow( 3 ).mul( radiusRatio ).add( 0.2 );
const randomOffset = range( vec3( - 1 ), vec3( 1 ) ).pow3().mul( radiusRatio ).add( 0.2 );

material.positionNode = position.add( randomOffset );

Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_tsl_vfx_flames.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
// main UV
const mainUv = uv().toVar();
mainUv.assign( spherizeUV( mainUv, 10 ).mul( 0.6 ).add( 0.2 ) ); // spherize
mainUv.assign( mainUv.pow( vec2( 1, 3 ) ) ); // stretch
mainUv.assign( mainUv.abs().pow( vec2( 1, 3 ) ).mul( mainUv.sign() ) ); // stretch
mainUv.assign( mainUv.mul( 2, 1 ).sub( vec2( 0.5, 0 ) ) ); // scale

// perlin noise
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/math/MathNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ export const pow = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW ).setPa
* @param {Node | number} x - The first parameter.
* @returns {Node}
*/
export const pow2 = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW, 2 ).setParameterLength( 1 );
export const pow2 = ( x ) => mul( x, x );

/**
* Returns the cube of the parameter.
Expand All @@ -910,7 +910,7 @@ export const pow2 = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW, 2 ).s
* @param {Node | number} x - The first parameter.
* @returns {Node}
*/
export const pow3 = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW, 3 ).setParameterLength( 1 );
export const pow3 = ( x ) => mul( x, x, x );

/**
* Returns the fourth power of the parameter.
Expand All @@ -920,7 +920,7 @@ export const pow3 = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW, 3 ).s
* @param {Node | number} x - The first parameter.
* @returns {Node}
*/
export const pow4 = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.POW, 4 ).setParameterLength( 1 );
export const pow4 = ( x ) => mul( x, x, x, x );

/**
* Transforms the direction of a vector by a matrix and then normalizes the result.
Expand Down
16 changes: 0 additions & 16 deletions src/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,6 @@ const wgslMethods = {
bitcast: 'bitcast<f32>'
};

// WebGPU issue: does not support pow() with negative base on Windows

if ( typeof navigator !== 'undefined' && /Windows/g.test( navigator.userAgent ) ) {

wgslPolyfill.pow_float = new CodeNode( 'fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }' );
wgslPolyfill.pow_vec2 = new CodeNode( 'fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }', [ wgslPolyfill.pow_float ] );
wgslPolyfill.pow_vec3 = new CodeNode( 'fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }', [ wgslPolyfill.pow_float ] );
wgslPolyfill.pow_vec4 = new CodeNode( 'fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }', [ wgslPolyfill.pow_float ] );

wgslMethods.pow_float = 'tsl_pow_float';
wgslMethods.pow_vec2 = 'tsl_pow_vec2';
wgslMethods.pow_vec3 = 'tsl_pow_vec3';
wgslMethods.pow_vec4 = 'tsl_pow_vec4';

}

//

let diagnostics = '';
Expand Down
Loading