Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Hair Shader #417402
02/12/13 10:55
02/12/13 10:55
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
I found this article
Hair Shading and Rendering

and was wondering if any of the gurus could whip up this kind of shader. I need the ability to pass the hair color to the shader as well so I cam simulate aging. I unfortunately do not have the knowledge base in writing shaders and figure this would be a little advance for me...


John C Leutz II

Re: Hair Shader [Re: lostzac] #417406
02/12/13 12:26
02/12/13 12:26
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I think that this is easy, the whole procedure is done in the pixel shader and it is explained in detail in that paper. Problem is, that there are little to no good and free human heads available with an adequate hair mesh. Do you have one that you are willing to contribute? If yes, I am sure that someone is going to check this out.

Re: Hair Shader [Re: HeelX] #417407
02/12/13 12:31
02/12/13 12:31
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
I can give you a hair model and textures if you like..not a problem...


John C Leutz II

Re: Hair Shader [Re: lostzac] #417410
02/12/13 12:32
02/12/13 12:32
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Would it be a free model then? Then post it here.

Re: Hair Shader [Re: HeelX] #417415
02/12/13 12:49
02/12/13 12:49
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
No it would not be free due to EULA issues....I can send you a link to the resources you would need, and the community is more then welcomed to the code. However I can not provide the community the models for download..


John C Leutz II

Re: Hair Shader [Re: lostzac] #417504
02/13/13 12:37
02/13/13 12:37
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Ok so I have tired to make a go of this myself, as it is something I need for my game, and one should not expect handouts..not to mention the more I can increase my knowledge base the better...

So breaking down the idea into parts, I figured I would first see if I could code the color change to make the colors of the hair...

Roots - being the Darkest
Main - the majority of the hair color
Highlights - being the lightest...

I know their is a lot more to real hair color but its a start..


This is the texture I am using with alpha channels , figuring the easiest way from what I have read would be to do an alpha-blending of the colors..where the texture was darkest would be the darkest color ect ect ect

Right now I am just trying to blend the color red into the hair
and I either am missing a step in the logic, or well as this is the first shader I am trying to write....way off base...

Code:
// Input parameters.
float4x4 matWorldView;
float4x4 matProj;

texture entSkin1;
sampler hair = sampler_state
{
    Texture = entSkin1;
 
    MinFilter = None;
    MagFilter = None;
    MipFilter = None;
    AddressU = clamp;
    AddressV = clamp;
};



// Vertex shader input structure.
struct VS_INPUT
{
    float4 Position : POSITION0;
    float2 TexCoord : TEXCOORD0;
};

// Vertex shader output structure.
struct VS_OUTPUT
{
    float4 Position : POSITION0;
    float2 TexCoord : TEXCOORD0;
};

// Vertex shader program.
VS_OUTPUT VS(VS_INPUT input)
{
    VS_OUTPUT output;
 
    //generate the view-projection matrix
    float4x4 vp = mul(matWorldView, matProj);
    output.Position = mul(input.Position, vp);
 
    output.TexCoord = input.TexCoord;
 
    return output;
}

float4 PS(VS_OUTPUT input) : COLOR
{
    float4 colour = tex2D(hair, input.TexCoord);
    
  
	 colour.r = (colour.r * colour.a) + (255 * 1);
	 colour.g = (colour.g * colour.a) + (0 * 1);
	 colour.b = (colour.b * colour.a) + (0 * 1);
;
    return colour;
}

technique Terrain
{
    pass Main
    {
        AlphaBlendEnable = true;
        SrcBlend = SRCALPHA;
        DestBlend = INVSRCALPHA;
        VertexShader = compile vs_2_0 VS();
        PixelShader = compile ps_2_0 PS();
    }
}



The issue I am having is the white are receiving the tint I want, but the rest is coming back grey...



Can someone point me in the right direction


John C Leutz II

Re: Hair Shader [Re: lostzac] #417550
02/13/13 19:49
02/13/13 19:49
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187


I have the alpha issue sorted out...next on the list is to add in lighting and highlights...


John C Leutz II

Re: Hair Shader [Re: lostzac] #417649
02/15/13 00:28
02/15/13 00:28
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
I know nothing about shaders, but Here is a "hair" texture that I made from the article provided.


Re: Hair Shader [Re: xbox] #417664
02/15/13 10:00
02/15/13 10:00
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Yeah I am not having much luck at the moment...as I am just learning.. probably should teach myself the basics first...so am going through the workshops and reading tutorials in hopes to get a better grasp..That is a really good texture bu the way, Thank you and I will try to use it.


John C Leutz II

Re: Hair Shader [Re: lostzac] #417670
02/15/13 12:31
02/15/13 12:31
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
haha grin , keep at the tutorials, that's the only way to learn. I give you credit for at least trying to learn. If you use my texture then cool, if not, don't worry about it. I wish you the best of luck though. laugh

Last edited by xbox; 02/15/13 12:31.
Page 1 of 3 1 2 3

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