Sign in to follow this  

Heightmap issue

This topic is 2394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I am new and I signed up for just one issue thats been bugging me for months.
It's the barrier between getting level of detail in this game, I need a heightmap of a 3d model.

However I just cannot figure out how to get a heightmap from the front and the back of this model.
I checked online for heightmap editors but they were for landscapes, and I am trying to get a heightmap of a 3d object from all (well just 2) sides.

I have 3ds max 2010, any help would be SOOOOOOOOOO appreciated. This stupid little issue that I never thought would come up has been holding the project back graphically :(

It needs to be according to the UV map. I don't know WHY this is so hard. I did render to texture, heightmap.. nothing... I did this gradient trick, but it doesn't work for both sides.
I just don't know what to do. Please help me!

The final product needs to be precise too, exactly fitting within the 1024 1024 uvmap.

Share this post


Link to post
Share on other sites
[quote name='Wrongfire' timestamp='1305859358' post='4813297']
I just don't know what to do. Please help me!
[/quote]
Dito.
Could you be more concrete about what you're talking ? Maybe some screenshots ?

Here are some keywords you should goolge for:
- hi-res modelling
- texture baking (hi to low poly)
- displacement mapping
- sculpting
- zbrush
- normal mapping

Share this post


Link to post
Share on other sites
Yeah for sure.. I was almost going to make a video explaining it. (Ive looked all over google and youtube as well.. No one uses height maps like this I guess..?)

Okay so here's the deal, It's a space rpg game, we are rendering lod objects via a 3d box that uses a normal map and a heightmap to project objects that are far away.. I think?.. I don't know the technical side of it but the programmer says it looks way better then just 2d billboards. I need a heightmap, and I already have the normal map.

Screenshots:

[img]http://i34.photobucket.com/albums/d135/Wrongfire/Heightmapissue.png?t=1305950254[/img]

So that's the model, and the uv map for it.
What I need is for each of those sides represented in the map to show a heightmap from that angle.. If that makes sense.. So 2 height maps of the same model from 2 different angles, the ones in the uv map.

If I need to show anything more im more then willing too if it'll help you help me solve this!

Share this post


Link to post
Share on other sites
I suspect that to get exactly what you want, you are going to have to do some scripting. I use Blender, and I know that in Blender you can use the compositing Node system to output the depthmap of a scene pretty easily, but that's maybe not exactly what you want. In Blender you can also bake a displacement map from one object to another, but again that doesn't seem exactly like what you want.

One problem I can see with your approach (or maybe I just mis-understand what you mean) is the assumption that the UV-map "islands" (clusters of faces in the UV unwrapping) each correspond to a view of the object from a particular angle. It is possible, of course, since you can orient the object to a view and project faces when UV-unwrapping, but this isn't really the best way to UV-unwrap an object, since faces that are oblique to the view when projected get very little texture space in the final map regardless of their size, in the worse case even turning "degenerate" (ie, projecting to a line in the UV map, rather than a triangle/quad), which results in severe stretching or distortion when rendered. The best ways to UV-unwrap an object are to unwrap it so that faces get space in the texture map proportionate to their actual size; in this case, then, the projected islands will not correspond to any particular view orientation.

One way of doing what you want might be to write a script that projects a series of rays. The rays are projected as eye or camera rays, using the desired projection/perspective settings. When an intersection is calculated, the UV coordinates of a face are interpolated to find the texture coordinates, then the calculated depth value of the ray intersection is written into the texture map. While this wouldn't really be too difficult to implement as a script, I do not know of any "standard" means by which it can be done without scripting.

But if you are using mapped boxes for LOD primitives, do you really need the baked heightmap to correspond to the UV map?

Share this post


Link to post
Share on other sites
I'm waiting for the programmer to get back to me on your question, but I know that the normal map and the heightmap need to match up exactly.

Couldn't I cut the asteroid in half, and use only half the UV map, to do a normal height map technique on it? and then just do the other side separately?

I don't know anything about scripting in 3ds, so Id have a really hard time trying to do that.
But do you think that raycasting technique could create the heightmap and the uv map at the same time? It might work that way.

Share this post


Link to post
Share on other sites
Maybe I just don't understand exactly how your LOD scheme really works. Maybe a more detailed explanation? I know from your previous posts that it involves a heightmap and a normal map and a 3D box. Are the maps actually applied to the box, or are you guys instead using a sort of beefed up billboard system, where the maps are used to add the illusion of depth to the billboard plane? If this is the case, I wouldn't think your height/normal maps for the billboard would need to correlate to the UV mapping of the object, but again I can't really picture what you are doing.

You wouldn't use a raycast to build the UV map, the best solution for that is just grunt work with a 3D editor. The raycast would just populate a texture image with data. The UV mapping would need to be done already. I just sort of tossed that idea out there, but I have no idea if its even relevant.

Share this post


Link to post
Share on other sites
For space games often "depth sprites" are used. In fact these are simple billboards + a depth map + normal map . Using a deferred render you could use this depth sprite for much better light interaction.

In this case you can simply render the object to the camera and use 3 render passes: standard texture only pass, a depth map pass(maybe you need to use nodes as JTippetts mentioned it) and a normal map pass (object space?).

To get the billboard texture right use a RGBA target format and turn off the sky to get a proper alpha value for your rendered models.

Share this post


Link to post
Share on other sites
Hey, here's a quote of how the lod system is working.

"we take a view of the asteroid from one side, with each pixel recording its distance to the camera
and then a view from the other side, this gives us two heightmaps, The engine draws a cube, and uses a shader to raycast into the cube, and figure out if the ray from the camera through the cube is intersecting one of the heightmaps and where it's doing so from there. We then take a view from both sides again that record the texture coordinates as RG colors so we can index in and get the object's stuff from it's normal map (object-space, not tangent space), as well as its texture color"

The advantage to this method is that the lod asteroids can rotate and move freely in the distance, and it's only rendering 8 vertex's from the cube, and then the amount of pixels visible from the lod asteriod, which is around 30 or so each. depending on it's distance.

Share this post


Link to post
Share on other sites
[attachment=2416:depthnormal.png]


Is this roughly like what you need? On the left is a normal map baked to a plane, in the center is the asteroid, on the right is a depth map baked to a plane. Of course, the depth map would need some post-processing to invert the depth and move the outside regions to black, but that is easy to do in the Gimp or Photoshop.

To make this image, I sculpted a quick asteroid then used Blender's Bake menu to bake an object-space normal map to one plane, and a displacement map to another. You can also bake texture (color) information to a third image, ambient occlusion map to a fourth, and so on.

Share this post


Link to post
Share on other sites
Yes, that depth map is exactly right, just needs to be inverted! how did you do that? And is it possible to get the depth map of the back side of the asteroid with the same size and orientation?
Is blender easier for this stuff then 3ds?

Lastly, I guess it isn't important if the normal map lines up, the height map can be 2 separate images, one of the front, and one of the back, while the normal map uses the UV map, if that makes things easier.

Share this post


Link to post
Share on other sites
[quote name='Wrongfire' timestamp='1306174926' post='4814689']
Yes, that depth map is exactly right, just needs to be inverted! how did you do that? And is it possible to get the depth map of the back side of the asteroid with the same size and orientation?
Is blender easier for this stuff then 3ds?

Lastly, I guess it isn't important if the normal map lines up, the height map can be 2 separate images, one of the front, and one of the back, while the normal map uses the UV map, if that makes things easier.
[/quote]

I honestly don't know if Blender is easier than 3DS for this, as I have never so much as started up 3DS. But in Blender, it really is very easy to do this, and you can bake a displacement map onto a texture from any angle. To make the above, I modeled an asteroid then created a new plane and associated a UV texture image with it. I moved the plane to sit close to the asteroid, aligned with the side of the asteroid I wanted to bake. Then, I selected the asteroid first, shift-selected the plane, and under the Render->Bake buttons I selected Displacement and bake from selected object to current object. I did have to play with the distance and bias sliders a bit.

Baking is a common process for extracting details of a higher-resolution object (the asteroid) onto a texture that is applied to a lower resolution object (the plane), and 3DS will most definitely support it, I'm sure. Try googling for displacement map baking in 3DS and see what pops up.

Share this post


Link to post
Share on other sites
It sounds alot like [url="http://www.inf.ufrgs.br/%7Eoliveira/pubs_files/Policarpo_Oliveira_Comba_RTRM_I3D_2005.pdf"]Real-Time Relief Mapping on Arbitrary Polygonal Surfaces[/url] where you can use two depth map, one for the front and one for the back , to produce some nice relief mapping (thought I doubt that the performance-visual effect ratio for lots of astroids which are far away is justified ;) ).

In this case use JTippetts approach, but use two cameras, one mirrored. You just need to switch the active camera and render the image again. If the "back" depth map needed to be inverted, you could either use nodes in blender or use the invert color function in gimp/photoshop.

Share this post


Link to post
Share on other sites
I cant figure out how to do it in 3ds max. It just says all the rays miss when I try to bake it.
I just got blender, could you go through step by step on how you got your displacement map? I have no clue how to use this program.

Share this post


Link to post
Share on other sites
[quote name='Wrongfire' timestamp='1306217757' post='4814916']
I cant figure out how to do it in 3ds max. It just says all the rays miss when I try to bake it.
I just got blender, could you go through step by step on how you got your displacement map? I have no clue how to use this program.
[/quote]

The quick way:

Model your asteroid, set the render sizes to output a texture of the desired size (use the Camera button whose tooltip says Render in the horizontal bank of buttons on the right hand side of the default view, assuming Blender 2.57). Position the camera relative to the object to get the correct view of the asteroid. Select the asteroid and press Numpad-0 to get a camera-view; scale the object appropriately so that it fills the view. If desired, you can switch to an Orthographic perspective; for this, select the camera and go to the Object Data submenu on the right (the icon to get there, with the camera selected, will be a side-view of an old-fashioned projector-style camera). Under the camera Object Data, you can switch to ortho projection and adjust camera settings. Obtain a view of the asteroid that fills as much of the camera viewport as you can.

In the lower-left corner of the default 3D view is a button to switch views. Select it and go to Node Editor view. Along the bottom of this view are 3 picture icons; a black and yellow circle (material nodes), a red/white checker icon (texture nodes) and an icon that looks like two images stacked on top of each other (compositing nodes). Select the compositing nodes, then check the box that says Use Nodes. When checked, two default nodes will appear; the larger will be labeled Render Layer, and there will be some lines connecting them. Disconnect the lines by dragging the endpoints of the lines away from the smaller box so that the nodes are completely disconnected.

Next, at the bottom of the view you see a menu bar that has submenus for View, Select, Add and Node. Click Add, go to the Vector submenu, and under Vector choose Normalize. (Not Normal; Normalize should be the last entry). Select Add again, go to Color submenu, and select Invert. Now, from the Render Layer node, click and hold on the Z output, and drag a line to connect with the Value input of the Normalize Node. (inputs are on the left sides of nodes, outputs are on the right.) Connect the Z to the Normalize node, connect the output of the Normalize node to the Color input of Invert, and connect the Color output of Invert to the Image input of the smaller Composite node. When done, the nodes should look something like this:

[attachment=2447:BlenderScreenNodes.png]


Now, if you click the little camera icon on the Render Layer node, it will render the view from the camera, capture the depth (Z) map of the render, feed that Z map through a normalize and invert process, and spit out the final result as the render. From the render preview window, you can select Image->Save As Image to save out the displacement map.

This is slightly different than the baking method I discussed earlier, and will probably be a little bit easier, at least to do the displacement maps.

Share this post


Link to post
Share on other sites
Awesome! Thanks so much, just one more thing, I added a 2nd camera, but when I press 0 it goes to the old one, How do I toggle which camera the render will use? Also is there a way to orbit the camera around the center point of the asteroid?
Need to get the 2nd image to view the exact opposite side of the asteroid, or at least as close as possible to it.

Share this post


Link to post
Share on other sites
[quote name='Wrongfire' timestamp='1306282347' post='4815371']
Awesome! Thanks so much, just one more thing, I added a 2nd camera, but when I press 0 it goes to the old one, How do I toggle which camera the render will use? Also is there a way to orbit the camera around the center point of the asteroid?
Need to get the 2nd image to view the exact opposite side of the asteroid, or at least as close as possible to it.
[/quote]

You can select the asteroid and press Shift+S, and select Cursor to Selected. This will move the 3D cursor to the center point of the selected object. Then, down at the bottom of the 3D view you will see a button that, in initial state, looks like two small white spheres intersecting at a blue rectangle. Click on it and you will get a submenu that allows you to set the pivot point. If you select 3D Cursor in this menu, then all rotations will be performed relative to the 3D Cursor which is now at the center of the asteroid.

You can use 1 camera for both views. Orient the camera, take a snapshot, then, with the camera selected, press 'r' followed by 'z', and type 180 then Enter. This is shorthand for Rotate, Around Z-Axis, 180 degrees. Conversely, you can press 'n' to get a Numeric control menu that allows you to set things like scale, translation, and axis rotations for the currently selected object via dialog rather than shorthand. At any rate, since the pivot point is set to the 3D Cursor, this will cause the camera to rotate around the Z axis 180 degrees to look at the other side of the asteroid. Take another snapshot from there for the other side.

On a side note, for some reason the Blender developers insist on releasing Blender builds with a default blend file that includes a camera in a wonky position. I usually use the 'n' menu to correct it, or just delete the default camera and create a new one.

Share this post


Link to post
Share on other sites
[img]http://i34.photobucket.com/albums/d135/Wrongfire/Asteriod1Heightmapfront.png[/img]
[img]http://i34.photobucket.com/albums/d135/Wrongfire/Asteriod1Heightmapback.png[/img]

Thanks a ton, I can't tell you how helpful this was! I have been looking around for about two months off and on to try and find out how to solve a problem that I never thought would be a problem.. lol
Our game can finally have LoD and that is extremely exciting!

I appreciate all the help!

Share this post


Link to post
Share on other sites

This topic is 2394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this