I have a toonshader in assembly that works on models (if i remember well i downloaded it from the wiki), but i want to convert it to work on level blocks:
Code:
texture entSkin1;
texture entskin2;
texture mtlSkin1;
texture mtlSkin2;
matrix matWorldViewProj;
matrix matWorld;
vector vecSkill1;
vector vecSkill5;
vector vecSunDir;
technique toon
{
//---------------------------------------------------------------------------paint
pass p0
{
// texture[0]=<mtlSkin1>;
// texture[1]=<mtlSkin2>;
// texture[2]=<entSkin1>;
// texture[3]=<entskin2>;
texture[0]=<entSkin1>; //colormap
texture[1]=<entskin2>; //shadowmap
texture[2]=<mtlSkin1>; //normalizationcube
texture[3]=<mtlSkin2>; //toonlookup
AlphaBlendEnable = false;
addressU[3]=clamp;
// magFilter[1]=point;
// minFilter[1]=point;
// mipFilter[1]=point;
magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
//vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[16]=<vecSkill1>;
vertexShader=
asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord1 v7 //color uv
m4x4 oPos,v0,c0 // transform position to clip space
m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w
mov oT0.xyz,r0.xyz // output normal to oT0
mov oT1.xyz,-c16 // output light direction to oT1
mov oT2.xy,v7.xy // output uvs to oT2
};
pixelShader=
asm
{
ps.1.3
tex t0 // sample color map
tex t1 //shadow
tex t2 // fetch normalized normal
texdp3tex t3,t2_bx2 // light.normal=u -> use u to lookup in t1 // _bx2 -> 0..1 of normcube will be -1..1
//
mul r0, t0, t1 //mul shadow with colormap
mul r0, t3, r0 // modulate with shading
};
}
//---------------------------------------------------------------------------ink
pass p1
{
cullMode=cw;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=<vecSkill1>; // outline_thickness, 0, 0, 0
AlphaBlendEnable = false;
vertexShader=
asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord1 v7 //color uv
mov r0,v0
mul r1,c16.x,v3 // scale normal
add r0.xyz,r0.xyz,r1.xyz // shell offset (vertex position + scaled normal)
m4x4 oPos,r0,c0 // transform position to clip space
};
pixelShaderConstant[0] = <vecSkill5>;
pixelShader=
asm
{
ps.1.3
mov r0,c0
};
}
}
I use it for all the mat_shaded blocks with effect_load, it hasn't sintax errors, but i can't see the shadows, the shadowmap and the black outlines.
It doesn't work because of blocks? And (maybe this is an offtopic) are there tools to export a .map to .mdl? This way i could use on the map the normal shader. Thanks, Tommaso.