playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.69k stars 1.36k forks source link

BASIS textures assets not usable with create cubemap #1983

Open gandhars opened 4 years ago

gandhars commented 4 years ago

When creating a CUBEMAP asset from BASIS compressed textures, the cubemap not created. If I use JPG files, everything works fine. I don't need create prefiltered cubemap, I need use cubemap with custom shader as 'samplerCube' uniform on posteffect.

https://forum.playcanvas.com/t/basis-texture-for-cubemap/12505

slimbuck commented 4 years ago

1983! :)

gandhars commented 4 years ago

Hello Donovan, thank you for informing me. Is possible to view to patch before it will be officially released ? Radek Hart

st 13. 5. 2020 v 12:22 odesílatel Donovan Hutchence < notifications@github.com> napsal:

1983 https://github.com/playcanvas/engine/issues/1983! :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/playcanvas/engine/issues/1983#issuecomment-627892975, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVT6YEDC7IEY2XEVG3GOY3RRJYHRANCNFSM4MGBQEKA .

slimbuck commented 4 years ago

Sorry @gandhars... I am busy working on cubemaps and while going through the tickets confused ticket 1983 with 1984 (the book :) ). I'll let you know when the fix is ready (though it probably won't be very soon).

willeastcott commented 4 years ago

Reopening because #2108 broke the After The Flood project, so I backed it out. @slimbuck - please have another go at a fix. 😄

leonidaspir commented 4 years ago

There seems to still be an issue with this. I observe that both BASIS textures and legacy compressed textures break a cubemap used for skybox.

image

Here is how it should look:

image

And here is how it looks after I compress the source files:

image

If I delete the prefiltered data, and try to prefilter again while the faces are compressed then It results in a black cubemap:

image

slimbuck commented 3 years ago

Hi @leonidaspir,

tldr: we flip textures upside-down during compression, this is why cubemaps are wrong.

This is related to the engine's treatment of texture origin. The PC engine follows the OpenGL convention of bottom left texture origin, whereas WebGL chose texture origin to be top left.

This means that we actually flip all (non-cubemap) textures upside-down:

This system works most of the time, but fails for cubemaps (since these faces can't be flipped).

We are planning to address this by adopting the WebGL convention and not flipping assets. Not a small job though since we must also keep support for the existing flipped compressed textures.

In the meantime, you can get compressed cubemaps to work by using your own (non-flipped!) cubemap faces.

Thanks!