Game Development Community

dev|Pro Game Development Curriculum

Atlas Bumpmapping

by Ves · 10/08/2007 (10:23 am) · 50 comments

Download Code File

Okay here is a simplistic implementation of blended bumpmapping on atlas terrian. Some things you should know before begining:

1) this implementation completely overides the normal clipmap operation in atlas. Since that is one of the larger bonuses to using atlas terrian please take that into consideration when deciding when and how to use this.

2) this requires shader 2.0 and greater. And the pixel shader is HUGE!!! I am not exagerating. In fact to have the code blend specular power (varying specular power with textures) you need to use pixel shader 3.0.

3) This is not optimised. A lot of the atlas clipmapping setup operations still take place dispite the fact that we aren't useing the texture clipmapping.

4) This only supports one light, the sun. And that light is hardcoded.

5) There are some requirements for the atlas map you use this on. Technically you can use this on ANY atlas map blended or unique as long as you specify the following in the atlas block in your mission file:
new AtlasInstance2(NewTerrain) {
      position = "-151.417 7.48933 80";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      
      //begin new atlas bumpmap variables
      //blended textures 1-4
      blendtex1 = "~/data/textures/grassfuzzy.jpg";
      blendtex2 = "~/data/textures/scorched.png";
      blendtex3 = "~/data/textures/rockbumpd.png";
      blendtex4 = "~/data/textures/rockbumpd.png";
      //corresponding bumpmaps
      bumpTex1 = "~/data/textures/grassfuzzybump.dds";
      bumpTex2 = "~/data/textures/scorchedbump.dds";
      bumpTex3 = "~/data/textures/rockbumpn.dds";
      bumpTex4 = "~/data/textures/rockbumpn.dds";
      //corresponding specular colors and specular power
      // rgb relate to the spec color while a is a specular power multiplyer
      // the specular power is hardcoded to 128 but that is multiplied by the alpha
      //specified here
      specular1 = "0.15 0.3 0.05 0.25";
      specular2 = "0.3 0.22 0.05 0.5";
      specular3 = "0.55 0.55 0.6 0.5";
      specular4 = "0.5 0.5 0.5 0.5";
      //opacity file for the terrian r, g, b, and a specify the texture for a particular vertex
      opacityFile = "~/data/terrains/desertAlpha_Alpha1.png";
      //this is a lightmap file for the terrian
      lmFile = "~/data/terrains/desert_LM2.jpg";
      //atlas file.. this not a new variable
      atlasFile = "~/data/terrains/Desert_blend.atlas";
      //this isn't new either but set it to 0 as we are loading a lightmap file directly with lmFile
      //you can set it to the map size and have torque generate the lightmap, rename it and put it in the
      //lmfile variable later also
      lightmapDimension = "0";
   };

Thats about it. Unpack the zip in a stock TGEA_1_0_3 directory and you should be good to go. This uses the terrain_water_demo mod so you will have to change your main.cs (from demo to terrain_water_demo).

Here are some examples of what it will look like:

This is using 1024x1024 textures and bumpmaps, but I think the results here speak volumes about what TGEA is capable of...
i5.photobucket.com/albums/y153/vesuvias/blended1.jpg
This is a good specular shot, the specular point moves with the camera view. Notice the difference between the specular on the road and the specular on the sand. That is a result of the specularX values defined in the mission file (see above). The road has (1, 1, 1, 1) while I think the sand has (0.3, 0.3, 0.3, 0.5). Different terrain will reflect light differently, I thought this feature added greatly to the realism.
i5.photobucket.com/albums/y153/vesuvias/blended_highspec.jpg
This is another good shot of the specular point being cast over the terrian.
i5.photobucket.com/albums/y153/vesuvias/blended_speccast.jpg
This a good shot to illustrate the effect of having the specular color vary across the terrian type. notice the road has a redish specular while the sand is more yellow. The Specular color you define in the mission file is multiplied by the sun's diffuse color as well so it's a blend all the way around.
i5.photobucket.com/albums/y153/vesuvias/blended_multicolorspec.jpg
I hope someone finds this of some use. If even for educational purposes only. Feel free to ask questions, i will try and post when I can. If it doesn't work, I may have left out a file (I am pretty sure I got everything though). I will correct it if that's the case.

enjoy....

Note: This resource is a bit of moving target. I intend to change quite a bit with regards to how this is done. I really want a seperate atlas type for this behavior so that TGEA can still support classic blended atlas, unquie atlas terrains and blended bumpmapped atlas terrians all at the same time. This will take a bit longer to implement but it is necessary if this is ever to be included in stock torque (it will take changes not only to the realtime portion of the atlas code but to the atlas file generation code as well). Expect the zip to go through multiple iterations before we are done. Ok, discliamer over, have fun...

Ves
Page «Previous 1 2 3 Last »
#1
09/18/2007 (5:09 am)
Edit: Fixed
#2
09/18/2007 (5:30 am)
Looks like GG won't let me upload a 4 meg file :). So I striped all of the images, bumpmaps and the atlas file from the code. This means that you will have to use your own resources is you want to play with this for now (the code modifications are there however, you will just need to modify the mission file appropriately). I am going to see about hosting the images on photobucket (and placeing links here). The atlas file is a bit bigger though. I wanted to give out the exact atlas file you see in the screen shots but that will have to wait till i figure how to get it hosted.

Ves
#3
09/18/2007 (5:33 am)
This is totally stunning and making me drool...
/cleaning up a bit.

Its really impressive work, and a fresh polished and clean 5 from me.
#4
09/18/2007 (5:33 am)
Ves, we will gladly host the file for you, on the dream games server!

BTW, for education purposes, you've solved one of the biggest hurdles there is not an elegant solution for: awesome looking roads without shapes!
#5
09/18/2007 (8:31 am)
It's amazing! Just wondering if it were compatible with the previous version of TGEA?
#6
09/18/2007 (8:41 am)
Now hosted on:
ftp://dreamgamesinc.com
u:torque
p:resource

Thanks Ves!!
#7
09/18/2007 (9:01 am)
Thanks Dave.

I appoligize for not including the textures you see in the screens. I don't have permission to distribute those. But I believe I got a lot of them from a DVD I bought from subdimension. You can probably google it if your interested. The atlas file, lightmaps and opacity maps I created with L3DT (they are included). The bumpmaps were created with photoshop and the nvidia normal map plugin. This is using parralex functionality in the shader so remember to set the option to include height in the alpha.

As for pervious versions of the torque, I am not sure. It "should" work (you may have to play with the code a bit) but at some point they added a normal variable to the vertex data. If you pick a version before that then I doubt it will work since the vertex data will be different from what the shader is expecting.

Ves
#8
09/18/2007 (9:59 am)
Looks interesting. We'll be checking into this for Arcanoria. Thanks.
#9
09/23/2007 (4:26 am)
Amazing work :)

This should be incorporated into the next release of TGEA!

Is there any way to add support for more than 4 textures and lights?

*Edit*
I cant seem to get this to work :S

I downloaded the 4mb file from the mirror and unzipped it into the TGEA folder.

All my DirectX files are up to date (aug07)

All i see is black terrain, any ideas?
#10
09/27/2007 (2:17 am)
Black terrain is normally caused when the blended file can't find its associated tile textures (for some bizarre reason the paths are hardwired into the atlas :) - so you need to compile your terrian in the correct folder structure for your demo/game.
#11
09/27/2007 (7:01 am)
Hmm, I tested it. It should work right out the box on stock 1.03. I will try this agian on a completely fresh install tonight and see if I get the same issue. It does sound like its having an issue finding the textures. But the console should report something to that effect if thats the case (since they are loaded from the mission file). No need to recompile the atlas file, I am circumventing all of the atlas texture structures for the time being, so as long as the geomtry is present you should be ok. I did reset all of the shaders to 2.0 but I never forced my version back to shader 2.0 so it maybe a problem with it requiring 3.0 to work correctly (I doubt it as an issue there would likely mean the shaders wouldn't compile at all).

Hope this helps please tell me if you figure this out or are still having issues... I will try a fresh install tonight.

Ves
#12
09/30/2007 (4:59 am)
Thanks for the reply :)

I am currently away from my workstaion, but I will try it again with a fresh install as asap :)
#13
10/03/2007 (8:55 am)
This is totally amazing work. Thank you.
#14
10/03/2007 (11:57 am)
Where are the hlsl file for this??? They don't appear in the zip file...never mind, found 'em in the .h file...
#15
10/07/2007 (11:24 am)
landscap is black?
#16
10/07/2007 (11:51 am)
Has anyone got this working?
#17
10/07/2007 (12:03 pm)
I still get black terrain :(

@Ves
Could you post a more detailed walk-through for this please?, It seems us mere mortals cannot get it right ;)
#18
10/07/2007 (12:20 pm)
lol
#19
10/07/2007 (12:27 pm)
Ok i tried again with a fresh install, this is what i did.

1. opened C:\Torque\TGEA_1_0_3
2. opened the atlasbumpmapped.zip file
3. extracted the contents of the zip file to C:\Torque\TGEA_1_0_3
4. when asked if i wanted to overwrite any files/folders with the same name i clicked yes.
5. changed the main.cs file located in C:\Torque\TGEA_1_0_3\example from
$defaultGame = "demo";
//$defaultGame = "terrain_water_demo";
$displayHelp = false;

to

//$defaultGame = "demo";
$defaultGame = "terrain_water_demo";
$displayHelp = false;

6. Ran the TGEA.exe

But im still getting black terrain. Any ideas?
#20
10/07/2007 (10:11 pm)
Hmmm.. sorry about that, I probably should have included the compiled TGEA.exe. I kinda of assumed everyone would want to compile it themselves since this is source code type distribution.

After you unzip the files, you will need to recompile the default project. If you don't then you will get black (sometimes blinky) terrain. I am verifying the compile on a fresh install right now but I don't think there should be a problem.

Ves

Edit: yup just verified that it should compile clean out of the box.
Page «Previous 1 2 3 Last »