thats what i got working so far.
Code:
//ghost shader based on nvidia's cgFX sample
// un-tweakables
float4x4 matWorldView;//worldIT: WorldIT;
float4x4 matWorldViewProj;//wvp : WorldViewProj;
float4x4 matWorld;//world : World;
// tweakables
int lodBias = 0;
float fade = 1.0f;
texture mtlSkin1;
//////// techniques ////////////////////////////
technique Ghostly
{
pass p0
{
VertexShaderConstant[0] = <matWorldViewProj>;
VertexShaderConstant[4] = <matWorldView>;
VertexShaderConstant[8] = <matWorld>;
VertexShaderConstant[11] = {1.1,1.1,0.6,0.0};
VertexShaderConstant[12] = <fade>;
VertexShader =
asm
{
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8
// Transform pos to screen space.
m4x4 oPos, v0, c0
// Normal to world space:
dp3 r0.x, v3, c4
dp3 r0.y, v3, c5
dp3 r0.z, v3, c6
// normalize normal
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w // r0 has normalized normal.
// vpos to world space.
dp4 r1.x, v0, c8
dp4 r1.y, v0, c9
dp4 r1.z, v0, c10
dp4 r1.w, v0, c11 // r1 has position in world space.
// eye vector, normalize.
add r2, c19, -r1
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w // r2 has normalized eye vector.
// E dot N
dp3 r0, r2, r0
mul r0, r0, r0
mul r0, r0, c12.xxxx
mul oD0, r0, r0
mov oT0, v7
};
ZEnable = true;
ZWriteEnable = true;
AlphaBlendEnable = true;
SrcBlend = One;
DestBlend = InvSrcColor;
CullMode = CCW;
Lighting = false;
Texture[0] = <mtlSkin1>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
MipMapLodBias[0] = <lodBias>;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = None;
MipMapLodBias[1] = <lodBias>;
AddressU[1] = Clamp;
AddressV[1] = Clamp;
ColorOp[0] = Modulate;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse | Complement;
AlphaOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaArg2[0] = Diffuse;
}
pass p1
{
VertexShaderConstant[0] = <matWorldViewProj>;
VertexShaderConstant[4] = <matWorldView>;
VertexShaderConstant[8] = <matWorld>;
VertexShaderConstant[11] = {1.1,1.1,0.6,0.0};
VertexShaderConstant[12] = {1.0,1.1,0.6,0.0};
VertexShader =
asm
{
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8
// Transform pos to screen space.
m4x4 oPos, v0, c0
// Normal to world space:
dp3 r0.x, v3, c4
dp3 r0.y, v3, c5
dp3 r0.z, v3, c6
// normalize normal
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w // r0 has normalized normal.
// vpos to world space.
dp4 r1.x, v0, c8
dp4 r1.y, v0, c9
dp4 r1.z, v0, c10
dp4 r1.w, v0, c11 // r1 has position in world space.
// eye vector, normalize.
add r2, c19, -r1
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w // r2 has normalized eye vector.
// E dot N
dp3 r0, r2, r0
mul r0, r0, r0
mul r0, r0, c12.xxxx
mul oD0, r0, r0
mov oT0, v7
};
ZEnable = true;
ZWriteEnable = true;
AlphaBlendEnable = true;
CullMode = CW;
Lighting = false;
SrcBlend = One;
DestBlend = InvSrcColor;
Texture[0] = <mtlSkin1>;
MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
MinFilter[1] = Linear;
MagFilter[1] = Linear;
MipFilter[1] = None;
AddressU[1] = Clamp;
AddressV[1] = Clamp;
ColorOp[0] = Modulate;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse | Complement;
AlphaOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
AlphaArg2[0] = Diffuse;
}
}
it may be what you want.
the textures need to be defined in the 3dgs way, and the matrices,vectors and other values have to be set up in a slightly different way. you can replace mtlSkin1 by entSkin1 for example to use the entities skin1
btw i found a fade falue of 3.0 much better, but this may depend on the texture.
i placed a little explanation for converting rendermonkey exported fx-files
here (its in german and i am a little lazy to translate it now) but if you look at the code and the differencies, you may get am idea of what has to be done.
btw, the simple blur shader i put in the shaderforum can be used for a glow effect ( to be honest it is a derivate of the "golden shine" from rendermonkey, so i think changing some renderstates like EnableAlphaBlend=1; and BlendOp=5; and/or setting the rendertarget transparence and brightflags will do the job)