2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Bump Mapping Shader
#22140
01/16/04 22:22
01/16/04 22:22
|
Joined: Aug 2002
Posts: 3,258 Mainz
oliver2s
OP
Expert
|
OP
Expert
Joined: Aug 2002
Posts: 3,258
Mainz
|
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
};
}
}
Last edited by [Rhuarc]; 07/24/04 00:06.
|
|
|
Re: Bump Mapping Shader
[Re: oliver2s]
#22141
01/16/04 22:28
01/16/04 22:28
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
Senior Expert
|
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
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..
Last edited by ello; 01/16/04 22:29.
www.earthcontrol.dequoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
|
|
|
Re: Bump Mapping Shader
[Re: oliver2s]
#22143
01/16/04 23:00
01/16/04 23:00
|
Joined: Aug 2002
Posts: 3,258 Mainz
oliver2s
OP
Expert
|
OP
Expert
Joined: Aug 2002
Posts: 3,258
Mainz
|
[Edited by Rhuarc] Code updated in first post.
Last edited by [Rhuarc]; 01/17/04 10:06.
|
|
|
Re: Bump Mapping Shader
[Re: oliver2s]
#22144
01/16/04 23:35
01/16/04 23:35
|
Joined: Oct 2002
Posts: 8,939 planet.earth
ello
Senior Expert
|
Senior Expert
Joined: Oct 2002
Posts: 8,939
planet.earth
|
btw. this looks extremely near like what was shown here . maybe you place a shot with texture?
www.earthcontrol.dequoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
|
|
|
Re: Bump Mapping Shader
[Re: ello]
#22145
01/17/04 01:33
01/17/04 01:33
|
Joined: Aug 2002
Posts: 3,258 Mainz
oliver2s
OP
Expert
|
OP
Expert
Joined: Aug 2002
Posts: 3,258
Mainz
|
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.
Last edited by [Rhuarc]; 07/24/04 00:07.
|
|
|
Re: Bump Mapping Shader
[Re: ello]
#22147
01/17/04 01:51
01/17/04 01:51
|
Joined: Apr 2002
Posts: 4,801 Richmond B.C., Canada
Captain_Kiyaku
Dichotomic
|
Dichotomic
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
|
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!
My Blog"Tag und Nacht schrei ich mich heiser, Wind weht alle Worte fort, Tag und Nacht schrei ich mein Krähenwort!"Subway To Sally - Krähenkönig
|
|
|
Re: Bump Mapping Shader
[Re: ello]
#22148
01/17/04 01:54
01/17/04 01:54
|
Joined: Aug 2002
Posts: 3,258 Mainz
oliver2s
OP
Expert
|
OP
Expert
Joined: Aug 2002
Posts: 3,258
Mainz
|
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
Last edited by oliver2s; 01/17/04 01:58.
|
|
|
|