Replies: 5 comments 5 replies
-
I love the idea, thanks for the contribution! This should be possible to implement and it sounds very useful, I'll take a look into it later this week! :)
ImPlot3D implements a "triangle" z-sort internally to make sure triangles are rendered in the correct order. It is not ideal when triangles overlap, but it works nice most of the time. |
Beta Was this translation helpful? Give feedback.
-
Hey @dcnieho! Just letting you know I started working on the Peek.2025-03-13.09-15.mp4When the image corners are too distorted, it doesn't look that great because of the way ImGui renders triangles. As far as I know, we would need a fragment shader to render quads with homography transformation to render distorted quads correctly (maybe future work? 👀). There’s still a bit of work left to support custom textures, but it’s getting there! The API currently looks like this: IMPLOT3D_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlot3DPoint& p0, const ImPlot3DPoint& p1,
const ImPlot3DPoint& p2, const ImPlot3DPoint& p3, const ImVec2& uv0 = ImVec2(0, 1), const ImVec2& uv1 = ImVec2(1, 1),
const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1),
ImPlot3DImageFlags flags = 0); I’m also working on an additional API for simpler image plotting, where users can define an image as a square/rectangle without manually specifying each corner’s position and UVs. Let me know if you have any feedback! |
Beta Was this translation helpful? Give feedback.
-
I just finished implementing support for custom textures in ImDrawList3D. Below is an example of rendering three different images in the same plot: Peek.2025-03-23.16-45.mp4To support multiple textures within the ImGui rendering pipeline, each unique texture requires a separate draw call. At the same time, we still need to ensure triangles are rendered in the correct order based on Z depth. I tried to keep overhead minimal -- so if no PlotImage calls are made, the plot remains as efficient as before (rendered with a single draw call). However, when custom images are used, we may need multiple draw calls. The image below illustrates how draw calls are generated from an In this case, To implement this, I added a I'm going to work on simplifying the |
Beta Was this translation helpful? Give feedback.
-
Done! The following two APIs were implemented to plot images. // Plots a rectangular image in 3D defined by its center and two direction vectors (axes).
// #center is the center of the rectangle in plot coordinates.
// #axis_u and #axis_v define the local axes and half-extents of the rectangle in 3D space.
// The rectangle is formed by moving from the center along ±axis_u and ±axis_v.
// #uv0 and #uv1 define the texture mapping.
// #tint_col can be used to tint the image.
IMPLOT3D_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlot3DPoint& center, const ImPlot3DPoint& axis_u,
const ImPlot3DPoint& axis_v, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1),
const ImVec4& tint_col = ImVec4(1, 1, 1, 1), ImPlot3DImageFlags flags = 0);
// Plots an image using four arbitrary 3D points that define a quad in space.
// Each corner (p0 to p3) corresponds to a corner in the image, and #uv0 to #uv3 are the texture coordinates for each.
// This overload allows full control over orientation, shape, and distortion.
// Note: The quad is internally split into two triangles, so non-rectangular quads may produce rendering artifacts
// since distortion is interpolated per triangle rather than over the full quad.
IMPLOT3D_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlot3DPoint& p0, const ImPlot3DPoint& p1,
const ImPlot3DPoint& p2, const ImPlot3DPoint& p3, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 0),
const ImVec2& uv2 = ImVec2(1, 1), const ImVec2& uv3 = ImVec2(0, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1),
ImPlot3DImageFlags flags = 0);
Below is the final demo Peek.2025-03-23.18-41.mp4 |
Beta Was this translation helpful? Give feedback.
-
Hi @dcnieho! #79 was finally merged into |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be super cool if you are able to draw images positioned at a certain 3D position/orientation.
According to some googling its possible in matlab like this:

https://se.mathworks.com/matlabcentral/answers/300826-how-do-i-insert-an-image-in-my-2-d-and-3-d-plots-in-matlab-8-2-r2013b
which produces:
If i mess with a corner point this still works fine:

Being able to texture surfaces would be super helpful for applications, e.g., where you show some 3D reconstruction result.
I guess it is possible using custom rendering, adapting your example there. But then it would be nice if the library would support a way to z-sort for the current frame so that i can draw back to front. That would entail submitting geometry and then being able to iterate over the plot objects and having them returned in the correct order so occlusions would be correct.
Beta Was this translation helpful? Give feedback.
All reactions