3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Ultimate Light Shader Problem
#40335
01/31/05 03:42
01/31/05 03:42
|
Joined: Jan 2004
Posts: 620 Germany
TimeOut
OP
User
|
OP
User
Joined: Jan 2004
Posts: 620
Germany
|
I use the Ultimate Light Shader from Matt. The demo works fine, but in my own Level I only see a black screen. What is the Error ?
Athlon 64 3700+
2048 MB DDR PC400 Dual Corsair
XFX Geforce 7800 GT
A6 Commercial 6.4
|
|
|
Re: Ultimate Light Shader Problem
[Re: Metal_Thrasher]
#40338
01/31/05 21:50
01/31/05 21:50
|
Joined: Jan 2004
Posts: 620 Germany
TimeOut
OP
User
|
OP
User
Joined: Jan 2004
Posts: 620
Germany
|
Here is my main script: Code:
//////////////////////////////////////////////////////////////////////// // A6 main wdl: // Created by WED. ////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////// // The PATH keyword gives directories where template files can be found. path "D:\\Programme\\GStudio6\\template_6"; // Path to A6 templates directory path "D:\\Programme\\GStudio6\\template_6\\code"; // Path to A6 template code subdirectory path "D:\\Programme\\GStudio6\\template_6\\images"; // Path to A6 template image subdirectory path "D:\\Programme\\GStudio6\\template_6\\sounds"; // Path to A6 template sound subdirectory path "D:\\Programme\\GStudio6\\template_6\\models"; // Path to A6 template model subdirectory
///////////////////////////////////////////////////////////////// // Filename of the starting level. string level_str = <testraum.WMB>; // give file names in angular brackets
//////////////////////////////////////////////////////////////////////////// // Included files
path ".\\tex_spec_diff_maps"; //normal mapping path ".\\tex_src"; //normal mapping
include <DrewParticles.wdl>;//crap i couldnt take out include <newtonparticles.wdl>;//crap i couldnt take out include <gid01.wdl>; include <display00.wdl>;
include <gid01.wdl>; // global ids include <display00.wdl>; // basic display settings include <plSelect.wdl>; include <cameraTarget.wdl>; include <miscInput01.wdl>;
string shader_file_lvl = <normalmap_level_ps2.0.fx>;//mat_lighting_lvl.fx normal mapping string shader_file_ent = <normalmap_ent_ps2.0.fx>;//mat_lighting_ent.fx normal mapping
include <plBipedInput01.wdl>; include <bipedPhy01.wdl>; include <bipedAnim01.wdl>; include <bipedSnd01.wdl>; include <plBiped01.wdl>; include <cameraSelect.wdl>; include <camera1stPerson01.wdl>; include <trigger00.wdl>; include <particle00.wdl>; include <weaponfx00.wdl>; include <weapons00.wdl>; include <plBipedWeap00.wdl>; include <plBipedWeapHUD01.wdl>; include <feuer.wdl>;
var move_vec[3] = 0,0,0; // I placed this right after my var video_ lines for now var idle_percent = 0; var walk_percent = 0;
/////////////////////////////////////////////////////////////////
// DX9 Normal mapping / Bump mapping shader // Multi source Per pixel Lighting // shader by Matt_Aufderheide // // Tutorial and Demo level by Drew Medina (www.drewmedina.com) // // This is a sort of mix and match from the forums. Matt's shader, converted to 2.0 by Steempipe, and structured by Nadester // included textures are taken from Nadesters demo. I have no idea where they come from...so dont use them for commercial..
// see below web links for more help...this test scene should be pretty self explanatory... //for some reason more than 2 lights wont work. may be scale, or I may have screwed some code up ;)
// HUGE thanks to: // Matt_Aufderheide (normal mapping shader- http://www.conitecserver.com/ubbthreads/showflat.php?Cat=&Number=455821&Main=452466#Post455821) // Steempipe (conversion to 2.0 (AWESOME) and help) // Nadester's "My Normal Mapping Demo - Free open source!" // (http://www.conitecserver.com/ubbthreads/showflat.php?Cat=&Number=454772&page=0&view=collapsed&sb=5&o=&fpart=1#454772) // //
var d3d_automaterial=1;
//quick world texture: you can just replace Nadester's... replace both textures in both folders with new texture, same name. restart WED. // its in src wad (textures)
//Normal maps bmap maps01 = <cmet01_maps.tga>; bmap maps04 = <gmet01_maps.tga>; bmap maps02 = <dmet01_maps.tga>; //bmap maps03 = <fmet01_maps.tga>; //bmap maps05 = <pmet01_maps.tga>; //bmap maps06 = <pmet03_maps.tga>; //bmap maps07 = <pmet04_maps.tga>; //bmap maps08 = <rock01_maps.tga>; //bmap maps09 = <tmet01_maps.tga>; //bmap maps10 = <tmet03_maps.tga>; //bmap maps11 = <tmet04_maps.tga>; //bmap maps12 = <wmet01_maps.tga>; //bmap maps13 = <wmet02_maps.tga>; //bmap maps14 = <wmet03_maps.tga>;
material mat_norm_ent { flags = tangent; }
action Shdr_NormalMap { my.material = mat_norm_ent; my.enable_scan=on; }
material cmet01_tga{ skin1 = maps01;flags = tangent;} material dmet01_tga{ skin1 = maps02;flags = tangent;} //material fmet01_tga{ // skin1 = maps03;flags = tangent;} material gmet01_tga{ skin1 = maps04;flags = tangent;} //material pmet01_tga{ // skin1 = maps05;flags = tangent;} // material pmet03_tga{ // skin1 = maps06;flags = tangent;} //material pmet04_tga{ // skin1 = maps07;flags = tangent;} //material rock01_tga{ // skin1 = maps08;flags = tangent;} //material tmet02_tga{ // skin1 = maps09;flags = tangent;} //material tmet03_tga{ // skin1 = maps10;flags = tangent;} // material tmet01_tga{ // skin1 = maps11;flags = tangent;} //material tmet04_tga{ // skin1 = maps11;flags = tangent;} //material wmet01_tga{ // skin1 = maps12;flags = tangent;} //material wmet02_tga{ // skin1 = maps13;flags = tangent;} //material wmet03_tga{ // skin1 = maps14;flags = tangent;} } var light_dist=2700; //Distance Light LOD...this is how far away from a light you can be until it shuts off/on
action light_pos_object { wait(5); my.invisible=on; my.passable=on; //NewtonCreateGravityEntity (wood_material); while(1) {
if vec_dist(my.x, player.x )<light_dist// or camera { my.light=on; my.lightrange=1800; //could be set also to a skill my.red= my.skill1; //just put in the r,g,b values my.green= my.skill2; my.blue= my.skill3; my.cast=on; //casts a shadow when on } else { my.lightrange=0; //if too far away turn it off my.light=off; my.cast=off;
} wait(1); }
}
function load_shaders() { effect_load(cmet01_tga,shader_file_lvl); //effect_load(dmet01_tga,shader_file_lvl); //effect_load(fmet01_tga,shader_file_lvl); effect_load(gmet01_tga,shader_file_lvl); // effect_load(pmet01_tga,shader_file_lvl); // effect_load(pmet03_tga,shader_file_lvl); // effect_load(pmet04_tga,shader_file_lvl); // effect_load(rock01_tga,shader_file_lvl); // effect_load(tmet01_tga,shader_file_lvl); // effect_load(tmet03_tga,shader_file_lvl); // effect_load(tmet04_tga,shader_file_lvl); // effect_load(wmet01_tga,shader_file_lvl); // effect_load(wmet02_tga,shader_file_lvl); // effect_load(wmet03_tga,shader_file_lvl);effect_load(dru_brik1_tga,shader_file_lvl);
effect_load(mat_norm_ent,shader_file_ent); wait(5); }
///////////////////////////////////////////////////////////////// // define a splash screen with the required A4/A5 logo bmap splashmap = <logodark.pcx>; // the default logo in templates panel splashscreen { bmap = splashmap; flags = refresh,d3d; }
function main() { // center the splash screen for non-640x480 resolutions, and display it splashscreen.pos_x = (screen_size.x - bmap_width(splashmap))/2; splashscreen.pos_y = (screen_size.y - bmap_height(splashmap))/2; splashscreen.visible = on; // wait 3 frames (for triple buffering) until it is flipped to the foreground waitt(3); level_load("testraum.wmb"); shadow_stencil=1; d3d_lightres=on; //normal mapping waitt(2); // wait the required second, then switch the splashscreen off. sleep(1); splashscreen.visible = off; bmap_purge(splashmap); // remove splashscreen from video memory max_lights=8; load_shaders(); //normal mapping freeze_mode = 0; }
/////////////////////////////////////////////////////////////////
I use A6 commercial 6.34
Athlon 64 3700+
2048 MB DDR PC400 Dual Corsair
XFX Geforce 7800 GT
A6 Commercial 6.4
|
|
|
Re: Ultimate Light Shader Problem
[Re: TimeOut]
#40339
01/31/05 23:23
01/31/05 23:23
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
Quote:
string shader_file_lvl = <normalmap_level_ps2.0.fx>;//mat_lighting_lvl.fx normal mappingstring shader_file_ent = <normalmap_ent_ps2.0.fx>;//mat_lighting_ent.fx normal mapping
these fx files.. they must be in your world directory for the engine to find them for some reason. Also, I'm not sure whether they can have a '.' in the filename.. try changing it to a '_' if this doesnt work i cant see any glaring errors in your code..let me know what happens. Do you get any errors when you run it or do the shaders just not show up? i mean does the level actually load, and you can walk around in it, or does the app just freeze?
|
|
|
Re: Ultimate Light Shader Problem
[Re: Matt_Aufderheide]
#40340
02/01/05 06:17
02/01/05 06:17
|
Joined: Jan 2004
Posts: 620 Germany
TimeOut
OP
User
|
OP
User
Joined: Jan 2004
Posts: 620
Germany
|
I have changed the . to _. Now I can see something but no normal mamping. I get the following errors:
cmet01_tga(1):error X3000 : syntax error: unexpected float constant.
gmet01_tga(1):error X3000 : syntax error: unexpected float constant.
īmat_normalent1(1):error X3000 : syntax error: unexpected float constant.
Athlon 64 3700+
2048 MB DDR PC400 Dual Corsair
XFX Geforce 7800 GT
A6 Commercial 6.4
|
|
|
Re: Ultimate Light Shader Problem
[Re: TimeOut]
#40342
02/01/05 16:24
02/01/05 16:24
|
Joined: May 2002
Posts: 2,541 Berlin
EX Citer
Expert
|
Expert
Joined: May 2002
Posts: 2,541
Berlin
|
Hello,
I have a problem too with that shader. Drews demos are working, but because he hides his wdls and models I donīt know why his demo works but not my testroom.
I have created one fx file (the model shader) as described in the ultimate light shader thread, the light entities and a model with a skin and a normal map as second skin using the model normal mapping material.
The normal mapped entity is reacting on the lights but it is just bright without normal mapping. If I turn the shader off the model looks the same, excepting the brightness.
I tried different light ranger like 1000 and 300 ad I moved the model around the level, but the model is rendered like without shader, just brighter.
Has anyone a idea where the problem is, or has anyone a working normalmapping demo, where the files are not hidden (maybe my normal map isnīt working, created with the nvidia plugin for photoshop. The normal map is created with a greyscale heightmap which looks totally different to the model skin1)?
EX Citer
:L
|
|
|
Re: Ultimate Light Shader Problem
[Re: EX Citer]
#40343
02/01/05 16:37
02/01/05 16:37
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
|
|
|
Re: Ultimate Light Shader Problem
[Re: Matt_Aufderheide]
#40344
02/03/05 00:20
02/03/05 00:20
|
Joined: Jan 2004
Posts: 620 Germany
TimeOut
OP
User
|
OP
User
Joined: Jan 2004
Posts: 620
Germany
|
Fx File: normalmap_ent_ps2.0 Code:
// ------------------------------------------------------------- // Diffuse and specular shader for models // ------------------------------------------------------------- //this is a 3 pass shader rendering 3 lights in each pass,3 rd pass has the last light
float4x4 matWorldViewProj; float4x4 matWorld; float4 vecLightPos[8]; //light position float4 vecLightColor[8]; //light position float4 vecViewPos;
texture entSkin1; //this is the color map texture entSkin2; //this is the normal map
sampler sColorMap = sampler_state { Texture = <entSkin1>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
sampler sBumpMap = sampler_state { Texture = <entSkin2>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //first pass /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------- // Output channels // ------------------------------------------------------------- struct VS_OUTPUT0 { float4 Pos : POSITION; float2 Tex : TEXCOORD0; float3 Light1 : TEXCOORD2; float3 View1 : TEXCOORD3; float3 Att1 : TEXCOORD4; float3 Light2 : TEXCOORD5; float3 View2 : TEXCOORD6; float3 Att2 : TEXCOORD7;
};
// ------------------------------------------------------------- // vertex shader function (input channels) // ------------------------------------------------------------- VS_OUTPUT0 VS_PASS0(float4 Pos : POSITION, float2 texcoord0 : TEXCOORD0, float3 Normal : NORMAL, float3 Tangent : TEXCOORD2 ) { VS_OUTPUT0 Out = (VS_OUTPUT0)0; Out.Pos = mul(Pos, matWorldViewProj); // transform Position // compute the 3x3 tranform matrix // to transform from world space to tangent space float3x3 worldToTangentSpace; worldToTangentSpace[0] = mul(Tangent, matWorld); worldToTangentSpace[1] = mul(cross(Tangent, Normal), matWorld); worldToTangentSpace[2] = mul(Normal, matWorld); Out.Tex = texcoord0.xy;
float3 PosWorld = mul(Pos, matWorld); float LightRange = 0.001;
//light 1 float3 Light1 = PosWorld - vecLightPos[1] ; Out.Light1.xyz = mul(worldToTangentSpace, -Light1); // L
float3 Viewer1 = PosWorld - vecViewPos; Out.View1 = mul(worldToTangentSpace, -Viewer1); // V Out.Att1 = Light1 * LightRange; // Point light
//light 2 float3 Light2 = PosWorld - vecLightPos[2] ; Out.Light2.xyz = mul(worldToTangentSpace, -Light2); // L
float3 Viewer2 = PosWorld - vecViewPos; Out.View2 = mul(worldToTangentSpace, -Viewer2); // V Out.Att2 = Light2 * LightRange; // Point light
return Out; }
struct PS_INPUT0 { float2 Tex : TEXCOORD0; float3 Light1 : TEXCOORD2; float3 View1 : TEXCOORD3; float3 Att1 : TEXCOORD4; float3 Light2 : TEXCOORD5; float3 View2 : TEXCOORD6; float3 Att2 : TEXCOORD7; }; float4 PS_PASS0( PS_INPUT0 psInStruct ):COLOR
{ float4 color = tex2D(sColorMap, psInStruct.Tex); // fetch color map float3 bumpNormal = 2 * (tex2D(sBumpMap, psInStruct.Tex) - 0.5); // fetch bump map float4 gloss = tex2D( sBumpMap, psInStruct.Tex ); //light1 float3 LightDir1 = normalize(psInStruct.Light1); float3 ViewDir1 = normalize(psInStruct.View1); float4 diff1 = saturate(dot(bumpNormal, LightDir1)); // diffuse component float shadow1 = saturate(4 * diff1); float3 Reflect1 = normalize(2 * diff1 * bumpNormal - LightDir1); // R float4 spec1 = pow(saturate(dot(Reflect1, ViewDir1)), 15); float4 Attenuation1 = saturate(dot(psInStruct.Att1, psInStruct.Att1)); //light2 float3 LightDir2 = normalize(psInStruct.Light2); float3 ViewDir2 = normalize(psInStruct.View2); float4 diff2 = saturate(dot(bumpNormal, LightDir2)); // diffuse component float shadow2 = saturate(4 * diff2); float3 Reflect2 = normalize(2 * diff2 * bumpNormal - LightDir2); // R float4 spec2 = pow(saturate(dot(Reflect2, ViewDir2)), 15); float4 Attenuation2 = saturate(dot(psInStruct.Att2, psInStruct.Att2)); return ( (0.1 * color) + //ambient ((shadow1 * (color * diff1 + (spec1*gloss.w)) * (1 -Attenuation1))*vecLightColor[1])+ ((shadow2 * (color * diff2 + (spec2*gloss.w)) * (1 -Attenuation2))*vecLightColor[2]) ); }
// ------------------------------------------------------------- // techniques// // ------------------------------------------------------------- technique two_pass { pass P0 { alphablendenable=false; srcblend=zero; VertexShader = compile vs_2_0 VS_PASS0(); PixelShader = compile ps_2_0 PS_PASS0(); } }
normalmap_level_ps2.0 Code:
// ------------------------------------------------------------- // Diffuse and specular shader for models // ------------------------------------------------------------- //this is a 3 pass shader rendering 3 lights in each pass,3 rd pass has the last light
float4x4 matWorldViewProj; float4x4 matWorld; float4 vecLightPos[8]; //light position float4 vecLightColor[8]; //light position float4 vecViewPos;
texture entSkin1; //this is the color map texture mtlSkin1; //this is the normal map
sampler sColorMap = sampler_state { Texture = <entSkin1>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
sampler sBumpMap = sampler_state { Texture = <mtlSkin1>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //first pass /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------- // Output channels // ------------------------------------------------------------- struct VS_OUTPUT0 { float4 Pos : POSITION; float2 Tex : TEXCOORD0; float3 Light1 : TEXCOORD2; float3 View1 : TEXCOORD3; float3 Att1 : TEXCOORD4; float3 Light2 : TEXCOORD5; float3 View2 : TEXCOORD6; float3 Att2 : TEXCOORD7;
};
// ------------------------------------------------------------- // vertex shader function (input channels) // ------------------------------------------------------------- VS_OUTPUT0 VS_PASS0(float4 Pos : POSITION, float2 texcoord0 : TEXCOORD0, float3 Normal : NORMAL, float3 Tangent : TEXCOORD2 ) { VS_OUTPUT0 Out = (VS_OUTPUT0)0; Out.Pos = mul(Pos, matWorldViewProj); // transform Position // compute the 3x3 tranform matrix // to transform from world space to tangent space float3x3 worldToTangentSpace; worldToTangentSpace[0] = mul(Tangent, matWorld); worldToTangentSpace[1] = mul(cross(Tangent, Normal), matWorld); worldToTangentSpace[2] = mul(Normal, matWorld); Out.Tex = texcoord0.xy*50;
float3 PosWorld = mul(Pos, matWorld); float LightRange = 0.003;
//light 1 float3 Light1 = PosWorld - vecLightPos[1] ; Out.Light1.xyz = mul(worldToTangentSpace, -Light1); // L
float3 Viewer1 = PosWorld - vecViewPos; Out.View1 = mul(worldToTangentSpace, -Viewer1); // V Out.Att1 = Light1 * LightRange; // Point light
//light 2 float3 Light2 = PosWorld - vecLightPos[2] ; Out.Light2.xyz = mul(worldToTangentSpace, -Light2); // L
float3 Viewer2 = PosWorld - vecViewPos; Out.View2 = mul(worldToTangentSpace, -Viewer2); // V Out.Att2 = Light2 * LightRange; // Point light
return Out; }
struct PS_INPUT0 { float2 Tex : TEXCOORD0; float3 Light1 : TEXCOORD2; float3 View1 : TEXCOORD3; float3 Att1 : TEXCOORD4; float3 Light2 : TEXCOORD5; float3 View2 : TEXCOORD6; float3 Att2 : TEXCOORD7; }; float4 PS_PASS0( PS_INPUT0 psInStruct ):COLOR
{ float4 color = tex2D(sColorMap, psInStruct.Tex); // fetch color map float3 bumpNormal = 2 * (tex2D(sBumpMap, psInStruct.Tex) - 0.5); // fetch bump map float4 gloss = tex2D( sBumpMap, psInStruct.Tex ); //light1 float3 LightDir1 = normalize(psInStruct.Light1); float3 ViewDir1 = normalize(psInStruct.View1); float4 diff1 = saturate(dot(bumpNormal, LightDir1)); // diffuse component float shadow1 = saturate(4 * diff1); float3 Reflect1 = normalize(2 * diff1 * bumpNormal - LightDir1); // R float4 spec1 = pow(saturate(dot(Reflect1, ViewDir1)), 15); float4 Attenuation1 = saturate(dot(psInStruct.Att1, psInStruct.Att1)); //light2 float3 LightDir2 = normalize(psInStruct.Light2); float3 ViewDir2 = normalize(psInStruct.View2); float4 diff2 = saturate(dot(bumpNormal, LightDir2)); // diffuse component float shadow2 = saturate(4 * diff2); float3 Reflect2 = normalize(2 * diff2 * bumpNormal - LightDir2); // R float4 spec2 = pow(saturate(dot(Reflect2, ViewDir2)), 15); float4 Attenuation2 = saturate(dot(psInStruct.Att2, psInStruct.Att2)); return ( (0.1 * color) + //ambient ((shadow1 * (color * diff1 + (spec1*gloss.w)) * (1 -Attenuation1))*vecLightColor[1])+ ((shadow2 * (color * diff2 + (spec2*gloss.w)) * (1 -Attenuation2))*vecLightColor[2]) ); }
// ------------------------------------------------------------- // techniques// // ------------------------------------------------------------- technique two_pass { pass P0 { alphablendenable=false; srcblend=zero; VertexShader = compile vs_2_0 VS_PASS0(); PixelShader = compile ps_2_0 PS_PASS0(); } }
Athlon 64 3700+
2048 MB DDR PC400 Dual Corsair
XFX Geforce 7800 GT
A6 Commercial 6.4
|
|
|
|