You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browser:
Firefox 126.0.1 (64-bit)
Chrome Version 125.0.6422.142 (Official Build) (64-bit)
Other browsers untested
Description
Normal maps for turrets on right side of ship not being applied unless they are at the exact same angle as other sprites with the same normal map on the left side.
Additional:
Workaround
This can be remedied by loading a separate texture for each sprite. I guess this could be done dynamically somehow / upon sprite creation? See Update Below
Based on the workaround, could this possibly be resolved by creating a separate normal map automatically for each sprite created with the same texture, if the texture contains a normal map? Since we could assume not all sprites created with that texture would be at the same location, and thus each need their own normal map information accordingly.
Update: If you ran into this issue you can easily generate a new texture based on one you already loaded in a preload function like so:
// Where we need a unique texture key / normal map per spritefor(leti=0;i<8;i++){constbaseTexture=scene.textures.get("turret");constcopiedTexture=scene.textures.addImage(`turret${i}`,baseTexture.getSourceImage(),baseTexture.getDataSourceImage());constnewTurret=scene.add.sprite(this.x,this.y,copiedTexture);}
This will ensure the newly created sprite has a completely unique normal map and associated data, and avoid possible normal map issues when sharing a texture across different sprites. I'm not sure what if any overhead this adds or other impacts.
To implement the workaround, just comment out line 28
constturretTexture="turret";
And un-comment line 31
// const turretTexture = `turret${i}`;
Additional Information
When all turrets are created using the same texture:
Edit: Had a thought, the reason the normals are not working on the right side, something to do with the FIRST turret that gets placed, controls properties of the normal map they are all referencing?
Hence all left side that do some normal calculation based on the first turret placed are OKAY, whereas all the others that would need normal map calculations based on right side placement do not... However, if the right side turrets match the left side angle exactly its OKAY.
The text was updated successfully, but these errors were encountered:
Version
Firefox 126.0.1 (64-bit)
Chrome Version 125.0.6422.142 (Official Build) (64-bit)
Other browsers untested
Description
Normal maps for turrets on right side of ship not being applied unless they are at the exact same angle as other sprites with the same normal map on the left side.
Additional:
Workaround
This can be remedied by loading a separate texture for each sprite.
I guess this could be done dynamically somehow / upon sprite creation?See Update BelowBased on the workaround, could this possibly be resolved by creating a separate normal map automatically for each sprite created with the same texture, if the texture contains a normal map? Since we could assume not all sprites created with that texture would be at the same location, and thus each need their own normal map information accordingly.
Update: If you ran into this issue you can easily generate a new texture based on one you already loaded in a preload function like so:
This will ensure the newly created sprite has a completely unique normal map and associated data, and avoid possible normal map issues when sharing a texture across different sprites. I'm not sure what if any overhead this adds or other impacts.
Example Test Code
https://github.com/PaulB-H/phaserbug2
To implement the workaround, just comment out line 28
And un-comment line 31
// const turretTexture = `turret${i}`;
Additional Information
When all turrets are created using the same texture:
Edit: Had a thought, the reason the normals are not working on the right side, something to do with the FIRST turret that gets placed, controls properties of the normal map they are all referencing?
Hence all left side that do some normal calculation based on the first turret placed are OKAY, whereas all the others that would need normal map calculations based on right side placement do not... However, if the right side turrets match the left side angle exactly its OKAY.
The text was updated successfully, but these errors were encountered: