Skip to content

Commit

Permalink
Add option to disable rendering images in VR with mipmaps.
Browse files Browse the repository at this point in the history
Summary: This resulted in slightly higher image quality for some specific images when shown on device, so I am adding the option to disable it (if / when needed).

Reviewed By: pigei

Differential Revision: D68157275

fbshipit-source-id: bb8f697cfb3bfb9380a014b222062fe4d5d6292b
  • Loading branch information
Mariano Jaimez authored and facebook-github-bot committed Jan 16, 2025
1 parent dc4f518 commit 307ac26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Quest
namespace Application
{

void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, Frame&& frame, const ObjectSize& objectSize, const bool referenceIsWorld)
void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, Frame&& frame, const ObjectSize& objectSize, const bool referenceIsWorld, const bool useMipMaps)
{
ocean_assert(engine_ && framebuffer_);
if (!engine_ && !framebuffer_)
Expand Down Expand Up @@ -99,7 +99,7 @@ void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMa
pixelImage->start();

Rendering::MediaTexture2DRef texture;
transform = Rendering::Utilities::createBox(engine_, Vector3(1, 1, 0.0001), pixelImage, &texture);
transform = Rendering::Utilities::createBox(engine_, Vector3(1, 1, 0.0001), pixelImage, &texture, useMipMaps);
ocean_assert(transform && texture);

transform->setName(transformName);
Expand Down
38 changes: 22 additions & 16 deletions impl/ocean/platform/meta/quest/application/VRImageVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param world_T_image The transformation at which the image will be displayed, transforming image to world, can be invalid to remove the existing visualization
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
* @see visualizeImageInView().
*/
inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize);
inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize, const bool useMipMaps = true);

/**
* Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world).
Expand All @@ -92,9 +93,10 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param world_T_image The transformation at which the image will be displayed, transforming image to world, can be invalid to remove the existing visualization
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
* @see visualizeImageInView().
*/
inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize);
inline void visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize, const bool useMipMaps = true);

/**
* Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the view).
Expand All @@ -104,9 +106,10 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param view_T_image The transformation at which the image will be displayed, transforming image to view, can be invalid to remove the existing visualization
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
* @see visualizeImageInWorld().
*/
inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, Frame&& frame, const ObjectSize& objectSize);
inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, Frame&& frame, const ObjectSize& objectSize, const bool useMipMaps = true);

/**
* Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the view).
Expand All @@ -116,9 +119,10 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param view_T_image The transformation at which the image will be displayed, transforming image to view, can be invalid to remove the existing visualization
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
* @see visualizeImageInWorld().
*/
inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, const Frame& frame, const ObjectSize& objectSize);
inline void visualizeImageInView(const unsigned int id, const HomogenousMatrix4& view_T_image, const Frame& frame, const ObjectSize& objectSize, const bool useMipMaps = true);

/**
* Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world or to the view).
Expand All @@ -129,8 +133,9 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param referenceIsWorld True, if reference is world; False, if reference is view
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
*/
void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, Frame&& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true);
void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, Frame&& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true, const bool useMipMaps = true);

/**
* Visualizes an image (e.g., for debugging purposes) at a specific location in the virtual environment (defined in relation to the world or to the view).
Expand All @@ -141,8 +146,9 @@ class OCEAN_PLATFORM_META_QUEST_APPLICATION_EXPORT VRImageVisualizer : public VR
* @param frame The frame to visualize, can be invalid to remove the existing visualization
* @param objectSize The size of the visualized image in virtual space (in object space), an invalid object to remove the visualization
* @param referenceIsWorld True, if reference is world; False, if reference is view
* @param useMipMaps Use mipmaps to reduce aliasing artifacts.
*/
inline void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true);
inline void visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld = true, const bool useMipMaps = true);
};

VRImageVisualizer::VRImageVisualizer()
Expand All @@ -156,29 +162,29 @@ VRImageVisualizer::VRImageVisualizer(const Rendering::EngineRef& engine, const R
// nothing to do here
}

inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize)
inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize, const bool useMipMaps)
{
return visualizeImage(id, world_T_image, std::move(frame), objectSize, true);
return visualizeImage(id, world_T_image, std::move(frame), objectSize, true, useMipMaps);
}

inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize)
inline void VRImageVisualizer::visualizeImageInWorld(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize, const bool useMipMaps)
{
return visualizeImage(id, world_T_image, frame, objectSize, true);
return visualizeImage(id, world_T_image, frame, objectSize, true, useMipMaps);
}

inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize)
inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, Frame&& frame, const ObjectSize& objectSize, const bool useMipMaps)
{
return visualizeImage(id, world_T_image, std::move(frame), objectSize, false);
return visualizeImage(id, world_T_image, std::move(frame), objectSize, false, useMipMaps);
}

inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize)
inline void VRImageVisualizer::visualizeImageInView(const unsigned int id, const HomogenousMatrix4& world_T_image, const Frame& frame, const ObjectSize& objectSize, const bool useMipMaps)
{
return visualizeImage(id, world_T_image, frame, objectSize, false);
return visualizeImage(id, world_T_image, frame, objectSize, false, useMipMaps);
}

inline void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld)
inline void VRImageVisualizer::visualizeImage(const unsigned int id, const HomogenousMatrix4& reference_T_image, const Frame& frame, const ObjectSize& objectSize, const bool referenceIsWorld, const bool useMipMaps)
{
return visualizeImage(id, reference_T_image, Frame(frame, Frame::ACM_COPY_REMOVE_PADDING_LAYOUT), objectSize, referenceIsWorld);
return visualizeImage(id, reference_T_image, Frame(frame, Frame::ACM_COPY_REMOVE_PADDING_LAYOUT), objectSize, referenceIsWorld, useMipMaps);
}

}
Expand Down

0 comments on commit 307ac26

Please sign in to comment.