@Raven
Thanks for the offer to help, but I'm fine at the moment. Actually, I don't plan to use the glow effect, or anything else that needs render targets in the game I'm working on. In fact, the most complex shader I'll be using is a combined bumpmap and depthmap shader for modelling realistic, 3D-looking debris and particle effects. I've already got one of each shader, but now I've just got to combine them. Should look pretty sw33t when it's done!
@Alexy
Well, it's only a quick attempt, and it might well be buggy, but I've had a go at your 'Doom III' shader:
float4x4 WorldViewProj : WorldViewProjection;
float4x4 World : WorldInverse;
float4x4 eyePos : ViewInverseTranspose;
//------------------------------------
// TWEAK HERE FOR THE LIGHT DIRECTION
// (Normalised in shader)
float4 lightDir <> = {1.0f, 0.0f, 0.0f, 0.0f};
// TWEAK HERE TO CHANGE DIFFUSE TEXTURE
texture texMap
<
string name = "Fieldstone.tga";
>;
// TWEAK HERE TO CHANGE NORMAL MAP
texture normMap
<
string name = "FieldstoneNormal.tga";
>;
//------------------------------------
technique bumpmap
{
pass p0
{
VertexShaderConstant[0] = <WorldViewProj>;
VertexShaderConstant[4] = <World>;
VertexShaderConstant[8] = <eyePos>;
VertexShaderConstant[12] = <lightDir>;
VertexShader = asm
{
// Initilise Shader
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
dcl_tangent v3
dcl_binormal v4
def c13, 1.0, 0.5, 0.0, 0.0
// Transform Position to Clip
dp4 oPos.x, v0, c0
dp4 oPos.y, v0, c1
dp4 oPos.z, v0, c2
dp4 oPos.w, v0, c3
// Output Texture Coordinates
mov oT0, v2
mov oT1, v2
// Move Light Vector to Object Space
mov r1, c12
dp4 r0.x, r1, c4
dp4 r0.y, r1, c5
dp4 r0.z, r1, c6
dp4 r0.w, r1, c7
// Normalise Light Vector
dp3 r1.w, r0, r0
rsq r1.w, r1.w
mul r0, r0, r1.w
// Move Light Vector to Texture Space
dp3 r1.x, r0, v3
dp3 r1.y, r0, v4
dp3 r1.z, r0, v1
// Scale, Bias and Output Light Vector
add r2, r1, c13.x
mul oT2, r2, c13.y
// Move Eye Position to Object Space
mov r2, c11
dp4 r0.x, r2, c4
dp4 r0.y, r2, c5
dp4 r0.z, r2, c6
dp4 r0.w, r2, c7
// Compute Eye Vector
sub r0, r0, v0
// Normalise Eye Vector
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Move Eye Vector to Texture Space
dp3 r0.x, r0, v3
dp3 r0.y, r0, v4
dp3 r0.z, r0, v1
// Compute Half Vector
add r0, r0, r1
// Normalise Half Vector
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
// Scale, Bias and Output Half Vector
add r0, r0, c13.x
mul oT3, r0, c13.y
};
PixelShader = asm
{
// Initialise Shader
ps.1.4
// TWEAK HERE TO CHANGE AMBIENT COLOUR
// R G B A
def c0, 0.1, 0.1, 0.1, 0.0
// Read Texture Data
texld r0, t0
texld r1, t1
texcrd r2.xyz, t2
texcrd r3.xyz, t3
// Dot3 Bumpmapping
dp3_sat r2, r1_bx2, r2_bx2
dp3_sat r3, r1_bx2, r3_bx2
// Scale Specular
mul r3, r3, r3
mul r3, r3, r3
mul r3, r3, r3
mul r3, r3, r3
// Combine the Textures
mad r0, r0, r2, r3
// Add Ambient Light
add r0, r0, c0
};
Texture[0] = <texMap>;
Texture[1] = <normMap>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = Linear;
}
}
Unfortunately, it's minus the gloss map that you asked for, but it does have specular bumpmapping to hopefully make up for that. As for tweaking, you can change the light direction by altering the
lightDir float4 either by hand in the .FX file or by plugging it into a vector in DarkBasic. Also, you should be able to find the lines that point to textures up near the top too. The only other things you might want to change are the ambient colour, which can be found as a constant defined in the pixel shader, and the specular power. I'm not sure if it's the best way to do it, but the specular power is controlled by the four
mul operations in the pixel shader - you won't be able to add any more, because I've hit the eight arithmetic instruction limit, but you can remove one or two of them to make the specular effect more pronounced.
I haven't had time to create a demo for you but, if you're having trouble getting it working, I'll knock one up for you. It shouldn't be too hard to make it work - all the non-tweakables are automatically set by DB.
I hope this is what you're looking for! If not, I can try to make a better one for you!