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:
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:
// pixel shader
float4 PS(output IN, float2 Tex1:texcoord1) : COLOR //Added parameter
float3 Lightmap=tex2D(lightMapSample, Tex1); //Added this
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:
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?
I figured texcoord1 (in the parameter of the PS function should be texcoord5 as the 5th stage is being used. But does not work.