My normal map is not showing!

My normal map is not showing!

Re: My normal map is not showing! Posted by RitchieTheBrit on Wed Mar 7th 2007 at 9:52pm
RitchieTheBrit
22 posts
Posted 2007-03-07 9:52pm
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
This is driving me nuts!

I've recompiled the textures for this model over and over again, and although the actual diffuse texture shows up fine, neither the normal map or the specular map seem to be doing anything!

I've tried using VMT's created both by hand and using VTFEdit, I checked the normal map flag when I comiled with VTFEdit, and when I compiled the texture in VTex the TGA was appended with _normal.

What the hells the problem? I've got the thing running in-game, I'm not testing using the model viewer, and I've built the cubemaps.

If anyone can take a look at the model and its textures for me, I would really appreciate it! It's precompiled, and just needs dropping into the HL2 folder.

Grab it HERE
Re: My normal map is not showing! Posted by Riven on Thu Mar 8th 2007 at 3:47am
Riven
1640 posts
Posted 2007-03-08 3:47am
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
You have everything in the right place, but what I believe you messed up on was the APC_N.vtf file. firstly, just to be sure, i would rename it apc_normal.vtf I like to stick with the lowercase as well as spelling out the "_normal" tag. [make sure to rename it in the .vmt as well] What you did wrong was when you made the .tga for the normal texture, you need to invert the colors in the alpha channel for the normal. apparently, for a normal map, if your going to have an alpha channel, make sure everything you want to see is black. You had it, or as I saw it through the .vtf plugin for photoshop (cause you didn't upload the .tga's) the alpha channel was highlighting everything you wanted to see in white, so I just switched it and re-saved it, and it came across fine. Also, I don't know if this matters, but I only use forward slashes in the .vmt "/" I changed that as well. Here is the .vmt after I was done with it:

"VertexLitGeneric"
{
"$model" 1
"$envmap" "env_cubemap"
"$envmaptint" "[.2 .2 .2]"
"$baseTexture" "models/apc/apc_t"
"$bumpmap" "models/apc/apc_normal"
"$surfaceprop" "Metal"
}

yes, I renamed the textures to suite the lower-case formality, but that's just my preference. I found that I was only able to see the _normal only if I had "$envmap" 1 included in the .vmt. It wouldn't show up otherwise. Let me know if this works!
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: My normal map is not showing! Posted by RitchieTheBrit on Thu Mar 8th 2007 at 1:42pm
RitchieTheBrit
22 posts
Posted 2007-03-08 1:42pm
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Funnily enough, I tried using the lower case _normal after this was posted, to see if that would make a difference. That naming system is what I use when I'm modelling, so I guess I'm going to have to change my ways! Lol!

The mixture of forward slashes and back slashes were the result from one of the automatic VTM generators. Can;t remember which, but it seems to find the texture regardless of which way the slashes lean. Strange!

I didn't think that the alpha channel was present in the normal map that I uploaded? Oh well. Strange that about the alpha channel. I was always under the impression that the alpha would work in the same that it does in 3D packages. Very strange!

Right. I can't check this right now, but when I get a chance, I'll make the changes you mentioned. There's a karma system here isn't there?
Re: My normal map is not showing! Posted by RitchieTheBrit on Thu Mar 8th 2007 at 3:16pm
RitchieTheBrit
22 posts
Posted 2007-03-08 3:16pm
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Arrrgh. This is really p***ing me off! That worked to a degree Riven, but the damn thing took on a weird purple cast, and the supposed specularity is actually causing the normal map to fade out in certain areas, whilst leaving the level of specularity unaffected.

I've seen people posting tutorials all over the place that works with a simple texture map and normal map, without any specularity. If I can get this, I can then tweak and mess around with specularity to my hearts content, but I can't seem to have one without the other. Is this normal?
Re: My normal map is not showing! Posted by Riven on Thu Mar 8th 2007 at 9:08pm
Riven
1640 posts
Posted 2007-03-08 9:08pm
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
I must admit, that up till now, I've worked with most of the commands for model textures (that is, the "vertexlitgeneric" shader) except with the normal maps, so this is a learning experience for me as well. I'm still working on it, unless someone else has a good idea. But I'm gonna try and take that _normal .vtf file and save it as a .tga and put it through vtex again. as well as the other texture just to be sure.

When you mention the "specular map" to which exactly are you referring to? Because you are not going to get any reflections whatsoever unless you have "$envmap" included in the .vmt, which you did not have before hand, so I don't know what you mean, you only had the base texture and the _normal texture included in the file.

EDIT:
Btw, your right, you shouldn't have to have reflections enabled to see a bumpmap, normally light rays will make it cast shadows on "lightmappedGeneric" and should as well on "vertexlitgeneric." I've been successful with world textures having _normals, and I feel that I'm doing the same thing here, but it's not working for you. I did have some problems beforehand where I only got the model to look like a complete sliver bump, but after toning down the "$envmaptint" command to: [.09 .09 .09] it looked pretty good. Heres what I am able to get:

User posted image

ABOVE: This was before adjusting the tint level and what it looked like with the exact same .vmt I posted for you. (notice the texture doesn't come through at all, it's just silver-looking)

User posted image

ABOVE: This is an upclose of the backside of the apc with the adjusted tintlevel to [.09 .09 .09].
You can clearly see the texture through this as well as the bump withought light. Come to think of it, I've never seen a bumpmapped model that was not reflective... Maybe you DO need "$envmap" enabled in the .vmt

If your still having problems, like with the purple and black checkerboard texture appearing instead, that may be due to after pasting my version of the .vmt you didn't change the names of the textures like I did to match, check that next, or if you want me to, I can just send you everything I've done, and you can just see for yourself, but I've told you about everything. :razz:

P.S. One last thing, dont forget to buildcubemaps!
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: My normal map is not showing! Posted by RitchieTheBrit on Thu Mar 8th 2007 at 9:55pm
RitchieTheBrit
22 posts
Posted 2007-03-08 9:55pm
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Some images in this post have been automatically down-sized, click on them to view the full sized versions:

Some images in this post have been automatically down-sized, click on them to view the full sized versions:Cheers for your help with this Riven. I'll a little ill at the moment (labrynthitis), so I guess I'm just being a little short tempered with myself and Half Life!

My idea was that the texture map was working, so the paths were correct and the VMT file was getting parsed. I wanted to see exactly what the model would look like without any reflectivity, just the texture and the normal map. Then I was going to leave out the normal map, and use a separate specularity map, and tweak the spec settings till I was happy. The get the two working together, and finally combine the spec map with the normal map (in the alpha channel). That way, I'll be learning how everything works in nice bit size chunks.

The problem is, I can;t get JUST the base texture and the normal map. Is this even possible? I'm too used to working in 3D applications. I'm haing trouble understanding specularity in HL2. Specularity and reflection are two very different things, normally! Specularity usually reflects just light sources. For example (like my APC) when painted edges get worn, they become smoother, and will reflect light more readily, but they won't necessarily reflect the world around them.

Maybe this will demonstrate what I mean...

<a href="http://i4.photobucket.com/albums/y144/RitchieTheBrit/spec_demo.jpg" target="_blank">User posted image</A>

EDIT: Hah, you edited the same time I posted!

Nope, no purple texture. It was working the way your first image was. In reality, because of the way that normal mapping works, it shouldn't require any reflectivity. It is a little harder to see, but you CAN still it it. I think that the 'specularity' in HL2 is just faked by using reflectivity.

If you could send me the stuff you've done, that would be great! I'll mark this damn thread as answered and be done for the night! :wink:

Heres a normal mapped model without specularity the way a scanline renderer sees it. No idea why a realtime engine like HL2 can't, I'm sure the Doom 3 engine works like this. Oh well!

User posted image
Re: My normal map is not showing! Posted by Riven on Thu Mar 8th 2007 at 10:26pm
Riven
1640 posts
Posted 2007-03-08 10:26pm
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Ah, I think I see what you mean now. In Source, specularity is handled strictly though the "$envmap" command in the .vmt. It can be changed through several other sub commands such as: "envmapcontrast" and "$envmapsaturation" as well with what I was using: "$envmaptint". Even with this, you still only get REFLECTIONS of the surrounding cubemaps and their light data. The closest thing I have been able to get to for true specularity was with HDR, simply compile the map with HDR enabled, which I did not in this example. I think that the new version of the Source engine comming out with Ep2 will have the new phong shader that will allow for true specularity. As of now, It is just reflections with pictures of light in them for models, (world textures can do dx9 specularity I think [as well as the water shader]). For more specifics, check out these links over at the valve developer wiki about reflections. They do mention specularity but their in contrast to what you and I are talking about.

http://developer.valvesoftware.com/wiki/Materials_for_models
http://developer.valvesoftware.com/wiki/Reflective_Materials

Please correct me if I am wrong on the specularity issue anyone...

EDIT: update: through a friend of mine who generously decided to upload this for me on HIS payed for server, I am able to bring my changes to you all in this file. It's just the updated textures, so, you need the model to see them which can be dl'ed from RitchieTheBrit's first post. enjoy! Get it here.
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: My normal map is not showing! Posted by RitchieTheBrit on Fri Mar 9th 2007 at 3:11am
RitchieTheBrit
22 posts
Posted 2007-03-09 3:11am
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Well, just for fun, I made the normal map more defined. I upped the contrast by 70% on each channel in photoshop. Bugger me if the thing didn't work the way it was supposed to! I'm going to have a muck around with tint and contrast settings, and see exactly what can be done inside the VMT. I'll keep this thread as a repository for my settings!

Cheers for all your help with this Riven.
Re: My normal map is not showing! Posted by RitchieTheBrit on Sun Mar 11th 2007 at 10:55pm
RitchieTheBrit
22 posts
Posted 2007-03-11 10:55pm
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Sweet! With a little digging around and a little help from a member of the Cinema4D forum, 3DAttack, it seems this is more than possible!

With the additions made to the Source engine when HL2:Ep1 got released, the phong shader was amongst them!

Screw me sideways if this isn't what I was after! The final result is a lot closer to my rendered model, and there's no reflection present!

I'll explain in slightly plainer English than the dev wiki does.

A normal map is simply a transparent image sitting over your model. When light is cast across the surface of the model, the normal map will produce shadow by calculating how the light is hitting the normal mapped image, and how the image should interact with that light.

The problem is, for the light effect what the player sees, it needs to ot only interact with the normal map, but also a surface property. This surface property normally comes in the form of a reflection in HL2.

When the cubemaps for a level are built, images are captured from each face of the cube, and then projected onto the surface of the model at rendertime, giving the false illusion of a reflection. The light and shadow that is generated from the notmal map then has a way to apply itself.

This is very handy, but in case of my model, and skin on characters, you find that you will need to apply a normal map to surfaces that don;t actually reflect all that much. This is where Phong shading somes in.

Without going into the technicality of what Phong shading is, it produces the kind of specular highlights that you can see in my above example. It will give the impression that light is bouncing off a surface and producing highlights, WITHOUT displaying the reflection of the surrounding environment. For matt paint, this is extremely handy, as you can have a normal map without making the paint appear glossy.

So, there you go! I simply added some lines into the VMT, and bingo! The following is an example VMT with a phong shader applied, commented to maybe cast a little light for others!

"vertexlitgeneric"
{
"$basetexture" "models/Alyx/alyx_faceandhair"
"$bumpmap" "models/alyx/alyx_head_normal"
"$halflambert" 1
"$nodecal" "1"
"$model" "1"

"$phong" "1" - This is a boolean value. 0=off, 1=on

"$phongexponent" 33 - The Phong Exponent is how the specular highlight appears. A lower value will spread more, and be generally less defined, whereas a higher value will be a lot sharper, and the highlight will be a lot tighter. You can exemplify the differences by imaging that the lower values will result in matt paint, or dry skin, the higher value would look more like gloss paint or sweaty skin. This overrides the use of a specular map.

"$phongexponenttexture" "(path to texture)/(texture)" - You can specify a greyscale image here. If the $phongexponent is commented out, this will act as a specular map, black being lower on the specularity scale, and white being higher, with degrees in between. I've yet to test this myself, but in theory, my spec map is pretty dark, with the edges of the model picked out in a white falloff brush. The result should be a rather matt finish to the model, except where the edges have been worn over time. I could combine an eviroment mask to make these areas appear slightly reflective as well.

"$phongboost" "6" - Boosts, or makes the effect more apparent in areas with specularity. I think that used in conjunction with HDRI, this would give some nice blooming effects an bright surfaces?

"$phongfresnelranges" "[0.05 0.5 1]" - Really not sure what the values mean. Experiment. Fresnel gives the appearance of a halo effect around the object. Imagine looking at a glass ball. The way the light hits it gives it a fresnel effect, causing the very edges of the ball to bounce a lot more light than the actual ball does towards the centre facing the viewer.

Hope this gives you a little insight into the phong shader. To be quite frank, this is freaking sweet! Now I'm a happy chap! Lol!

Here's some examples of the shader on my model. I only actually tried this about 20 mins ago before I started to feverishly write this post, so there's quite a few problems, like the strange artifact that I've pointed out in one of the images., but as you can see, it's worked pretty well.

User posted image

User posted image

If anyone can talk more broadly on the subject, I would be interested to see what others have done with this shader!
Re: My normal map is not showing! Posted by Riven on Mon Mar 12th 2007 at 4:18am
Riven
1640 posts
Posted 2007-03-12 4:18am
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
I had no idea Source version: Ep1 had the phong shader. I was getting too comfortable with the regular hl2 shaders and .vmt commands, that I didn't give it a second thought! Good catch, looks like I need to do some more research on what I could be doing with my textures in Source.

Thanks for sharing, I'm glad you found exactly what you needed!
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: My normal map is not showing! Posted by RitchieTheBrit on Mon Mar 12th 2007 at 5:14am
RitchieTheBrit
22 posts
Posted 2007-03-12 5:14am
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Well Riven, you've got my model and textures there, see if you can recreate the effect I had in the post above, I mucked around with the VMT and now I can't get it back!

More info in the phong shader can be found HERE.

See what you can do, and if you get anything neat, can you post the VMT here so I can compare it with the one I have now?

<div class="code">Code:<pre>"VertexLitGeneric"
{
"$baseTexture" "models/apc/apc_t"
"$bumpmap" "models/apc/apc_normal"
"$halflambert" 1
"$surfaceprop" "Metal"
"$phong" "1"
"$phongexponent" 66
"$phongboost" "10"
"$phongfresnelranges" "[0.05 0.5 1]"
}
[/pre]
Re: My normal map is not showing! Posted by Riven on Tue Mar 13th 2007 at 3:51am
Riven
1640 posts
Posted 2007-03-13 3:51am
Riven
Wuch ya look'n at?
super admin
1640 posts 1266 snarkmarks Registered: May 2nd 2005 Occupation: Architect Location: Austin, Texas, USA
Well, I was able to see the phong shader! Get this:

As before where I changed the alpha channel in the _normal to all black for the bumps to show for "$envmap", well this time I changed it to all white, and wouldn't you know it worked. Once again you have everything in the right place, but I did some reading on that page you posted and it talked about the phong mask and sure enough it said:

The Phong mask is a greyscale image stored in the alpha channel of the models normal map (defined by $bumpmap). This mask defines on a per texel basis the intensity, or strength, of the Phong highlight for that texel. Black represents the lowest intensity and shows no Phong highlight at all (literally knocking it out), whereas white represents the brightest, or full intensity for that texel.

So, it was just hidden, but it's there. I did not change the .vmt you posted either.

One other thing, I don't know cause I haven't tried (will get to it eventually); can you use the phong shader and all the other Source updates in regular 'ol HL2? For the sake of this test to save myself some time, I compiled and ran the map in EP1; is that what you did?
Blog: www.playingarchitecture.net
LinkedIn: Eric Lancon
Twitter:@Riven202
Re: My normal map is not showing! Posted by RitchieTheBrit on Tue Mar 13th 2007 at 10:01am
RitchieTheBrit
22 posts
Posted 2007-03-13 10:01am
22 posts 2 snarkmarks Registered: Mar 7th 2007 Occupation: Full time Student
Nope, haven't even got EP1! Works fine for me in HL2 without EP1, sp it must have been included in the Source update after EP1 was released, maybe even earlier?

I saw the phong mask as well. I didn;t try that, but I did try the map on the phongexponent setting. Results were mixed, and again, I had to invert the specularity map.

Still couldn't get exactly what I saw in the renderer (the normal map seems a lot more defined), but damn, I had some very close results.

This is definetely a step in the right direction from Valve. I may just do another map to use as an env_mask to get a little bt of reflectiona round the edges!