- Home /
How to project objects outline on floor when placing it in real time?
In simple room configurator I can place objects like different sofas, tables, lamps etc. The view is a first person 3D view. When picking up an object from a menu, I want to place it in the room. The idea is to show the outline of the object on the floor. Because the objects can have quite complex shapes, the outline on the floor should look as if projected from above the object. I do not use a grid, the objects can be placed freely.
When searching for anything with the keyword outline, the results are mostly about outline shaders.
My first idea was to look at the vertices of the object and get the ones which are at the farthest points as seen from the top, independent of their placement in height. Then draw a spline with a glow shader a little above the floor.
But I wanted to ask if someone in the community knows of a better solution? Maybe there is a standard way to do this and I just cannot find it :)
Answer by Bunny83 · Jun 21, 2016 at 08:26 PM
Well, it's more complex than you might think but not too difficult. First of all you should filter out the top facing triangles. This can be done by simply calculating the face normal from the 3 vertices of each triange and check the direction in relation to the up vector. This way you are left with only up faceing triangles.
This stripped down mesh can be used in conjunction with the helpers i've posted over here. Note that those helpers are designed for meshes with fully shared vertices / edges. So if the original mesh was a closed mesh by "cutting" it in half with the above mentioned procedure the mesh will have an edge around the mesh which would be returned by my helper classes.
Thank you, this looks very interesting. Because I cannot control how the meshes are made or even if the objects consist of multiple meshes, I am thinking of doing it by shader. Rendering the object from above, detecting the edges and rendering the outline to a texture. I only have to do it once, when a new object was added to the library. Hopefully I can try both methods soon and post the results.
Your answer
Follow this Question
Related Questions
Accessing a projectors renderer 2 Answers
Blob shadow changes transparency 2 Answers
www.texture on Projector wont clamp 1 Answer