Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(37 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

[MAXScript] How to position orthograpic camera to fit a plane perfectly?
show user profile  Nanne
Hello MAXScripters!

I have a plane 1x1 or 2x2 or perhaps 1x2, and I want to create a Free Camera set to Orthographic right above that fits the plane pixel perfectly in the render frame, with rendering set to something like 512x512, 1024x1024 or perhaps 1024x2048.

What I want to do is to render textures. But using Render To Texture doesn't work properly, and some renderers does not support RTT (like Arnold apparent).

Kristoffer Helander
  :: Works ::   |  :: Resumé ::   |  :: Contact ::   |  :: CG Blog ::   |  :: Links ::     
read 385 times
5/10/2017 11:33:48 PM (last edit: 5/10/2017 11:33:48 PM)
show user profile  Garp
From memory.
Do NOT use an orthographic camera. With the texture applied to a square plane, position a free camera at its center and a distance of half the plane's side (e.g. for a 100x100 plane centered on the origin on the construction grid, position the camera facing down at [0, 0, 50]) and use a FOV of 90°.
Worked for me in the past.

Try it with one of these UV grid textures, for a 800x800 render and check in photoshop that you get an exact fit.

read 373 times
5/11/2017 12:21:40 AM (last edit: 5/11/2017 12:24:17 AM)
show user profile  Nanne
Thanks Garp! That simple huh? Why didn't I think of that! :P

Why NOT use a orthographic camera? Wouldn't a perspective camera distort the texture towards the edges?

Kristoffer Helander
  :: Works ::   |  :: Resumé ::   |  :: Contact ::   |  :: CG Blog ::   |  :: Links ::     
read 358 times
5/11/2017 10:30:42 AM (last edit: 5/11/2017 10:30:42 AM)
show user profile  Garp
With an orthographic camera, there doesn't seem to be a clear relation between the different values. So the process consists of trying different values by ever smaller increments until satisfied.
About the distortion, frankly I don't remember. Maybe I had one but it didn't matter or it was small enough for my purpose. You can check it with a dense UV grid (16x16 or 32x32 squares, rendered at 800x800 pixels) by counting the pixels in a few squares in photoshop. If a square on the side has the same size as one in the middle, no distortion.

edit: I just made a try with a non-ortho camera, rendering at the same size than the original map and got a perfect match in photoshop.

read 346 times
5/11/2017 4:15:33 PM (last edit: 5/11/2017 8:31:39 PM)
show user profile  Nanne
Alright, that's cool, thanks! :)

It's good news that it works with perspective cameras, since some renderers does not support orthographic cameras. Some people works around this by placing a perspective camera really, really far away with a very narrow field of view and then just zooming in. I was expecting something like that as a necessary workaround here as well.

Thanks for helping! :)

Kristoffer Helander
  :: Works ::   |  :: Resumé ::   |  :: Contact ::   |  :: CG Blog ::   |  :: Links ::     
read 333 times
5/12/2017 9:18:54 AM (last edit: 5/12/2017 9:18:54 AM)
show user profile  Nanne
That didn't work for me, I think it's because I'm using Displacement Mapping on my plane to create an uneven ground to bake a tileable displacement map from the mesh. So the perspective of the camera and the uneven ground mesh causes a distortion.

I did however found a thread on CGTalk about the exact same thing.

"Ortho camera FOVs depend on the target distance. Other than that, it's the usual trigonometry bits.
I.e. if you have a target 100 units away from the camera and you want the camera to cover, horizontally, 100 units as well, then imagine the full horizontal FOV as two right triangles with the target distance as the adjacent length and the desired view in units, divided by two, as the opposite length.

halfHorizontalFOV = atan(opposite/adjacent) = atan (50/0/100.0) = atan (0.5) = 26.5651°
Then to cover the full horizontal FOV, simply multiply by two."

And there was also a convenient simple rule for this

"if you set camera FOV to 90, the width of the view will be target distance * 2"

So far it works pretty nice :)

Kristoffer Helander
  :: Works ::   |  :: Resumé ::   |  :: Contact ::   |  :: CG Blog ::   |  :: Links ::     
read 317 times
5/14/2017 1:23:49 AM (last edit: 5/14/2017 1:27:13 AM)
#Maxforums IRC
Open chat window