Bump Mapping Shader

Posted By: oliver2s

Bump Mapping Shader - 01/16/04 22:22

Ich habe mich mal daran versucht das Dot3 Bump Mapping aus "Shader Studio" in 3DGS zu übersetzten. Hat auch wunderbar geklappt und sieht toll aus.


(URL EDITED by Rhuarc)

hier ist der Code. Das Modell mit dem Bump Mapping muss als ersten Skin eine normale Textur haben und als zweiten Skin eine Normal Map.

Code:
matrix matWorldViewProj;

matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1f,1f,1f,1f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0f,1f,0f,0f};
VertexShaderConstant[31]={1f,0f,0f,0f};
VertexShaderConstant[32]={0f,0f,1f,0f};
VertexShaderConstant[90]={1f,0f,0f,0f}; //damit oFog gefüllt ist

VertexShader =
decl
{
stream 0;
float v0[3]; //Position
float v3[3]; //Normal
float v7[2]; //Textur Koordinaten 0
}
asm
{
vs.1.0
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}




Posted By: ello

Re: Bump Mapping Shader - 01/16/04 22:28

suppi!
ich denke mal du musst mit nem pixelshader die originaltextur nehmen und mit dem vertexshader-output "multiplizieren?" vielleicht mul_x2 oder so

tex t0;
mul_x2 r0,t0,v0 // bin kein crack, aber das würd ich als erstes versuchen..
Posted By: oliver2s

Re: Bump Mapping Shader - 01/16/04 22:29

Danke ello. Hab den Fehler schon gefunden und den Post Editiert, jetzt funzt es. Ich hab bei der 2ten Textur-Stage zweimal hintereinander Colorarg1 geschrieben.
Posted By: oliver2s

Re: Bump Mapping Shader - 01/16/04 23:00

[Edited by Rhuarc] Code updated in first post.
Posted By: ello

Re: Bump Mapping Shader - 01/16/04 23:35

btw. this looks extremely near like what was shown here .
maybe you place a shot with texture?
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 01:33

Here's the same Texture with another model:


(URL EDITED by Rhuarc)

btw: the texture and the normal map is from ATI's Render Monkey.
Posted By: ello

Re: Bump Mapping Shader - 01/17/04 01:39

da fällt mir grade ne frage ein die mir schon lange aufm herzen liegt. sind normalmaps immer rot,grün und blau gefärbt?
Posted By: Captain_Kiyaku

Re: Bump Mapping Shader - 01/17/04 01:51

hi,

ich glaub ich bin einfach zu blöd das dingen einzufügen


Also was genau ist ne normal map? und muss ich den code einfach in die wdl kopieren oder mit
material blabla
{
effect=
"
//und hier dann den code einfügen=???


so hatte ich das vorhin gemacht, dann kam aber nen error mit video device blabla.

irgendwas mache ich falsch ^^


Sayonara!
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 01:54

Ja, ich mach meine Normal Maps imemr mit ATI's "TGAtoDOT3" Programm. Es gibt auch noch so ein Tool für NVidia Karten, aber ich muss das ersten benutzten weil das andere mit meiner Readon 9600 Pro nicht funktioniert.

[EDIT]: Du musst ein neues Material machen:
Code:
MATERIAL dot3bump

{
effect
"
hier den oberen Code einfügen
";
}



Vielleicht unterstüzt auch deine Grafikkarte keinen VertexShader 1.0.

PS: das hier ist eine Normalmap (in der mitte):
http://www.stonehill-online.de/gfx/wip3.jpg
Posted By: Captain_Kiyaku

Re: Bump Mapping Shader - 01/17/04 02:16

HI, ok vielen dank, werde das ganze gleich mal ausprobieren


Sayonara
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 03:35

@all english users: If you want to add this code to your models you must use the code which I posted second time. The first code in my first post has a faliure (not really for shader experts, but for noobs).
Posted By: Dan Silverman

Re: Bump Mapping Shader - 01/17/04 03:52

Oliver2s,

I would edit the first post with code and place a note where the code was telling people to get the code below it. This could save a few headaches.
Posted By: myrlyn68

Re: Bump Mapping Shader - 01/17/04 03:57

He can't edit it anymore (15 minute timer), though I agree it would help save a few headaches - perhaps you could?
Posted By: Dan Silverman

Re: Bump Mapping Shader - 01/17/04 05:41

Ahhhh ... I forgot about that "feature" being implemented. If he wants his initial post edited, then I will certainly do it (or one of the other mods). But I will not, as a policy of mine, mess with someone's post that does not violate any forum policies without the user's permission.
Posted By: ello

Re: Bump Mapping Shader - 01/17/04 05:55

however, now at home i could try this script and that is really cool!
if you place mov oT0,r3 and/or mov oT1,r3 it looks also interessting , and i m thinking of mixing it with render to texture, or environment mapping:-)
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 06:12

thx Dan, but I have send a PM to [Rhuarc] that he edit the wrong code.
Posted By: EX Citer

Re: Bump Mapping Shader - 01/17/04 06:24

In der Manual A6.2 war schon ein Dot3Bumpmap shader drin. Darum ist meine Kritik hier Zwecklos: Also, erstens finde ich glänzt es ein bsichen zu doll (sieht aus wie plastik), und zweitens kann ich sone bunte bumpmap nicht (so einfach) zeichnen.... Yo, ich zeichne normalerweise bumpmaps in graustufen (kann man auch mit filtern wie relief, emboss und plastic erstellen). Ansonsten gute arbeit.
MfG EX CIter
Posted By: Stansmedia

Re: Bump Mapping Shader - 01/17/04 06:28

Very noob question.... Sorry, but this would clear lots up if it was answered. Is it possible to get shaders on WED geometry? Or is it ONLY models..?
Posted By: EX Citer

Re: Bump Mapping Shader - 01/17/04 06:43

lol, ich hab son nvidia tga converter gefunden. Jetz muss ich den nur noch raffen.
@Bloodred: The 3DGSdeveloper said: until now only models, terrain and sprites (and mapentities(?)) can be used for shaders.
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 06:47

@EX Citer: Ja im Handbuch war ein Dot3 Bump Mapping dabei, allerdings fand ich das *******. Mir gefiel schon immer das Bump Mapping aus Shader Studio sehr gut. Dot3 Bump Mapping braucht keine Bump Maps (die mit Graustufen) sondern Normal Maps. Es gibt dafür spezielle Programme die aus Texturen Normal Maps machen, man muss sie also nicht selbst zeichnen.

@bloodred: Shaders are only possible on Models and Terrain, not on levelgeometrie.
Posted By: Drew

Re: Bump Mapping Shader - 01/17/04 09:54

works great! even has proper lighting in shadows...

here is the code, with action and material (for shader newbies like me)

Code:
 

MATERIAL bumpmap
{
effect
"
matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1f,1f,1f,1f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0f,1f,0f,0f};
VertexShaderConstant[31]={1f,0f,0f,0f};
VertexShaderConstant[32]={0f,0f,1f,0f};
VertexShaderConstant[90]={1f,0f,0f,0f}; //damit oFog gefüllt ist

VertexShader =
decl
{
stream 0;
float v0[3]; //Position
float v3[3]; //Normal
float v7[2]; //Textur Koordinaten 0
}
asm
{
vs.1.0
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}



action Shader_bumpmap
{
my.material=bumpmap;
}


Posted By: Drew

Re: Bump Mapping Shader - 01/17/04 15:24



I applied the bump shader to a chunk of wall entity, works great except the ambient color. Is there a way to match the ambient of the level better?
or some rgb value we can change to match? The bumpmapped object does pick up the light and dark of the shadows nicely, but is way too dark.. you can see the same object on thr right,, without bumpmapping.
also- thank you for sharing the shader!!

i translated this using babelfish

Ich wendete das Stoß shader an einem Klumpen des Wandwesens, bearbeite großes ausgenommen die umgebende Farbe an. Gibt es eine Weise, das umgebende des Niveaus besser zusammenzubringen? oder etwas rgb Wert, den wir zum Gleichen ändern können? Bumpmapped Gegenstand aufhebt das helle und die Dunkelheit der Schatten freundlich, aber ist die dunkle Weise zu. Sie kann den gleichen Gegenstand auf thr Recht, ohne bumpmapping. sehen danken Ihnen auch für das Teilen des shader!!
Posted By: Orange Brat

Re: Bump Mapping Shader - 01/17/04 15:58

You might be able to better match the ambient with the level if both the ambient value of the level and the entity matches. I'm talking about using materials and not setting it in WED. I've pretty much gotten everythign to match(levels, models, entities, flat surfaces) using the one that is in the templates folder. It's global, but works for quick tests. Just fiddle with the values. Once you get the hang of it...you'll appreciate the extra control.


________________

The bumpmapping is nice. Thanks for the contrib.
Posted By: EX Citer

Re: Bump Mapping Shader - 01/17/04 16:55

Yo, dann könnte man passend zu diesem Topic hier ein paar normal map translator programme links einfügen, hm? ZB ich könnte den für nvidia hier reinsetzen, den ich allerdings noch nicht getested habe und daher nochnicht bewerten kann.
Ausserdem fahr ich gleich nach berlin und kann also eh erst morgen abend das hier machen.
EX
Posted By: oliver2s

Re: Bump Mapping Shader - 01/17/04 20:13

Here are some programms to create the normalmaps you need for this shader:

ATI's Normalmap Generator (I use this tool)
Normalmap 3D Studio Max Plugin (I've not tested this)
Adobe Photoshop Normalmap Filter (I've not tested this)
Posted By: jcl

Re: Bump Mapping Shader - 01/18/04 01:43

You don't need a normal map converter. Just use a greyscale bumpmap and apply the bmap_to_normals() instruction - it is then converted to a normal map within the engine.
Posted By: oliver2s

Re: Bump Mapping Shader - 01/18/04 03:07

@jcl: danke für den Hinweis. Hab diesen Befehl doch glatt übersehen im neuen Handbuch.
Posted By: fuxerz

Re: Bump Mapping Shader - 01/19/04 02:12

looking good but why cant i get it to work right?all i get is a transparent material with a gradient color!
my model has notmal skin with alpha for bump.
Posted By: DarkShadow

Re: Bump Mapping Shader - 01/21/04 02:11

hi all,

i tried this code even though my card doesnt support hardware shaders, it seems to work, but not really too sure, i modified a model and added a normal map to it, added the action to the model then ran it with a plain version of the model beside it to compare, well the shader is definately working but it is really dark and i can only really make out one part of the model skin and it is definately bumpmapped, however this won't due for a game, i must be missing something, do i need a dynamic light in the scene to really see the effect, or maybe do i need to adjust the material? i'm rather new to this, i just upgraded from a5 and really don't know about all the material effects and stuff, if anyone can help, i'd be grateful, i'll even send my test project if anyone wants to see it. Also while i'm at it, i have another questionit seems rather easy to apply this shader to a model or terrain, but how would i go about using it on a map entity, as map entities don't have skins really, just textures, so i don't really understand how to add a normal map to a map entitiy for use by the shader, anyway, like i said, i'm new to this stuff so bear with me on these. Anyway that's all i need right now, thanks in advance for any help.


James
Posted By: er_willy

Re: Bump Mapping Shader - 01/22/04 03:53

hello thanks for you work but... I use the sader and work fine the ligting areas but the sadows zone in very dark (excesive ) i playing when materials opcions but no work.

hasta luego colega
Posted By: Drew

Re: Bump Mapping Shader - 01/22/04 04:47

it's not using the 'ambient values' of the level...
Can this be added? (wish I knew how)

Posted By: ventilator

Re: Bump Mapping Shader - 01/22/04 06:40

i think conitec should provide a simple example for a shader which does exactly the same lighting as the default mat_model does. with ambient, albedo and all that things considered... i couldn't reproduce the mat_model lighting behavior yet. with an example it would be quite easy to combine that lighting with shaders like this bump mapping one...
Posted By: jcl

Re: Bump Mapping Shader - 01/22/04 10:44

Use

COLOROP[1] = modulate2x;

instead.

The default model ColorOp is modulate2x. The material color values can just be copied from mat_model like in the effects.wdl example.
Posted By: Drew

Re: Bump Mapping Shader - 01/22/04 10:55

can somebody add that to the code (for us shader noobs)?
Posted By: ventilator

Re: Bump Mapping Shader - 01/22/04 11:22

actually i didn't really investigate this bump mapping example. i knew that if you set the directx states it's possible to achieve the same lighting as with mat_model...

but i haven't been able to achieve the same lighting with a pure vertex and pixelshader combination (using veclight and so on). i don't know how to combine the influence of the shadowmap and other lightsources in the right way. a simple example for this would be nice!

...
@drew:

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate2x; // here
COLORARG1[1] = texture;
COLORARG2[1] = current;
Posted By: Drew

Re: Bump Mapping Shader - 01/22/04 16:30

ok, thanks... What that (modulate2x) did was to just bring the brightest levels up, the ambient is still black.

Posted By: ventilator

Re: Bump Mapping Shader - 01/22/04 17:13

i think the vertex shader would have to do the same lighting calculation (with the shadowmap, albedo and everything taken into account) as the engine does for models without any shader and then pass the result to a third stage which applies the lighting. but i don't know how the engine calculates the lighting and so a simple vertex shader example by conitec would be nice!
Posted By: jcl

Re: Bump Mapping Shader - 01/23/04 01:02

Yes, ventilator is right.

This is the default render setting used by the engine:

Models, sprites, and flat textures:

SetTexture(0,Skin);
SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); // entity texture
SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE); // lighting


Shaded textures:

Stage 0 adds dynamic lights to the lightmap:

SetTexture(0,LightMap);
SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_ADD);
SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); // lightmap
SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE); // lighting

Stage 1 modulates the actual texture with the result of stage 0:

SetTexture(1,Texture);
SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE); // texture
SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT); // stage 0


The shader must emulate this setting.
Posted By: Aaron_H

Re: Bump Mapping Shader - 01/23/04 06:28

Excuse me about this, but isn't there bump mapping with the engine, without the need for shaders?

Sorry, but I don't know anything about shaders or anything, so maybe someone could help me on this one.
Posted By: RAFU

Re: Bump Mapping Shader - 01/23/04 07:17

good question... Hmmmmmm.. No
Need shaders:)

Posted By: Alexander Esslinger

Re: Bump Mapping Shader - 01/23/04 07:52

DirectX 8 supports bumpmapping even in the fixed function pipeline. This technique uses interpolated data from the vertices and does not look as specular as per-pixel bumpmapping does.
Posted By: ventilator

Re: Bump Mapping Shader - 01/24/04 08:42

Quote:

This is the default render setting used by the engine:

Models, sprites, and flat textures:

SetTexture(0,Skin);
SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE); // entity texture
SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE); // lighting




but how does the engine calculate the diffuse value? ...in case i want to do that myself in the vertex shader...
Posted By: Aaron_H

Re: Bump Mapping Shader - 01/24/04 18:44

Thanks Alexander, I understand now.
So this is just a better looking more enhanced Bump Mapping technique...

Posted By: Stansmedia

Re: Bump Mapping Shader - 01/25/04 09:55

I tried that bump mapping code. But it gave me an error message when I looked at it: BUMP MAPPING: NOT SUPPORTED BY HARDWARE...
Not supported my ass, ive got a geforce 4 128 mb of vram. Like, my max has bump mapping and stuff, so why is 3dgs complaining? Can somebody help? I want shaders

(im a total shader noob btw... so, help is good )
Posted By: Ultra

Re: Bump Mapping Shader - 01/29/04 06:07

Quote:

works great! even has proper lighting in shadows...

here is the code, with action and material (for shader newbies like me)

Code:
 

MATERIAL bumpmap
{
effect
"
matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1f,1f,1f,1f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0f,1f,0f,0f};
VertexShaderConstant[31]={1f,0f,0f,0f};
VertexShaderConstant[32]={0f,0f,1f,0f};
VertexShaderConstant[90]={1f,0f,0f,0f}; //damit oFog gefüllt ist

VertexShader =
decl
{
stream 0;
float v0[3]; //Position
float v3[3]; //Normal
float v7[2]; //Textur Koordinaten 0
}
asm
{
vs.1.0
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}



action Shader_bumpmap
{
my.material=bumpmap;
}






Hi, I copied this code and apparently can't get it to work.



any idea why i get this error? (and yes, if you haven't guessed, I'm quite the noob)
Posted By: qwerty823

Re: Bump Mapping Shader - 01/29/04 07:17

Its missing an '=' for starters. (In red)

Code:

MATERIAL bumpmap
{
effect=
"
matrix matWorldViewProj;


Posted By: Ultra

Re: Bump Mapping Shader - 01/29/04 10:25

Unfortunately, adding '=' did nothing different
Posted By: Drew

Re: Bump Mapping Shader - 01/29/04 12:34

thats exactly my code and it works, so it must be something different... ill look at it.
can you post your code if its different from above?
or pm it to me...
Posted By: qwerty823

Re: Bump Mapping Shader - 01/29/04 14:23

I noticed from your profile you have 6.11. Is it Commercial or Pro? Only Commercial and Pro support shaders.

You might want to grab 6.20 upgrade, since 6.11 might not support shaders.
Posted By: Drew

Re: Bump Mapping Shader - 01/29/04 14:42

I use 6.2 commercial, just never updated my profile... thanks
Posted By: qwerty823

Re: Bump Mapping Shader - 01/30/04 00:10

My bad Drew, my 6.11 comment was meant for Ultra.

@Ultra, what version of 3DGS do you have? Unless Im mistaken, you need 6.20 Commercial or Pro for shaders to work. That might explain the unknow "effect" keyword.
Posted By: Joey

Re: Bump Mapping Shader - 01/30/04 01:24

I think that the compiler would just ignore the shader effects, not return an error message in standard/extra. Or am I wrong?
Posted By: Ultra

Re: Bump Mapping Shader - 01/30/04 02:48

Quote:

I use 6.2 commercial, just never updated my profile... thanks




I should have 6.2 pro.. I recently reinstalled windowsxp on my system as i got a new motherboard. It's possible that i could have not applied that patch correctly.. I will see what went wrong.. I'm sure its a stupid error made my me
Posted By: Ultra

Re: Bump Mapping Shader - 01/30/04 02:59

Yep, sorry guys, i'm idiot. Apparently the update I executed didnt work the first time.. Works fine now.. Thank you.
Posted By: Posti_dup1

Re: Bump Mapping Shader - 01/30/04 17:39

ich hab das gerade eben mal ausprobiert aber ich seh nicht wirklich einen unterschied ich hab meine bild datei in adobe eingeladen und dort normal mapping gemacht und scale auf 10 gestellt in med hab ich einen würfel erstellt und der textur eins die textur verpaßt und der ebene 2 die normal map
aber ich sehe keinen unterschied die action hab ich meinem model auch hinzugefügt

i habe da noch eine frage will soll der shader mit map entitys funktionieren da ich denen ja keine 2 textur hinzufügen kann

thx
Posted By: robertternes

Re: Bump Mapping Shader - 02/02/04 02:00

Hallo!

Ich finde BumpMapping ganz OK, aber müssen es unbedingt Modelle sein? Ich hab nähmlich einen Raum (bzw. einen Cube) mit verschiedenen Texturen drauf, die eine Abbildung von Einritzungen darstellen sollen.
Da dachte ich mir, dass es bestimmt 100mal besser aussehen würde, wenn man da noch BumpMapping mit dazu nimmt.
Geht das auch mit Cubes, oder muss ich dann alle Räume als extra Modelle machen? Oder kann ich den Raum als Map-Entity speichern und da den Code drauflegen?
Posted By: oliver2s

Re: Bump Mapping Shader - 02/02/04 02:34

Ich habs zwar noch nicht getestet, aber mit Map-Entitys müsste es auch gehen, du musst nur vorher die Textur und die Normalmap als BMAP definieren und dann ganz oben im Material als Skin definieren, und im Effect String auch die "entSkin1" und "entSkin2" in "mtlSkin1" und "mtlSkin2" umbenennen.

Code:
bmap steine3DOT3 = <steine3DOT3.tga>;
bmap steine3 = <steine3.tga>;

Material Dot3Mapping
{
skin1 = steine3DOT3;
skin2 = steine3;
...
...
texture mtlSkin1;
texture mtlSkin2;
...
...
Texture[0] = <mtlSkin1>;
Texture[1] = <mtlSkin2>;
...
...
}


Posted By: Posti_dup1

Re: Bump Mapping Shader - 02/02/04 18:17

hei hab den shader endlich zum laufen gebracht beim code kopieren vom forum ist wohl ein fehler passiert ich find edie code funktion vom forum mist das der da alles auf eine zeile stezt nun auf jeden fall hab ich jetzt ein weiteres problem wen ich zum beispiel mein model rotieren laß wird der kohlraben schwarz ich hab auch schon das mit modulate2x ausprobiert hat nix gebracht
Posted By: robertternes

Re: Bump Mapping Shader - 02/03/04 01:01

Hallo!

Vielen Dank für die Antwort! Ich hätte da noch eine Frage: Mit welchem Programm kann ich diesen zweiten Skin für die Textur machen? Bitte Name des Progs und Link.

Und ist dass schon so im Script eingestellt, dass die textur gekachelt wird, doer wird sie der Länge und Breite langgezogen? Die textur müsste nähmlich gekachelt werden.
Posted By: oliver2s

Re: Bump Mapping Shader - 02/03/04 02:19

Links zu dem Prog ist irgendwo in dem Thread. Kannst aber auch den C-Script Befehl für Normalmaps benutzten, aber ich hab keine Ahnung wie der funzt. Ob die Texturen gekachelt sind weiß ich auch nicht, muss du ausprobieren.
Posted By: Zarg

Re: Bump Mapping Shader - 02/03/04 03:12

Hi!
Coole Sache dieses Bump Mapping. Ich hab mal den Code für Map-Entities ausprobiert, kompiliert alles, aber sobald das Programm Startet, gibt es einen Syntax-Error in diesen Zeilen:

skin1 = steine3DOT3;
skin2 = steine3;

Weiss jemand, woran das liegt?
Vielen Dank für eure Hilfe
Greetz
Zarg
Posted By: Posti_dup1

Re: Bump Mapping Shader - 02/03/04 04:16

@ oliver2s
könnte ich dir einmal ein paar screenshots von meinem Problem schicken da ich keinen webspace habe
Posted By: TheZero

Re: Bump Mapping Shader - 02/03/04 05:52

Für den Code brauchst du zwei Skins. Map-entitys haben nur eine Textur und das lässt sich auch nicht ändern. Der Shader funktioniert also nur mit Model-Entities!

Ich hab auch noch eine Frage:
Wiso unterstützt meine Grafikkarte diesen Effekt nicht?
Ich habe eine Gforce4 TI4200. Ich dachte die TI-Serie unterstützt Vertex und Pixel shading.
Posted By: Drew

Re: Bump Mapping Shader - 02/03/04 08:27

has anyone been able to get the ambient light value to work? also, reactive to shadowmaps?

Posted By: blaaaaa

Re: Bump Mapping Shader - 02/09/04 01:38

bei mir funtzt das komplett original sagenhaft GARNICHT
ich hab 1. skin ne normale textur und 2. skin ne normal map ( von adobe photoshop) nen würfel gegeben. dann hab ich den code geadded und wenn ich das level starte dann ist der würfel dunkel und mit lila,blau und grünen sachen da drin aber nicht das was sich eingendlich BUMP MAPPING NENNT !!!!!!! verdammt ich hab jetz endlich A6 2.20 pro und jetz geht das immer noch nicht wozu kauf ich mir denn diese sch***** alles kacke !!!!!!!!!!!!!!!! ich hätte mir besser ne GeforceFX5950Ultra dafür KAUFEN SOLLEN !!!!!!!!!!!!!!!!!!!!!
ok ich bin wieder ruhig, kennt jemand eine lösung für das problem ????
Posted By: oliver2s

Re: Bump Mapping Shader - 02/09/04 01:46

Vertausch mal die 2 Skins im Model. Nach deiner Beschreibung kann ich mir nur vorstellen das die Skins vertauscht sind.
Posted By: blaaaaa

Re: Bump Mapping Shader - 02/09/04 03:22

hab ich schon dann ist der würfel komplett schwarz ich kapier das nicht eigendlich müsste das doch gehen ....
Posted By: zero

Re: Bump Mapping Shader - 02/15/04 06:50

what part of this script tells the light where to come from? i thought it was the lightvec if it is i must have done sumthing wrong :-P
Posted By: Shurik

Re: Bump Mapping Shader - 03/05/04 00:55

code work fine, but models look so dark, also, when I place light this is not mapped on model
Posted By: Drew

Re: Bump Mapping Shader - 03/05/04 03:10

the shader only reacts to the sun light I believe...If we could get ambient light (so they are not so dark) and point lights to show, it would be fantastic...
The only way to use the shader right now is if you want to make a level with extreme contrast...like doom3.
Maybe one of the shader gurus can help out?
(I just remember that this might not be possible yet, until the new lighting system that conitec have forecast is released)


Posted By: danthaman015

Re: Bump Mapping Shader - 07/26/04 20:58

It seems no matter how bright I make the sun in my level the model is still as dark... so do we really have to wait until we get the new dynamic lighting system????
Posted By: oliver2s

Re: Bump Mapping Shader - 07/26/04 21:05

This shader don't react with any lighting, also not with a new lighting system.
Posted By: danthaman015

Re: Bump Mapping Shader - 07/26/04 21:45

So then wouldn't that make it kind of... useless?? All I can see is like a quarter of the model.. barely.. raising it's ambience and making it bright didn't do anything to it...
Posted By: Grimber

Re: Bump Mapping Shader - 08/06/04 08:59

This is my first try of any shader ( I don't know how shaders and materials work realy) but this one is effecting it with some sort of lightsource. I applied this shader to my planet earch model ( with a colored skin and a bumpmapped skin)

planet is lit by a dynamic light at level origin and planet rotates on its axis aprox once every minute. the lit up area on the model is also rotating around the model but at a slower rate then the model rotation speed ( imagine a flashlight orbiting the planet at a slower rate then 1 minute per orbit) thats the sort of effect I'm getting from this shader. any ideas what can be causing it?


earth model with bumpmap shader. lite up area not facing level origin


same model without shader effect on it at reversed angle from the above pic ( lit up area is facing dynamic light.)


bump mapped revese angle towards sun ( dynamic light) shows the lighted surface comaired to 1st pic shifts location.


BTW anyone know of a good effect to create a corona or flaring effect to the sun model?
Posted By: danthaman015

Re: Bump Mapping Shader - 08/06/04 16:54

Well for the sun I used a few transparent models that were slightly larger than the main sun model, and had them rotating at different speeds, which kind of made it look like it had a glow.

Notice the sun in the background here:

Posted By: BrainGamble

Re: Bump Mapping Shader - 02/10/05 01:36

Hallo oliver!

Habe GS A6 Com, upgedatet auf 6.3
wenn ich die engine starte bekomme ich eine Fehlermeldung:

Malfunction W1550

Error in effect:
bumpmap(52): error X3000: syntax error: unexpected token 'f'

Die fehlermeldung kommt aber erst wenn die engine gestarten ist !!!

Zwar öffnet sich das Spiel aber ich bemerke an dem Model keinen BumpMap effect:

Please Help :-)

PS: eine frage zum Update auf 6.3 : wie kann ich es einstellen das das spiel im Vollbild modus starten? Das dürfte sich geändert haben?!?
Posted By: oliver2s

Re: Bump Mapping Shader - 02/10/05 01:45

Der Shader funktioniert nur mit A6.22, man muss in ein bischen umschreiben damit der mit A6.31 (DX9) läuft.
Posted By: BrainGamble

Re: Bump Mapping Shader - 02/10/05 02:06

Hab jetzt auf 6.22 upgedatet.

Funzt jetzt nur is die engine so was von langsam nun (wenn das model im bild ist)

Am PC kanns nicht liegen, der is gut genug...
Posted By: Red Ocktober

Re: Bump Mapping Shader - 02/10/05 02:20

danthan... i think that you've gotta have a light emitting object with the following behavior in your scene, and set the light range so that it is greater than distance of the bumpmapped object...


var light_dist=80000;

action shader_light{
my.invisible=on;
my.passable=on;
while(1){
if vec_dist(my.x, camera.x)<light_dist{
my.light=on;
my.lightrange=60000;
my.red=255;
my.green=255;
my.blue=255;
}
else{
my.lightrange=0;
my.light=off;
my.cast=off;
}
wait(1);
}

just add this action to one a cube model, or any model you want to act as a light object... and place it in your scene near the object(s) you are using the bumpmapping shader on.

good luck
--Mike
Posted By: MASTERJUNOJET

Re: Bump Mapping Shader - 02/12/05 15:21

This code is really good ,one thing however, everything I apply this code to is really dark, I have adjusted my.albedo and my.ambient and all of those, however, it doesnt seem to be affected, how can I brighten up the objects I apply this to?
Posted By: Red Ocktober

Re: Bump Mapping Shader - 02/12/05 23:03

MJ... open up the shader code and look for a line in the first pass vertex shader function that looks like this...

float LightRange = 0.00some value;

try changing it to float LightRange = 0.00001;

i think this line determines the light falloff... and it may be a set a lil
high, causing the light to drop off before it reaches your normalmapped object.

also, make sure that the no fog property is set... and that you have a light emiiter object...

i hope this is of some help... i'm not the expert on this... just passing on
some stuff i struggled with that might not be so obvious...

good luck

--Mike
Posted By: MASTERJUNOJET

Re: Bump Mapping Shader - 02/14/05 13:09

I cant find that line in this bump map code, am I looking in the right code?
Posted By: Red Ocktober

Re: Bump Mapping Shader - 02/14/05 23:16

open the .fx file up in SED and look around line 74... in a section of code that looks like this...


Out.Tex=texcoord0.xy;
float3 PosWorld=mul(Pos,matWorld);
[u]float3 LightRange= 0.004;[/u]


simply do a text search for LightRange...

we are talking about the pix hsader 2.0 version of the ent bumpmapping code from the ultimate shader thread... aren't we...

--Mike
Posted By: MASTERJUNOJET

Re: Bump Mapping Shader - 02/15/05 12:02

Oh I was looking at a different code, could you perhaps give me a link to the one your talking about please?
Posted By: Red Ocktober

Re: Bump Mapping Shader - 02/15/05 23:19

sure... Matt's code is in the first post of this thread
Ultimate Shader Thread

go there and use your browser's edit/find on this page menu option to find the third oocurance of LightRange.

that thread has about all you need to implement the dx9c shaders... and this is where you'll find the code for entity as well as level geometry bump mapping implementation...

good luck

--Mike
Posted By: MASTERJUNOJET

Re: Bump Mapping Shader - 02/17/05 13:28

Thanks for all your help, I finally found it, didnt fix the dark problem though

Here is what I keep getting:





As you can see the lit areas look pretty good, so all that I need is to fix the dark.
Posted By: old_bill

Re: Bump Mapping Shader - 02/28/05 05:29

Has anyone converted this line to DX9:

Code:
VertexShaderConstant[18]={1f,1f,1f,1f};


because i get a crash there:

Malfunction W1550: Error in effect:
mat_bumpmap(28): error X3000: syntax error: unexpected token 'f'

> VertexShaderConstant[18]={1f,1f,1f,1f}; <

Thanks for any help!

old_bill
Posted By: Rhuarc

Re: Bump Mapping Shader - 02/28/05 05:40

With Dx9, the f suffix is only valid on floating point numbers (to my knowledge).

Try this:
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};


-Rhuarc
Posted By: old_bill

Re: Bump Mapping Shader - 02/28/05 05:57

Fixed that problem, now the next error appears:

Quote:


Malfunction W1550: Error in effect:
mat_bumpmap(47): error X5326: Read of uninitialized components(*) in v0: *x/0 *y/1 *z/2 *w/3
(48): error X5326: Read of uninitialized components(*) in v0: *x/0 *y/1 *z/2 *w/3
(49): error X5326: Read of uninitialized components(*) in v3: *x/0 *y/1 *z/2 w/3
(50): error X5326: Read of uninitialized components(*) in v7: *x/0 *y/1 *z/2 *w/3
(51): error X5326: Read of uninitialized components(*) in v7: *x/0 *y/1 *z/2 *w/3
(52): error X5326: Read of uninitialized components(*) in v7: *x/0 *y/1 *z/




Thanks
old_bill
Posted By: Rhuarc

Re: Bump Mapping Shader - 02/28/05 06:09

From the manual:
Quote:

Note that DX8 vertex shaders require a small modification for running
under DirectX 9. The following declaration:
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv 1
float v8[3]; //uv 2
}
has to be replaced by a DX9 declaration:
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8





-Rhuarc
Posted By: old_bill

Re: Bump Mapping Shader - 02/28/05 06:24

Thanks,
i've totaly forgotten this entry!
EDIT:
But it still wont work:
Quote:

Malfunction W1550: Error in effect:
mat_bumpmap(36): error X3000: syntax error: unexpected token 'v0'

> dcl_position v0 <




Setting to 0.0 did not help.

old_bill
Posted By: old_bill

Re: Bump Mapping Shader - 02/28/05 06:39

To make it more easyer to correct, where are possible DX9 problems in this code:
Code:
material mat_bumpmap
{
effect"

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

asm
{
vs.1.1
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}


action fx_bumpmaping
{
my.material = mat_bumpmap;
}



Thanks
old_bill
Posted By: Steempipe

Re: Bump Mapping Shader - 02/28/05 07:40

Make it like this:

Code:

asm {
vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8


.................



Posted By: old_bill

Re: Bump Mapping Shader - 02/28/05 20:44

Thanks Steempipe, this part works now!

But the next error lies here:
Code:
VertexShader =

asm
{
vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
-----------------------------------------------
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}



Downwards the red line several errors coming up:

Quote:

Malfunction W1550: Error in effect:
mat_bumpmap(65): error X5326: Read of uninitialized component(*) in r8: x/0 y/1 z/2 *w/3
(79): error X5430: When writing to scalar output register, mov instruction must use replicate swizzle on source parameter(s), in order to select single component. i.e. .x | .y | .z | .w (or rgba equivalent)

> mov r2, r8 <




Please excuse my kind of ignorance, but i have absolutley no knowledge of shaders.

old_bill
Posted By: Rhuarc

Re: Bump Mapping Shader - 03/01/05 06:11

This error is saying that r2 needs to have a "swizzle" on it that grabs only part of it.
Code:
mov r2.w,r8



I'm not sure what it's supposed to be, try using x, y, and z in place of W if the shader doesn't operate properly . I'd have to look at the rest of the code to figure it out and ASM makes me dizzy (I made Phoenix 2 for TI-89... all 68k asm.... YUCK! )

-Rhuarc
Posted By: MASTERJUNOJET

Re: Bump Mapping Shader - 03/03/05 11:54

So no one knows why Im gettin all this dark stuff?
Posted By: indiGLOW

Re: Bump Mapping Shader - 03/28/05 20:44

Yeah I had the same problems trying to use the 2.0 version on my radeon 9800 pro, and just like old_bill I can't get it to work....

In all honesty I have been trying to implement any shader today, including the code from the manual for a basic bump map shader and im struggling there...

If anyone knows how to solve the problems Old Bill mentions and or someone wants to take the time to help me get ANY shader running I would really appreciate it....

Last year I managed to get the multi texture terrain working, but since then lots of new stuff is out there, at the time I think it was like pixel shader 1.4 or something... so its been a while and it looks like everything I learned then (which was not a gr8 load) has flown the rusty old brain...
Posted By: Steempipe

Re: Bump Mapping Shader - 03/29/05 10:35

Man.... these codes are old.

However, this is what I was using at one point.

If it helps anyone, great.

Code:
 
////////////////////////////////////////////////////
//
// Basic Dot3 Bumpmapping.
//
// Calulates diffuse lighting from Sun and Level Light
//
// Needs: A6.31 Comm+ DX9c vertexshader.1.1
//
// Todo: Lighting improvements
//
// Eric Hendrickson-Lambert (Steempipe)
//
// 3/28/05: Made changes for DX9 A6

material mat_bumpmap
{

flags=tangent;

effect="

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1; //Colormap
texture entSkin2; //Normalmap

vector vecLight;
vector vecFog;
vector vecSunDir;

technique dot3mapping
{
pass p0
{

AlphaBlendEnable = False;
AlphaTestEnable = False;
Lighting = True;
DitherEnable = True;

Texture[0] = <entSkin2>;
Texture[1] = <entSkin1>;

ColorOp[0] = Dotproduct3;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;

ColorOp[1] = Modulate;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;

vertexShaderConstant[9]= <vecFog>;
vertexShaderConstant[10]=<vecSunDir>;
vertexShaderConstant[11]=<vecLight>;
VertexShaderConstant[12]={0.5f, 0.5f, 0.0f, 0.0f};

VertexShader =
asm
{

vs_1_1

// Declarations
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

// Transform position to clip space
m4x4 oPos, v0, c0

// Tranform normal and tangent to world space
m3x3 r3, v8, c4
m3x3 r5, v3, c4

// Compute binormal
mul r0, r3.zxy, r5.yzx
mad r4, r3.yzx, r5.zxy, -r0

// Transform (Sun)light vector to tangent space
dp3 r0.x, r3.xyz, -c10
dp3 r0.y, r4.xyz, -c10
dp3 r0.z, r5.xyz, -c10

// Normalize transformed light vector
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w

// Put light vector in range from 0 to 1
mad r0, r0, c12.x, c12.x
// Adjust the intensity
mul r0, r0, c12.y
// Add environment light then send it down the diffuse pipe
add oD0.xyz,r0,c11

// Fog calculations
mov r1.w,c9.w
dp4 r0,v0,c6 // distance to camera position
add r0,r0,-c9.x // distance-fog_start
mad r0.x,-r0.x,c9.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog,r0.x,c12.w // clamp with custom max value

// Pass the texture coordinates through
mov oT0, v7
mov oT1, v7
};
}
}
";
}



action fx_bumpmaping
{
my.material = mat_bumpmap;
}




Posted By: indiGLOW

Re: Bump Mapping Shader - 03/29/05 19:08

Thanks Steampipe, I will give it a go later today. Wonder if I will manage anything more than black!
Posted By: indiGLOW

Re: Bump Mapping Shader - 03/30/05 19:37

Thanks Steampipe, that worked just great for me.

Thanks for getting me back to at least being able to add a material!

I notice that my normal map doesnt seem to make it very obvious that it is bumpy, is there a way to force the depth? So that the raised areas are more...raised and the depth is deeper

Is it just a matter of changing the normal map? I have tried fiddling with the Nvidia Normal plugin for Adobe but have yet to tackle the Studio Max Normal map tools, and i dont seem to be able to get exagerated bump mapping. Any suggestions?
Posted By: Grimber

Re: Bump Mapping Shader - 03/31/05 02:31

i tried your shader, i can't seem to get any real effect out of it otehr then reduction in frame rate.

I used the photoshop nvidia plug in to generate a normal map

from the normal standard wad texture assigned that to entskin1

and the normal map assigned that to entskin2


then assigned the material to a map entity I textured with the stone texture ( block on the right side) block wall behind it textured with same texture for compairison



do they both need to be the same format? tga bmp ?
do I need to crop the normal map or is my normal map not normalized enough?

sorry i don't know realy anything on shaders but i didn't notice any differance
Posted By: Steempipe

Re: Bump Mapping Shader - 03/31/05 04:06

indiGLOW: Adjusting your normalmap will need to be done. There is no real "depth" adjustment. There is not even specular or self-shadowing in this effect so it is pretty basic.

Grimber: To me it seems a combination of normalmap values, and possible the overall light directions.
1). try changing c12.y in the vertexShaderConstants to a lower number like 0.2 and see what happens. vertexShaderConstant[n] = {x, y, z, w,};
2). Change the sun position and elevation and see what effect that has.
3). Play with the normalmap.

Both textures do not need to be the same format (ie; bmp or tga only).

My cube on the left has no normalmap, just entSkin1 applied.
My cube on the right has the normalmap in entSkin2 applied to entSkin1.



Eric
Posted By: Grimber

Re: Bump Mapping Shader - 03/31/05 05:11

well tried all that, even using a dynamic light and no change.
mabey its my video card its just too old for shaders? XFX geforce 5200?

or mabey its just my pick of textures. Ill try some other texture later on.

Edited

Dah never mind IF i had read back further in the thread, I would have realised this is for models only .

soon as I changed it to a model and applyed both skins to the mdl it worked
had to go back and make a new normal map because it had too much depth
( on the nvidia plug in for photoshop, adjust the "Scale" value to get more depth, but surface also gets darker)




scale of 5



scale of 15


Added

Hehe so happy i made this work went and tried it on my Earth and Moon models for my space game. Think they look better. have to do something about the darkness but thats minor


Posted By: Steempipe

Re: Bump Mapping Shader - 03/31/05 10:38

Glad you got it working. Some small changes to the material need to be done if you want the effect on level geometry.

Possibly the effect you are envisioning might require a bit of tweaking on a per planet basis in the vertexshader and/or texture stages. You may even want to make a pixelshader version at some point that will give you more flexibility in your color operations.

I do like the moon very much
Posted By: Grimber

Re: Bump Mapping Shader - 03/31/05 13:43

would it be difficult to modify it to work with the d3d_automaterial =1 (level geometry) or 2 (geometry and models) so it works on the level geometry textures? hehe thats wat i was trying to do at the very first with the shader. tried to directly assign the textures through script:

bmap entSkin1 = <stoneblocks.bmp>;
bmap entSkin2 = <stoneblocks.tga>;

then renamed the material effect to:

material stoneblocks_bmp

which is suppost to be how your suppost to get a material to work on geometry textures. at least to define it to the automaterials
Posted By: indiGLOW

Re: Bump Mapping Shader - 03/31/05 21:43

I have a couple of questions, mainly to do with lighting.

I noticed that the material doesn't seem to work with lights in the level, I added a green, blue and red light and the material didnt take these into account. Is there a way to change this?

Also there didnt appear to be any kind of hi-lights, I would like to see metalic like surfaces and shiny wet surfaces....I have seen some of these in the ultimate shader pack so maybe now that I have some form of shaders working I will revisit that...

Is there a way to combine several shader effects into one material? I am guessing not...

The last thing is that I noticed that as my model was in a spin, the normal map seemed to work in reverse at some times, the optical illusion that is used to create depth, when inverted (i.e upside down), seems to create the opposite effect...

I will dig out some screen shots of what I mean....


In the upper areas of the block, it looks like the veins are raised, yet in the lower part the opposite is true... or is it my eyes playing tricks
Posted By: indiGLOW

Re: Bump Mapping Shader - 03/31/05 23:32

Here is a shot about the lighting question.


The blocks on the right have no shader. The top two blocks, it is hard to see the bump map working as the bump map matches the texture, however the lower two show the bump clearer.

There is a dynamic light model that is emmiting a blueish light, which can be seen on both the non-shader versions on the right, where as the left pair only seem to be illuminated based on the suns location, which is set to 0,0,0 in this example. The light follows the cameras location and angles.

I will take a look at some of the other shader threads here and see what I can learn. I posted these shots for reference.
Posted By: Steempipe

Re: Bump Mapping Shader - 04/01/05 10:09

Grimber:
Applying the FX to the level would not be all that hard. However, I think that a fast reply is not going to help you. There are a few things to consider that will help with the performance when applying an FX to level geometry.
If I can find some time I will work something out. Right now there are things on my list to followup on and very little time.

indiGLOW:
For the dynamic lighting you would need to incorporate the dynamic light positions into the shader code. Some other things that I have never worked out was successfully getting the level light and ambient colors into the diffuse. I had to resort to hard coding those typse of values in.
For static lights you would also need to incorporate something into the shader code. I cannot find the code I had where I had made progress on these particular things. I believe it to be nixed from my computer. Which is very, very bad.

The Hi-lights/specular you refer to will have to be coded into the shader. A gloss/specular or darkmapping type thing is not in the code I put here. This code had been abandoned.

By multi-passing you can combine some things. With FFP it is easier to use the framebuffer continually down the passes. With the vetex/pixel shaders it is not always the case unless you can pass the result from the previous pass into a texture. Also I have noticed that alot of codes will render_mesh, render_technique, render_mesh, render_technique. And so on, blending as they go.

I think that the other issues you wrote about are based on the normals. So depending on the orinetation to the light source/model normals you might see some difference in the bumpmapping. I can't make out from your screenshot so well.

There tends to be the need to tweak things per model and particular situation, which is no big deal if you know what you're tweaking and what you want to accomplish. But it can be tedious at best if you do not know.
Posted By: Steempipe

Re: Bump Mapping Shader - 04/03/05 11:00

Quote:

would it be difficult to modify it to work with the d3d_automaterial =1 (level geometry) or 2 (geometry and models) so it works on the level geometry textures? hehe thats wat i was trying to do at the very first with the shader. tried to directly assign the textures through script:

bmap entSkin1 = <stoneblocks.bmp>;
bmap entSkin2 = <stoneblocks.tga>;

then renamed the material effect to:

material stoneblocks_bmp

which is suppost to be how your suppost to get a material to work on geometry textures. at least to define it to the automaterials




I added a small tutorial to the WIKI that I hope may help you out.
From the main page it is under... Resources/Tutoruals/Effects
Posted By: Grimber

Re: Bump Mapping Shader - 04/06/05 22:29

Thanks for putting up that Steempipe. I gave it a try ( even used the church you used for example) and it worked nice. but i ran into this problem. after running it once and tried to re run it I would get some very odd errors. rebooted my computer, would run fine again Once. then the same errors.

My guess is the fx file is setting soemthing in my video card then not releasing it after it runs? donno just guessing here...

error is typicaly this....
W1550
Error in effect:
floor1(26): error X3004: undeclaired identifier 'vecLight'

sometimes its wall3(26) error X3004: undeclaired identifier 'vecLight'
Posted By: Steempipe

Re: Bump Mapping Shader - 04/07/05 04:44

Thats strange. Maybe put a "wait" after each instance of loading the effect?? If that does not work, then try changing the <vector>'s to <float4>'s??

Let me know what fixes it if you can so that I can update the code. Thanks.

Eric
Posted By: Grimber

Re: Bump Mapping Shader - 04/07/05 07:50

well found the prolem after looking into the .fx file the: vector vecLight; was missing, script gremlins actualy when i pasted it in a text file, the declaration ended up nested behind the comment line above it

runs every time, but its all dark ( sun set at 80 elevation 110 on R G and B then lowered sun elevation to 45 still dark ) and both textures turning out pitch black ( REALY close I can see the bump mapping which looks REALY good) what do i adjust to lighten it up? does it need a dynamic light(s) besides teh sunlight?

can at last tell its running frame rate facing the chursh is 30 ish. look away jumps to around 80 ( normal frame rate i usualy get)
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/24/05 04:00

I got bored and decided to try and update this old shader to dx9.
There's one problem though... I don't know how to do the swizzle.
I would be very gratefull if someone shows me how to do it... and shows me how to figure out what the swizzle would be in the first place.

here is the code:

material bumpmap
{
effect ="

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate2x;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

VertexShader = asm
{
vs.1.1
dcl_position v0; //Position
dcl_normal v3; //Normal
dcl_texcoord0 v7; //Textur Koordinaten 0
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m4x4 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2.w,r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}";
}
Posted By: Daedelus

Re: Bump Mapping Shader - 06/24/05 06:53

Maybe this link will offer clues for somebody about the "swizzle".
Can't say I fully understand this yet. Maybe I'll look for it on the MSDN pages later.

http://www.gamedev.net/columns/hardcore/dxshader3/page4.asp
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/24/05 19:13

I have stopped the "read of unititialized components in r2" by placing r2.xyzw.
I still get an error though:

Error in effect:
bumpmap(74): error X5430: When writing to scalar output register, mov instruction must use replicate swizzle on source parameter(s), in order to select single component. i.e. .x|.y|.z|.w|(or rgba equivalent)


matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

VertexShader = asm
{
vs.1.1
dcl_position v0; //Position
dcl_normal v3; //Normal
dcl_texcoord0 v7; //Textur Koordinaten 0

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m4x4 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2.xyzw, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3.w
mov oFog,c90
};
}
}
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/25/05 05:31

I am still having no luck with this...
Posted By: Stansmedia

Re: Bump Mapping Shader - 06/27/05 11:22

Quote:

I tried that bump mapping code. But it gave me an error message when I looked at it: BUMP MAPPING: NOT SUPPORTED BY HARDWARE...
Not supported my ass, ive got a geforce 4 128 mb of vram. Like, my max has bump mapping and stuff, so why is 3dgs complaining? Can somebody help? I want shaders

(im a total shader noob btw... so, help is good )




Holy crap i was an idiot.
Posted By: ello

Re: Bump Mapping Shader - 06/27/05 12:57

Quote:

I have stopped the "read of unititialized components in r2" by placing r2.xyzw.
I still get an error though:

Error in effect:
bumpmap(74): error X5430: When writing to scalar output register, mov instruction must use replicate swizzle on source parameter(s), in order to select single component. i.e. .x|.y|.z|.w|(or rgba equivalent)


matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

VertexShader = asm
{
vs.1.1
dcl_position v0; //Position
dcl_normal v3; //Normal
dcl_texcoord0 v7; //Textur Koordinaten 0

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m4x4 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2.xyzw, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3.w
mov oFog,c90
};
}
}




place mov oFog,c90.x
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/27/05 19:26

Thanks so much ello.
I think I am starting to understand this swizzle thing a little better...

Now the colorOp and colorArgs are giving me trouble...
They belong in the pass though right?
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/27/05 23:14

Okay... it actually runs now...

the colorOps and colorArgs had to go after the vertexShaderConstants.


but it shows up as just black...
Maybe it's just my card... it's been acting up...

Please test it and post your results.



MATERIAL bumpmap
{
effect
"
matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

colorOp[0] = DotProduct3;
colorArg1[0] = Texture;
colorArg2[0] = Diffuse;
colorOp[1] = Modulate;
colorArg1[1] = Texture;
colorArg2[1] = Current;

VertexShader = asm
{
vs.1.1
dcl_position v0; //Position
dcl_normal v3; //Normal
dcl_texcoord0 v7; //Textur Koordinaten 0

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m4x4 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2.xyzw, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3.w
mov oFog,c90.x
};
}
}
";
}


action normalMap_ent
{
my.material = bumpmap;
}
Posted By: Inestical

Re: Bump Mapping Shader - 06/28/05 14:17

it's black with me too
Posted By: nightshade

Re: Bump Mapping Shader - 06/28/05 14:51

Dito, bei mir auch .
Posted By: nightshade

Re: Bump Mapping Shader - 06/28/05 15:51

Sorry für Doppelpost, aber geht Steempipes Shader :

Code:
 

material mat_bumpmap
{

flags=tangent;

effect="

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1; //Colormap
texture entSkin2; //Normalmap

vector vecLight;
vector vecFog;
vector vecSunDir;

technique dot3mapping
{
pass p0
{

AlphaBlendEnable = False;
AlphaTestEnable = False;
Lighting = True;
DitherEnable = True;

Texture[0] = <entSkin2>;
Texture[1] = <entSkin1>;

ColorOp[0] = Dotproduct3;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;

ColorOp[1] = Modulate;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;

vertexShaderConstant[9]= <vecFog>;
vertexShaderConstant[10]=<vecSunDir>;
vertexShaderConstant[11]=<vecLight>;
VertexShaderConstant[12]={0.5f, 0.5f, 0.0f, 0.0f};

VertexShader =
asm
{

vs_1_1

// Declarations
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

// Transform position to clip space
m4x4 oPos, v0, c0

// Tranform normal and tangent to world space
m3x3 r3, v8, c4
m3x3 r5, v3, c4

// Compute binormal
mul r0, r3.zxy, r5.yzx
mad r4, r3.yzx, r5.zxy, -r0

// Transform (Sun)light vector to tangent space
dp3 r0.x, r3.xyz, -c10
dp3 r0.y, r4.xyz, -c10
dp3 r0.z, r5.xyz, -c10

// Normalize transformed light vector
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w

// Put light vector in range from 0 to 1
mad r0, r0, c12.x, c12.x
// Adjust the intensity
mul r0, r0, c12.y
// Add environment light then send it down the diffuse pipe
add oD0.xyz,r0,c11

// Fog calculations
mov r1.w,c9.w
dp4 r0,v0,c6 // distance to camera position
add r0,r0,-c9.x // distance-fog_start
mad r0.x,-r0.x,c9.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog,r0.x,c12.w // clamp with custom max value

// Pass the texture coordinates through
mov oT0, v7
mov oT1, v7
};
}
}
";
}



action fx_bumpmaping
{
my.material = mat_bumpmap;
}




Auch für Levelgeometrie? Geht ja normal, aber wie? Sorry bin noob in Shadern;).

MfG, reaver
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/28/05 18:44

Ok... since the shader is black for all of you as well I must have done something wrong...

I guess I'll just keep working on it.
Posted By: Inestical

Re: Bump Mapping Shader - 06/28/05 18:51

aighty i want to get the code asap
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/29/05 02:57

Quote:

aighty i want to get the code asap




I hope to have it finished asap...
I have no idea what's causing this though.
Posted By: Inestical

Re: Bump Mapping Shader - 06/29/05 05:22

which part of the code actually puts the bumpmapping-effect on the cube

EDIT: I can get it working with this:
Code:

ColorOp[0] = Modulate;
ColorArg1[0] = Texture;
ColorArg2[0] = Current;

ColorOp[1] = Bumpenvmap;
ColorArg1[1] = Texture;
ColorArg2[1] = Diffuse;


But it won't show the bumpmapefftect well..
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/29/05 08:22

Quote:

which part of the code actually puts the bumpmapping-effect on the cube

EDIT: I enbled AlhpaBlendEnable and i got the bumpmapping effect. but there is no colors.




@ whine that's not the shader I am trying to convert... that's the one Reaver posted... the bumpmapping with show up even with alphaBlendEnable = false.
I don't understand why Reaver posted that... it's off topic...

Here's my code:

MATERIAL bumpmap
{
flags=tangent;

effect ="
texture entSkin1;
texture entSkin2;
matrix matWorldViewProj;
matrix matWorld;
vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

ColorOp[0] = DotProduct3;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;
ColorOp[1] = Modulate2x;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist


VertexShader = asm
{
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m4x4 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2.xyzw, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3.w
mov oFog,c90.x
};
}
}
technique fallback
{
pass P0
{
//set texture stage states
Texture[1] = <entSkin1>;
ColorArg1[1] = Texture; // stage 0 = skin texture
ColorOp[1] = Modulate;
ColorArg2[1] = Diffuse; // modulate by lighting

}
}
";
}
Posted By: Inestical

Re: Bump Mapping Shader - 06/29/05 08:28

oh ok
Posted By: nightshade

Re: Bump Mapping Shader - 06/29/05 10:58

omg, I only want to use Steempipes Shader on level-geometry, is it to many?
(pls post a script)
thanks, Reaver.

EDIT : Look on the search-function, and type in "shader collection". theres a demo with bump-mapping shader on blocks (not map-entitys). But the file isn't not on the server, admin removed it .
Posted By: ello

Re: Bump Mapping Shader - 06/29/05 11:04

better say goodbye to that idea. it is getting miles too slow. just be patient and wait for matt to complete his dll and than you will have anything you want. in the meantime start converting your level to mdl-based level
Posted By: nightshade

Re: Bump Mapping Shader - 06/29/05 11:42

bahnhof????
Nein ich will nur die .zip haben, weil bei mir alle Shader gingen und auf Modells nur Shaders is umständlich;).

EDIT : Habe sie:); hat sich erledigt .
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 06/29/05 19:12

@ Reaver if you could accept private messages I would send you a bumpmapping shader that works on level geometry for you to play around with. With Steempipes shader there is no lighting and the block have to be set to flat mode... so I won't give you that one...

Both of these bumpmapping shaders that work on geometry aren't really worth it and are sorta slow and you can do the same thing in photoshop... the bumps arent dynamic and don't react so light positions... the bump stay the same.
Posted By: nightshade

Re: Bump Mapping Shader - 06/30/05 09:56

Ok, thanks for the tips. I dont know, who changed the settings, that I cannot accept pm's. But I changed it, so you can send it.
Reaver
Posted By: Marcio Esper

Re: Bump Mapping Shader - 07/02/05 06:35

Hi,

Very cool effect.

It is possible to use shaders with a comercial edition of game studio A6 or just in the professional edition it can be used ?

I try to use this code in a test but I get an error when the program start.

Thank you for atention and sorry the terrible english.

Best regards,

Marcio
Posted By: Josh_Arldt

Re: Bump Mapping Shader - 07/02/05 06:44

You can use this effect in the commercial edition.
You need to have the latest update and DX9 installed.
Posted By: fear

Re: Bump Mapping Shader - 03/05/06 16:46

funktioniert das auch mit der standart version?
bei mir kommt da immer ein error...
Posted By: broozar

Re: Bump Mapping Shader - 03/05/06 16:53

nein, ab comm.
© 2024 lite-C Forums