Skip to content

Commit

Permalink
NodeBuilder: Add .getFragCoord(), .isFlipY()
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Nov 10, 2022
1 parent f2fce01 commit fb06574
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
12 changes: 12 additions & 0 deletions examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ class NodeBuilder {

}

getFragCoord() {

console.warn( 'Abstract function.' );

}

isFlipY() {

return false;

}

getTexture( /* textureProperty, uvSnippet */ ) {

console.warn( 'Abstract function.' );
Expand Down
16 changes: 7 additions & 9 deletions examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,21 @@ class WebGLNodeBuilder extends NodeBuilder {

}

getTextureEncodingFromMap( map ) {
getFrontFacing() {

const isWebGL2 = this.renderer.capabilities.isWebGL2;
return 'gl_FrontFacing';

if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
}

return LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
getFragCoord() {

}

return super.getTextureEncodingFromMap( map );
return 'gl_FragCoord';

}

getFrontFacing() {
isFlipY() {

return 'gl_FrontFacing';
return true;

}

Expand Down
12 changes: 12 additions & 0 deletions examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,18 @@ class WebGPUNodeBuilder extends NodeBuilder {

}

getFragCoord() {

return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>', 'fragment' );

}

isFlipY() {

return false;

}

getAttributes( shaderStage ) {

const snippets = [];
Expand Down

0 comments on commit fb06574

Please sign in to comment.