Z-Axis Scaling

CarlR's picture

I have made a patch that places an image on a sprite. It fades in and out. Each time it does this its x y position is randomised so it appears in a different place. It also flips the x y rotation 180 degrees and randomises the z rotation. Problem is, I want to also randomise the z axis BUT keep the image on the screen. Struggling with how to get the randomisation to cover the width hight at different z axis. minus figures centralise the positions and higher numbers push the image off the screen. I would like to keep at least 25% of the image always on the screen and get a good coverage of random positions at different z axis. Did a search for Z-Axis scaling and too much stuff came up nothing I could see would help me. This is how far I have got. Any illumination much appreciated C Sorry about the picture was all I could find ;)

PreviewAttachmentSize
scaleZ.qtz389.94 KB

gtoledo3's picture
Re: Z-Axis Scaling

CarlR wrote:
minus figures centralise the positions

I'm going to try to help on this, but I feel like I need to back into it a bit.

I understand that when you write this, you mean that if you have an object interpolating between -1 and +1 at z=0, it appears to go from the left side of the screen to the right. As you decrease the z value, the objects make the objects "appear" to not reach the boundaries of the screenspace.

This is a minor point, but minus figures don't actually make positions more "central". They are still traversing the same amount of units back and forth. In the same way that they also appear smaller, the scale of the area which they travel back and forth within also appears smaller.

1 point_prespective.jpg (from http://www.dreamroutes.net/varsha/index.php?option=com_content&view=cate... )

Note this picture. This is the basic law of perspective. The road is the same width. The distance from a building on one side of the street is the same from the other, though it appears to be less as one reaches the vanishing point.

If you do things to "scale up" images in the background, or make them further apart, you may find yourself in a scenario where you're manually removing the natural feeling of perspective and depth from your scene... there are times when this "feels" like the right thing to do, but it often isn't. I'm making no verdict on it and whether it's the right way to go for you, just throwing this out there as food for thought.

If you need a feeling of some kind of very infinite/jam packed scene, where objects that are very far span the whole width, then I would define exactly what my furthest space in Z is going to be, and then through a little trial and error, see how far I have to move an object left or right to get it to appear "all the way" to the left or right (just before it draws offscreen). Then, I would see what the x positions are at z=0. From that, I would calculate the rate of change.

If you want to correct for that rate of change, this is a good article about sussing it:

http://www.ugrad.math.ubc.ca/coursedoc/math100/notes/derivative/slope.html

However, it's not linear in QC... so I don't know if it's worthwhile or not.

I tend to think I would get stuff drawing all across in X at my furthest point. Then I would take that row, and keep moving it forward... when it got to a point where I thought it would be good to start eliminating offscreen geometry, I would duplicate the macro and reign in the X movement, or make some kind of logic to do it automatically.

You might also want to investigate orthographic perspective, since it sounds like you're going down a path that will eliminate the feeling of perspective (or maybe this is my misreading). That will make all of your images appear to cover the same area in x or y bounds regardless of z placement. http://en.wikipedia.org/wiki/Orthographic_projection

PreviewAttachmentSize
1 point_prespective.jpg
1 point_prespective.jpg82.98 KB

CarlR's picture
Re: Z-Axis Scaling

Wow thanks so much. You are totally right I am trying to eliminate the perspective. The perspective is really useful to me although I will end up with a 2d image. I guess I will have to do a bit of study to work this one out. Thanks for pointing me in the right direction. I have in the past either not needed to do this as the patch was one where I could just slide the sprites into place in the scene or I have guessed or its not been important.

I know the orthographic thing is fundamental to QC and am guilty of not looking into it properly. It even shows up in the hints for many patches. So I think I will have to build a numbers thing I can re use. My math is very weak. I tend to approach QC with my art head on, I am actually using it like a kind of crazy photoshop and then rendering out huge stills to print out with the Quartz Crystal CLI. Problem is when I have an idea I then have to smash my way through the logic of it. If I get a solution I will post back an "counter-perspective" version. I like that term!

gtoledo3's picture
Re: Z-Axis Scaling

CarlR wrote:
Wow thanks so much. You are totally right I am trying to eliminate the perspective. The perspective is really useful to me although I will end up with a 2d image. I guess I will have to do a bit of study to work this one out. Thanks for pointing me in the right direction. I have in the past either not needed to do this as the patch was one where I could just slide the sprites into place in the scene or I have guessed or its not been important.

I know the orthographic thing is fundamental to QC and am guilty of not looking into it properly. It even shows up in the hints for many patches.

To clarify, QC uses GL Modelview (this has perspective/vanishing point). You can get ortho projection going by installing kineme's gl tools environment (versatile..I recommend this, but "skanky"/non-apple approved) or by using my Ortho_gt layer plugin (standard api).

If you do that, boom, no vanishing point :)

Quote:
So I think I will have to build a numbers thing I can re use. My math is very weak. I tend to approach QC with my art head on, I am actually using it like a kind of crazy photoshop and then rendering out huge stills to print out with the Quartz Crystal CLI.

Nice! That's not a bad way to look at it.

Quote:
Problem is when I have an idea I then have to smash my way through the logic of it. If I get a solution I will post back an "counter-perspective" version. I like that term!

In your off time, look through as many official apple QC examples as you can :)

psonice's picture
Re: Z-Axis Scaling

I've been considering this "use QC to make a picture" idea too.

There's this thing we have in the demoscene, called 'procedural graphics'. Basically, it's a competition. You have to submit an executable, and it has to be smaller than 4KB. The executable just generates a picture, and shows it on screen, nothing else.

With 4k, you don't have any space for nice things like textures, 3d models etc. You have to make everything yourself, and you have to do it extremely efficiently. QC is ideal for at least prototyping this (and if you use GLSL you can write the main part of the code in QC).

It's a really different way to use it - no worries about performance, framerate etc. You only care about a high quality picture.

There's a quick guide to what can be done with only code and 4kb here: http://www.pouet.net/top10.php?type=procedural+graphics&platform=any+pla... (just click on each one and view the screenshot, if you want the full hi-res picture you'll probably have to run the .exe in windows). (And note that 'patter' is not work safe - it features nipples ;)

usefuldesign.au's picture
Re: Z-Axis Scaling

CarlR wrote:
I tend to approach QC with my art head on, I am actually using it like a kind of crazy photoshop and then rendering out huge stills to print out with the Quartz Crystal CLI.

I've used QC to make stills. I used the Apple ImageWriter(name ?) plugin but was not completely satisfied with the max resolution. I'm pretty sure I tried using Quartz Crystal and found the same limitation, so being a more involved workflow just pulse triggered the writing of PNGs from the comp itself.

What sort of resolution did you get from Quartz Crystal, Carl? I believe it's GPU dependant if anybody would like to clarify?

CarlR's picture
Re: Z-Axis Scaling

Going OT a bit but everything you need to know about how big you can go is here http://kineme.net/Release/Production/QuartzCrystalmaximumrendersize you need to use the QuartzCrystal CLI version. On a new 27inch i5 iMac with 8Gb RAM I managed to get a near 8K wide still. This only gives you an image of 67.73cm @ 300PPI 16K would be 135.47cm @300PPI or a quite decent 67.73cm @600PPI I would like to go bigger and higher res than 8k. The 8k image test was of a frame of a mandalbulb mutation, all inside a GSL shader. Will attach a jpg version. I did a test with another comp that had a few Render In Image patches and this came out much smaller. the demo.qtz attached. There is a limitation with render in image patches I think. Not sure I understand. All I did was keep going bigger until all I got were blank frames.

PreviewAttachmentSize
RENDERTEST.jpg
RENDERTEST.jpg27.88 MB
Feedback_mock_up_demo.qtz47.2 KB

CarlR's picture
Re: Z-Axis Scaling

Before I read this I just got the z-axis numbers and inverted them and then use a division slider to "tune" the maximum area. The result was a total fudge. Although the area covered was right things still tended to hang out in the middle. Cant wait to try your Ortho_gt layer plugin! Can't imagine how it will work at the mo but will hunt it down. My slightly altruistic dream is to see a QC generated artwork win the turner prize ;)

CarlR's picture
Re: Z-Axis Scaling

Procedural graphics is what I have been exhibiting for years now. Thanks for the links will have a dip into that. At the moment I am using super high res images in my comps so no 4k stuff for me at the mo. The latest project is a formal abstract expressionist video painting that uses at least 200 of these images composited together. I really want to jump the gap between CGI and fine art. GLSL would be brilliant to do lots of the things I need to do though. Like for example getting rid of render in image patches! This summer I am going to try doing some GLSL stuff. I will.

gtoledo3's picture
Re: Z-Axis Scaling

I was thinking "what's this Turner prize...". For the Brits only :) !

CarlR's picture
Re: Z-Axis Scaling (not stuck in the middle anymore)

GT I hunted down your ortho_gt plug in and here is a new version of my patch that defies the perspective problem. Thank you so much for guiding me on this one. I now have the basic building block that I need. In the end I actually stopped using the z-axis to scale the picture. I put z-axis right to the back of its limit (-98) set the zFar on the ortho plug-in to the same and used a different way to change the size of the image. Now I have even random coverage at all sizes. I am very happy. Thanks GT!

Coming full circle on this now. I put in the ortho_gt plug-in, spent ages trying to tune everything in, slept on it, tweaked some more and only when satisfied 1000% that it was exactly right I turned off the ortho_gt plug-in. Everything jumped to the middle, which is where I started!

I know this stuff must look pretty basic to some here but may be of use to other lurkers like myself who have also wondered "Why is everything stuck in the middle?" :)

PreviewAttachmentSize
Counter_perspective.qtz395.79 KB