Tangent normal mapping fixed

Blitz3D Forums/Blitz3D Programming/Tangent normal mapping fixed

JoshK(Posted 2004) [#1]
I got it working. This updates vertex colors based on a point or directional light. Unlike every other normal mapping demo I have seen on walls, this makes the light appear correct on all surfaces, without needing a special normal map for each angle.

Have fun:
http://www.leadwerks.com/post/DOOM3BB.zip




Ross C(Posted 2004) [#2]
Your zip seems to be corrupted :)


JoshK(Posted 2004) [#3]
Try again. I just updated with a nicer moving light and added point light range.


Sledge(Posted 2004) [#4]
Lovely.


Jeremy Alessi(Posted 2004) [#5]
Sweet!


Ross C(Posted 2004) [#6]
Very nice man :)


AntonyWells(Posted 2004) [#7]
Heh, very nice moving light there. Thx for including the code too, never had much luck getting it to work on the per vertex level in blitz(As opposed to entityColor method) should provide some much needed insight ;p


N(Posted 2004) [#8]
Good work there, halo.


AntonyWells(Posted 2004) [#9]
-Edit - Never mind, my mistake.


slenkar(Posted 2004) [#10]
the dynamic lighting looks nice but the normal maps didnt work on my crappy PC


Picklesworth(Posted 2004) [#11]
Hey, nice job! Thanks :)


JoshK(Posted 2004) [#12]
I am confident I could do geometric shadows for walls on walls, and objects on walls, but without clipping planes, you cannot do wall on character shadows.


sswift(Posted 2004) [#13]
I'm not trying to bash Halo's accompishment here. I am simply commenting on normal lighting.

Is it just me, or does this look like crap? The surfaces are light properly, but what's with the extreme highlights on the support beams? They appear to be there because the beams are a medium gray. The darker walls display the same effect, but to a much lesser extent, simply because they are darker.

Is Halo doing something wrong? Are the normals not being normalized properly with this method? Or is this how normal mapping normally looks?

Even aside from this effect... this lighting just doesn't impress me. I really _really_ don't think it looks better than a regular texture. In fact, I think it looks worse. It actually looks less realistic. The most AWESOME texturing/lighting I've seen was a specular mapping demo someone did in Blitz on Blitzcoder. The effect of that was amazingly real looking. But this doesn't look particulalry real at all. The surface looks "soft", and the highlights are too harsh, and the lighting overall is too soft.

Perhaps normal maps look better when combined with stencil shadows. I don't know, as I have not played Doom, and the only stencil shadow demo I have tried on my PC ran much too slow to get any real feel for it.


Don't get me wrong, the demo is neat. But I just don't think this ligthing method looks good.


Oh, and Halo... If you're updating the vertex colors every frame, or every time the light moves, isn't that going to kill your framerate with any level of realistic detail? I have done tests when making terrains, and Blitz will choke at around 64K polys when updating a mesh terrain. And the realistic number of verts you can update and maintain a good framerate is well below that. One reason I've not come out with any sort of water simulation system, and why my terrain system does not fix seams in real time. It doesn't even matter how few verts you update, if I recall, what matters only is the total number of verts in the mesh.


JoshK(Posted 2004) [#14]
You should play some Doom 3. It is extremely low-poly, and the whole game does look plastic and reflective.

I am not trying to make a game with this technique, and I'm not a huge fan of the look. But I do like the whole everything-is-dynamic approach, and the way id simplified game production in this title. I think it works okay for sci-fi stuff, but would not be good for realistic environments. UT2004 still has the best graphics:



AntonyWells(Posted 2004) [#15]
I looked through halo's code and did a similar method for cryo minus his .dlls, about an hour ago, see what it came out like, and it definitely does work in MOST cases, with any normal map/diffuse map.

But it doesn't work on big triangles, they remain unlit. while all small ones light pretty well.(my level is awful, so it's not the greatest test)


Jeremy Alessi(Posted 2004) [#16]
Personally, I love the normal mapping. When used properly it gives the 3D world a tangible feeling that cannot be matched no matter how many polygons you use (although it doesn't appear to me that Doom 3 is that low poly). Personally, I think UT (although potentially more detailed in terms of polygons) looks very flat while Doom 3 looks like you could touch it ... every little nook and cranny looks like it would have a feeling to your hand instead of just being flat.


JoshK(Posted 2004) [#17]
That's just because you have too few tris. Same thing that happens with vertex lighting.

I feel bump-mapping is rather overrated anyways. I can't fool my brain into thinking it is anything but a flat texture, and it gives me a creepy tingling feeling in my spine. I am serious.


sswift(Posted 2004) [#18]
Doom 3 does look awesome in many stills, but it wouldn't surprise me if it didn't look so hot in motion. And it is a damn shame that almost all the levels look pretty much the same from what I've heard. But it is understandable given how precisely everything is textured and designed, and given the size of Id's team. It takes a lot of work to align all those textures and design stuff that truly rises to the level of detailed high-tech art that one might see in an anime movie. I dare say that above shot is even more detailed than Metal Gear was.

I wonder though... how many polygons it would take to model most of the above normal map details with actual polygons? I know ID did not neccessarily do that because of the polygon count, but rather because high polygon counts don't work well with stencil shadows. But if one turned off the stencil shadows, could all that detail be done with actual polygons if one segmented one's level properly for vis culling? That would be pretty damn spiffy.

Problem is modeling that detial though. Seems to me that we need a modeling tool designed specifically for creating flat sections to use in our worlds. A displacement map is not really suitable. But I think one could design a 2D tool where one places down 2d shapes and then defines the height at the vertcies, and created a displacement polygon of sorts which would be placed when one clicks on a wall just like one would place a texture. One could even add decals to said surface... signs for example, which would be placed as well when applying this displacement geometry to a wall.

Hm...


Jeremy Alessi(Posted 2004) [#19]
Just looked at it again ... I just love that stuff! Great job on this Halo, thanks for sharing.


JoshK(Posted 2004) [#20]
Look carefully. All the walls in the above shot are completely flat. The doorframe is a solid piece with the wall. The rectangular indentations are completely flat.


Jeremy Alessi(Posted 2004) [#21]
Sswift you should really get a chance to play through all of Doom 3 ... it's really good looking espeically on high detail with Anti-Aliasing on etc... It looks like you're playing a CG movie ... it actually reminded me of that Final Fantasy movie with the amount of detail in some areas ... only you're controlling it in real time ;) Of course it wasn't quite that detailed but it was close enough to make me think about it. I especially enjoyed the scenes where you could see Mars outside ... like this one part in a tram I was running from window to window like a tourist just so I could see it all ;) Truly great eye candy.


Jeremy Alessi(Posted 2004) [#22]
Oh yeah, I mean why shouldn't it be polygonally flat though ... the normal mapping adds the depth. Of course someone had to model a lot of this stuff in high poly anyway. The thing is you couldn't run that level of detail with the lights etc... and play the game in real time without the normal mapping.


JoshK(Posted 2004) [#23]
Yeah, but it doesn't really look like geometry. I mean, to me, it is obviously pixels making up the shapes.


sswift(Posted 2004) [#24]
"Look carefully. All the walls in the above shot are completely flat."

I know that. I was saying I wonder if one could model all that in polygons and get away with it. Assuming one does not use stencil shadows, which require such low poly geometry.


Jeremy:
Oh... I'll play it. But I'll wait till I have a video card capable of running it, and can borrow it from a friend. I'm NOT paying $55 for a game which I will probably play through two or three levels of and then get bored. I payed $50 for Wolfenstein and I only played part of the first level and I'm still pissed about wasting my money on that. :-)

I think the game industry has a real problem with their game pricing. They're just not priced for an impulse buy like movies are. I cannot justify spending $55 on a game I might not play even halfway through.

That said, I'll be buying Half Life 2. I'm sure I'll finish that. I loved both HL and Opposing Force. Did they ever come out with Blue Shift? I forget if I played that or not. I don't think I did. Blue Shift was supposed to be where you play through HL1 as barney, like Opposing Force was where you play through as a solider.


Mustang(Posted 2004) [#25]
IMO normal maps work well when you want to add some detail for example to player charaters like facial features, and when you want to add some bumpiness/detail to terrains (like rock type of surfaces) & weapons. Flattish, metallic surfaces like "spacestation walls & floors" look easily too flat. Normal maps have their limitations and their advantages, but since Blitz does not support them properly it's waste of time to even think them. And like said here, you can do very nice looking game without them.


AntonyWells(Posted 2004) [#26]
Here's a shot of my modified version running cryo. There's one moving light source in the scene, outlined.
The characters however are not normal mappped, they're using a new per pixel cubic lighting system of mine.



the cool thing is I don't really notice any speed diff with or without the normal mapping..so I don't see any reason not to include it as option, whether you personally like it or not. IT's a buzzword.;p..took me 2 mins to make those normal maps in deep exploration.


Jeremy Alessi(Posted 2004) [#27]
Yeah, I think they have their place also.

The thing is everything is made of just pixels even the polygons. The problem with the normal maps is that they aren't as dynamic as polys and also sometimes you see artifacts in them. In Doom 3 when I cranked up the resolution and texture quality it was very nice ... I think on the highest quality with the uncompressed normal maps it'll be pretty tight.

In the future I suppose though we'll be back to dealing with high polygon counts in real time ... unless this shader thing sticks around. For now though there's no way to really have this sort of detail and tangible look without them. High quality textures just aren't enough because the light adds such depth ... like the hallway in your demo if you just stand at one end and watch the light travel back and forth it brings the whole scene to life because you can see 'depth' in the walls.


Jeremy Alessi(Posted 2004) [#28]
Ant, that looks very sweet! Can't wait to see the new alpha ;)


JoshK(Posted 2004) [#29]
... like the hallway in your demo if you just stand at one end and watch the light travel back and forth it brings the whole scene to life because you can see 'depth' in the walls.

Really? To me it just looks like the texture is shifting horizontally.


AntonyWells(Posted 2004) [#30]
The textures arn't aligned properly true, but that's merely texture scale/rotation not being exactly the same.(I apply the normal map manually, however the diffuse maps were done in decorator.)

It is working though, the light moves around in a circle and it lights the scene perfectly bar the big triangle issue(And by big I mean it would take 20 seconds for me to run from one end to the other. thank you very much maplet.

Thx J.


AdrianT(Posted 2004) [#31]
yeah. I prefer polys to bump maps for the most part, It's really hard to get clean sharp edges with a normal map, everything looks like cheap moulded plastic.

However it does have its place, but its going to need a lot more clever shaders to make it really outstanding outside of man made surfaces I guess thats whats coming next from reading the sigraph news and the direction that direct3D is going.

I think the problems with normal maps for me is that they don't have the subtlety of lightmaps, but I'm sure that things will change a great deal in the next 3 years. It's nice that we can create .FX shaders from directly within our 3d apps, so were really justtoutching the edge of wher ethis is all going.

To be honest though, I really want more polys out of blitz, doom's lighting allthough impressive is pretty flat, and doesn't project shadows well overcurved polygon surfaces.

anyway, nice job on the normal maps Halo, in the right kind of game this tech would be really useful.


MSW(Posted 2004) [#32]
Nice job!

some things i've been trying out instead (I ain't concerned with dynamic lights...so this is for static stuff)

1) I've been playing around with a "normal light map"...instead of the verticy coloring, generateing a special lightmap that contains the light normals colors (instead of the actual light color)...this gets around issues with big polygons not lighting correctly (but this is static lighting too)...the map would be rendered fullbright (surface colored white) with this "normal light map" multiply blended atop it (in layer 0....the actual normal texture in layer 1, followed by the normal texture in layer 2 and real lightmap in layer 3)

2) from my experiments you sometimes have to take the way the normal map texture lays upon the surface into consideration when comeing up with the light normal color values...for example say a wall is directly faceing you with a light evenly hitting it from above and to the left ...if the normal map is textured directly on the polygon as you would see it in Photoshop/Paintshop pro then the lighting can appear correct...however if the normal map texture is mapped differently to this polygon (say rotated 90 degrees) given the same verticy colors...the lighting can look off, sometimes so far off that the light source can seem to be comeing from a entirely different direction...this is most apparent in completely flat colored polygons (verticies share the same colors, etc..)...it's easy to spot in that supposedly raised areas seem to be sunken...but for the most part it isn't that bad for organic looking normal maps...its the machined sci-fi looking stuff that it can realy be apparent on.

Just trying to say that if you use the defualt texture cords of CShop and Maplet then you should be fine...even if you transform the texture cords left/right/up/down it should still work okay...but when you get into rotation and flipping the cords to use specific areas of the texture then the normal mapping can start to look a bit screwy, unless your lighting routines takes that into consideration when calculateing the normal colors.


*(Posted 2004) [#33]
nice :)

The bestway to use Normal maps is to use them as an addition to the game (like extra detail where required) not as the game, Doom3 looks spectacular but would it still be as playable without the normal/bump maps?


Jeremy Alessi(Posted 2004) [#34]
If you turn them off it looks stupid ... they add a lot of depth and make the whole world look more tangible (I'm starting to sound like a broken record)... I played it for a while just to see ... it actually wrecked the game for me since it didn't seem so real or touchable.


MSW(Posted 2004) [#35]

Doom3 looks spectacular but would it still be as playable without the normal/bump maps?



They along with the shadows and other effects can be turned off from the in game system options menu...yeah, it's still quite playable without them. you do loose a lot of the atmosphere though and it becomes quite apparent that there arn't a lot of polygons being rendered...also the regular textures are a bit lower resolution then most other current games (a lot of the apparent texture detail comes directly from the normal maps)


AdrianT(Posted 2004) [#36]
Just found out today whilst looking at the sigraph reports, that most modern video cards don't even have built in vertex lighting support like blitz uses anymore, thats emulated these days. Pretty funny. I remember when I first started using blitz and I couldn't figure out why the lighting looked like vertex colours :) I thought Jeremy was screwing around with the lighting at first lol


Jeremy Alessi(Posted 2004) [#37]
Hey I was just about to type something to you! You signed off LOL!


HNPhan(Posted 2004) [#38]
very nice indeed, but once i move the camera abit higher up, and look at the floor, when in point light, the highlight on the floor seems inacurate to the falloff

also when turning the object the light direction doesnt get updated, how would someone code that?


N(Posted 2004) [#39]
Thought I'd dig up this thread and post my try at using normal mapping in Blitz (using halo's framework).

Blitz3D:


Quite unsatisfactory, wouldn't you agree? No idea what's wrong with it, but it's obviously not very pretty.

Orb:


Renders fine. So, I'd say that halo's method, while it works fine in his framework, doesn't apply to all situations.

Just my thoughts on this.


Jeremy Alessi(Posted 2004) [#40]
Doesn't seem to be much of a problem ... why don't you show the same angle so it's easier to see the difference?


jhocking(Posted 2004) [#41]
What are you talking about? The shading in the top pic is terrible.


Dreamora(Posted 2004) [#42]
Light direction is terrible ...
the smaller the difference 90 - AngleBetweenViewdirectionAndLightdirection is, the less you see the normal mapping effect.


Jeremy Alessi(Posted 2004) [#43]
Can we see a shot from the same angle though? I mean it just looks like the guy is ugly either way ... doesn't look like the normal map isn't working though.


N(Posted 2004) [#44]
Doesn't seem to be much of a problem ... why don't you show the same angle so it's easier to see the difference?


Jeremy.. really.. not much of a problem? You're kidding, right? Look at the top picture. That is not how it should look at all. Seeing it from a different angle isn't going to magically make it any better- I know 'cause I looked at it from a lot of different angles.

The normal map on the model isn't mirrored, as well, so there shouldn't be a problem with that.

I'd guess that any triangle that isn't flattened along a certain axis is not going to work out too well with Blitz3D's (and halo's framework) 'version' of normal mapping.


JoshK(Posted 2004) [#45]
Use a directional light. You might be lighting it with a point light inside the head. Also, your normals could be messed up.

I can't tell what the problem is without the model and code.


N(Posted 2004) [#46]
Would you like me to send you the model (and textures) later so you can mess with it yourself, halo?

Makes no difference to me.


Jeremy Alessi(Posted 2004) [#47]

Jeremy.. really.. not much of a problem? You're kidding, right?



I have a bad eye for that stuff ... why do you think Adrian is the other half at Leadfoot Productions ;)


Rob(Posted 2004) [#48]
Normal mapping imho, delivers the greatest benefit on characters. You've only got to look at my early demo of the athene statue to see that.

On walls and stuff - you'll never see much benefit because:

a) lights are pretty static in the real world
b) a good texture and lightmap looks just as good

But with dynamic characters, they make a world of difference. However, it's a nearly impossible to do this effectively in blitz as we don't know which vert is where on animated meshes.


Jeremy Alessi(Posted 2004) [#49]
I like it actually on floors and walls like in Halo. Doom 3 also on the environments looks good. Of course it's best seen with a flashlight ... or in Halo when you die and it puts a camera up in the air over your partner during co-op and you can see all the weapon fire lighting the bumps up!


Kalisme(Posted 2004) [#50]
ok... erm stupid question I guess... But I'm using a really dodgey Voodoo2 card... (embarising) I presume this is why dot3 isn't working... (I have the newest updates)


Rob(Posted 2004) [#51]
dot3 does not work on those cards.


Kozmi(Posted 2004) [#52]
Your link doesn't seem to be working there halo! :(


TartanTangerine (was Indiepath)(Posted 2004) [#53]
Same problem here. Dead Link.


TartanTangerine (was Indiepath)(Posted 2004) [#54]
Link now works... Thanks


Raitsun(Posted 2005) [#55]
The link for the doom3.bb is 404...
Halo... can you give link that's working? or can anyone else post a working link here?
I'm really interested in this code...

mfg Raitsun


Naughty Alien(Posted 2005) [#56]
..well..Link doesnt work at all...Error 404 appear...if its possible post file somewhere else..I would like to see this stuff...


Danny(Posted 2005) [#57]
link failing :(


Raitsun(Posted 2005) [#58]
If noone has the .zip file, but have the .bb file(s), could you at least post the code here?

Raitsun


Raitsun(Posted 2005) [#59]
Halo... don't you have this file anymore? That'd be a pity... I can't believe noone has this code anymore... well a lot of people downloaded it... this file cannot have been dissappeard or something o.O


puki(Posted 2005) [#60]
"halo", how about uploading it onto RapidShare?

http://rapidshare.de/

then I can have a go on it too.

WAIT A MINUTE - THIS IS AN OLD THREAD

I thought this was new

sniff


Raitsun(Posted 2005) [#61]
that this thread is old does hopefully not mean that this file is lost or something.... i mean... if you made great code, would you delete it after a few months just because the thread you posted it in is old?

I still hope that someone relocates this, in all probabillity amazing, file in the deeps of his hard drive and links it again in this thread...

raitsun


Morbius(Posted 2006) [#62]
Is this file available somewhere?

Thanks


Naughty Alien(Posted 2006) [#63]
emailme and I'll send it to you..


Morbius(Posted 2006) [#64]
On the way. Thank you!


Naughty Alien(Posted 2006) [#65]
..done I email you already..


Steven Noyce(Posted 2006) [#66]
Can you post the code instead of e-mailing it? Please?


skyfire1(Posted 2006) [#67]
can you email it to me?


Steven Noyce(Posted 2006) [#68]
You tried twice to e-mail it to me but it said there was a virus attached. Could you post the code?


N(Posted 2006) [#69]
If anyone still wants this, here's the zip.

http://noelcower.com/doom3-bb.zip


Steven Noyce(Posted 2006) [#70]
Thanks!


Kalisme(Posted 2006) [#71]
I actually had a problem compiling the code...
"function pointdistance not found"
(this is an error with the "normalmapmesh.bb" file
can someone help?
I'd really like to get into this code, it's exactly what I'm after


Kalisme(Posted 2006) [#72]
okies, I just found halos "pointdistance" function...
where can I find the "normalize" function?


Kalisme(Posted 2006) [#73]
oh god... I'm sorry to post so many times in a row....
but I think I found all the functions I need...
but wen I ran the program it doesn't look like the lights pointing the way it does in the *.exe file...

could someone check these functions I collected from Halos other work?

Function PointDistance#(Ax#,Ay#,Az#,Bx#,By#,Bz#)
Return Sqr((ax-bx)^2.0+(ay-by)^2.0+(az-bz)^2.0)
End Function

Function Normalize(nx#,ny#,nz#)
m#=Sqr(nx*nx+ny*ny+nz*nz)
VectorX=nx/m
VectorY=ny/m
VectorZ=nz/m
End Function

Function VectorX#()
Return VectorX#
End Function

Function VectorY#()
Return VectorY#
End Function

Function VectorZ#()
Return VectorZ#
End Function


Kalisme(Posted 2006) [#74]
oh sod... I'm sorry... I'm posting again...
I found everything and got it working...
but erm... what ia the *.dll for?
does it have any use for re coding this?


Danny(Posted 2006) [#75]
I'm not sure what you're asking, but the dll contains the functions you listed above. see the PhobosGL.decls for a list of functions....?!

By the way, if you remove the bit where halo creates a temp-pivot for every vertex and free's it in the same for..next loop, and in stead create the temp-pivot once at the end, and free it once at the end of the loop, then this will give you MORE THAN DOUBLE the FPS than before - with the same result! :D

Does anyone have idea idea how to turn this into colored lights?! I'm just starting with this normal mapping / lightmapping business, but you'd expect that changing the VertexColor paramters would do the trick, but the light always seems to give a greyscale tint...!??!

cheers,
Danny


Pinete(Posted 2006) [#76]
Hi!,
Please, someone could post the code of Leadwerks,
"doom3bb.zip"?
It seems the link is broken and I cannot download it..

thanks in advance!


simonh(Posted 2006) [#77]
Noel posted a working link a few posts up:

http://www.noelcower.com/doom3-bb.zip


Pinete(Posted 2006) [#78]
Thanks a lot simonh!
I missed it! sorry!
:)


Raitsun(Posted 2006) [#79]
hm.. no it works no more... >.<


Shifty Geezer(Posted 2006) [#80]
Ignore this. Forgot the PhobosGL dll


AntonyWells(Posted 2006) [#81]
Does anyone still have a copy of this?

If so please e-mail it to me, antonycoder@...


Naughty Alien(Posted 2006) [#82]
..yeah..email me and I'll send it to you..


AntonyWells(Posted 2006) [#83]
Thanks man, e-mail sent.