Creating Reflective Textures

Tutorial collection, comprehensive listings on main site.

Creating Reflective Textures

Postby Tutorial on Thu May 19, 2005 6:42 pm

category
Texture Creation

description
How to get your texture to shine with the cubemaps applied to it.

keywords
reflect, reflective, texture, textures, cubemap, cubemaps.

This tutorial assumes that you have a basic understanding of how env_cubemaps work (there are 2 tutorials about them already), and that you've already made your own custom texture and got it showing up properly in your maps, but you want to make it shiny, using env_cubemaps.

I've got my texture up and running, called "Greymetal1wornedges", but it's not giving me the kind of shine that metal should have, no matter how many env_cubemap entities I put next to it.

Getting your textures shiny is easy- just use your favourite text editor to go into your vmt file (which, as you probably know, is in your Steam\steamapps\yournamecounter-strike source\cstrike\materials folder, if you're working on Counter Strike) and add this line in the vmt file:
"$envmap" "env_cubemap"

An example of what a basic vmt file will look like;

Code: Select all
"lightmappedgeneric"
{
   "$baseTexture" "Greymetal1wornedges"
   "$surfaceprop" "metal"
   "$envmap" "env_cubemap"
}


This will work in the game- however, it's way too shiny to look realistic (except maybe for adding details.) It needs to be toned down to be of any real use.

I think the best way to do this is to add a mask. This is basically a greyscale image, where the black will block the reflection completely, and the white will be the full reflection that we got before. Once you've made your greyscale image tga and compiled it, add the following line to your vmt; "$envmapmask" "SRNgreyscale1" (where my greyscale is called "SRNgreyscale1", obviously.)

So my finished vmt file now looks like this;

Code: Select all
"lightmappedgeneric"
{
   "$baseTexture" "Greymetal1wornedges"
   "$surfaceprop" "metal"
   "$envmap" "env_cubemap"
   "$envmapmask" "SRNgreyscale1"
}


Put the texture where you want it in your map, stick an env_cubemap next to it, compile and run. You should get a nice reflection as you move around it. (Unless you are running an advanced compiler, you may need to run "buildcubemaps" in the console to get the reflections to show up properly.)


somerandomnerd
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby CoolHandLuke on Sun May 22, 2005 4:15 pm

Ithink to add image would help. like to hae a image of before and after but more important the image of the greyscale mask. That would give a better idea of how to work the mask. I understand the principal of the mask but have no clue of what it should look like.

Other then this it's a good tutorial. Thank for sharing the info.
CoolHandLuke
Dumpling
Dumpling
 
Joined: Sat Apr 02, 2005 9:15 am

Postby somerandomnerd on Sun May 22, 2005 5:02 pm

No problem; here's a very basic demonstration.

Here's my greyscale mask:

Image

And here's it in action- both sides of the room have the same plain grey base texture, but one has the cubemap mask and the other doesn't;

Image
Image
somerandomnerd
Been Here A While
Been Here A While
 
Joined: Thu Mar 17, 2005 7:16 pm

Postby Evil_Squirrel on Wed Jun 01, 2005 11:13 pm

is there any way to get an almost perfectly reflective texture? like a mirrior?
Evil_Squirrel
Dumpling
Dumpling
 
Joined: Wed Jun 01, 2005 11:11 pm

Postby Blink on Wed Jun 01, 2005 11:22 pm

Only by upping the cubemap res, but that's barely a mirror
User avatar
Blink
Cool 'n that
Cool 'n that
 
Joined: Fri Oct 08, 2004 4:16 pm
Location: UK

Postby somerandomnerd on Mon Jul 04, 2005 8:06 pm

You're not creating "real" reflections with cubemaps- you're creating a fake reflection effect. A real reflection (ie. one that reflects characters etc.) must be possible, as water has real reflections. However, creating them is very intensive, as the scene pretty much has to be rendered again for the reflection.
somerandomnerd
Been Here A While
Been Here A While
 
Joined: Thu Mar 17, 2005 7:16 pm

Postby Rick_D on Tue Aug 09, 2005 11:03 am

Funnily enough we were discussing this last night and it came up that the cameras in HL2 take images and place them onto brushes, like the TV screens in the labs.

Surely you could create a large brush as a 'mirror' and have a camera entity looking out from the 'mirror' and projecting onto the brush that is acting as a tv screen?
Rick_D
May Contain Skills
May Contain Skills
 
Joined: Wed Jul 13, 2005 1:41 pm
Location: stockholm

Postby ColinDoody on Fri Aug 12, 2005 12:20 pm

The obvious problem with that the camera will always be pointing the same direction. A mirror reflects the normal vector of what you see, and a camera pointing straight out would not do this unless you could program it to rotate according to where you are looking.

Here look . I made you a pretty picture.

Image

Ah ... that obviously really accurate and talented and beautiful image :roll:

The only way I can think of making a mirror would be to actually have another instance of the room on the other side of the mirror. For example, you have a bathroom ... a 'mirrored' copy of the bathroom would exist on the other side of the mirror , and your 'mirror' texture would actually be just glass.

Thats a very inefficient way of doing it however , and valve probably didnt include mirrors because it requires processing double the polys sooo ... yeah there you have it .
Vicious Specs: eVGA geForce 6800GT 2.8ghz p4, 1gb ddr, 22" NEC, Audigy 2 Plat, 860GB
Image
User avatar
ColinDoody
Regular
Regular
 
Joined: Wed Jul 27, 2005 11:10 am
Location: Tokyo, Japan

Postby Rick_D on Fri Aug 12, 2005 2:05 pm

I see your point (drawings served their purpose ;) )

The mirrored room effect was used back in the day, and while it serves it's purpose it doesn't reflect the player - which is the point of using a camera.


I guess there just isn't a foolproof way of doing this.
Rick_D
May Contain Skills
May Contain Skills
 
Joined: Wed Jul 13, 2005 1:41 pm
Location: stockholm

Postby Jest@ on Sat Aug 20, 2005 6:12 pm

no player model except hands is ever rendered on the client machine = no mirrors, whether reflective or camera.

The mirrors thing has been discussed on every forum a thousand times. It's just not gonna happen without a lot of coding, maybe some extra modelling and certainly a huge resource hit.
Highlight to read:
It was earth all along
User avatar
Jest@
Veteran
Veteran
 
Joined: Mon Nov 22, 2004 1:50 am
Location: London UK

Postby somerandomnerd on Sun Aug 21, 2005 4:24 pm

Maybe I should have just called it "creating shiny textures" :wink:
somerandomnerd
Been Here A While
Been Here A While
 
Joined: Thu Mar 17, 2005 7:16 pm

Postby KILLA-COW on Wed Sep 14, 2005 5:16 pm

Mine go pink and black mask over texture :S
KILLA-COW
Veteran
Veteran
 
Joined: Sun Jun 12, 2005 1:37 pm
Location: The Island of britania!

Postby jimmer on Sun Sep 18, 2005 2:19 pm

is it possible to add this reflective property to a decal, to create shiny wet blood etc?
"how was i supposed to know he was an alabaster retard?"
jimmer
Just Joined
Just Joined
 
Joined: Sun Sep 18, 2005 2:15 pm
Location: Uk

Postby jister on Thu Oct 27, 2005 3:53 pm

what's the max resolution of cubemaps then, i did hear 512x512 but hammer only show 256x256...?and that's just a little to crappy to act as mirrors...
User avatar
jister
May Contain Skills
May Contain Skills
 
Joined: Wed May 11, 2005 7:35 pm

Postby soundwave on Mon Nov 07, 2005 6:39 am

back at the days that I made maps for Duke3D,
in order to make a mirror we had to create another room, the same size as the original room, and place it next to the orginal room, with the mirror as the "window" between them.

I saw on the net somewhere a tutorial for making a mirror in Source.
I can't find it now, but it had something to do with downloading a texture file... maybe that solves all the angle problems...
soundwave
Member
Member
 
Joined: Mon Oct 24, 2005 12:44 am
Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users