Hey there fellow game developers,
So I got Deferred Shading to work with .DBO level files. But got one problem. I tried to add a Lightmap stage to the original .fx file ( which is attached to this post ) but failed.
So here is how I did it:
First I added this:
Code:
texture lightMap
<
string Name= "";
>;
sampler lightMapSample = sampler_state
{
Texture = <lightMap>;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
ADDRESSW = CLAMP;
};
Next I went to the float4 PS function , and added here a new parameter, Tex1:texcoord1 .
I used this parameter in the same function. Here is the full edited float4 PS function:
Code:
//--------------
// pixel shader
//--------------
float4 PS(output IN, float2 Tex1:texcoord1) : COLOR //Added parameter
{
float3 View=normalize(IN.ViewVec);
float HeightTex=tex2D(Height,IN.Tex).x+BiasHeight;
float2 NewUv=(Heightvec*HeightTex-0.02)*View+IN.Tex;
float3 Texture=tex2D(Base,NewUv);
float3 Lightmap=tex2D(lightMapSample, Tex1); //Added this
float3 Light=tex2Dproj(Lighting,IN.Proj)*1.5f;
return float4(Lightmap*Texture*(Light+Ambient),1); //Changed this
}
After done and saved, I textured my object limb with a lightmap texture on Stage 5, like this:
Code:
dbTextureLimb(1,iMesh,5,imageID);
The deferred shading kept working , altough the brithness of the entire object seemed to be very high, and no lightmap whatsoever was applied.
Is there something I am doing wrong in the HLSL shader?
Cheers,
Leo
EDIT: I figured texcoord1 (in the parameter of the PS function should be texcoord5 as the 5th stage is being used. But does not work.