Per Pixel / Normal Mapping Tutorial v1.1..

Posted By: Drew

Per Pixel / Normal Mapping Tutorial v1.1.. - 07/12/04 12:34

****** UPDATED ****** v1.1

*Added info on converting textures to normal maps, which works great. Plus an amazing link so people can get versions going for other 3D apps...

Here's the first version of my "Normal Mapping / Per Pixel shading" Tutorial. Its based on Matt Aufderheide's perpixel code and took me a while to get it out to A6
So, its a work in progress, this is the first technique I came up with that works. Please help expand and improve it!

Im not a shader coder, so Im sorry If I can't answer the technical questions, but Im sure the gurus are watching and answering...

I've also included 2 crate models, each with a norm map.
One has just a norm map for surreal editor, the other has a 32bit alpha specular map for my tutorial...

grab it Here:
TUTORIAL .zip

Playable tech demo:
Demo

killer Normal mapping link:
http://sv3.3dbuzz.com/vbforum/showthread.php?s=&threadid=77037

please share screens and demos!
Drew


Posted By: Alexander Esslinger

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/12/04 20:36

How about calling it "per pixel diffuse lighting", instead of normalmapping? The later one would be a model with a normal map applied .
Posted By: Dan Silverman

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/12/04 21:09

Quote:

How about calling it "per pixel diffuse lighting", instead of normalmapping? The later one would be a model with a normal map applied .




Possibly because there is a model in there that has a normal map applied?
Posted By: Dan Silverman

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/12/04 21:10

Thanks, Drew! I will be working through this one when I can find the time ... Time! Time! Wherefore art thoyu, Time!
Posted By: Alexander Esslinger

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 00:55

Quote:

Possibly because there is a model in there that has a normal map applied?



I guess you know how a normal map looks like, Dan... which model has one then? ...none, else it would be blue... but I don't want to make this more offtopic.

I look though the tutorial aswell when I have time.
Posted By: Buluen

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 03:47

Hooray! just what ive been waiting for
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 04:07

Alexander-
It is a Normal mapping tutorial that uses perpixel lighting to shade. If you read the tutorial you see it 80% normal map generation, and 20% applying the perpixel shader... hehehe you wont see the blue texture unless you open the tutorial... its not a texture you are supposed to see in screenshots, its the shading. The perpixel lighting uses the normal map to create the perpixel shading...every object you see has normal mapping AND perpixel lighting...
Im confused why you think it isnt a normal mapping tutorial?

Posted By: DWilki

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 06:00

Thanks Drew. I really appreciate the tutorial and examples. I especially appreciate the work put into the point lights. One of the problems I was having was that I couldnt get the location of the standard WED lights. This is a much better solution.
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 07:29

Thats all Matt, he deserves the thanks... wouldn't really be useful without it!
Posted By: Salva

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/13/04 20:24

Hi Drew!

I have download this tutorial and tried this effect in my [test level], I have used different models. now
I have seen that the models that locate near to the center, (where the two green lines in WED are crossed) then the model comes illuminated or if the model locates on the Y+ line or Y- then comes illuminated only from the side that has turned toward the center, while the part of behind is completely black! if I move the model on the X line or I remove it from the center then is seen all black!
from what does it depend? I have an ATI Radeon 9000 graphiccard 64 MB

However very nice work!


Greet
Salva
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/14/04 03:09

I have no idea..seems like a redraw problem in WED?
Are you are usimg the 8.1DX settings for the viewports? try changing that, otherwise I dont know....
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/14/04 10:18

Anyone have success with the tutorial?
Posted By: Dan Silverman

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/14/04 16:07

I wish I even had time to look at it! I hope to in a week or so ...
Posted By: MaxF

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/15/04 02:14

Hi Drew

WOW - great work
Posted By: Drittz_Dourden

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/15/04 03:05

Drew,
i have not had a chance to fully complete your tutorial but i gotta say...wow thanks alot. I first heard of NORMAL MAPPING when i read a artical in game informer about Vin Desials new game Riddick. I was like wow i wonder if 3dgs could do that.. well here comes DREW with my answer ...Thanks

daniel

p.s this might be a stupid question but do you think normal mapping could be used with terrian? cause at the moment that is my main goal is to Create High Detailed Terrian kinda like that of FINAL FANTASY XI
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/15/04 15:34

Im sure it could be used on terrain...the hardpart is getting the map to match uvw coords..ibet there are many ways to do it...
Posted By: William

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/15/04 16:08

Next week i'll go through the tutorial when I'm back on schedule with things, I only had time to skim through it now. I must say, the crates look great in the surreal editor. Thank you Drew for the great tutorial, and Matt for the perpixel lighting code!
Posted By: Crossy

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/16/04 10:46

Good job Drew,
I was just thinking about trying to do something like this, and then I came across this thread, awesome.

Thanks
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/28/04 11:18

Drew, Great tutorial. Thanks!

I'm trying to determine how ready Normal Mapping is for genuine production, and it seems to me that at this point it's really only ready for little demonstrations due to the lighting restrictions, and the inability to apply it to level geometry.

Are these shortcomings being addressed in an upcoming beta? (Am I right that Automatic Material Assignment will let me assign shaders to Level Geometry? Will the dynamic dynamic lighting limitation still make it too cumbersome to implement?)

Am I just approaching the problem in the wrong way?

Or should I just not try to implement these high-end features yet?


Posted By: Nadester

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/28/04 13:31

Hey Drew - Awesome work man! Is it possible that I could include this in the documentation for SMEE2? (Its well under way in construction). I'd give you creds of course. Plus it'll feature a lot of cool stuff like opening wdl's and converting normal maps on the run (and bunches of other new features), so it'll be even more compatable with the tut. Again, nice work
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/28/04 14:24

of course... PM sent

Argonautut -
Its a tough call on how much to use the effect, for now keep it simple... I suggest for items and physics objects..

I really hope this shader is improved if possible, its so close to being really great...
Nice screen!
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/28/04 15:10

Im having a problem, maybe other have too or recognize it...

Some of my meshes contain some sort information that I cant clear. The problem model is the reflective one, its using the tutorial shader, which works great on the walls. The other test models use the basic perpixel shader from Nadester's shader viewr...
Has anyone seen this effect?


Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/30/04 06:28

Got it it was a normals problem. The fix is the select the faces and drag them off to a new object, leaving a few behind. I assume this breaks up whatever UV or bad normal info thats in there. IT LOOKS AMAZING NOW!!!
getting closer to "Doom3-like" lighting...screens soon
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/30/04 06:33

On my slow computer, my objects show up transparent--kind of a cool ice-cube effect actually. (If you can't see it, there's "ice" on the floor and left wall--and two large "ice-cubes" below the "ice" torus).

Does that mean this shader needs some kind of fallback?


Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/30/04 08:37

yes, seems like it...what card?
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/30/04 09:03

It's an ATI Mobility, but I found it's a problem in A5 mode. For instance, if I force my Quadro 900 to A5 Mode "var d3d_transform = off;" it has exactly the same display.
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/30/04 12:45

why do you use A5 mode? curious...
also, were they transparant because of the shader code then, (my.transparant=on;) ? IS A5 mode truly A5 without shader support?

Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/31/04 01:04

When the engine boots up it detects the quality of video card available. It categorizes them as Bad, Weak, Slow, Good, or T&L. The engine then defaults to A5 mode for everything less than T&L quality "like GeForce or Radeon." I forced A5 mode on my Quadro just to make sure that was indeed the problem.

I don't have their transparent set to on or anything--I'm using the shader exactly as it was posted. But they do look like they're transparent. What do your objects do when you force A5 mode?
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/31/04 03:30

Drew, I'm not sure if this is the same problem you're having, but some of my objects stay "ON" even when the light leaves them far behind. Also, the dynamic light has some problems striking objects sometimes. Here's a 6MB Quicktime of some of the good and bad luck I'm having so far--apoligies for the large size, but it takes some time to see what's going on. (It's basically a room where the floor and one wall are covered with dozens of tile-grid objects. The Normal Map I made for the tile using Maya and ATI's NormalMapper.exe looks like this:

Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/31/04 03:42

Nice video. perfect example... yes I did the same thing, attached a light to the player, and in my halls it looked amazing, until I left the object behind, the same exact thing happened, the light stuck. Since Im not a programmer I have no idea how to fix this... this is a prime example why I posted the shader, Maybe the other shader folks or Matt have some ideas how to fix it. BTW the normal map looks fine...

I'm still screwed with my meshes, If I chop off the front half of my character it works great, but If I use a full character (from max) it looks reflection mapped with the shader poking through.. I beleive its a normals problem, anyone know of a way to fix/unify normals besides using max's edit mesh or normal modifiers? they screw my models up worse...

Update-
Got it...Had to weld verts and unify normals
Also , seems like the effect is stronger based on scale of my objects in MED...


Posted By: ChrispiZ

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/14/04 17:56

How do you apply bumpmapping to this? I believe it explains in the tutorial but i do not get how, I'm using photoshop as my image editor, i need help please!
Posted By: Buluen

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/15/04 00:14

do you mean apply bumpmapping to player models or walls? because I know how to set it up for walls and floors ect but im gonna learn to do player models soon.
Posted By: ChrispiZ

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/17/04 01:32

I mean, bumpmapping with the Normal map shader, if you read the normal mapping tutorial, it says somthing about it, like "If you want to add bumps and wrinkles, make a Normal map from a grayscale......". I'm using adobe photoshop, if anybody could help, please, i would be grateful!
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/17/04 01:59

If you get the Normal Mapping shader working correctly then you're basically there. Normal Mapping is really just an impressive version of bump-mapping.

Typically, you use Normal Mapping to convincingly portray large bumps, like rivets and such. In those cases, your Normal Map will have some fairly high contrast around the rivet. To add small details like cracks or creases, you simply need to add or use some lower-contrast or finer-detail aspects to the image. For instance, if you convert a normal bump-map of cracks and grooves to a Normal Map, it will show small bumps and cracks. Also, when you generate a Normal Map from a high-res model, you can also usually blend the resulting Normal Map with a second bump-map to add fine details--at least that's true of ATI's utility.

Anyway, so if you just want to know how to convert a bump-map to a Normal map in Photoshop, there's a plug-in for it. I believe it's on the NVidia site, but it could have been ATI that I got it from. Check out the "Killer Normal Mapping Link" listed in the very first post of this thread for the specifics.
Posted By: Sichlid

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/17/04 02:51

Hi Drew,

First of thanks for the cool demo and tutorial.

I got the ATI normal map maker and put it on my weapon and it shows up.

I have also attached the action light_perpixel to some light sources in the level
but the shading on the weapon does ot change when below these ligh entities.

I'm sure I'm doing something wrong here..though not sure what it is.

Secondly I have put ur Example MDL crate (32 bit) one in the level and attached
the per_pixel action ,,but it just becomes orange in the level.

Any help on how to get around andget the cool DOOM3 feel to my game
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/17/04 05:27

MAybe try lowering all your lighting to black, including ambient and sun. Place an object, assign perpixel lighting action, place an omni light right in the same location, turn it to white. Build and run your level, making sure your player is using the perpixel shader... thats how I always start my perpixel levels, since this technique is wonky... If you see lighting show up att all, go from there.. sorry I cant be more helpful, I actually havent touched this for weeks, been playing with the doom3 engine
Posted By: Nadester

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/24/04 10:56

Anyone attempt to adapt this to level geometry now that the new public beta is out? Just curious.
Posted By: Alexander Esslinger

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/24/04 12:04

Still no chance. Bumpmapping isn't supported for level geometry.
Posted By: Ranger1

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/24/04 16:24

Hi Alexander,

Can u explain what you mean by 'not supported' in specific terms ?

Is there a work around ?

What amount of work is required to get Bump mapping supported for Level Geometry ??

My apologies in advance if you don't know
Posted By: Alexander Esslinger

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/24/04 20:23



For getting DOT3 bumpmapping to work, you need the vertex's tangent, which is not avaiable for level geometry. There is no work around, dispite storing the normals in the normalmap in worldspace, which doesn't make much sens.. or generating the texturespace matrix manually, which also doesn't make much sens.

I have a shader here, that will work for level geometry, once it is supported.
Posted By: EX Citer

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/25/04 01:31

Hello,
The demo dowload doesnīt work. To a tutorial a demo would be fitting well. Something with two scripts and a small room and two models maybe. All open source. I think that would be a big help.

In Anyway good work (espacially the skinning, as always...) Drew.

EX Citer

EDIT: Hey, there were some example models and wdls in the tutorial. Nice. And I read the tutorial. The use of 3D max is maybe professional, but I wonder who owns that software. Itīs something around 5000$ I think. In anyway, the wdls and example models are very usefull.
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/25/04 14:10

Im glad you find it useful, sorry about the max only instructions, I use max for everything I do at work so I forget its not readily available ...I would love if someone would write an update with support for a free or cheaper app...:)

I won't be supporting the tutorial anymore...Im way to busy and am putting gamestudio down for a while...

Can anyone host the zip file? Thanks!!
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/26/04 01:36

Quote:

The use of 3D max is maybe professional, but I wonder who owns that software. Itīs something around 5000$ I think.




Not true. You can buy Maya for $2K, but you can use it for free for non-commercial use. They've already got the Personal Learning Edition for 6.0 out. You just have to invest some time. (I'm not positive what Softimage or Max offer).
Posted By: SFMAT4

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/26/04 06:35

Hi,

sry for my question...

I put the Code in my wdl, create a cobe Model (color Skin, Normalmap, TGA + alphamap) and add the PerPixel Shader to these model. Also I add a light_perpixel Action to a other Box.
But I have only Black boxes. If I remove the third Skin (TGA + alphamap)the model is very bright.
The Demolevel works very Well. What is my failing?

best regards

SF
Posted By: BigBrainz

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/26/04 07:15

It sounds like you're using 3 textures, with the alpha on the 3rd texture. As I recall, you use 2 textures, color map and Normal map. And you put the alpha on the first one--the color map.

If they're pitch black, that's strange. Normally, you always get at least a bit of specularity. Make sure that you're light object is very close to the object with the Normal Map.

I often had an easier time trouble-shooting when I had zero normal lights in the scene. Just the Per Pixel dynamic light.
Posted By: Nadester

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/26/04 11:55

If it is pitch black, chances are it is because your hardware does not support the effect. There might be a fallback, I didn't take the time to check.

If that is the case, download the Surreal Editor, there is a similiar shader in there that's a little more computer-friendly.
Posted By: Red Ocktober

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/28/04 23:29

hey, i just wanna take a few lines to THANK Drew and Nadester for their selfless efforts in helping a lot us ease our way into this shaded, normal mapped, new world that is rapidly becoming the new order of things...

the tuts and apps from you guys have been verrrrrrrrrry helpful...

thx

--Mike
Posted By: Sylic

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/22/04 23:32

Hi,

I have the same problem (Black boxes).

Please, somebody help-me, why donīt work?

My level: http://www.sylic.com/acknex/normalmap.zip

And in beta 6.30.2, has a error:


Sorry my bad english
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 06:45

I believe black boxes mean you dont support that shader type...what vidcard do you have?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The errors are because of the changes to the latest beta, someone will have to update this to work with it, I dont have the knowledge....Matt?

So far I cant get most of my older shaders to work
thats ok, dx9 is very worth it.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted By: Matt_Aufderheide

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 13:11

i am trying to fix it..but frankly i dont have a clue.. i asume there is somehow an sysntax error that the dx8 compiler allows but not the dx9. if so i cant figure out what it is
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 13:51

thanks!! any help is appreciated.
Posted By: Matt_Aufderheide

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 16:51

ok i understand what the problems are.. its really quite simple..
i dont have time to correct this shader line by line as im not using this one anymore.. but bascially here are some pointers to remember:
1)in vertex shader constant definitions use {} instead of ()..using the () will generate an error saying 'comma expression used where an initializing list expected'.
2)make sure you use the new Dx9 vertex shader declarations.. and put them under the vs_1_1 version number in the asm body.
3)if you get "uninitialized component" error it is often because you multiplied a register by a matrix that doesnt contain enough components.. for instance.. if you use a 3x3 matrix and then use the 'w' component of that register later you will get this error.. the quick way to fix this is to simply use 4x4 matrixes..
4)an error mentioning "scalar" errors should refer to the 'oFog' output register. for instance.. use 'mov oFog,c95.x' instead of oFog.x ..if you swizzle the oFog now it will give you an error saying 'scalar components cant be masked'.

there may be other things in there that wont work but it shouldnt be too big a job to go through and correct it. The error messages are nice and detailed..this is huge pain to for some of us..especially if you have a lot of long shaders to fix.. oh well..
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 17:35

I totally understand, great details.

thank you
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 17:35

I totally understand, great details.

thank you
Posted By: Matt_Coles

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 17:37

Is It possible and practical with the a6.3.0 beta to apply normal mapping to level geometry?
I got bump mapping to work nearly on level geometry but it was always out of alignment.
Posted By: Sylic

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/23/04 23:53

I think the problem is not my video card, because the PixelDemo4 work!!!

My video card is a Radeon 9600.
Posted By: Red Ocktober

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 09/24/04 00:03

i'm currently using a radeon 9200 and the demos seem to work ok here...

driver maybe?

--Mike
Posted By: okitainda

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/07/05 05:19

Can someone please mirror the link as the link provided in the first post by Drew on TUTORIAL.ZIP no longer works.

P.S. I just wanna try out any tutorial possible to get things going...
Posted By: Joozey

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/18/05 19:43

Yes me too, the link is dead.
Posted By: voodoofactory1

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/18/05 19:59

Maybe someone should PM Drew or something...
Posted By: PHeMoX

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/18/05 23:19

Quote:

Im glad you find it useful, sorry about the max only instructions, I use max for everything I do at work so I forget its not readily available ...I would love if someone would write an update with support for a free or cheaper app...:)

I won't be supporting the tutorial anymore...Im way to busy and am putting gamestudio down for a while...

Can anyone host the zip file? Thanks!!




If only you've read the whole thread
Anyways, I don't have the tutorial readily available, but should have it somewhere....
Also what versions of 3DGS do you have?

Cheers
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/19/05 07:36

Quote:

Also what versions of 3DGS do you have?





Everyone here should have A6.31.4.
If they don't they should go download the update.

I have been wanting to play around with this tutorial in A6.31.4 for some time now. I thought I saved this tutorial to a cd when Drew first released it but I can't find it.
Posted By: Steempipe

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/19/05 07:49

Here:

NormalMapping Tut
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/19/05 22:14

Thanks a bunch steempipe!
Posted By: PHeMoX

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/19/05 23:33

Thanks!
I think it's very much needed to keep these kind of files/tutorials hosted, because when you search for (this is mostly with shaders) quite some links are broken/dead...


Cheers
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/20/05 00:58

What would I change float v7[3]; //uv to to make it dx9?
Would I change it to dcl_texcoord v7; //uv ?

Thanks for your help.
Posted By: okitainda

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/20/05 14:40

Thanks steempipe ^^

5 stars for you
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/21/05 04:55

I finally got this shader updated to dx9!
There's a problem with it though.

I have no idea(yet) why it does this.
It ends up looking like this:



I would be very gratefull if somebody would take a look at the effect and try to fix it.
If you think you can fix it pm me.

Would it be right changing these:

Quote:

float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv
float v8[3]; //tangent




to these:

Quote:

dcl_position v0; //position
dcl_normal v3; //normal
dcl_texcoord0 v7; //uv
dcl_texcoord1 v8; //tangent


?
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/22/05 08:48

Where art thou Matt?
If you would be so kind. I need you to look over the shader to hopfully find the problem.

Posted By: Bright

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/29/05 21:17

The tutorial link is broken for me
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 05/29/05 21:29

Quote:

The tutorial link is broken for me




I may upload a dx9 version of the tutorial with a small demo even if I never get the little problem that it has fixed.
I'll also include the dx8 version.
Posted By: Mantis1967

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/16/05 02:15

I emailed Drew for this tutorial and he said he didn't have it anymore, if any one still has it I would be very grateful I you could share. Thanks in advance.

Mantis
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/16/05 02:21

Quote:

I emailed Drew for this tutorial and he said he didn't have it anymore, if any one still has it I would be very grateful I you could share. Thanks in advance.

Mantis




I have it and I have converted it to dx9... it has a prob though.

If you want the dx8 version you can contact me through msn messenger.
My msn address is humansandbag@hotmail.com
Posted By: PHeMoX

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/19/05 21:00

Could you please post your code, the DX9 adapted version??
I've had similar problems with adding fog and that's almost fixed now, maybe I can be of some use?


Cheers
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/20/05 06:59

I seem to have lost the code do to a system restore.
No worries though. I'll just convert it again and have it posted here soon enough.
Posted By: PHeMoX

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/21/05 12:22

Josh, I guess you will stick to ASM anyways, but I've found this one somewhere on my harddisk. It should work too...

Code:
 /**************************************************************/

// HLSL NormalMapping Shader

// -------------------------

// By: Daniel "Rhuarc" Niezgocki

// Requires: []VS 1.1

// []PS 1.4

// Skin1: Texture

// Skin2: Normal Map

//

// Usage: Free to use, credit is nice, but not required.

/**************************************************************/





function normalMap_init

{

mat_inverse(mtl.matrix, matWorld);

}





material normalMap_fx {

flags=tangent;

event = normalMap_init;





effect="

// VertexShader ------------------


float4x4 matWorldViewProj;

float4x4 matWorld;

float4 vecSunPos;

float4 vecViewPos;

float4x4 matMtl;


texture entSkin1;

texture entSkin2;


sampler base_map = sampler_state

{

texture = (entSkin1);

};


sampler bump_map = sampler_state

{

texture = (entSkin2);

};


struct VS_INPUT_STRUCT

{

float4 position : POSITION;

float3 normal : NORMAL;

float3 texcoord0 : TEXCOORD0;

float3 tangent : TEXCOORD2;

};


struct VS_OUTPUT_STRUCT

{

float4 position : POSITION;

float2 bump_map : TEXCOORD0;

float3 light_angle : TEXCOORD1;

};


VS_OUTPUT_STRUCT mainVS( VS_INPUT_STRUCT vsInStruct )

{

VS_OUTPUT_STRUCT vsOutStruct;

vsOutStruct.position = mul( vsInStruct.position, matWorldViewProj );


float3 position = mul( matWorld, vsInStruct.position );


vsOutStruct.bump_map = vsInStruct.texcoord0;


float3 light_normal_vector = mul( vsInStruct.normal, matWorld );


vsOutStruct.light_angle = light_normal_vector;


return vsOutStruct;

};


// PixelShader -------------------


float bumpiness = 0.5;

float specular = 0.5;

float4 vecAmbient;

float4 vecDiffuse;

float4 vecSpecular;

float vecViewDir;

struct PS_INPUT_STRUCT

{

float2 bump_map : TEXCOORD0;

float3 light_angle : TEXCOORD1;

};


struct PS_OUTPUT_STRUCT

{

float4 color0 : COLOR0;

};


PS_OUTPUT_STRUCT mainPS( PS_INPUT_STRUCT psInStruct )

{

PS_OUTPUT_STRUCT psOutStruct;


float3 base = tex2D( base_map, psInStruct.bump_map );

float3 bump = tex2D( bump_map, psInStruct.bump_map );


// Uncompress vectors ([0, 1] -> [-1, 1])

float3 lightVectorFinal = (psInStruct.light_angle - 0.5);

float3 bumpNormalVectorFinal = bumpiness * (bump - 0.5);


// Compute diffuse factor

float diffuse = dot(bumpNormalVectorFinal, lightVectorFinal);


psOutStruct.color0.rgb = ( diffuse * base + + max(diffuse-specular,0));

psOutStruct.color0.a = 1.0f;

return psOutStruct;

};


technique normalMap

{

pass P0

{

VertexShader = compile vs_1_1 mainVS();

PixelShader = compile ps_1_4 mainPS();

}

}

";

}



action normalMap_ent

{

my.material = normalMap_fx;

}


Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/23/05 06:26

Thanks PHeMoX.
This could be usefull.
Posted By: Daedelus

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/23/05 08:55

Phemox, That NormalMapping Shader is cool w/DX9?
Didn't appear so after a quick test.
Posted By: Josh_Arldt

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 06/23/05 19:16

Quote:

Phemox, That NormalMapping Shader is cool w/DX9?
Didn't appear so after a quick test.




That's an old normal mapping shader that Rhuarc wrote.
It doesn't have dynamic lighting or static lighting, so it may not be usefull to you.
Posted By: Why_Do_I_Die

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/01/05 07:56

I have the tutorial from Drew , the original one , If anyone needs it let me know

Edit: Just saw steempipe's link to it , lol , btw , I'm getting the all black models error as well , Geforce FX 5200 Ultra Vid Card, DirectX9 , did anyone figure out how to fix this ?
Posted By: Drew

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 07/16/05 23:29

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

This tutorial is no longer supported by me.
Please no requests for help or links, I dont have the
files... sorry to let this go, but I havent used GS in
about 8 months, and lost my files...
thanks
Drew
!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Posted By: slacker

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/16/05 14:26

Could someone email me this tutorial? It would be mighty appreciated!

gregdbowen@hotmail.com
Posted By: Sebe

Re: Per Pixel / Normal Mapping Tutorial v1.1.. - 08/16/05 14:30

This tutorial is for the old 3dgs version. You'd have to convert the shaders, hf. You better use the search function, there are much other normal mapping shaders out there.
Posted By: LeHuuLoc

4 shader on player's bottom. - 12/26/06 03:18

Hi ! I want to create 4 shaders on the bottom of player (just like shader of football player when he player in the evening). How can I do it ? Thank you very much.
Posted By: TWO

Re: 4 shader on player's bottom. - 12/26/06 11:32

-.-
Posted By: Loopix

Re: 4 shader on player's bottom. - 12/26/06 13:03

Hi LeHuuLoc

Obviously you are talking about shadows, not shaders Better ask in the scripting-forum. To achieve this, you would need animated shadow sprites of your player movements (named something like: player_shadow+10.pcx). Their frame states will need to be synchronized with the player movement frames (wich is hard to achieve and only works well on flat ground). Maybe it can also be done with a rather complicated projection-shader.
If you are new to A6, better try to accomplish more simple task...what you 're asking is already medium to high level...I guess
© 2024 lite-C Forums