Skip to content

Commit

Permalink
WebGPU: Fixes (#23003)
Browse files Browse the repository at this point in the history
* WGSL: deprecated attribute: [[ block ]]

warning: use of deprecated language feature: [[block]] attributes have been removed from WGSL [[ block ]]

* fix alpha used in color

* fix non-float roughness
  • Loading branch information
sunag authored Dec 11, 2021
1 parent 8f22ee5 commit b31270c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getRoughness = new ShaderNode( ( inputs ) => {

const geometryRoughness = getGeometryRoughness();

let roughnessFactor = max( roughness, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.
let roughnessFactor = max( roughness.r, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.
roughnessFactor = add( roughnessFactor, geometryRoughness );
roughnessFactor = min( roughnessFactor, 1.0 );

Expand Down
1 change: 0 additions & 1 deletion examples/jsm/renderers/webgpu/WebGPUTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class WebGPUTextureUtils {
this.device = device;

const mipmapVertexSource = `
[[ block ]]
struct VarysStruct {
[[ builtin( position ) ]] Position: vec4<f32>;
Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class WebGPUNodeBuilder extends NodeBuilder {

}

colorNode = this.addFlow( 'fragment', new VarNode( colorNode, 'Color', 'vec3' ) );
colorNode = this.addFlow( 'fragment', new VarNode( colorNode, 'Color', 'vec4' ) );

this.addFlow( 'fragment', new VarNode( colorNode, 'DiffuseColor', 'vec4' ) );

Expand Down Expand Up @@ -232,7 +232,7 @@ class WebGPUNodeBuilder extends NodeBuilder {

// SPECULAR_TINT

this.addFlow( 'fragment', new VarNode( new ExpressionNode( 'mix( vec3<f32>( 0.04 ), Color, Metalness )', 'vec3' ), 'SpecularColor', 'color' ) );
this.addFlow( 'fragment', new VarNode( new ExpressionNode( 'mix( vec3<f32>( 0.04 ), Color.rgb, Metalness )', 'vec3' ), 'SpecularColor', 'color' ) );

// NORMAL_VIEW

Expand Down Expand Up @@ -783,7 +783,7 @@ fn main( ${shaderData.varys} ) -> [[ location( 0 ) ]] vec4<f32> {

_getWGSLStruct( name, vars ) {

return `[[ block ]]
return `
struct ${name} {
\n${vars}
};`;
Expand Down

0 comments on commit b31270c

Please sign in to comment.