Convert 3D Point To 2D Point - unity3d

What I am doing is displaying the same 2D texture map on the screen as the model in the scene.
And fit the model perfectly on the screen.
as the picture shows
The red dot is the center of Bounds.
The blue dot is the center of the 2D texture image.
Since 3D has depth, the center point of the 3D model is applied to the 2D image. 2D images will deviate from a certain position and cannot be connected together.
Edit
Finally I found the answer in this link.

You can check Camera.WorldToScreenPoint method, if you wanna get 2D screen position, as I understood.

Related

Can I make a unity camera mask inside a shape?

Is there a way to render a camera only inside a sphere (or any 3D object)?
I want to render 2 cameras...each of them has different post processing effects...but one of them renders its effects in a spherical area around the player (with feathered edges if possible)...and the other renders the rest of the screen.

World to Cube projection Unity

That's the setting:
I have 2 cameras in the game scene. The game must be played in a room with screens on frontal wall and on the floor. To be able to test it I just recreated the 2 screens in Unity. The goal is to make the game immersive, creating the correct illusion as the image on the left.
What I've tried so far (and it kinda worked as you can see from the screenshot) is:
Camera0: goes directly in the frontal display.
Camera1: I created a post processing effect that deforms the output texture to create the correct perspective illusion.
The problem:
The fact that I'm basically working over a texture creates some blurry effect on the borders, because the pixel density is not the same in start and deformed image.
I think the best approach would be to make the deforming transformation happen on the projection matrix of Camera1 instead. But I just failed. Have you any idea on how to approach this problem correctly?
You can let your perspective cameras do the work for you.
Set the fov of the floor camera so that it shows only as much as will fit on the screen.
Then, have the cameras at the same position.
Finally, have the floor camera rotated on the +x axis by half of the sum the fov of both cameras. For example, if the wall camera is fov 80º and the floor fov is 40º, set the floor camera to be rotated by 60º along the x axis.
This will guarantee that the view of the cameras do not overlap, and they will have the correct projection along their surfaces to create the desired illusion.

Clamp camera within bounds of a Polygon Collider?

Hi I am making a 2d platformer game and right now I am working on the camera. while I succeeded in clamping the camera inside a rectangular shape, my game involves slopes, so I want my camera to be able to clamp inside a curved shaped too. Can anyone help me find an idea for the code?
Cinemachine gives you a flexible 2D camera controller, with the option to confine it inside a PolygonCollider2D. This section contains explanation for that and other cool things.

Displaying 3D animation on 2D Raw Image in Unity

I have 3D animation and display it on Raw Image.
The animation was quite ok testing on 3D plane, now changed to 2D Raw Image, then I am a bit weird about origins of GameObjects.
On 3D plane, animation models have origin on the ground between two legs.
Once changed to 2D Raw Image, the origin is shifted to chest. The first image is on 3D plane and the second is on 2D Raw Image.
All other position of club handle, club shaft and club head are also shifted to chest.
When I print the (x,y,z) position of club head, I have 374.9705,741.7168,-0.4869962. They should be less than 2 in 3D plane and less than 2 is correct.
How I run 3D animation on 2D Raw Image is discussed here and stated below
(1)Put the object in a specific layer (called MyLayer for the sake of the example)
(2)Set the Culling mask of a new camera to render only this specific layer
(3)Uncheck the MyLayer in the Culling mask of your main camera in order to prevent the latter to render your model
(4)Create a new Render texture in the project, and drag & drop it in the Render Texture field of your new Camera
(5) Add a new Raw Image to your UI canvas and assign the render texture in the Texture field
(6)Run my 3D animation
How can I have position of clubhead same as in my previous 3D plane?
I can't shift the origin, when I drag the whole GameObject is also shifted.
EDIT:
Let me add in why I run animation on RawImage is I need to display 3D animation on 2D canvas. For that I need Raw Image and RenderTexture to run 3D animation.
Please see the below image.
EDIT 1:
I take out of the canvas, but I don't see my model at the scene view to set the position. Why I can't see my model.
I see the model on the preview of my RawImage, but not at the scene.
DisplayCamera can see the model, but when I run I don't see model on the greencanvas too.

Unity3D Gui Sphere having distorted edges

I'm trying to make a make switch board with circular button.
For it i'm using Quad as a base and then overlaying 3D Spheres for the buttons.
For the texture of sphere's, I have made a Material to which a rectangular image is set.
in preview it looks good with all smooth edges, however, in game preview when I look closely at the sphere's their edges are distorted/pixelated.
Is there any restriction which should be adhered to make the sphere's have perfect smooth edges.
or I must be missing something.
Image uploaded. The Quad is of White color and there is a light source.
the texture was imported and overridden for platform for 2048.