|
Re: Bump Mapping Shader
[Re: nightshade]
#22262
06/28/05 15:51
06/28/05 15:51
|
Joined: Mar 2003
Posts: 1,095 Germany
nightshade
Serious User
|
Serious User
Joined: Mar 2003
Posts: 1,095
Germany
|
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
|
|
|
Re: Bump Mapping Shader
[Re: Inestical]
#22265
06/29/05 02:57
06/29/05 02:57
|
Joined: Sep 2004
Posts: 1,214 Austin, Texas
Josh_Arldt
Senior Developer
|
Senior Developer
Joined: Sep 2004
Posts: 1,214
Austin, Texas
|
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.
|
|
|
Re: Bump Mapping Shader
[Re: Josh_Arldt]
#22266
06/29/05 05:22
06/29/05 05:22
|
Joined: Apr 2005
Posts: 3,815 Finland
Inestical
Rabbit Developer
|
Rabbit Developer
Joined: Apr 2005
Posts: 3,815
Finland
|
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..
Last edited by Whine; 06/29/05 08:26.
"Yesterday was once today's tomorrow."
|
|
|
Re: Bump Mapping Shader
[Re: Inestical]
#22267
06/29/05 08:22
06/29/05 08:22
|
Joined: Sep 2004
Posts: 1,214 Austin, Texas
Josh_Arldt
Senior Developer
|
Senior Developer
Joined: Sep 2004
Posts: 1,214
Austin, Texas
|
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
} } "; }
|
|
|
Re: Bump Mapping Shader
[Re: Inestical]
#22269
06/29/05 10:58
06/29/05 10:58
|
Joined: Mar 2003
Posts: 1,095 Germany
nightshade
Serious User
|
Serious User
Joined: Mar 2003
Posts: 1,095
Germany
|
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 .
Last edited by Reaver; 06/29/05 11:07.
|
|
|
|