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 / What is the code to make bump-mapping work?

Author
Message
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 18:34
Hi everyone,
I am working with normals and want to apply a bump-map to a wall. This is the code I am using right now.
--------------------------
`load a bump-mapped wall
ObjectNumber=4:ImageNumber=3
wire=0:trans=0:cull=0:fliter=0:light=0:fog=0:ambient=0
load image "flowerland\rockwall_bump.tga",3
load object "flowerland/wall1.x",4
set dir "flowerland"
set object specular 4,0
set bump mapping on 4,3
--------------------------
but the wall just turns solid black. What am I doing wrong here?

thanks for your help~
Always~
Vickie

Mr Bigger
20
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 2nd Oct 2008 18:59
Hi Vickie,

You need a texture and a normal map.
________________________
load image "base.jpg",1
load image "normals.png",2
make object sphere 1,100,30,30
texture object 1,1
set bump mapping on 1,2

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Quantum Fusion
16
Years of Service
User Offline
Joined: 1st Aug 2008
Location: The Great White North
Posted: 2nd Oct 2008 19:10
I noticed you put the "/" in the load object directory ... try replacing it with this:

load image "flowerland\rockwall_bump.tga",3
load object "flowerland\wall1.x",4

DBPro never likes it when I use "/" in a directory, so I always use "\".

But I've never been able to make bump mapping work in DBPro without the use of a shader.

And the shader loads the texture and normal in stages.

So try this.



Dual-Core Pentium D @ 3.00GHz, 1.0 GB nVidia GeForce 8500 GT, 20" Wide screen LCD @ 10,000:1 Contrast, 4.0 GB DDR2 SDRAM, Triple-boot: 32-bit Windows XP MCE, 64-bit Vista, 64-bit Linux Ubuntu
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 19:11
ok, I see how it works! thanks for your help Mr.B, hey do you know if there is a way to make the Db engine use the mapping that is already on a created model rather than loading the textures in on top of the model? To me this seems a little "old scool" if you know what I mean.

thanks again~

Always,
Vickie

Mr Bigger
20
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 2nd Oct 2008 19:21 Edited at: 2nd Oct 2008 19:30
If your object is already textured then ...

________________________
load image "normals.png",2
set bump mapping on 1,2

*edit sorry i misread your post

I am not sure how to do that,i would think you would use a shader as suggested.

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:20
Thanks for the code Quantum Fusion, I used yours too but after everthing I tried I still get a model with a black skin. Using Mr.B's code I made a sphere but had the same effect. There must be something wrong with my textures. Would you guys mind slapping them on a model and seeing if you can get them to work please?
this is the texture:

This is the Normal map:

maybe I'm making the textures wrong for Dark Basic?

thanks~

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:25
The .tga file won't show up so I made a .rar file you can download to get the textures,

[href]http://www.eaglesoftworxstudio.com/DB/DB Project.rar[/href]

Thanks for your help~

Always~
vickie

James H
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Oct 2008 20:32
I don`t think its possible with texture stages without a shader - also it depends on the model exporter properties to not have to load up the diffuse texture(non shader related) and the image file needs to be in the correct directory. You can use the shader flag of 1 when loading a shader to instruct DBP to use the textures defined in the shader to apply to the object. Hope that helps.
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:40
I just saw your edit in your post Mr.B, and yes the model has a texture on it already. I want to apply a normal map to it. Someone here must know how to do this, you guys are all coders

does anyone know?

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:42
Hi James~
What does the code look like for that? (to use shaders)

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:44
oh, and the model is exported as a .X file at 32bits and all the textures are in the same directory as the model.

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 20:55
I used a shader on a chain I made, it worked really well!

this is the code I used:
-------------------------
`load big chain model
load object "flowerland\chain.x",1
load image "flowerland\glass.jpg",1
set sphere mapping on 1,1
set object specular 1,0
`set smoothing on the chains, looks cool at 75%
SET OBJECT SMOOTHING 1,75
-------------------------
there must be a way to do this with bumpmaps as well~

what do you guys think?

Always~
Vickie

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 2nd Oct 2008 21:03
That doesn't use a shader, only certain things in DBPro, such as cartoon shading, stencil shadows etc use shaders. You're best off using a better normal mapping shader though, as the built in one that comes with DBP is pretty bad, have a look here for better ones.

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 21:09
The links are dead,
Do you know how to use the ones built in to Dark Basic?

Always~
Vickie

James H
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Oct 2008 21:19
To use a shader, you will need a shader. The shader you use would be either a normal shader or bump shader these are a file of the ".fx" format - you can use the search feature of the forum to find one - look for Ultimate Shader Pack. The commands would be

Load object "Vickie.x",1
Load effect "Normal mapping.fx",1,1
(Load effect "path/filename", effect number, texture flag)
Set object effect 1,1

Its odd that your object turns out black, this may be object related, or maybe your using an older version of DBP that the set bump mapping command isn`t working properly in. The code works fine that Quantum Fusion provided and the textures were fine also. Maybe your texture file name in the code is directing to the wrong path - can you double check?

I used this code in addition to Quantums as movement shows things better


Can you tell us the version of DBP your using, and your graphics card model? Can you provide a copy of your model?
Mr Bigger
20
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 2nd Oct 2008 21:25
Here is a simple project using your textures and the default DBP shader that works fine for me.

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b

Attachments

Login to view attachments
James H
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Oct 2008 21:34
The link isn`t dead, it works for me. If your using IE and google toolbar beta version its likely that the IE pop-up blocker and googles pop-up blocker are screwing things up - happened to me a week or so ago. After a couple of days I had to uninstall the toolbar add-on and turn off the pop-up blocker for IE just to get access to the internet!

Dark Coder is right, and is nearly always right. You should get shaders working. You should check out his winning entry in the Dark Physics competition aswell, his experience shows.
Quantum Fusion
16
Years of Service
User Offline
Joined: 1st Aug 2008
Location: The Great White North
Posted: 2nd Oct 2008 22:19
Here you go Vickie,

I've used Mr. Biggs attachment and I've added Evolved's Parallax Shader (since I find it more dramatic of a effect).

So you can take a look at it and see how basically you can use shaders to make it look like you want, and see the basic layout of how it works.

Note: with this parallax shader you need three images, a texture, a normal map, and a height map.

Dual-Core Pentium D @ 3.00GHz, 1.0 GB nVidia GeForce 8500 GT, 20" Wide screen LCD @ 10,000:1 Contrast, 4.0 GB DDR2 SDRAM, Triple-boot: 32-bit Windows XP MCE, 64-bit Vista, 64-bit Linux Ubuntu

Attachments

Login to view attachments
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 22:47
Thanks Guys!
I found out something I didn't know about DB, you have to save your models out clean with no material settings in the .X format in order for the bump maps to work right from TrueSpace.

now it works great!
here is the code I used:
----------------------------------------
`Bump Mapped wall
load image "flowerland\rockwall.jpg",1
load object "flowerland\wall1.x",5
texture object 5,1
load image "flowerland\rockwall.tga",2
set bump mapping on 5,2
set object specular 5,2
set object smoothing 5,75
----------------------------------------
Again, thanks for all your help! you guys Rock~

Always~
Vickie

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Oct 2008 22:55
Just a quick tip Vickie, use CODE tags next time.


Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Oct 2008 23:08
Internal bump mapping has always been a bit disappointing, the benefits are kinda lost unless you go for parallax mapping with a shader. This pic is from a relief mapper, uses a diffuse, normal, and height map to give a much more natural look.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 23:10
Things are really moving along now! Next I must tackle animated water~


thanks for the tip Phaelax~

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 23:16
That is Very nice Van, looks really crisp and clean~

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 23:20
you know what would make the default bump mapping look different would be to find a way to change the color of the specular lighting. Is there a way to do that you guys know of?

Always~
Vickie

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Oct 2008 23:29
Internal bump mapping only uses light 0, but really you should download the ultimate shader pack, that has some great examples, plus a few with coloured normal mapping.
It has water shaders as well, although one thing that annoys me is how tricky it is to get fresnel water shaders working on scenery that is already using a shader. I think the general rule is that you can't render shaded objects with additional cameras (which are vital for the reflection in water shaders).


Health, Ammo, and bacon and eggs!
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 2nd Oct 2008 23:46
Wow Quantum Fusion!
There is a HUGE difference between the DB bump mapping the FX bump mapping. The FX bump mapping is incredible, it looks like the mapping out of Doom3!

Thanks for turning me on to this~

Always~
Vickie

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 3rd Oct 2008 00:04
Van where do you get the ultimate shader pack from?

Always~
Vickie

Quantum Fusion
16
Years of Service
User Offline
Joined: 1st Aug 2008
Location: The Great White North
Posted: 3rd Oct 2008 00:12 Edited at: 3rd Oct 2008 00:12
This is the thread topic for the Ultimate Shader pack:

http://forum.thegamecreators.com/?m=forum_view&t=79849&b=8



And this is the download link for the pack:

http://cordierfr.free.fr/UltimateShaderPack1.0finale.zip


But take note that the use of shaders can slow down the programs performance, sometimes by a little bit and sometimes by a lot.

Dual-Core Pentium D @ 3.00GHz, 1.0 GB nVidia GeForce 8500 GT, 20" Wide screen LCD @ 10,000:1 Contrast, 4.0 GB DDR2 SDRAM, Triple-boot: 32-bit Windows XP MCE, 64-bit Vista, 64-bit Linux Ubuntu
James H
18
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd Oct 2008 00:30 Edited at: 3rd Oct 2008 00:32
VanB - just tested light 0, I get no changes. Although its an internal command(bump mapping), lights don`t affect it - as its a shader. The Highlights appear to be determined by object rotation,camera position, and world coords 0,0,0 I think.(half angle - mentioned in the shader file rem statement) - though this might be down to me using U7.04b

Vickie - you don`t need the specular command for internal bump mapping. It has no effect as internally its for objects that use internal lights. Shaders don`t use DBP internal lights. I can not find any way of changing the bump map highlights color. I`d stick with shaders if you can. This link may be of interest to you, its Evolveds site(a forum member here) - all of the downloads are DBP projects. Look on the left panel to see more pages available with downloads (post-processing, refraction/reflection etc).
Link:http://evolveduk.googlepages.com/BumpMapping.html
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 3rd Oct 2008 00:36
Thank you Quantum Fusion!
and thanks for the tip, I guess I will have to use these shaders sparingly~

Always~
Vickie

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Oct 2008 14:04
OK, that last screenie is looking damn good, can't wait to see the full package

By the way, are you using the latest beta of 7.0? It has updates specific to TrueSpace 7.6 exported models.

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 3rd Oct 2008 16:57
Hi Steve~
Thank you! and yes I am using the 7.0 beta 4 version of DB. So what sort of updates specific to Truespace are there You guys should put them in a list somewhere so I can pass the news on to all the other TS users.

Always~
Vickie

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Oct 2008 17:35
Looks so much more tangible than the bump mapping, damn you work quickly too!.

It's a shame that Evolved's relief map and shadow shader demo is so slow - looks incredible but it slows things down a great deal .


Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Oct 2008 21:41
[Only just seen this thread. ]

Quote: "I think the general rule is that you can't render shaded objects with additional cameras (which are vital for the reflection in water shaders)."


New one on me - I'll have to check.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 3rd Oct 2008 21:54
Perhaps he means with clipping planes? As objects with shaders don't clip correctly using multiple cameras, which would be noticed in some water shader examples.

Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 3rd Oct 2008 22:04
Well the Bump mapper seems to work really well~

But now I have to get the water shader to work with an animated model. I could play with this bump mapping all day..LOL! its really cool what all you can do with it.

Always~
Vickie

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Oct 2008 01:34
Quote: "But now I have to get the water shader to work with an animated model."


There are several different ways of simulating water - depends what effect you are after really. I suppose you want the animated object to be relected/refracted in the water. Not immediately obvious why that should be a problem (other than the performance issue), but then ...

Quote: "I could play with this bump mapping all day"


Yep, that's what got me hooked on shaders.

Quote: "Perhaps he means with clipping planes?"


Ahh! I hadn't thought of that. When I get time I'll try to pinpoint the problem - or have you done that already? It rings a bell now you mention it.
Juso
22
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: Finland
Posted: 4th Oct 2008 12:51
Why it doesnt have bump map on both sides if you use plain instead of cube?

`make object cube 1,100
make object plain 1,100,100
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Oct 2008 18:04 Edited at: 14th Oct 2008 18:40
Quote: "Why it doesnt have bump map on both sides if you use plain instead of cube?"


The reverse side of a plain is not bumpmapped for the same reason that the inside of a cube is not bumpmapped.

To fix this you need to disable culling and also change the directions of the normals when the reverse side is rendered.

The attached demo shows four rotating cubes with both sides bumpmapped using a shader - the shader has been amended to make sure both sides of a surface are bumpmapped.

Edit Ouch! I meant four rotating plains (or planes ) of course.

Attachments

Login to view attachments
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 14th Oct 2008 18:07
What's a good way of generating a normal map?

The optomist's right, The pessimist's right.
BlobVanDam
16
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 15th Oct 2008 05:54
I know 3DS Max can generate them from geometry, I'm not sure what other 3D programs can do it though, and it's a bit tricky.
What I often do though is if you have Photoshop, make yourself a normal grayscale bump map, and download the nvidia dds exporter plugin for it, and that can convert a bump map into a proper normal map.
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 15th Oct 2008 06:36
I typically just use Gimp's normal mapping plugin, but Xnormal looks pretty good as well (both are free). Normal mapping utilities typically don't like regular textures, so I suggest generating them from a heightmap if possible.

I don't have much time to elaborate right now, but if you would like me to go into it further I will check back tomorrow.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Oct 2008 12:49
If anyone can pull together a small tutorial of making a normal map, it would make a nice little newsletter feature It would need to use tools that are readily available and free or cheap.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Oct 2008 14:32
Quote: "It would need to use tools that are readily available and free or cheap."


Like DBPro? I use my own DBPro program to create my normal maps. Would that be acceptable? It would need a decent GUI added to it for selecting files, naming the normal map images,etc.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Oct 2008 21:33
Sounds good to me

calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 15th Oct 2008 21:37
I've made a normal mapper based on a texture and heightmap:



The optomist's right, The pessimist's right.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Oct 2008 00:11
Quote: "I've made a normal mapper based on a texture and heightmap:"


Intriguing.

Why do you need the texture if you have the heightmap?
Vickie
18
Years of Service
User Offline
Joined: 23rd Oct 2006
Location:
Posted: 16th Oct 2008 00:28
if you have photoshop you can download a plugin that make normals, plus its a free plug. Thats what I use~

Always~
Vickie

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Oct 2008 01:23
Or you can try the free nVidia utilities such as nvDXT.exe which I've just found lurking on my PC. Will give it a go tomorrow.
revenant chaos
DBPro Master
18
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 16th Oct 2008 03:46
Vickie - have you tried Gimp with it's normal mapping plugin? In my experience it creates higher quality normal maps than melody could ever hope to. It still isn't up to par with Crazybump, but I still think that it is much better.

Calcyman - That is a good idea. Since heightmaps only depict Z offsets, I find that the normal maps generated from them are generally much smoother than is desired. I will have to play around with that example of yours.

Login to post a reply

Server time is: 2025-06-13 11:02:18
Your offset time is: 2025-06-13 11:02:18