Hi there,
I'm new to the whole shader scene but I managed to hack and slice a fur shader I found with a Massive Shader Collection. I've added more passes to get rid of that anoying fuzz effect. It looks really nice however it is a major drop on performence so I don't think it would be much use to you guys. But maybe another couple of years down the track it'll be handy
Heres a screenshot:
To run the shader you will need a TGA image of noise (any size, I use 256x256). Save it as noise.tga.
Example:
Heres the script (orignal script by PHeMoX).
Save the following into a fur.fx file:
Code:
float4x4 matWorldViewProj;
void mainVS
(
in float4 position:POSITION,
in float4 normal:NORMAL,
in float2 texCoord:TEXCOORD0,
out float4 pos:POSITION,
out float2 oT0:TEXCOORD0,
uniform float offset
)
{
position.xyz+=normal.xyz*offset;
//scale vertexposition in normals direction
//changing the 100 value changes the 'distance' or height of the fur
pos=mul(position,matWorldViewProj);
oT0=texCoord*1; //scale for fur density 14--->original comment
//this is the amount of tiling of the fur texture
}
//Define the material skins which we use;
texture entSkin1;
sampler basemap = sampler_state
{
texture=(entSkin1);
};
texture mtlSkin1;
sampler noiseMap=sampler_state
{
texture=(mtlSkin1);
};
texture mtlSkin2;
sampler furmap = sampler_state
{
texture=(mtlSkin2);
};
// Next the main pixel shader (can't explain much on it though)
float4 mainPS
(
in float4 nrm:COLOR0,
in float2 texCoord:TEXCOORD0,
uniform float alpha
) : COLOR
{
float4 base=tex2D(basemap,texCoord); //mtlskin1 sampler
float4 fur=tex2D(furmap,texCoord); //mtlskin2 sampler
float4 noise=tex2D(noiseMap,texCoord);
base *= fur; //this is for color fur
base.a=alpha*noise.rgb; //this is for making it transparent using the noisemap as for, 'how much and where' transparency should be(???)
return base;
}
// Through these passes, the amount of fur-layers are determined, the more passes, the less fps (and even a changing effect, too much contrast)
technique test1
{
pass p0
{
alphablendenable=true;
VertexShader=compile vs_1_1 mainVS(0);
PixelShader=compile ps_1_4 mainPS(1);
}
//fur part:
pass p1
{
AlphaBlendEnable=true;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.1); //the last numbers gives the height of the layer
PixelShader=compile ps_1_4 mainPS(0.9); //the last numbers sets the transparency of this pass
}
pass p2
{
AlphaBlendEnable=true;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.2);
PixelShader=compile ps_1_4 mainPS(0.9);
}
pass p3
{
AlphaBlendEnable=true;
destBlend=13; //7/9
VertexShader=compile vs_1_1 mainVS(0.3);
PixelShader=compile ps_1_4 mainPS(0.9);
}
pass p4
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.4);
PixelShader=compile ps_1_4 mainPS(0.8);
}
pass p5
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.5);
PixelShader=compile ps_1_4 mainPS(0.7);
}
pass p6
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.6);
PixelShader=compile ps_1_4 mainPS(0.6);
}
pass p7
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.7);
PixelShader=compile ps_1_4 mainPS(0.5);
}
pass p8
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.8);
PixelShader=compile ps_1_4 mainPS(0.4);
}
pass p9
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(0.9);
PixelShader=compile ps_1_4 mainPS(0.4);
}
pass p10
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1);
PixelShader=compile ps_1_4 mainPS(0.4);
}
pass p11
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.1);
PixelShader=compile ps_1_4 mainPS(0.4);
}
pass p12
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.2);
PixelShader=compile ps_1_4 mainPS(0.4);
}
pass p13
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.3);
PixelShader=compile ps_1_4 mainPS(0.3);
}
pass p14
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.4);
PixelShader=compile ps_1_4 mainPS(0.3);
}
pass p15
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.5);
PixelShader=compile ps_1_4 mainPS(0.3);
}
pass p16
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.6);
PixelShader=compile ps_1_4 mainPS(0.2);
}
pass p17
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.7);
PixelShader=compile ps_1_4 mainPS(0.2);
}
pass p18
{
AlphaBlendEnable=true;
zWriteEnable = True;
destBlend=13;
VertexShader=compile vs_1_1 mainVS(1.8);
PixelShader=compile ps_1_4 mainPS(0.1);
}
}
Add this to your script:
Code:
// call local images
bmap noise_bmap = <noise.tga>;
bmap color_bmap = <noise.tga>;
material mtl_fur
{
skin1 = noise_bmap;
skin2 = color_bmap;
effect = "fur.fx";
}
Should work. If there are any problems let me know and I'll try my best to help you out
Cheers
-Bright