Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by superliminal · May 08, 2012 at 09:12 PM · render texture

Perspective Correction with Render Texture

Hello

I am working on a project that involves some basic perspective distortion correction. I am having some trouble getting it to work. Specifically, I'm having trouble mapping the Render Texture to my "correction plane" so that the perspective distortion is eliminated. Some help and feedback would be greatly appreciated. Let me explain my setup:

My scene is simple, I have a vertical plane with some simple objects (shelves) on the surface. The plane and shelves are going to be projected (mapped) onto a wall. The trick is, the projector will be ceiling mounted and pointed about 15 degrees downward. This means I have to compensate for the projector angle in Unity. This is done by adding a virtual camera where the projector would be in virtual space. THEN, I have to correct the perspective distortion of that virtual camera so the end projection fills the entire wall with proper proportions.

My workflow for solving the problem is to recreate the space in Unity. First, the modeled wall and shelves are created in proportions that will match the real wall and shelves. Next, a virtual camera is placed at the same location as the real projector and with the same angle. That camera image is then sent to a render texture, which is then applied to a second wall (basically a duplicate with the exact size and placement as the original wall but on a different render layer). A second camera (Main Camera) is placed directly in front of the textured wall, perpendicular, and set to orthographic mode. The idea is to correct the perspective distortion by stretching the texture to exactly fit the textured plane.

Here is the perspective correction signal flow: Camera 1 (perspective) --> RenderTexture --> plane with renderTexture applied --> main Camera (orthographic) --> out

An image illustrating the setup: alt text

What I have so far:

I cant seem to get the texture mapped correctly to the plane that has the Render Texture applied. If you look at the below image you can see the texture does not match the plane exactly, it still has the perspective distortion. I think the way to solve this problem is to map the uv coordinates so that the texture is mapped correctly to the plane, but I'm not sure how to do this. I did not see much support for uv placement through scripting either. I also tried modeling a single-face plane with the correct dimensions and importing that instead of using plane in Unity.

alt text

Main camera output, you can see the texture placement issue here: alt text

I am really stuck on this problem and need to figure out a solution to this. Any help on the subject would be much appreciated!

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image syclamoth · May 08, 2012 at 09:14 PM 0
Share

I thought most modern projectors had functionality for fixing this kind of thing with clever lensing? Am I misunderstanding the problem here?

As far as I know, perspective distortion should probably be done with clever manipulation of the camera's projection matrix. Could you explain why? I think I can see what, but it's sometimes difficult to know what the proper solution is without fully understanding the background of a problem.

avatar image superliminal · May 08, 2012 at 09:34 PM 0
Share

No its more complicated than that. Imagine you have a grid painted on the wall that you will be projecting onto, 10cm x 10cm grid. And you want to project the exact same grid pattern onto the wall, using a wall with a grid you created in Unity. If your camera in Unity is simply perpendicular to the modeled wall, and then you project that at an angle, your projected grid will not match with the real grid. Simple $$anonymous$$eystone correction within the projector will not fix that problem.

I am going to be projecting onto a wall with objects on it. Simple projection mapping. If the perspective distortion is not corrected, is simply will not match up. A good intro to the topic can be found here: http://vvvv.org/documentation/how-to-project-on-3d-geometry#projection-on-a-flat-surface

avatar image superliminal · May 08, 2012 at 10:25 PM 0
Share

I'll post this project also because it is doing similar things (but more complicated). What is most relevant I think is that he distorted the camera output in a similar way that I describe, without using custom shaders. I think he did it only with uv texture mapping with his surface. http://paulbourke.net/papers/cgat09b/ http://paulbourke.net/miscellaneous/domefisheye/unity3d/

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How could i achieve unity pro features in unity indie 1 Answer

Pixel perfect render texture sprites moving irreguarly 0 Answers

Odd rendering issue: texture image is only displayed half 0 Answers

URP Bokeh DoF not showing in render texture 0 Answers

Render to texture in a 2d game 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges