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.

Dark GDK / Normal map

Author
Message
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Jan 2012 01:11
I want to make normal maps from images. Does anyone know the math to do this?

I know there are converters out there, but I want to do it myself. I have looked on the internet and have only found vague articles 'about' normal mapping and plenty of converters.

The fastest code is the code never written.
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 9th Jan 2012 02:07 Edited at: 9th Jan 2012 02:08
You could take a look at the source code of the Irrlicht Engine (Open Source), because there is a method called "makeNormalMapTexture()" of the IVideoDriver class, which transforms a height map image to a normal map. Maybe you can get your math from there...

And I just found this GLSL code snippet from here:



Quite interesting since it performs the algorithm directly on the GPU. If you read up on GLSL you may find out what these commands do and translate it to C++.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Jan 2012 20:24
Searching using your suggestions gave me procedures to use an existing normal map. I am wanting to make my own. I know it can be done because there are programs out there that can do it. I need the method for doing it.

Thanks for the input though.....

The fastest code is the code never written.
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 9th Jan 2012 20:56
i dont know if you want this, but i used one code in allegro that generates a map from a config file

Like you use 1 for grass, 2 for platform, 3 for metal and stuff...

if is that what you want check this tutorial:

http://www.youtube.com/watch?v=PYelV2kBJBU&list=PL62B63CC836DCB7C8&index=5&feature=plpp_video

I think you can understand it.. if you dont know some of the allegro syntax just ask i will be here to help you or at least try

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Jan 2012 21:22 Edited at: 9th Jan 2012 21:22
I did see this somewhere and have just searched for ages on google for it again. It was basically the same algorithm that the GIMP normal map plugin uses and needed a little conversion to work with GDK.

I'll keep an eye on here for a solution though in the meantime...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Jan 2012 21:41
It's the algorithm (or method) that I'm looking for.....

The fastest code is the code never written.
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 9th Jan 2012 21:47
there's no need to search on google. There's a working code in dbpro's code snipet subforum, search for that

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 9th Jan 2012 23:54
Ok. I looked at as many of the code snipets that had anything to do with normal/bump mapping that I can stand. Thanks for the point in the right direction though.
I remembered back in my DX days there was an old example of how to make a bump map. Here is my code. It's not doing what I want, but it's a start. I would like for someone to help me figure out what I'm doing wrong.

There's a function in it that you will need to make. FindFreeImage();
The rest will port into whatever you want to test with. I got the code from a DX example. Here is the function in it's original form:

I MUST be doing something wrong because the bump texture doesn't come out right.

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Jan 2012 00:37
Here is the original code (slightly converted). I get the same results. WHY???


The fastest code is the code never written.
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 10th Jan 2012 00:43
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Jan 2012 00:58
Thanks. I'll try to adapt it to DGDK and let everyone know how it works.

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 10th Jan 2012 01:24
Here it is:

That was amazingly simple! Thanks Brendy boy! I don't know why it's so hard to find in google.... I will post this exact code in the Code Snipets for others to use (considering there's not a DGDK version of it).

The fastest code is the code never written.
Benjames8
14
Years of Service
User Offline
Joined: 6th Jan 2010
Location: Your Nightmares
Posted: 12th Jan 2012 22:13
Thats really cool I want to try it out.
Do you make shaders hawk blood?
One time I took the bumpy gloss shader from invidea and made it only bump then made it work with only one texture, it wasn't exactly great looking but I learned a little about shaders.
I like that shader that makes the texture look three dimensional, I can't remember what its called, but I think I'll try it with your bump code.
Btw it sucks that models need to be mapped so well for shaders to look half decent.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Jan 2012 22:38
Sorry. I don't.

Parallax makes your texture look 3D. They all do to some degree, but Parallax does it the most-- it's a displacement.

I use Evolved's shaders.

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 15th Jan 2012 02:20 Edited at: 15th Jan 2012 02:22
I'm still having problems making this work right. It's almost correct, but I'm doing something wrong. Here is a sample:

On the left is done by my code. On the right is the one I got from Evolved's. What am I doing wrong? I think it's the difference between "bump" and "normal". How can I fix this?

The fastest code is the code never written.

Attachments

Login to view attachments
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 15th Jan 2012 02:58 Edited at: 15th Jan 2012 03:01
What about this? http://www.smart-page.net/smartnormal/fl10.htm

Edit: Oh, you want to know how to do it, ok... well, I guess I'll learn from this.


Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 15th Jan 2012 03:00
i think the difference is in contrast so you'll need to find and algorithm for enhancing contrast

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 15th Jan 2012 03:24
It seems to be made from a smoothed version of the original. I tried this, but it gave me no better results. I think I'll try to make a contrast enhancement proceedure and see if that works..... It will be a few days, because I have to work, but I'll post to let you know if it works.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-11-19 04:18:46
Your offset time is: 2024-11-19 04:18:46