Yet Another Fur Shader
From GameStudio Wiki
Credits to zefor. This shader extrudes your model 13 times. Assuming that you have an alpha channel texture on your model this will create 13 translucent skin layers on top of each other.
This goes into your WDL file :
material mat_fur
{
flags = tangent;
}
ACTION atifur
{
my.transparent=on; // to get alpha
my.material=mat_fur;
effect_load( my.material, "atifur.fx" );
}
Create a file called 'atifur.fx' in your game folder and copy the following shader definition into it:
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
texture entSkin1;
technique fur
{
pass p0
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={1.0f,1.0f,1.0f,1.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1 /////vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
pixelshader=
asm
{
ps.1.4 //////////ps.1.4
texld r0, t0 // base map
mul r0, r0, c0
};
}
pass p1
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={2.0f,2.0f,2.0f,2.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p2
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={3.0f,3.0f,3.0f,3.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p3
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={4.0f,4.0f,4.0f,4.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p4
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={5.0f,5.0f,5.0f,5.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p5
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={6.0f,6.0f,6.0f,6.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p6
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={7.0f,7.0f,7.0f,7.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p7
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={8.0f,8.0f,8.0f,8.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p8
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={9.0f,9.0f,9.0f,9.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p9
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={10.0f,10.0f,10.0f,10.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p10
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={11.0f,11.0f,11.0f,11.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p11
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={12.0f,12.0f,12.0f,12.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p12
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={13.0f,13.0f,13.0f,13.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
pass p13
{
Texture[0] = <entSkin1>;
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]={0.76f,0.76f,0.76f,0.76f};
VertexShaderConstant[5]={14.0f,14.0f,14.0f,14.0f};
PixelShaderConstant[0]={0.628f,0.373f,0.121f,0.424f};
VertexShader =
asm{
vs.1.1
dcl_position v0
dcl_normal v1
dcl_texcoord v2
// get model space vertex
mov r0, v0
// get shell distance
mov r1, c4
// offset shell in direction of normal
mul r1.x, r1.x, c5.x
mul r1.xyz, r1.xxx, v1.xyz
add r0.xyz, r0.xyz, r1.xyz
// output transformed vertex
m4x4 oPos, r0, c0
// output texture coordinates
mov oT0, v2
};
}
}
