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
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/TextureSizeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TextureSizeNode extends Node {
const textureProperty = this.textureNode.build( builder, 'property' );
const levelNode = this.levelNode.build( builder, 'int' );

return builder.format( `textureDimensions( ${textureProperty}, ${levelNode} )`, this.getNodeType( builder ), output );
return builder.format( `${builder.getMethod( 'textureDimensions' )}( ${textureProperty}, ${levelNode} )`, this.getNodeType( builder ), output );

}

Expand Down
22 changes: 19 additions & 3 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ class WebGLBackend extends Backend {
textureUtils.setTextureParameters( glTextureType, texture );

gl.bindTexture( glTextureType, textureGPU );
gl.texStorage2D( glTextureType, levels, glInternalFormat, width, height );

if ( ! texture.isVideoTexture ) {

gl.texStorage2D( glTextureType, levels, glInternalFormat, width, height );

}

this.set( texture, {
textureGPU,
Expand All @@ -298,17 +303,21 @@ class WebGLBackend extends Backend {

const { gl } = this;
const { width, height } = options;
const { textureGPU, glTextureType, glFormat, glType } = this.get( texture );
const { textureGPU, glTextureType, glFormat, glType, glInternalFormat } = this.get( texture );

const getImage = ( source ) => {

if ( source.isDataTexture ) {

return source.image.data;

} else if ( source instanceof ImageBitmap || source instanceof OffscreenCanvas ) {

return source;

}

return source;
return source.data;

};

Expand All @@ -326,6 +335,13 @@ class WebGLBackend extends Backend {

}

} else if ( texture.isVideoTexture ) {

texture.update();

gl.texImage2D( glTextureType, 0, glInternalFormat, glFormat, glType, options.image );


} else {

const image = getImage( options.image );
Expand Down
7 changes: 6 additions & 1 deletion examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import UniformsGroup from '../../common/UniformsGroup.js';
import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';

const glslMethods = {
[ MathNode.ATAN2 ]: 'atan'
[ MathNode.ATAN2 ]: 'atan',
textureDimensions: 'textureSize'
};

const precisionLib = {
Expand Down Expand Up @@ -35,6 +36,10 @@ class GLSLNodeBuilder extends NodeBuilder {

return `textureCube( ${textureProperty}, ${uvSnippet} )`;

} else if ( texture.isDepthTexture ) {

return `texture( ${textureProperty}, ${uvSnippet} ).x`;

} else {

return `texture( ${textureProperty}, ${uvSnippet} )`;
Expand Down