- Home /
Generate a plane and change it's UV's to give perspective
I’m using the CreatePlane script from the Unity Wiki.
I'm building a roof visualiser app, that allows a user to see what a new roof product will look like on their existing home's roof.
So what I’m doing is allow the user to define 4 points on a screen in 2D, and what I want to do is generate the plane to match those points, all good.
But now the problem comes, where if the plane is a trapezoid, I.e the top 2 points are closer together than the bottom 2, I want the UV’s of the texture to converge along with this angle.
Any tips or advice on how to do this?
Or am I better rotating the plane in 3D space and somehow mapping it to the 2D points? If so, what would be the easiest way to do this while keeping the correct perspective.
Probably I'm missing something, but wouldn't the UVs just be (0, 0) for the bottom left, (1, 0) for the bottom right, (0, 1) for the top left, and (1, 1) for the top right? (Assu$$anonymous$$g a square texture.) It doesn't matter that the top two points are closer together; that doesn't change the UV mapping.
I go with Eric5h5 here. If you never touch the UVs it should get perspectively distorted all by itself.
It wouldn't create a 'perfect' distortion as the texture needs to be distorted along the Y axis as well, but yeah, it should kinda work.
I see what you mean. You could project the handles into the 3D space and tilt the quad accordingly, or use the angle between top and bottom points for the tilt angle
@Eric5h5 You were correct, I was doing something wrong in my trapezoid Vertex/UV generation that was causing some issues, the texture does slant correctly :)
Your answer
Follow this Question
Related Questions
Transfer lighting and other information from 3D sphere to 2D plane 0 Answers
Object follow cursor using plane due to perspective cam? 2 Answers
What is Vector3.Exclude for? 2 Answers
i've messed something up 1 Answer
hot to use raycast 2 Answers