Cube maps: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 3: Line 3:
==Create your room==
==Create your room==
Create the room you want to have your pseudo-reflective water in. Add all the large parts, but you can leave small details (and of course the AI) out. Your room might for example look like this:
Create the room you want to have your pseudo-reflective water in. Add all the large parts, but you can leave small details (and of course the AI) out. Your room might for example look like this:


[http://img207.imageshack.us/img207/9677/shot00127wq7.jpg http://img207.imageshack.us/img207/9677/shot00127wq7.th.jpg]
[http://img207.imageshack.us/img207/9677/shot00127wq7.jpg http://img207.imageshack.us/img207/9677/shot00127wq7.th.jpg]
Line 24: Line 23:
  Wrote env/water_pool_nz.tga,etc
  Wrote env/water_pool_nz.tga,etc


(You might want to make a few more envshots at slightly different positions, so that you don't have to repaet the whole procedure if your images are not appropriate.)
You might want to make a few more envshots at slightly different positions, so that you don't have to repaet the whole procedure if your images are not appropriate. The direction at which you are facing during the shots is not important.


* You should now find six new images in your /env folder:
* You should now find six new images in your /env folder:
Line 38: Line 37:


[http://img152.imageshack.us/img152/7623/envshotli0.jpg http://img152.imageshack.us/img152/7623/envshotli0.th.jpg]
[http://img152.imageshack.us/img152/7623/envshotli0.jpg http://img152.imageshack.us/img152/7623/envshotli0.th.jpg]
You can of course also move them to a different folder if you want.


==Edit your images==
==Edit your images==
If you leave the images like this, they will not work ingame. You have to rename them to _up, _down, etc and there is also some rotating / flipping required.
If you leave the images like this, they will not work ingame. You have to rename them to _up, _down, etc and there is also some rotating and flipping required.


* Rename water_pool_pz to water_pool_up. Flip it horizontally and rotate it 90° counter clock wise.
* Rename water_pool_pz to water_pool_up. Flip it horizontally and rotate it 90° counter clock wise.
Line 61: Line 62:


[http://img157.imageshack.us/img157/7884/envshot2iz1.jpg http://img157.imageshack.us/img157/7884/envshot2iz1.th.jpg]
[http://img157.imageshack.us/img157/7884/envshot2iz1.jpg http://img157.imageshack.us/img157/7884/envshot2iz1.th.jpg]
You can also add some blurryness if you want.


==Write a material shader==
==Write a material shader==
Line 85: Line 88:


If you have forceOpaque in your shader, the texture will be opaque and you will not be able to see the ground. If you leave it out, it will be semi-transparent and you can see the ground also.
If you have forceOpaque in your shader, the texture will be opaque and you will not be able to see the ground. If you leave it out, it will be semi-transparent and you can see the ground also.
If you moved the images to a different folder, make sure that the correct paths are entered at the qer_editorimage and the cameraCubemap lines. (The path entered in the name of the shader (before the { ) is for the folder the texture will appear in Darkradiant. It can be different from the path the images are in.)


==Get your enviromental map ingame==
==Get your enviromental map ingame==
Line 97: Line 101:
[http://img267.imageshack.us/img267/7850/envshot4hw9.jpg http://img267.imageshack.us/img267/7850/envshot4hw9.th.jpg]
[http://img267.imageshack.us/img267/7850/envshot4hw9.jpg http://img267.imageshack.us/img267/7850/envshot4hw9.th.jpg]
* Convert the brush to a func_liquid. (You don't want to be able to walk on water, do you? That would happen if you didn't convert your brush)
* Convert the brush to a func_liquid. (You don't want to be able to walk on water, do you? That would happen if you didn't convert your brush)
* you should now be able to see your water ingame.
[http://img403.imageshack.us/img403/7541/shot00128rm6.jpg http://img403.imageshack.us/img403/7541/shot00128rm6.th.jpg]
It will still look flat, like a mirror, so you might want to add a patch slightly above the water textured with water_clear for example(or any other water texture that produces water waves).
[http://img184.imageshack.us/img184/1882/shot00137au6.jpg http://img184.imageshack.us/img184/1882/shot00137au6.th.jpg]
Here you can see the same pool textured with a true reflective water for comparison:
[http://img442.imageshack.us/img442/7907/shot00120lt3.jpg http://img442.imageshack.us/img442/7907/shot00120lt3.th.jpg]
==Notes==
You have to take into consideration that in contrast to a true reflection, the cube map texture will not react to changes in the environment. So if you for example put the torch out, it will still be lit in the cube map.
[http://img252.imageshack.us/img252/3339/shot00139km2.jpg http://img252.imageshack.us/img252/3339/shot00139km2.th.jpg]
So it would be more practical to have non-extinguishable lights and no large moveables near the water.
[[Category:Editing]]
[[Category:Tutorial]]

Revision as of 16:50, 20 April 2007

How to create a cube map (also called environmental map) of your environment using the envshot command in Doom3

Create your room

Create the room you want to have your pseudo-reflective water in. Add all the large parts, but you can leave small details (and of course the AI) out. Your room might for example look like this:

shot00127wq7.th.jpg

Create your images

  • Set the screen resolution of Doom3 to 640 x 480. If you don't do that, part of your images might be cut of and they will not fit together any more. You might have to close and reopen Doom3 for the changes to take place.
  • Make sure you are on full screen before you take your images. (If you don't, you can see windows task bar and it doesn't look that good ingame.) If you are in windowed mode, you can change to full screen by pressing Alt + Enter.
  • Open your map in Doom3 and get to the position of your water. In the console, type
envshot [prefix] [size]

[prefix] is how the images are going to be named. The size should be in powers of two. For example, your command could look like this:

envshot water_pool 512

Press enter, and you will see some flickering on the sreen while your images are created, and a message in the console will appear saying

Wrote env/water_pool_nz.tga,etc

You might want to make a few more envshots at slightly different positions, so that you don't have to repaet the whole procedure if your images are not appropriate. The direction at which you are facing during the shots is not important.

  • You should now find six new images in your /env folder:
water_pool_nx.tga
water_pool_ny.tga
water_pool_nz.tga
water_pool_px.tga
water_pool_py.tga
water_pool_pz.tga

looking like this:

envshotli0.th.jpg

You can of course also move them to a different folder if you want.

Edit your images

If you leave the images like this, they will not work ingame. You have to rename them to _up, _down, etc and there is also some rotating and flipping required.

  • Rename water_pool_pz to water_pool_up. Flip it horizontally and rotate it 90° counter clock wise.
  • Rename water_pool_py to water_pool_left. Rotate it 180° and flip it horizontally. This is going to be located at the north.
  • Rename water_pool_ny to water_pool_right. Flip it horizontally. This is going to be loacted at the south.
  • Rename water_pool_nx to water_pool_back. Rotate it 90° counter clock wise and flip it horizontally. This is going to be located at the west.
  • Rename water_pool_px to water_pool_forward. Rotate it 90° clock wise and flip it horizontally. This is going to be located at the east.
  • Rename water_pool_nz to water_pool_down. You don't have to manipulate the direction here, since it is located at the bottom and will not be visible anyway.

You should now have six files in your /env folder called

water_pool_back
water_pool_down
water_pool_forward
water_pool_left
water_pool_right
water_pool_up

looking like this:

envshot2iz1.th.jpg

You can also add some blurryness if you want.

Write a material shader

Open an already existing material file or create a new one. Add the following shader:

textures/env/water_pool
{
    qer_editorimage env/water_pool_up.tga

    noFragment
    noshadows
    noimpact
    nooverlays
    forceOpaque
    nonsolid
    
    {
  	forceHighQuality
	blend add
	cameraCubeMap env/water_pool
	texgen reflect
    }
}

If you have forceOpaque in your shader, the texture will be opaque and you will not be able to see the ground. If you leave it out, it will be semi-transparent and you can see the ground also. If you moved the images to a different folder, make sure that the correct paths are entered at the qer_editorimage and the cameraCubemap lines. (The path entered in the name of the shader (before the { ) is for the folder the texture will appear in Darkradiant. It can be different from the path the images are in.)

Get your enviromental map ingame

  • Open darkRadiant (if you already have it open you might have to close and reopen it to be able to see the texture).
  • Draw a brush that is going to be your water. Texture it with common/nodraw.
  • Go to the media browser. You should find your texture in the /env folder.

envshot3na3.th.jpg

  • Select it and apply it to the top face of the water brush. You should now see the water_pool_up image as editor image (that's what the qer_editorimage line in the shader was for). Scale and position of the texture is not important.

envshot4hw9.th.jpg

  • Convert the brush to a func_liquid. (You don't want to be able to walk on water, do you? That would happen if you didn't convert your brush)
  • you should now be able to see your water ingame.

shot00128rm6.th.jpg

It will still look flat, like a mirror, so you might want to add a patch slightly above the water textured with water_clear for example(or any other water texture that produces water waves).

shot00137au6.th.jpg

Here you can see the same pool textured with a true reflective water for comparison:

shot00120lt3.th.jpg


Notes

You have to take into consideration that in contrast to a true reflection, the cube map texture will not react to changes in the environment. So if you for example put the torch out, it will still be lit in the cube map. shot00139km2.th.jpg So it would be more practical to have non-extinguishable lights and no large moveables near the water.