Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 25, 2024, 02:05:11 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperArt (Moderator: JWK5)Making "pixel perfect" models in Blender?
Pages: [1]
Print
Author Topic: Making "pixel perfect" models in Blender?  (Read 7837 times)
Manboobs
TIGBaby
*


View Profile
« on: July 05, 2014, 05:53:50 AM »

[Deleted]
« Last Edit: March 07, 2023, 02:12:25 PM by Manboobs » Logged
jgrams
Level 3
***



View Profile
« Reply #1 on: July 05, 2014, 06:46:35 AM »

I'm not a 3D modeller, so take this with a grain of salt, but... My impression is that people who do 3D modelling usually do things as art and by eye, and that they usually don't do that sort of measurements-and-exact-coordinates thing much. So the programs aren't set up for it? Maybe? So you probably want of a CAD program for that. You might give SketchUp a try? Make the models there and then import them to Blender for rendering?
Logged
pen
Level 8
***


babyman


View Profile WWW
« Reply #2 on: July 05, 2014, 07:01:49 AM »

make 1 unit = 1 pixel...? You can always change it later / scale your model down later.
Logged

I AM FREE!
Lee
Level 1
*


View Profile
« Reply #3 on: July 06, 2014, 09:27:39 AM »

This tutorial is from my own experience with doing something similar in Maya, so it might not be helpful for blender but whatever.

Firstly you want to set the render to the exact tile size you want (or clean multiples), then set the camera to ortho, then the camera has a "size" property which seems arbitrary but it seems to be related to the grid units. I would suggest using size 10 with a 10 tile grid because it will make pixels columns perfect as there hopefully won't be floating point rounding (sub-pixel rounding). If the grid size for the x or y value was not a whole number then the grid spacing will be inconsistent which is the problem I was having.



I came up with the following formulas (for a camera only rotated through the x axis (pitch)):
Code:
grid_x = render width/camera ortho size
grid_y = sin(camera angle)*grid_x

So if you have the render set to 100x100 pixels and the camera size is set to 10 then:
Code:
grid_x = 100px/10 = 10px
grid_y = sin(camera angle)*10px

Now grid_y is a little trickier. You can keep changing the camera angle to get the desired grid spacing through trial and error or you can use the power of mathematics (inverse sin)!

sin-1(desired grid_y/grid_x) = camera angle

So say you want the height to be twice the width, you do sin-1(0.5) which would be a 5 pixel desired_grid_y if following the formula (5px/10px = 0.5). This gives a 30 degree camera angle.

So with that you have the ortho camera size set to 10, camera x position set to 0, camera rotation set to the desired angle, render settings to the actual size you want. I think camera y position can be whatever you want, I just set it to 15 I think because it "looked right". Lastly all you need is to get the camera z position... I forgot that part, but it looks important and is underlined in the image Evil


Also (pretty obviously) if you raise an object UP by 1 unit in the y axis (up in 3d position) it won't move up by one y_grid spacing when rendered (2d render position). Instead it will move up by {camera y position/sin(camera angle)} pixels... I think (might be wrong)... So if you did want to line it up to the ortho grid you'd have to follow this equation {y_grid/(camera y position/sin(camera angle))} to get how many units you should move its 3d position along the y axis to go up one y_grid spacing in the render. However maya was having some issues with floating point rounding I think and so to get around this when raising up I added a certain amount and when pushing down I negated a certain amount from this value (this is why it's +1.14 and -1.13 in the image).
« Last Edit: July 11, 2014, 05:37:11 AM by Lee » Logged
Lee
Level 1
*


View Profile
« Reply #4 on: July 06, 2014, 09:55:02 AM »

Sorry my examples and the image aren't using the same values, the image is old and I found it after writing it out.

In the example image the ortho render is 320x320, and the camera is ortho size 10:
grid_x = 320px/10 = 32px

I wanted grid_y to be 24 so the angle I needed was:
angle = sin-1(24/(320/10)) = 48.59

Although I can't remember how I got the camera z position...

Maybe try ((0.5*render width)/camera ortho size)*sin(camera angle) ... that gives me a position of 12 for the image... I think I just fudged it until it worked to be honest... although it is a precise number (maybe that's why I had to fudge the y position of the raised parts).

Also for the record I wasn't just using it to do stupid slopes like that, I was using it for all game objects like so:

Although the above character didn't need to be set on a pixel perfect grid, only the terrain did.
« Last Edit: July 11, 2014, 06:20:18 AM by Lee » Logged
Gravitaria
Level 0
**


Fi


View Profile WWW
« Reply #5 on: July 10, 2014, 06:37:32 PM »

Wow Lee, that's a really interesting method and approach for this task, as I've had the same problem before. nice!
Logged

Lee
Level 1
*


View Profile
« Reply #6 on: July 11, 2014, 06:19:23 AM »

I just realized a mistake in this:
grid_y = sin(camera angle)*(render height/camera ortho size)
This is not true, I assumed that it would be render height as it seemed to make sense but it's actually render width you want to use, because the scaling of the y axis is proportional to the x axis using this method. I didn't notice this because I was using a square render setting in my testing. I fixed the previous posts.

I think if you wanted isometric models using this tutorial you can follow the same steps using a camera angle of 30 degrees (y_grid is half x_grid, i.e 45 degree lines come out half as tall as they are wide giving the classic 2 pixels per y increment line step) and once it's set up rotate the model by 45 degrees along the z axis as well. But it may (will) be annoying to work on the model at a 45 degree. So instead follow the tutorial up to the camera position and set all three 3d coordinates to the same value (I think the z position value from the tutorial should work) and then rotate the camera 45 degrees on the z axis.

Also for rotations what I did was added a plane below the character and set the rig to have an orientation constraint with the character rig:

This meant that I could have a static camera set-up and a single animation set, all I had to do was rotate the base and render out the frames, and it also means the lighting set-up was consistent and the only thing changing between assets were the models and animations.

---
It does annoy me a little how much 3D artists just "bung it until it works" with positioning objects and cameras and stuff. But that attitude is built into the tools, there's no 3D alignment grids, guides or stuff, everything is by eye. Which works most of the time but the functionality is not there for the times when you don't want to go by eye, you have to use tools like "make planar" and then type in the position to move to... Or like this you have to try and figure out the math and pretty much reverse engineer what exactly "orthographic size" even means beyond being an arbitrary number. Every tutorial on isometric 3d I've seen essentially has them saying to "find a value that works" regarding either orthographic size, camera positioning or object scaling. But you know what render settings you want and how many units the camera area should be, why is the rest so complicated.
« Last Edit: July 11, 2014, 06:33:45 AM by Lee » Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic