Ok here's my progress on combining the two shaders I'm looking for, and I'd like a little guidance.
I'm trying to combine GG's lightmap blend shader:
http://delvarworld.com/stuff/lightmap.fx
with Evolved's new flashlight shader
http://delvarworld.com/stuff/FlashLight.fx
I'm merging the LIGHTMAP into the FLASHLIGHT shader.
The first thing I did is copy these lines to the top of flashlight.fx:
float4 ambient = {1.0, 1.0, 1.0, 1.0};
float4 blend1 = {0.0, 0.0, 0.0, 1.0};
float4 blend2 = {1.0, 1.0, 1.0, 1.0};
Cause those are needed for blending. It compiled and ran.
Then I tried putting these variables into the flashlight:
texture diffuseTex < string ResourceName=""; >;
texture lightMap < string ResourceName=""; >;
sampler2D diffuseSamp = sampler_state { texture = <diffuseTex>; };
sampler2D lightMapSamp = sampler_state { texture = <lightMap>; };
at the top, but it crashed. I realized that the two programs were fighting for variables or something, since the Flashlight already had
texture LightmapTX <string Name="";>;
sampler2D Lightmap = sampler_state { texture = <LightmapTX>; };
texture BaseTX < string Name=""; >;
sampler2D Base = sampler_state { texture = <BaseTX>; };
texture CubeLightTX < string Name = ""; >;
sampler CubeLight = sampler_state { Texture = <CubeLightTX>; };
BUT the lightmap uses those variables,
diffuseSamp and
lightMapSamp. So NOW in the lightmap shader I repalce all instances of
diffuseSamp with
Base, and replace
lightMapSamp with
Lightmap so that these programs are using the same variables.
THEN I pasted this technique from lightmap into flashlight, since it seemed pretty standalone:
technique basicLightMap
{ pass p0
{ vertexShader = compile vs_2_0 VShader();
pixelShader = compile ps_2_0 PShader();
}
}
And it crashed the exe. I realized that it was because the FLASHLIGHT shader did NOT have the methods
VShader and
PShader.
BUT NOW I'M CONFUSED. The FLASHLIGHT has methods like these:
Foutput VS(Finput IN)
...
float4 PS(Foutput IN) : COLOR
And it SEEMS LIKE these methods are supposed to do similar as
VShader and
PShader from the lightmap. I tried just copying the methods from the lightmap verbatim (VShader and PShader) but it crashed. Ok...why is that? Ah! It's missing some of the structs from the lightmap! So I copied the structs:
struct VSInput
{ float4 pos : Position;
float2 UV0 : Texcoord0;
float2 UV1 : Texcoord1;
};
struct VSOutput
{ float4 pos : Position;
float2 UV0 : Texcoord0;
float2 UV1 : Texcoord1;
};
struct PSInput
{ float2 UV0 : Texcoord0;
float2 UV1 : Texcoord1;
};
struct PSOutput
{ float4 col : Color;
};
into the lightmap. Still no compile. You can view my garbled mess of the combinaion here:
[href=http://delvarworld.com/stuff/lighting.fx ]http://delvarworld.com/stuff/lighting.fx [/href]
This is designed to replaec FlashLight.X in Evolved's demo posted up there.
The code copied from the lightmap is commented with start and end comments. Am I overwriting variables like
col and
pos? For example the lightmap uses a simple float4 named
col, but the flashlight shader uses variablse like
Out.col. Are they the same thing.
Am I on the right track? Why isn't it comipling?! Help!!
