Shader for metal with reflection?

If you're looking for mapping help or you reckon you're a mapping guru, post your questions / solutions here

Moderator: Moderators

Post Reply
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Shader for metal with reflection?

Post by wacko »

Hi!

with a shader like

Code: Select all

textures/glass/glass
{
	qer_editorimage textures/glass/glass_rad.tga
	qer_keyword window
	qer_keyword glass
	qer_trans .5
	surfaceparm glass
	{
		map textures/mohcommon/envnormndy_day.tga
		tcgen environment
		alphagen const .2
		blendFunc blend
	}
	{
		map textures/glass/glass.tga
		depthWrite
		alphaFunc GE128
		alphagen const .2		
	nextbundle
		map $lightmap
	}
}
i get a plain glass texture with the well know environment reflection.
So far so good!
But now, I want to have a metal texture (or atleast something NOT transparent) with that reflection and can't get it working.

Any ideas?
panTera
Brigadier General
Posts: 573
Joined: Wed Jan 29, 2003 11:46 pm
Location: The Netherlands
Contact:

Post by panTera »

Hi Wacko, just take a look at this door texture, this is the effect you want => general_structure/interior_door1

[this is the shader]:
textures/general_structure/interior_door1
{
qer_keyword wood
qer_keyword door
surfaceparm wood
{
map textures/special/copperenv1.tga
tcGen environment

}
{
map textures/general_structure/interior_door1.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA

}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
rgbGen identity
}
}

The white parts of the alpha won't be affected, and black parts won't show. So you have to make an alpha channel with white and gray parts (the parts you want to make shiney) or a whole gray layer. I'd suggest at least 25% opacity, or even better make a gray layer and use a little "add noise" effect. But just take a look at that door texture and its alpha and you'll know what to do.
8-)
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

hey, PanTera

Thanks!! :D I was checking the forum every 5 minutes for a solution...

will give it a try immediately!
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

WAHOOOO

it works!! you might say: "of course, why not?!" but this is probably the most beautiful and important texture ever (well, for me...)

thank you very much again! :D
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

mud

Post by tltrude »

The mud puddle texture works great as a reflection layer.
Tom Trude,

Image
panTera
Brigadier General
Posts: 573
Joined: Wed Jan 29, 2003 11:46 pm
Location: The Netherlands
Contact:

Post by panTera »

Alrrright! You're welcome.
Oh yes, that's right tltrude, forgot to mention that. You can of course use any texture as the reflection layer.
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

I'm not having any luck getting this trick to work. I've looked at the .tga files for those door textures. There isn't really an Alpha channel on them. The metal parts of the door are just more transparent than the rest in the color channel. If I understand it correctly, that shader will overlay the envmap on top of the alpha parts.

I want a reflective titanium wall so I need the environment map all over. I've tried using a grey alpha channel with no effect. I also tried cutting out sections in the color channel just like in the door texture. That doesn't work either. So I'm really not sure what I am doing wrong.

This is what I have for my shader:


textures/bktown/w_steel.tga
{
qer_keyword pipe
qer_keyword special
qer_keyword metal
qer_keyword rusted
surfaceParm metal

{
map textures/special/silverenv.tga
tcGen environment
}
{
map textures/bktown/w_steel.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
}

{
map $lightmap
rgbGen identity
blendFunc GL_DST_COLOR GL_ZERO
}
}
Diego
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Go to the mohaa trashbin and download the whole UFO to study its textures. Maybe u just didn't save the tga as 32-bit? What image editor are u working with?
As far as I remember u will have to make the complete layer with the texture almost totally transparent and that's the shader:

Code: Select all

textures/ufo/glanz2 
{ 
	qer_editorimage textures/ufo/glanz2.tga
	surfaceparm metal 
	{ 
		map textures/mohcommon/envnormndy_day.tga 
		tcGen environment 
	} 
	{ 
		map textures/ufo/glanz2.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
	} 
	{ 
		map $lightmap 
		blendFunc GL_DST_COLOR GL_ZERO 
		rgbGen identity 
	} 
} 
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

I'm using photoshop 7. The .tga was 32 bit, but maybe I didn't make the alpha transparent enough. I don't really see any significant difference between your shader and mine. But I'll go check out the trashbin when I get off work.
Diego
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

I downloaded your ufo map. I've copied your shader exactly. And I've double checked my .tga file. Your images did not have a separate Alpha Channel either. It was built into the color information. My texture works the same way. My Opacity is at 30%. Is that still too high? Because I'm not seeing anything yet.

I also tried applying this to a texture that I need to have a completely transparent border. The area of the .tga file that is 100% transparent, simply shows up as white in MOH.
Diego
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

with the ufo-lager.pk3, u got textures/ufo/glanz2, glanz3, glanz_double.
A grey, a green and one with cull=none for patchmeshes.
Do they work? Just for testing, did u put in ur map e.g. 3 brushes each with one of those textures?
if u did and they worked, then ur shader or texture must be somehow different (obviously). if they didn't work either, the problem is something else... :roll:

unfortunately, i'm off over xmas and won't be back before 25th, but if u still can't get it working by then, send me ur tga and i'll make it work!

in ps7, ur image should have no background-layer, 30% opacitiy is fine. when u save this as a 32bit Targa, it ought to work...
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

Sorry, I didn't think to actually try your textures in my map. I was just checking out the shader and the images in Photoshop to see if I was making them correctly. I'm off for xmas as well until Jan 1. I'll try your textures when I get back. Thanks for the help.
Diego
User avatar
diego
Captain
Posts: 245
Joined: Sun Dec 21, 2003 10:47 pm

Post by diego »

Finally got this fixed. My texture was fine. I had extra qer editor image lines in my shader. I assumed that these were to help you query radient to display all textures that were wall, or metal, or whatever. I guess I was wrong. In any case, I made my shader identical to yours and the reflection map is working and so is the metal sparks and bullet holes that I wanted. Thanks for the help.
Diego
Post Reply