2 registered members (AndrewAMD, Ayumi),
1,405
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Help with material error (maybe s my fault!)
#160099
10/10/07 03:04
10/10/07 03:04
|
Joined: Aug 2007
Posts: 7 Buenos Aires,Argentina
chochi
OP
Newbie
|
OP
Newbie
Joined: Aug 2007
Posts: 7
Buenos Aires,Argentina
|
Hello,there,good people of this forum. I need some help with a normal mapping tutorial.I used the Nvidia plugin for photoshop,i skinned my model ,etc.I added the code,& builded the proyect,but at the moment of make it run,i got the following error:
Error in effect: MtlNormalMaped(1): syntax error
heres the code.The version is 3dgsPro 6.22.0 :
//////////////////////////////////////////////////////////////////////////////////////////////////////////
var video_mode = 7; var video_depth = 32; var video_screen = 1;
//////////////////////////////////////////////////////////////////////////////////////////////////////// string test2_wmb = <test2.wmb>; var eye_tall = 25; var dist_planar = 300; var cam_angle = 0; var dist_total = 300; // Change THIS value to zoom in or out var tilt_3rd = 0; var dist_traced;
//////////////////////////////////////////////////////////////////////////////////////////////////////// // Declare the material: material MtlNormalMapped //<---Here´s the bastard! { ambient_red = 64; // The ambient color. ambient_green = 64; ambient_blue = 64; flags = tangent; effect = <NormalMapped.fx>; // The effect file containing the vertex shader, pixel shader and technique. }
function main() { fps_max = 30; level_load (test2_wmb); wait (3); }
function camera3d() { dist_planar = cos (tilt_3rd) * dist_total; camera.x = my.x - cos (cam_angle) * dist_planar; camera.y = my.y - sin (cam_angle) * dist_planar; camera.z = my.z + eye_tall + sin (tilt_3rd) * dist_total; camera.pan = cam_angle; camera.roll = 0; camera.tilt = - tilt_3rd; }
function validate_view() { trace_mode = ignore_me + ignore_passable; dist_traced = trace (my.x, camera.x); if (dist_traced == 0) { return; } // No obstacles hit... fine if (dist_traced < dist_total) { dist_traced -= 5; // Move it out of the wall dist_planar = cos (tilt_3rd) * dist_traced; camera.x = my.x - cos (cam_angle) * dist_planar; camera.y = my.y - sin (cam_angle) * dist_planar; camera.z = my.z + sin (tilt_3rd) * dist_traced; } }
ACTION dLight { my.lightrange = 300; my.red = 255; my.green = 255; my.blue = 0; }
action pop { my.material = MtlNormalMapped; my.fat = on; my.narrow = on; c_setminmax(my); while (1) { //posicion incial de camara camera3d(); validate_view(); //controles de camara if(mouse_middle == 1) { dist_total += mouse_force.y * -30; if (dist_total <= 30) { dist_total = 30; } }
if (mouse_right == 1) { cam_angle += mouse_force.x * -4; tilt_3rd += mouse_force.y * -4; } if (key_cuu == on) { dist_total -= 10; if (dist_total <= 30) { dist_total = 30; } } if (key_cud == on) { dist_total += 10; if (dist_total <= 30) { dist_total = 30; } } if (key_cur == on) { cam_angle += 2; } if (key_cul == on) { cam_angle -= 2; } //control de personaje if (key_a == on) { my.pan += 1; } if (key_d == on) { my.pan -= 1; } if (key_w == on) { c_move (my,vector(4,0,0),vector(0,0,-4),glide); } if (key_s == on) { c_move (my,vector(-4,0,0),vector(0,0,-4),glide); } wait(1); } }
Any help will be welcome
Thanks & my apollogize for my terrible inglish!
Stop pointing me with that thing!!!
|
|
|
Re: Help with material error (maybe s my fault!)
[Re: chochi]
#160100
10/10/07 06:38
10/10/07 06:38
|
Joined: Aug 2006
Posts: 652 Netherlands
bstudio
User
|
User
Joined: Aug 2006
Posts: 652
Netherlands
|
You need to update to the newest version (6.60)
BASIC programmers never die, they GOSUB and don't RETURN.
|
|
|
Re: Help with material error (maybe s my fault!)
[Re: chochi]
#160101
10/10/07 08:01
10/10/07 08:01
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
Quote:
3dgsPro 6.22.0
Keep working at it.. or you can email Conitec directly and they can help you.
|
|
|
Re: Help with material error (maybe s my fault!)
[Re: bstudio]
#160103
10/10/07 10:02
10/10/07 10:02
|
Joined: Aug 2007
Posts: 7 Buenos Aires,Argentina
chochi
OP
Newbie
|
OP
Newbie
Joined: Aug 2007
Posts: 7
Buenos Aires,Argentina
|
oh,thanks! (I told you...it was MY fault!) I´m gratefull for the fast answer!
Last edited by chochi; 10/10/07 10:03.
Stop pointing me with that thing!!!
|
|
|
Re: Help with material error (maybe s my fault!)
[Re: ello]
#160104
10/10/07 10:07
10/10/07 10:07
|
Joined: Aug 2007
Posts: 7 Buenos Aires,Argentina
chochi
OP
Newbie
|
OP
Newbie
Joined: Aug 2007
Posts: 7
Buenos Aires,Argentina
|
oh!I see... here´s the shader code:
/*********************************************************************************************** / Copyright 2006 by Taco Cohen. All rights reserved /***********************************************************************************************/
/*********************************************************************************************** / Global Variables: /***********************************************************************************************/ // Tweakables: static const float AmbientIntensity = 1.0f; // The intensity of the ambient light. static const float DiffuseIntensity = 1.0f; // The intensity of the diffuse light. static const float SpecularIntensity = 1.0f; // The intensity of the specular light. static const float SpecularPower = 8.0f; // The specular power. Used as 'glossyness' factor. static const float4 SunColor = {0.9f, 0.9f, 0.5f, 1.0f}; // Color vector of the sunlight.
// Application fed data: const float4x4 matWorldViewProj; // World*view*projection matrix. const float4x4 matWorld; // World matrix. const float4 vecAmbient; // Ambient color. const float4 vecSunDir; // The sun direction vector. const float4 vecViewPos; // View position.
texture entSkin1; // Color map. sampler ColorMapSampler = sampler_state // Color map sampler. { Texture = <entSkin1>; AddressU = Clamp; AddressV = Clamp; };
texture entSkin2; // Normal map. sampler NormalMapSampler = sampler_state // Normal map sampler. { Texture = <entSkin2>; AddressU = Clamp; AddressV = Clamp; };
/*********************************************************************************************** / Vertex Shader: /***********************************************************************************************/ void NormalMapVS( in float4 InPos : POSITION, in float3 InNormal : NORMAL, in float2 InTex : TEXCOORD0, in float3 InTangent : TEXCOORD2, out float4 OutPos : POSITION, out float2 OutTex : TEXCOORD0, out float3 OutViewDir: TEXCOORD1, out float3 OutSunDir: TEXCOORD2) { // Transform the vertex from object space to clip space: OutPos = mul(InPos, matWorldViewProj); // Pass the texture coordinate to the pixel shader: OutTex = InTex; // Compute 3x3 matrix to transform from world space to tangent space: half3x3 worldToTangentSpace; worldToTangentSpace[0] = mul(InTangent, matWorld); worldToTangentSpace[1] = mul(cross(InTangent, InNormal), matWorld); worldToTangentSpace[2] = mul(InNormal, matWorld); // Calculate the view direction vector in tangent space: OutViewDir = normalize(mul(worldToTangentSpace, vecViewPos - mul(InPos, matWorld))); // Calculate the light direction vector in tangent space: OutSunDir = normalize(mul(worldToTangentSpace, -vecSunDir)); }
/*********************************************************************************************** / Pixel Shader: /***********************************************************************************************/ float4 NormalMapPS( in float2 InTex : TEXCOORD0, in float3 InViewDir : TEXCOORD1, in float3 InSunDir : TEXCOORD2) : COLOR { // Read the normal from the normal map and convert from [0..1] to [-1..1] range float3 BumpNormal = 2 * tex2D(NormalMapSampler, InTex) - 1; // Calculate the ambient term: float4 Ambient = AmbientIntensity * vecAmbient; // Calculate the diffuse term: float4 Diffuse = DiffuseIntensity * saturate(dot(InSunDir, BumpNormal)); Diffuse *= SunColor; // Calculate the reflection vector: float3 R = normalize(2 * dot(BumpNormal, InSunDir) * BumpNormal - InSunDir); // Calculate the specular term: InViewDir = normalize(InViewDir); float Specular = pow(saturate(dot(R, InViewDir)), SpecularPower) * SpecularIntensity; // Fetch the pixel color from the color map: float4 Color = tex2D(ColorMapSampler, InTex); // Calculate final color: return (Ambient + Diffuse + Specular) * Color; }
/*********************************************************************************************** / Technique: /***********************************************************************************************/ technique SpecularTechnique { pass P0 { VertexShader = compile vs_2_0 NormalMapVS(); PixelShader = compile ps_2_0 NormalMapPS(); } }
Stop pointing me with that thing!!!
|
|
|
Re: Help with material error (maybe s my fault!)
[Re: chochi]
#160105
10/10/07 10:48
10/10/07 10:48
|
Joined: Aug 2006
Posts: 652 Netherlands
bstudio
User
|
User
Joined: Aug 2006
Posts: 652
Netherlands
|
Yeah, shaders do not work with 6.22 you need to have at least 6.4 Also, the 6.22 appears to circulate in the warez scene So I strongly recommend you buy the product first and then try to apply shaders
BASIC programmers never die, they GOSUB and don't RETURN.
|
|
|
|