-
-
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
Conversation
|
|
||
| #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) | ||
|
|
||
| // TODO, replace 8 with the real maxMIPLevel |
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 TODO comment, but only one got removed. Was that intentional?
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!
|
|
||
| _gl.generateMipmap( target ); | ||
|
|
||
| var image = Array.isArray( texture.image ) ? texture.image[ 0 ] : texture.image; |
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.
Can I expect images for cubic map have the same size?
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.
It's not guaranteed, but lets assume that.
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.
OK. I wanna add comment about our assumption here later.
|
Changes and notes.
I add some questions inline. |
|
|
||
| var image = Array.isArray( texture.image ) ? texture.image[ 0 ] : texture.image; | ||
| var textureProperties = properties.get( texture ); | ||
| textureProperties.__maxMipLevel = Math.max( Math.log2( Math.max( image.width, image.height ) ), textureProperties.__maxMipLevel ); |
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.
Will gl.generateMipmap() clear the existing mipmap configuration?
For example, imagine you have 64x64 texture image and set mip level up to 10 with gl.texImage2D and then call gl.generateMipmap. gl.generateMipmap sets mip levels 1-6. So 7-10 levels will be removed?
I suppose it doesn't, so using max to choose the bigger one here.
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.
@kenrussell do you know the answer for this?
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.
Please see section 3.8.10.5 "Manual Mipmap Generation" of the OpenGL ES 3.0.5 spec.
It says that levels levelbase+1 through q are derived from the contents of levelbase. Other mip levels are untouched.
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.
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.
@kenrussell thanks!
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.
I think I had just misunderstood a bit.
In the example I mentioned, 7-10 levels makes no sense (seems like we can set 1x1 image tho)
I can remove max.
|
Merging for now. |
|
Confirmed it with Windows + Edge here, too. Hm, I guess it could be from the WebGL (extensions) capability? |
|
Which extension would it be? |
|
I was not aware this code relied in floating point textures...? |
|
I guess |
Ah, sorry. I just said floating texture without thinking deeply because I haven't looked into the related shader code yet. |
You meant, you guess the behavior of gl.generateMipmap() could be different? |
|
This issue seems appearing even in r90. I'm really not sure if it's related to mipmap yet. |
That is a good point. |
|
Wild guess... Maybe this is related to |
|
@takahirox is |
|
Another related point: Our How the shader selects the mipmap level based on the |
Same. |




This PR is still WIP but you can test if this change fixes #13107
I calculate max mip level by log2( max( image.width, image.height ) ) for gl.generateMipmap.
I'll add comments later about what I'm worried about in this impl.