-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Replace 8 with real maxMipLevel in lights_fragment_maps.glsl #13501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
|
|
||
| } | ||
|
|
||
| function generateMipmap( texture, target ) { | ||
|
|
||
| _gl.generateMipmap( target ); | ||
|
|
||
| var image = Array.isArray( texture.image ) ? texture.image[ 0 ] : texture.image; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I expect images for cubic map have the same size?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not guaranteed, but lets assume that.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I wanna add comment about our assumption here later. |
||
| var textureProperties = properties.get( texture ); | ||
| textureProperties.__maxMipLevel = Math.max( Math.log2( Math.max( image.width, image.height ) ), textureProperties.__maxMipLevel ); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will I suppose it doesn't, so using
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kenrussell do you know the answer for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see section 3.8.10.5 "Manual Mipmap Generation" of the OpenGL ES 3.0.5 spec. It says that levels I'm not sure what the intent of this code is, but probably you need to zero out all levels of the texture that were previously set, and set the max mip level to the one that will be set by GenerateMipmap.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kenrussell thanks!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I had just misunderstood a bit. |
||
|
|
||
| } | ||
|
|
||
| // Fallback filters for non-power-of-2 textures | ||
|
|
||
| function filterFallback( f ) { | ||
|
|
@@ -325,9 +335,19 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
|
|
||
| } | ||
|
|
||
| if ( ! isCompressed ) { | ||
|
|
||
| textureProperties.__maxMipLevel = 0; | ||
|
|
||
| } else { | ||
|
|
||
| textureProperties.__maxMipLevel = mipmaps.length - 1; | ||
|
|
||
| } | ||
|
|
||
| if ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) { | ||
|
|
||
| _gl.generateMipmap( _gl.TEXTURE_CUBE_MAP ); | ||
| generateMipmap( texture, _gl.TEXTURE_CUBE_MAP ); | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -514,10 +534,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
| } | ||
|
|
||
| texture.generateMipmaps = false; | ||
| textureProperties.__maxMipLevel = mipmaps.length - 1; | ||
|
|
||
| } else { | ||
|
|
||
| state.texImage2D( _gl.TEXTURE_2D, 0, glFormat, image.width, image.height, 0, glFormat, glType, image.data ); | ||
| textureProperties.__maxMipLevel = 0; | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -547,6 +569,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
|
|
||
| } | ||
|
|
||
| textureProperties.__maxMipLevel = mipmaps.length - 1; | ||
|
|
||
| } else { | ||
|
|
||
| // regular Texture (image, video, canvas) | ||
|
|
@@ -565,16 +589,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
| } | ||
|
|
||
| texture.generateMipmaps = false; | ||
| textureProperties.__maxMipLevel = mipmaps.length - 1; | ||
|
|
||
| } else { | ||
|
|
||
| state.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, image ); | ||
| textureProperties.__maxMipLevel = 0; | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| if ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) _gl.generateMipmap( _gl.TEXTURE_2D ); | ||
| if ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) { | ||
|
|
||
| generateMipmap( texture, _gl.TEXTURE_2D ); | ||
|
|
||
| } | ||
|
|
||
| textureProperties.__version = texture.version; | ||
|
|
||
|
|
@@ -754,7 +784,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
|
|
||
| } | ||
|
|
||
| if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) _gl.generateMipmap( _gl.TEXTURE_CUBE_MAP ); | ||
| if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) { | ||
|
|
||
| generateMipmap( renderTarget.texture, _gl.TEXTURE_CUBE_MAP ); | ||
|
|
||
| } | ||
|
|
||
| state.bindTexture( _gl.TEXTURE_CUBE_MAP, null ); | ||
|
|
||
| } else { | ||
|
|
@@ -763,7 +798,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
| setTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, isTargetPowerOfTwo ); | ||
| setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D ); | ||
|
|
||
| if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) _gl.generateMipmap( _gl.TEXTURE_2D ); | ||
| if ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) { | ||
|
|
||
| generateMipmap( renderTarget.texture, _gl.TEXTURE_2D ); | ||
|
|
||
| } | ||
|
|
||
| state.bindTexture( _gl.TEXTURE_2D, null ); | ||
|
|
||
| } | ||
|
|
@@ -789,7 +829,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, | |
| var webglTexture = properties.get( texture ).__webglTexture; | ||
|
|
||
| state.bindTexture( target, webglTexture ); | ||
| _gl.generateMipmap( target ); | ||
| generateMipmap( texture, target ); | ||
| state.bindTexture( target, null ); | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, this file appears to contain two copies of this
TODOcomment, but only one got removed. Was that intentional?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I've just missed another one. I'll update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks!