PDA

View Full Version : 2D grid with color value fields

elrakone
04-12-2013, 08:02 PM
Hello!

I am doing a project in which I have a 3D model, from which I need to extract hight information (z-value) of each (x,y) coordinate, and then transform it into a 2D grid map, where each coordinate will have a particular colour gradient (e.g. green to red) depending on the value of the z-coordinate. Also, an alternative is to group a couple of "pixels" in a 10x10, or larger, tile, which will have an uniform color based on the medium value of the pixels within it.

I appologize if this is a too basic question, I have researched the forum and a couple of guides, but I can only find how to make regular grids, without any information in their tiles.

tonyo_au
04-13-2013, 06:21 PM
By height do you mean distance from the camera? If so it is just your depth buffer.

elrakone
04-14-2013, 06:30 AM
well, basically it's the real height of the object the camera sees. It's already calculated within the program, it can be considered as known. I just need to transform that value into the tile color..

Mustard
04-17-2013, 07:22 AM
Not sure what you are trying to do. z value is normally the depth as tonyo_au said. y value is normally height.

But if you are trying to simply color objects with a gradient going from green to red. This shouldn't be hard as you can either use the world position of the fragment to pick a color depending on the fragment position relative to the near and far plane (if you want a gradient based on the depth from the camera). Or you could use the bounds of the object and color it with the gradient based on the position of the fragment relative to the bounds of the object. (Think axis aligned bounding box (or just use min and max value of y or which ever coordinate you want to use)).

If I have miss understood what you are trying to do feel free to clarify.

elrakone
04-17-2013, 06:14 PM
Ah, yes, I apologize, my mistake, the height is the Y coordinate.

I'll try to clarify, maybe I didn't express myself very well, but basically it's the second thing you've mentioned..
Basically, I would like to make a 2D grid, table or something similar, where each field (whose coordinates would be (X,Z) - which are the two of the (X,Y,Z) 3D coordinates) would have a value which is dependent on the value of the Y coordinate of that particular pixel. These values X,Y and Z I already know, I can extract them from the image.

The problem I have, is that I don't now which structure would provide this. Should I make a grid consisting of lines intersecting - then how do I color the fields? Or, should I make like a square for each pixel and color it individually?
Also, could you please point me maybe to some tutorials that explain this, because I was unable to find one..maybe because I didn't know how to specify my problem when I searched.

When I manage to do this, I could maybe extend it to making one field in that grid not equivalent to just one pixel, but maybe to a tile consisting of 10x10 pixels, and then the value of that tile would be the average Y of those pixels included.

Thanks again for your help! :)