Skip to content

Commit

Permalink
[PicoXR] Use compressed ETC2 textures for environments
Browse files Browse the repository at this point in the history
PicoOS v5.4 added support for ETC2 compressed textures. We removed
support for PicoOS < v5.7 when the version check was added. This means
that we can now finally switch to using compressed textures also
for Pico devices.

There is no need to distribute the PNG versions in the Pico package.
That would save us 14MB in the distributed APK. Apart from that
the external environments code was also modified to download the
KTX versions of the textures.

The already downloaded environments will be used though because
we have the same id for the different formats of the same environment.
But for the builtin ones, and new downloads the KTX versions
would be the selected choice.

Fixes #522
  • Loading branch information
svillar committed Oct 3, 2024
1 parent 6d8007f commit d6bd6b4
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class EnvironmentUtils {

public static final String ENVS_FOLDER = "envs";
public static final String BUILTIN_ENVS_PREFIX = "cubemap/";
public static String[] SUPPORTED_ENV_EXTENSIONS = (DeviceType.isPicoXR() || DeviceType.isOculusBuild()) ?
public static String[] SUPPORTED_ENV_EXTENSIONS = (DeviceType.isOculusBuild()) ?
new String[]{".jpg", ".png"} : new String[]{".ktx", ".jpg", ".png"};

/**
Expand Down Expand Up @@ -209,10 +209,10 @@ public static Environment getExternalEnvironmentById(@NonNull Context context, @
*/
@Nullable
public static String getEnvironmentPayload(Environment env) {
// Pico4x and Meta Quest (after v69) do not support compressed textures for the cubemap.
if (DeviceType.isPicoXR() || DeviceType.isOculusBuild()) {
String payload = env.getPayload();
String format = "_misc";
// Meta Quest (after v69) do not support compressed textures for the cubemap.
String format = DeviceType.isOculusBuild() ? "_misc" : "_ktx";
int at = payload.lastIndexOf(".");
return payload.substring(0, at) + format + "_srgb" + payload.substring(at);
}
Expand Down
21 changes: 13 additions & 8 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2028,19 +2028,24 @@ BrowserWorld::CreateSkyBox(const std::string& aBasePath, const std::string& aExt
}
return;
}
#if PICOXR
// Pico's OpenXR runtime does not support compressed textures at the moment. Use PNGs in the
// meantime.
const std::string extension = aExtension.empty() ? ".png" : aExtension;
GLenum glFormat = GL_SRGB8_ALPHA8;
#elif OCULUSVR
#if defined(OCULUSVR) || defined(PICOXR)
bool usesSRGB = true;
#else
bool usesSRGB = false;
#endif

#if OCULUSVR
// Meta Quest (after v69) does not support compressed textures for the cubemap.
const std::string extension = aExtension.empty() ? ".png" : aExtension;
GLenum glFormat = GL_SRGB8_ALPHA8;
#else
const std::string extension = aExtension.empty() ? ".ktx" : aExtension;
GLenum glFormat = extension == ".ktx" ? GL_COMPRESSED_RGB8_ETC2 : GL_RGBA8;
#endif
GLenum glFormat;
if (usesSRGB)
glFormat = extension == ".ktx" ? GL_COMPRESSED_SRGB8_ETC2 : GL_SRGB8_ALPHA8;
else
glFormat = extension == ".ktx" ? GL_COMPRESSED_RGB8_ETC2 : GL_RGBA8;

const int32_t size = 1024;
if (m.skybox) {
m.skybox->SetVisible(true);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/negx_srgb.png
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/negy_srgb.png
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/negz_srgb.png
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/posx_srgb.png
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/posy_srgb.png
Binary file not shown.
Binary file removed app/src/picoxr/assets/cubemap/wolvic/posz_srgb.png
Binary file not shown.

0 comments on commit d6bd6b4

Please sign in to comment.