|
normal maps
#59565
11/25/05 17:50
11/25/05 17:50
|
Joined: Jul 2002
Posts: 1,364 Minbar
MaxF
OP
Serious User
|
OP
Serious User
Joined: Jul 2002
Posts: 1,364
Minbar
|
Hi All Done a few searchs but can't find any. Does anyone have a good normal maps for models script. Thanks
|
|
|
Re: normal maps
[Re: Sebe]
#59570
11/27/05 09:34
11/27/05 09:34
|
Joined: Oct 2003
Posts: 1,550 United Kingdom
indiGLOW
Serious User
|
Serious User
Joined: Oct 2003
Posts: 1,550
United Kingdom
|
In all honesty I have had similiar problems locating a normal shader here, I found a few older ones that worked, I had to expand my search and what I did find was full of bugs anyway. I have noticed a lot of people asking this question and being given the same answer...search for it! lol I think you can find a Normal shader in the Wiki, so If I was you, and you are having the same problems finding any others, use the one in the Wiki Hope thats a little more helpful to ya!
The Art of Conversation is dead : Discuss
|
|
|
Re: normal maps
[Re: indiGLOW]
#59571
11/27/05 19:16
11/27/05 19:16
|
Joined: Aug 2005
Posts: 34
AAO
Newbie
|
Newbie
Joined: Aug 2005
Posts: 34
|
Hey I found a specular bump mapping shader on the search here it is
float bumpiness = { 1.0f }; //Stärke des Bumpmappings float specular_power = { 128.0f }; //Stärke des Lichts (1 = sehr stark, über 1 schwächer) float Ka = { 1.0f }; //Gesamthelligkeit float4 specular = { 1.0f, 0.956737f, 0.670380f, 1.0f }; //Specular Farbe float4 ambient = { 0.37647f, 0.37647f, 0.24314f, 1.0f }; //Ambient Farbe alt: alles 1.0f float4 diffuse = { 0.37647f, 0.37647f, 0.24314f, 1.0f }; //Diffuse Farbe alt: 0.839216f, 0.862341f, 0.890411f, 1.0f
float Kd = { 1.0f }; float Ks = { 1.0f }; float4 light_position = { -100.0f, 100.0f, -100.0f, 1.0f }; float4 eye_position = { 0.0f, 0.0f, -10.0f, 1.0f }; float4 vecViewPos; float4 vecSunDir; float4 vecAmbient; float4x4 matWorldViewProj: register(c0); float4x4 matMtl; texture entSkin1; texture entSkin2; struct VS_INPUT_STRUCT { float4 position: POSITION; float3 normal: NORMAL; float2 texcoord0: TEXCOORD0; float3 binormal: TEXCOORD1; float3 tangent: TEXCOORD2; }; struct VS_OUTPUT_STRUCT { float4 position: POSITION; float2 bump_map: TEXCOORD0; float3 light_vector: TEXCOORD1; float3 half_angle: TEXCOORD2; }; VS_OUTPUT_STRUCT VS( VS_INPUT_STRUCT vsInStruct ) { VS_OUTPUT_STRUCT vsOutStruct; //** Declare the output struct //**----------------------------------------------------------- //** Calculate the pixel position using the perspective matrix. //**----------------------------------------------------------- vsOutStruct.position = mul(vsInStruct.position, matWorldViewProj ); //**---------------------------------------------- //** Pass the bump and base texture coords through //**---------------------------------------------- vsOutStruct.bump_map = vsInStruct.texcoord0; //**-------------------------------------------- //** Calculate the light vector in object space, //** and then transform it into texture space. //**-------------------------------------------- float3 temp_light_position = mul( vecAmbient, matMtl ); float3 temp_light_vector = temp_light_position - vsInStruct.position; vsOutStruct.light_vector.x = dot( temp_light_vector, vsInStruct.tangent ); vsOutStruct.light_vector.y = dot( temp_light_vector, vsInStruct.binormal ); vsOutStruct.light_vector.z = dot( temp_light_vector, vsInStruct.normal ); //**------------------------------------------- //** Calculate the view vector in object space, //** and then transform it into texture space. //**------------------------------------------- float3 temp_eye_position = mul( vecViewPos, matMtl ); float3 temp_view_vector = temp_eye_position - vsInStruct.position; float3 temp_view_vector2; temp_view_vector2.x = dot( temp_view_vector, vsInStruct.tangent ); temp_view_vector2.y = dot( temp_view_vector, vsInStruct.binormal ); temp_view_vector2.z = dot( temp_view_vector, vsInStruct.normal ); //**------------------------- //** Calculate the half angle //**------------------------- vsOutStruct.half_angle = vsOutStruct.light_vector + temp_view_vector2; return vsOutStruct; //** Return the resulting output struct } sampler base_map = sampler_state { texture=(entSkin1); MAGFILTER = LINEAR; MINFILTER = LINEAR; MIPFILTER = LINEAR; }; sampler bump_map = sampler_state { texture=(entSkin2); MAGFILTER = LINEAR; MINFILTER = LINEAR; MIPFILTER = LINEAR; }; struct PS_INPUT_STRUCT { float2 bump_map: TEXCOORD0; float3 light_vector: TEXCOORD1; float3 half_angle: TEXCOORD2; }; struct PS_OUTPUT_STRUCT { float4 color0: COLOR0; }; //**--------------------------------------------------------- //** Function: main //** Description: Declare the main entry point for the shader //** Input: PS_INPUT_STRUCT, derived from the output of //** the associated vertex shader //** Returns: PS_OUTPUT_STRUCT //**--------------------------------------------------------- PS_OUTPUT_STRUCT PS( PS_INPUT_STRUCT psInStruct ) { PS_OUTPUT_STRUCT psOutStruct; //** Declare the output struct //**------------------------------------------------------ //** Retreive the base color and bump components from the //** respective textures, based on the passed bump coords. //**------------------------------------------------------ float3 base = tex2D( base_map, psInStruct.bump_map ); float3 bump = tex2D( bump_map, psInStruct.bump_map ); //**---------------------------------------------------- //** Normalize the passed vectors from the vertex shader //**---------------------------------------------------- float3 normalized_light_vector = normalize( psInStruct.light_vector ); float3 normalized_half_angle = normalize( psInStruct.half_angle ); //**-------------------------------------------------------- //** "Smooth out" the bump based on the bumpiness parameter. //** This is simply a linear interpolation between a "flat" //** normal and a "bumped" normal. Note that this "flat" //** normal is based on the texture space coordinate basis. //**-------------------------------------------------------- float3 smooth = { 0.5f, 0.5f, 1.0f }; bump = lerp( smooth, bump, bumpiness ); bump = normalize( ( bump * 2.0f ) - 1.0f ); //**--------------------------------------------------------- //** These dot products are used for the lighting model //** equations. The surface normal dotted with the light //** vector is denoted by n_dot_l. The normal vector //** dotted with the half angle vector is denoted by n_dot_h. //**--------------------------------------------------------- float4 n_dot_l = dot( bump, normalized_light_vector ); float4 n_dot_h = dot( bump, normalized_half_angle ); //**-------------------------------------- //** Calculate the resulting pixel color, //** based on our lighting model. //** Ambient + Diffuse + Specular //**-------------------------------------- psOutStruct.color0.rgb = ( base * ambient * Ka ) + ( base * diffuse * Kd * max( 0, n_dot_l ) ) + ( specular * Ks * pow( max( 0, n_dot_h ), specular_power ) ); psOutStruct.color0.a = 1.0f; //** Set the alpha component manually return psOutStruct; //** Return the resulting output struct }
technique spec_bump { pass Single_Pass { VertexShader = compile vs_2_0 VS(); PixelShader = compile ps_2_0 PS(); } }
|
|
|
Re: normal maps
[Re: MaxF]
#59573
12/05/05 20:24
12/05/05 20:24
|
Joined: Nov 2004
Posts: 7,121 Potsdam, Brandenburg, Germany
Machinery_Frank
Senior Expert
|
Senior Expert
Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
|
No, you can do dot3 bump mapping via the fixed function pipeline for models as well. This is a good fall back technique when the target system does not support normalmapping via vs/ps shaders.
A6 has problems with shaders on blocks. So I would suggest to use it on models for now.
Models, Textures and Games from Dexsoft
|
|
|
|