Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, kzhao), 901 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hi-Pass Fur Shader - No Fuzz! (almost) #150510
08/27/07 11:31
08/27/07 11:31
Joined: Jan 2003
Posts: 798
New Zealand
Bright Offline OP
User
Bright  Offline OP
User

Joined: Jan 2003
Posts: 798
New Zealand
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

Last edited by Bright; 08/27/07 11:33.

KAIN - Coming soon...
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Bright] #150511
08/27/07 11:38
08/27/07 11:38
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
It looks good, I can't deny that. But 18 passes for a single object..?! Maybe 17 will do the trick too...


Always learn from history, to be sure you make the same mistakes again...
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Uhrwerk] #150512
08/27/07 13:18
08/27/07 13:18
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
can u please make the hairs longer?

Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Scorpion] #150513
08/27/07 14:21
08/27/07 14:21
Joined: Oct 2005
Posts: 528
Italy
M
Mondivirtuali Offline
User
Mondivirtuali  Offline
User
M

Joined: Oct 2005
Posts: 528
Italy
awesome, i'll try it

Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Bright] #150514
08/28/07 09:27
08/28/07 09:27
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Nice effort but the more passes, the more instruction slots you use which leads into a decreasing framerate like you mentioned. This is also partly caused because when using one technique and several passes, the technique encapsulates the effect state that determines a rendering style. A technique is made up of one or more passes. An effect file that uses one technique and multiple passes like yours, has result that one pass depends on the result of the previous pass so you get a fps decrease. Anyway, nice work

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: frazzle] #150515
08/28/07 19:14
08/28/07 19:14
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Quote:

the more passes, the more instruction slots you use which leads into a decreasing framerate like you mentioned. This is also partly caused because when using one technique and several passes, the technique encapsulates the effect state that determines a rendering style. A technique is made up of one or more passes. An effect file that uses one technique and multiple passes like yours, has result that one pass depends on the result of the previous pass so you get a fps decrease.




This explanation leaves something to be desired..

The basic reason multipass shaders like this are slow (aside from the mulitple draw calls and polygon transforms) is the excessive overdraw.

Think about it, each pixel in the effect has to be redrawn at least 18 times, often more.


Sphere Engine--the premier A6 graphics plugin.
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Matt_Aufderheide] #150516
08/28/07 20:30
08/28/07 20:30
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Quote:


This explanation leaves something to be desired..





Well it may leave something to be desired but it makes sense.
You said the following:

Quote:


Think about it, each pixel in the effect has to be redrawn at least 18 times, often more.





In theory, this replicates my explanation.
Btw I love reading your comments Matt, they have a satire style but helpful at the same time

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: frazzle] #150517
08/28/07 23:12
08/28/07 23:12
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
"maybe 17 will do the trick"...funny.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: Hi-Pass Fur Shader - No Fuzz! (almost) [Re: Nowherebrain] #150518
09/13/07 03:12
09/13/07 03:12
Joined: May 2007
Posts: 11
M
mohsen123 Offline
Newbie
mohsen123  Offline
Newbie
M

Joined: May 2007
Posts: 11
hi
thank you .
but . where can i use your material code ?
whene i save .fx file and .tga file and past material script in my proje i see :
http://i5.tinypic.com/4md6rkx.jpg
thank you.


Last edited by mohsen123; 09/13/07 03:14.

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1