Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Can DB Pro do normal mapping

Author
Message
bobj
20
Years of Service
User Offline
Joined: 2nd Jul 2003
Location: North Carolina, United States
Posted: 12th Sep 2006 19:41
I'm using version 5.7 I don't know what normal mapping is and a person that is making a model for me needs to know. Do I need to code something to turn it on?
Mr Kohlenstoff
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 12th Sep 2006 20:25
I think, it's not integrated in DBP (just bump-mapping) but it may be possible to create your own normal map shader... maybe. I never really worked with shaders, so I don't know.

Visit the DBPro - Speed up your game-Thread. http://forum.thegamecreators.com/?m=forum_view&t=88661&b=1
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 12th Sep 2006 20:46
Ofcourse it can, goto here http://forum.thegamecreators.com/?m=forum_view&t=79849&b=8

And there are atleast 2 shaders there which do normal mapping, some even do specular highlighting and there are tonnes more shaders in there to tart up your game and wave goodbye to your fps with.

Hallowed are the ori.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Sep 2006 20:53
You don't need any external shaders to do normal mapping in DBP, it is built-in. Although, confusingly the command used to activate it is:
SET BUMP MAPPING ON
Despite the name of the command it is normal mapping that is performed and you will need a normal map to apply to your texture.


bobj
20
Years of Service
User Offline
Joined: 2nd Jul 2003
Location: North Carolina, United States
Posted: 12th Sep 2006 21:01
Thanks very much for this information.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Sep 2006 22:09
Quote: "Despite the name of the command it is normal mapping that is performed and you will need a normal map to apply to your texture."


True - but the visual appearance can be a bit odd. If you're interested I have a shader which does normal (bump) mapping with a single directional light, ambient light and specular reflection which is easy to use and may be faster than the built in DBP bumpmapping (i.e. in some limited tests it was somewhat faster then DBP bumpmapping on both of my machines under all conditions tested).

It would be nice if others tested it and let me know how they get on.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Sep 2006 22:18
Quote: "but the visual appearance can be a bit odd"

Indeed! DBP's built in bump mapping can be a little odd!

If you have a better option GG then post it up and I will gladly speed test it for you


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Sep 2006 22:29
Will do. Just been called away to supper. As soon as I've eaten, I'll tidy up the calling dba file and post it.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Sep 2006 23:28
@Scraggle

Here it is. Any questions/problems, just ask.

The program demos 5 of my attempts at bumpmapping - all doing much the same thing. Version 1.0 is possibly the correct way to do it - but the others are faster and all involve some sort of approximation. On my machine, version 1.0e is the fastest and is faster than DBP bumpmapping. I tried other variants, including cube and volume maps, but failed to improve on the speed. Any suggestions welcome.

The demo's instructions are self explanatory, I hope, except that it helps NOT to move the mouse when you start up, otherwise the camera might be facing the wrong way. I've included a few textures and normal maps to play with.

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Sep 2006 09:54
I've just tested them with your normals and with some of my own and the results are impressive.
The speed test showed that only version 1.0d was faster on my machine than DBP bump mapping but all of them were far superior in image quality.

1. Standard texture no mapping : 1020 fps
2. DBP Bump Mapping : 1000 fps
3. GG Bump Mapping v1.0 : 980 fps
4. GG Bump Mapping v1.0a : 995 fps
5. GG Bump Mapping v1.0c : 990 fps
6. GG Bump Mapping v1.0d : 1010 fps
7. GG Bump Mapping v1.0e : 985 fps

There is no version 1.0b - I presume that is just a typo in your code.
After seeing your version of bump mapping compared to DBP's built in version, I think DBP's would be better if called gloss mapping instead because it does seem to simply turn the objects surface into a very glossy one. Where yours actually bump maps


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Sep 2006 11:03
Thanks Scraggle.

I get the following on my PC (nVidia GeForce FX 5200 128MB):

1. Standard texture no mapping : 188 fps
2. DBP Bump Mapping : 120 fps
3. GG Bump Mapping v1.0 : 92 fps
4. GG Bump Mapping v1.0a : 112 fps
5. GG Bump Mapping v1.0c : 113 fps
6. GG Bump Mapping v1.0d : 116 fps
7. GG Bump Mapping v1.0e : 130 fps

and similar results on my laptop (but, like yours, 1.0d was slightly faster). Can I have your PC please?

Quote: "There is no version 1.0b - I presume that is just a typo in your code."


Not a typo - there is a version 1.0b (and 1.0f, 1.0g, etc) but I had to draw a line somewhere ... (I thought of relabelling them all - but the consequences could be dire ...)

Quote: "I think DBP's would be better if called gloss mapping instead"


Indeed.

Interesting that there's not much difference in speed on your machine. I guess that's the usual thing that you can't get much improvement beyond a certain point because of all the other things the PC is trying to do per frame.

I'm thinking of extending the shader to deal with two or three additional lights (Lee says my earlier attempt on the WIP thread is too "heavy" - and I agree). Your comments might help spur me into action!

Cheers!
Fireburst
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 13th Sep 2006 14:30
I get the following
tested on
WinXP pro
ATi X800
AMD X2 3800
2gig ram

1) 1091 fps
2) 1030 fps
3) 995 fps
4) 990 fps
5) 995 fps
6) 990 fps
7) 940 fps

In theory, there is no difference between theory and practice. But in practice, there is.

AMD X2 3.8 Ghz-Win XP 64-2GB Ram-2x500gb HD-ATI X850
Lukas W
20
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 13th Sep 2006 15:10
i got this:
1. Standard texture no mapping : 50 fps
2. DBP Bump Mapping : crash
3. GG Bump Mapping v1.0 : 53fps (object is white)
4. GG Bump Mapping v1.0a : 54fps (object is white)
5. GG Bump Mapping v1.0c : 54fps (object is white)
6. GG Bump Mapping v1.0d : 54fps (object is white)
7. GG Bump Mapping v1.0e : 53fps (object is white)

on my:
Pentium4 2.8ghz
512mb ram
64mb integrated intel gfx card

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Sep 2006 15:32
@Fireburst

That is odd - although it suggests there's not much difference. Method 3 should be the slowest. I guess a really fancy solution would be to include a check for the GFX card/CPU combination and choose the appropriate bumpmapping technique (all five of my methods could be wrapped as different techniques in a single shader) - assuming the results are reproducible of course.

@Lukas W

Sounds like a GFX card problem to me. I used to have all sorts of problems like yours till I upgraded to an nVidia GeForce FX 5200 card. My machine is a P3 930 MHertz so speed shouldn't be your problem. I've heard that Intel integrated GFX should be avoided - no idea whether that's true though.
bobj
20
Years of Service
User Offline
Joined: 2nd Jul 2003
Location: North Carolina, United States
Posted: 14th Sep 2006 20:23
GG, does this need a DBPro version higher than 5.7? I get a missing dll error
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Sep 2006 21:39
I'm using DBP upgrade 6.2 (i.e. version 1.062). Haven't tested it on earlier versions.

Just reminded myself of the dba code and it all looks like fairly standard DBP commands. Which dll is missing? Is it a runtime error or a compile error?
bobj
20
Years of Service
User Offline
Joined: 2nd Jul 2003
Location: North Carolina, United States
Posted: 15th Sep 2006 00:53
GG,

A wierd message as follows:
Could not find function '?strex@@yakkmh@2' in 33:dbprotextdebug.dll
bobj
20
Years of Service
User Offline
Joined: 2nd Jul 2003
Location: North Carolina, United States
Posted: 15th Sep 2006 00:54
Oh Also, it's a runtime error
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Sep 2006 01:12 Edited at: 15th Sep 2006 02:38
As you say - WEIRD! I have no idea what that means. I haven't got time now, but if you're still having problems next week (I'm away at the unofficial convention over the weekend), I'll re-install 5.7 and see what happens. In the meantime, could you narrow down the source of the error a bit? For example, omit some of the shaders or some of the options, etc, till you get to the minimal code which fails. Do other shaders work? What vertex and pixel shaders does your graphics card support? I specified VS2 and PS2 in all of them - but some of them will run on earlier versions I think (I haven't checked).

Of course, could be a 5.7 bug. Any reason for not upgrading? I'm glad I did despite the temporary hassles with the DirectX9c thing (not a big deal really unless you've got a slow internet connection).

Run out of other ideas - except the bug board.

Edit: just reinstalled 5.7 and ran the program - got exactly the same weird message you described (plus a few others because of other files created by later upgrades) - so it looks like 5.7 is the culprit.
Arat
19
Years of Service
User Offline
Joined: 19th Jun 2004
Location:
Posted: 15th Sep 2006 10:51
I got:

1. Standard texture no mapping : 957 fps
2. DBP Bump Mapping : 880 fps
3. GG Bump Mapping v1.0 : 821 fps
4. GG Bump Mapping v1.0a : 839 fps
5. GG Bump Mapping v1.0c : 848 fps
6. GG Bump Mapping v1.0d : 877 fps
7. GG Bump Mapping v1.0e: 846 fps

Thank you Green Gandalf ! I think this could be the first satisfying
normal map shader for me.
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 16th Sep 2006 02:34
so the best way to do normal maps would be with a shader

The admiral
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Sep 2006 15:17
@Arat

Glad to be of help - and thanks for the feedback info.

@The admiral

I think so.

Will continue to post shaders from time to time.
RaceGT
18
Years of Service
User Offline
Joined: 15th Aug 2005
Location:
Posted: 11th Oct 2006 11:06
GG: Great demo there...I used it to make some bump mapping for shooting purposes, have a look at the pic.

It's an excellent effect (for realism's sake, anyway)...these are just quickly mocked-up, so they're not even artistically drawn yet, but still looks pretty good. I can move the light around (changed your code a little bit), and the lighting in the dimples changes to suit. Very cool, but I'm not sure useful it would be...if it were the walls in a city or something, or even in a static level, the light would most likely be unchanging, so the same effect could be achieved with a variety of statically-drawn '2d' dimples (as long as they're pasted in correct orientation), without the overhead of a shader. Although, this one seems to pose no real effect on CPU usage.

But if it were a game or level or something, where the player had a light attached to them, that moved with them, then I could see wanting this effect, though I'm still not sure how much it would ever be seen. (Dimples are likely to be small, and how much would they be noticed, anyway?). It would look cool, but how much is it really needed. I just wanted to see if I could replicate in DB the effect I heard about, and with your routine it works very well, with the right settings (ambient, spec. level, etc.)

It may not be totally useful in the application I came up with, but I still learned alot about normal mapping by examining your routine, so thanks for that...

http://www.geocities.com/crmnlelmnt/

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2006 13:57
@RaceGT

You're right. Excessive realism isn't necessary for a good game - lots of good games have very crude graphics - and lots of good books have no graphics at all! In practice a lot of the "graphics" are in your own imagination when you get absorbed in a game (or a book). Even so, realistic graphics do help - and they are a selling point. Look at how many games start with a visually realistic video setting the scene - but then the actual game uses less sophisticated graphics.

You also make a good point about the fixed scenery. If the light is fixed you don't need real-time normal/bump mapping as used in my shaders - you can precalculate the effects in an image or light map and save a lot of real-time processing.

Glad you found the shaders useful - I'll be posting another version soon which uses a point light rather than a directional light.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Oct 2006 15:30
nahhh, he's wrong... the realer, the better

seriously though, nice job optimizing the shader GG...

for all of you shader gods... try adding a lil fog to the demo, and see what (doesn't) happen...



just copy and paste this snippet to the end of the key select block...

i'm not a shader coder, but i messed with a shader in 3DGS, and got it modded to be aware of the fog... can't find the code now...

are any of you guys fog shader coders i mean, capable of making the shader fog aware...

--Mike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2006 16:01
Quote: "for all of you shader gods... try adding a lil fog to the demo, and see what (doesn't) happen...
"


Shaders take control of all lighting effects, so obviously you need to extend the shader to include fog if you want it - you can't just add fog (or any other lighting effect) via DBP.

Getting robust (and efficient) shaders which cover all lighting scenarios that you might want ain't easy - better to use the built-in DBP lighting if you can as most of the hard work is already done for you.
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 11th Oct 2006 16:06
that's exactly what i'm talking about... i can understand a custom shader not being fog aware, but it just amazes me how the default bumpmapping shader in DBPro just ignores everything about the environment... and has for the past couple of years...

should i hope for a surprise along these lines in the new shader util that is on the calendar for the end of the year

--Mike
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2006 16:38
Quote: "but it just amazes me how the default bumpmapping shader in DBPro just ignores everything about the environment"


Indeed - and a shame really.

Quote: "should i hope for a surprise along these lines in the new shader util that is on the calendar for the end of the year"


I'm sure there will be some surprises - quite looking forward to it. I'm hoping to learn something from it ...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Oct 2006 22:53
@Red Ocktober

You asked:

Quote: "are any of you guys fog shader coders i mean, capable of making the shader fog aware..."


Well, here you are. The attached zip file contains my original bump map shaders plus a new one which is version 1.0e with simple fog ("GGbumpfog01e.fx"). The shader allows you to change the fog colour and the attenuation. It uses simple linear attenuation of the fog based on distance from the camera. The demo program only allows you to change the attenuation. I used your f/g suggestion.

As you might expect, the extra processing slows it up a bit - but not too badly.

I leave it as "exercises for the reader" to make the corresponding changes to the other bump mapping shaders.

Attachments

Login to view attachments
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 12th Oct 2006 03:48
hey, great... i was messing around with something myself, but couldn't get anything working...

will take a look at this in a few...

thanks GG...

--Mike

Login to post a reply

Server time is: 2024-05-06 06:23:48
Your offset time is: 2024-05-06 06:23:48