Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Joachim Hofer, posted on February 08, 2001

Image Description, by Joachim Hofer

Not long ago I thought it would be cool to have materials that partially look metal and partially not.

I thought that the best way to do this is to use inhomogenous specular highlighting. This can simply be done by using two textures, one with the metal parts white and one with dark metal parts. And then I use the specular light to blend between the two textures. This is really fast on a board that supports multitexturing, and for the little effort it requires, I think it looks quite good. I haven´t seen this anywhere so far, so I just thought about posting it here. Maybe you can even use this technique for any game. A car with such a texture might look good, I think...

You may download this program at in the download section (Be sure to get DirectX 8 first...) It´s rather slow as it draws the stones two-pass as my graphics card doesn´t support multi-texturing, and so I can´t test one-pass. It also doesn´t support T&L and for sure contains many bugs. Enjoy it ;-)

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

February 08, 2001, 05:42 AM

Neat. Can someone think of another way that would not eat that much texture stages ?

Joseph Crevier

February 08, 2001, 05:52 AM

2 stages is a lot? You can do it with multiple passes. In general you should use the multitexturing as your first choice.

zed zeek

February 08, 2001, 06:04 AM

such a technique as u are using looks very fake ie 2d textures glued onto the surface of a 3d mesh, real metal doesnt look like this u maybe wanna look at using 3d textures. well anyways best of luck jochie.


February 08, 2001, 06:51 AM


I'm not one for going "Wow! Awesome!" but hell, that is a very impressive effect.

Like zed zeek says, it's probably not totally realistic but I still think that its cool.

I have seen it elsewhere though. It was used to create a Half Shiny/Half Rusty crate in a demo somewhere...



February 08, 2001, 07:01 AM

There is a 'wet concrete' shader in Quake 3 (well, there is in Q3F anyway) which has shiny puddles on a matt texture.

I dont have the shader with me to check, but knowing Q3 it will be using a second texture for the puddles, with the dry parts masked out in the alpha channel. Similar idea. I suspect Josephs is faster but harder to set up and a little less flexible :o)


February 08, 2001, 09:41 AM

If you really wanted to avoid that, you could blend the textures in software, but I don't think you'd be saving any time.


February 08, 2001, 11:11 AM


Isn't this technique called "gloss" mapping?


February 08, 2001, 12:13 PM

Sure, 2 stages is not much and multipass is also possible, but I wonder if this is possible in just one stage. I think it could be.

Hannu K.

February 08, 2001, 12:15 PM

The reason this doesn't look so realistic is that the screenshot isn't maybe the best one. But the technique is correct.

3d textures? Why? Object's surface is 2d you know


February 08, 2001, 01:44 PM

Well, It ran pretty damn good on my TNT2 (60fps), and I really like the way it looks realtime. Would it be possible for you to go into a bit more detail on your method? perhaps post a tutorial on it somewhere?

Good work!



February 08, 2001, 02:17 PM

Won't this technique be fairly slow, even with multi-texturing? I am assuming that by using the specular light to adjust blending, you, per triangle, figure out the specular lighting factor and set the alpha blend factor based on that? So you eliminate any type of batching. I was thinking you could do it in two pass like this:

- Have the "white" version of the texture actually have an alpha mask
where the white is
- Render the first texture (dark) with specular lighting on.
- Render the second texture (alpha) with specular lighting off.

This would make the gray react to the specular lighting, but the purple would be rendered with just diffuse. You could the send all triangles that use this at once.

Or I could just be clueless.


February 08, 2001, 02:39 PM

Glad someone else out there hasn't forgotten that Single TMU cards still exist out there En-Masse. I've yet to see a mainstream 3d video game box with "Minimum Requirements: Dual TMU 3d accelerator" stamped on the back :)
I know they're getting less and less common now, but I still don't think, for the minor effort of supporting MultiPass texture stages (especially with the new DX8 effect file format) that they are worth overlooking, and alienating a potential target audience. Then again, I am only really thinking of people who were sucked into buying a Voodoo Banshee here, although I know there are other chipsets out there in the same boat :)
My Rant done - Nice IOTD - Mmm glossy. Doesn't matter if someone else *has* done it before, Joachim; At least you had the initiative to think up something cool and follow through it's implementation off of your own volition. (CYNIC/) If everyone just copied what they'd seen elsewhere, we'd have a videogame market full of clone FPS and RTS games ;) (/CYNIC)


February 08, 2001, 02:49 PM

Its not supposed to be metal. Its supposed to be something inbetween, like a molded fiberglass. Pay attention.

Alexander Stockinger

February 08, 2001, 02:52 PM

Using Dx8 the Voodoo Banshee DOES support multitexturing (if you check the caps it returns that there are two texture stages).
In any other case the demo probably wouldn't run on your Voodoo Banshee (nor mine - no I outed my self...)



February 08, 2001, 02:53 PM

Well, the way I would look at it if I were making a game is that the people who dont upgrade their videocard for 2 years, are probably the people who are also not going to go out and spend 50 bux on my hot new game. There are ehough hardcores out there, upgrading their HW every 6 mos, that I could probably afford to leave you legacy folk out to dry. No offense, Im not saying you should upgrade your card every 6 mos, just that if you dont, youre probably not the target audience of a 50 dollar game. So screw ya=)

Warren Marshall

February 08, 2001, 03:00 PM

That attitude is the fast track to selling 50,000 copies as opposed to a million. :)


February 08, 2001, 03:04 PM

well said..!
And his mother is a transsexual satanworshipping crackwhore that smokes cigars and dances on wooden shoes, too.


February 08, 2001, 03:21 PM

Looks nice!

Joachim Hofer

February 08, 2001, 03:30 PM


first of all, thanks for the nice comments. I have some additional things to say:

First of all, I do not think that a Voodoo Banshee can do multitexturing. Even though my program works on such cards as it uses multi-pass singletexture.

To Mitch: No, it is not slow. I indeed use two DrawPrimitive() calls per Stone. It works the following way:
I have two textures, one with dark parts and one with bright (have a look at the two .dds files and you know what I mean). As I do all the lighting in software, I first lock the vertex buffer to calculate diffuse light, and render it once. Then I lock the VB again, calculate the specular light and store it in the alpha chanel of the diffuse (without changing the other parts of the diffuse). Then I call drawPrimitive() again, and thats it.

This could also be done singlepass with multitexturing, and even hardware T&L. You must only explain the pixel shader to use the specular light for texture blending between the two stages, or, even better, you write the vertex shader so that it calculates the specular color in the alpha of the diffuse. This way you only need a diffuse color for both, specular and diffuse lighting. And, if you don´t need the second texture stage for something different, it is as fast as drawing it without the effect.

To Waramp:
I would of course like to write a tutorial about it. But I don´t think that there is very much demand of this, as it is really not that difficult if you once understand the idea behind it. You might write me an email though, and I can explain you everything in detail, if you want.

To everyone else:
I had to know it already existed. I already thought of quite some things, finding out later that it already existed. Well, anyways thanks about everything. I also think it is better to use the alpha channel of the second texture to create this effect. But I simple didn´t mind this while writing the effect.



February 08, 2001, 09:53 PM

nVidia did something similar with one of the demo that come with the GeForce. I don't know if they use the same system or not.
The demo is their logo mapped with electronic circuits.


Lion V

February 09, 2001, 12:57 AM

That looks nice. If you could 'crud' it up a little bit, it would look really realistic. As it is, it just looks almost realistic.

Johan Wallström

February 09, 2001, 04:02 AM

I haven't been doing 3d for a long time, but when I think of this it seems to me that light on diffuse surfaces should be calculated with the dotproduct of the lightdirection and the normal, while "not-diffuse" surfaces should be calculated with the dotproduct U and V, where U is the vector from origion to the point, and V is the reflected lightdirection. I think it looks like the metal too is calculated with dot(L, N), but with a treshold.

Jonas Norberg

February 09, 2001, 04:05 AM

Great work!

When I bought my nVidia GeForce 2MX a demo; "the principles of shading" was bundled, where they achieved the same effect. But they programmed the shader i guess.. so that probablyonly would not work on older cards.
the link to the demo is:

Jonas Norberg

February 09, 2001, 04:16 AM

In most cases one only calculates normals per vertex, while one want metal/not metal per pixel.

Johan Wallström

February 09, 2001, 06:33 AM

Well, the normal of the surface is the same over (flat) surfaces and so is the the reflected light, if we're using directional light (lightsource at infinite distance), but the vector _origion-point_ changes ... Maybe it would be possbile to interpolate it? hehe


February 09, 2001, 06:45 PM

Warren we always agree on everything!
Hehe. I agree, but I think that progression is more important than sales. If we fail to use the advanced features that we have in today's hardware, than where will we be tomorrow? Don't code for the past, code for the future.

This thread contains 26 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.