Hi there,
Have a scenario where 3d objects/SK meshes need to be flattened to a 2d plane, so that the camera can get close to them without clipping (screen capture cannot be used here). Have followed the recommended answer from stack (for the 3d to 2d projection), however the issue is that the models are rotated and offset quite a lot from their origin points, essentially rendering this WPO useless. This is what the WPO looks like:
And this is the wrong outcome (rotated and with wrong offset):
Ideally the flattening should occur at the original vertex positions (seen as the empty box above). Not an expert so seeking advice here if possible. Thank you in advance!
Which formula are you copying, because at this point
You just have ācamera positionā again 
Supposed to use this method:
- Make a vector from your
orig
point to the point of interest:
v = point-orig (in each dimension);
- Take the dot product of that vector with the unit normal vector
n
:
dist = vx*nx + vy*ny + vz*nz;
dist = scalar distance from point to plane along the normal
- Multiply the unit normal vector by the distance, and subtract that vector from your point.
projected_point = point - dist*normal;
Have no idea why this half-worked. Using any other combination (like not reversing the normal) breaks the shader. Trying to understand why, but so far any attempt breaks (the mesh disappears of remains intact).
Strangely, there is

and whatās inside looks like this formula
I can get flat looking things, but itās not right yet⦠
Iām assuming itās something like
Mehā¦
Looking at this node made me realize that technically thereās no need to make a direction vector from the object to camera, because the transform is done in place. Hence, the node that you shoved is much simpler (just a dot and multiply/subtract).
However, upon trying this:
Thereās still a massive offset with a wonky rotation issue. Also, if you move the object, it gets worse. Must be a conversion issue, or something along those lines (no idea).
Shouldnāt be the āplane normalā from the object to the camera? (not the camera vector transformed) But when I try that, it creates a tube from the object to the camera. First thought it was an issue in the material preview, but breaks in game as well.
Itās the normal of the plane you want to project onto, the plane that is the camera.
1 Like
Figured that the issue was the definition of the plane, because it had no origin (other than 0.0.0). So decided to add the objās location and normalize the incoming vector. Which seemed to have sort of solve the problem. Issue is that now the object is only half squashed, not nearly as flat as hoped to be.
1 Like
Iāll give that a go later 
1 Like
It still acts weird (especially when moved far away from the camera) and not sure if itās the right thing, since I canāt tell from looking at it. Thought that flattening an object was a much simpler problem to solve⦠Would be nice to move on with this after 2 days of trying (in crunch atm).
1 Like
This is what itās like, Iām afraid. There will be āknotsā along the way 
I was thinking ( I still think the plane is the camera plane ), and maybe get the forward vector of the camera as the plane normal, but add it onto the camera location ( although that sounds nuts now I say it ).
Also possibly a plane somewhat in front of the cam, otherwise itās all going to be squashed in your face.
Problem is that have seen this transformation being solved in different engines/languages/etc., as well as checked out that 2 content examples (meant for billboards, but break the mesh), so something is off just not sure what. Otherwise thereās no other way to flatten a SK mesh (apart from the render target), especially knowing that it has to be per object level (not actor) in this case. Which turns out now has become a critical issue to solve for the project. Not ideal.
1 Like
Thereās a method on yt for stopping the first person weapon from colliding with scenery, but the code is just RIDICULOUS 
I think itās just a matter of having the plane at the object location and flattening the vectors along the camera normal. I think itās quite easy, I just need to get enough time to take a proper look. Hopefully todayā¦
Saw the one with the default fps template (panini projection something), using some basic mat attributes, but didnāt touch it as it worked with FOV changes and numerical inputs, and was just another āblack boxā method.
1 Like
Try this
Itās totally flat. Youāll need to lerp between normal and this, depending on camera distance 

1 Like
Gave it a go, and had mix results: Works OK on a cube, but on a SK mesh it looks weird (it slightly rotates with the camera, almost arching around its center). Tried it in game, in the menu the model showed Z fighting (result of the flattening, so tried to decrease the squash just a fraction, which worked), but in game (different level), the model was constantly at a 45 degree angle (speaking of world coords, facing away from their X forward axis), no matter how the camera was positioned, and the model wasnāt squashed at all (or was somewhat, couldnāt tell, because couldnāt get around it to see), but rotated some. No idea whatās going on (the cam is on a boom, but thatās it).
Ps. The issue with the SK model could come from the fact that itās not moving accordance with itās parent (there are several meshes on one actor). So that has to be accounted for.
1 Like
Iām pretty sure the principle is correct, but obviously the shading is all wrong, because the normal isnāt being translated.
Not sure about the skeletal mesh. Tried the mannequin, does look well weird 
1 Like
Well, on a side note, gave that panini projection a go. It really just scales the model, you can still clip into it, as itās still 3D.
Not sure what to do now. Guess will just have to live with it, and somehow come back to this at one point.
Thank you for trying to help!
1 Like