Jump to content

Transparency Shader for Hair (Help!)


Go to solution Solved by Iofiel,

Recommended Posts

Howdy-hoody! Sorry if this has been answered before or something similar has come up, but I can't for the life of me find anything addressing this.

 

Anyways, to get to the point, I've been trying to wrap my head around making a shader work on a hair-texture (in .png format) to make the cut-off pieces transparent and not an untextured... texture (REDUNDANCY!!!). I've tried multiple different scripts, borrowing a few from shaders with similar use of transparency, and yet still the non textured whiteness persists! The hair pieces I've been using are 5 separate pieces on the model itself (Yeah, this is all for a custom model, should've mentioned that) and I separated the hair-textures into 5 different pieces while keeping them in .png format. Any help would be appreciated! I'll post images of the problem itself, thank you all!

 

JnDWUuf.jpg

 

b6bI2qG.jpg

 

ql3NS4x.jpg

 

42hJPGu.jpg

Link to comment

Well, I just tried changing the textures to .tga, yet the problem still persists. Curse you, Jedi Academy! CURSE YOU! Thank you for the reply, by the way!

Also, here's the .png of the hair-texture. I don't know if imgur changed it at all or not, but it still looks to have the removed locations still there- hopefully that sticks!

 

OeIws1m.png

 

Sorry, forgot to add this.

 

I've also tried:

 

models/players/Iofiel/Hair_Ex
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex
        rgbGen lightingDiffuse
        alphaFunc GE128
    }
}
 

models/players/Iofiel/Hair_Ex2
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex2
        rgbGen lightingDiffuse
        alphaFunc GE128
    }
}
 

models/players/Iofiel/Hair_Ex3
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex3
        rgbGen lightingDiffuse
        alphaFunc GE128
    }
}
 

models/players/Iofiel/Hair_Ex4
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex4
        rgbGen lightingDiffuse
        alphaFunc GE128
    }
}
 

models/players/Iofiel/Hair_Ex5
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex5
        rgbGen lightingDiffuse
        alphaFunc GE128
    }
}
---

and

---

models/players/Iofiel/Hair_Ex
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex
        alphaFunc GE192
        depthWrite
        rgbGen lightingDiffuse
    }
}
 

models/players/Iofiel/Hair_Ex2
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex2
        alphaFunc GE192
        depthWrite
        rgbGen lightingDiffuse
    }
}
 

models/players/Iofiel/Hair_Ex3
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex3
        alphaFunc GE192
        depthWrite
        rgbGen lightingDiffuse
    }
}
 

models/players/Iofiel/Hair_Ex4
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex4
        alphaFunc GE192
        depthWrite
        rgbGen lightingDiffuse
    }
}
 

models/players/Iofiel/Hair_Ex5
{
    cull    disable
    {
        map models/players/Iofiel/Hair_Ex5
        alphaFunc GE192
        depthWrite
        rgbGen lightingDiffuse
    }
}
 

Link to comment

This is what I use for hair

 

models/players/.....
{
cull disable
    {
        map models/players/.....
        alphaFunc GE128
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        depthWrite
        rgbGen lightingDiffuse
    }
}
 
It should work
Link to comment

Howdy-hoody! Sorry if this has been answered before or something similar has come up, but I can't for the life of me find anything addressing this.

 

Anyways, to get to the point, I've been trying to wrap my head around making a shader work on a hair-texture (in .png format) to make the cut-off pieces transparent and not an untextured... texture (REDUNDANCY!!!). I've tried multiple different scripts, borrowing a few from shaders with similar use of transparency, and yet still the non textured whiteness persists! The hair pieces I've been using are 5 separate pieces on the model itself (Yeah, this is all for a custom model, should've mentioned that) and I separated the hair-textures into 5 different pieces while keeping them in .png format. Any help would be appreciated! I'll post images of the problem itself, thank you all!

 

<script pagespeed_no_defer="">//=d.offsetWidth&&0>=d.offsetHeight)a=!1;else{c=d.getBoundingClientRect();var f=document.body;a=c.top+("pageYOffset"in window?window.pageYOffset:(document.documentElement||f.parentNode||f).scrollTop);c=c.left+("pageXOffset"in window?window.pageXOffset:(document.documentElement||f.parentNode||f).scrollLeft);f=a.toString()+","+c;b.b.hasOwnProperty(f)?a=!1:(b.b[f]=!0,a=a<=b.e.height&&c<=b.e.width)}a&&(b.a.push(e),b.d[e]=!0)};p.prototype.checkImageForCriticality=function(b){b.getBoundingClientRect&&q(this,b)};h("pagespeed.CriticalImages.checkImageForCriticality",function(b){n.checkImageForCriticality(b)});h("pagespeed.CriticalImages.checkCriticalImages",function(){r(n)});var r=function(b){b.b={};for(var d=["IMG","INPUT"],a=[],c=0;c=a.length+e.length&&(a+=e)}b.g&&(e="&rd="+encodeURIComponent(JSON.stringify(s())),131072>=a.length+e.length&&(a+=e),d=!0);t=a;if(d){c=b.f;b=b.h;var f;if(window.XMLHttpRequest)f=new XMLHttpRequest;else if(window.ActiveXObject)try{f=new ActiveXObject("Msxml2.XMLHTTP")}catch(k){try{f=new ActiveXObject("Microsoft.XMLHTTP")}catch(u){}}f&&(f.open("POST",c+(-1==c.indexOf("?")?"?":"&")+"url="+encodeURIComponent(b)),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(a))}}},s=function(){var b={},d=document.getElementsByTagName("IMG");if(0==d.length)return{};var a=d[0];if(!("naturalWidth"in a&&"naturalHeight"in a))return{};for(var c=0;a=d[c];++c){var e=a.getAttribute("pagespeed_url_hash");e&&(!(e in b)&&0=b[e].k&&a.height>=b[e].j)&&(b[e]={rw:a.width,rh:a.height,ow:a.naturalWidth,oh:a.naturalHeight})}return b},t="";h("pagespeed.CriticalImages.getBeaconData",function(){return t});h("pagespeed.CriticalImages.Run",function(b,d,a,c,e,f){var k=new p(b,d,a,e,f);n=k;c&&m(function(){window.setTimeout(function(){r(k)},0)})});})();pagespeed.CriticalImages.Run('/mod_pagespeed_beacon','http://jkhub.org/index.php?s=0a26b51b5c3bc0371f83fb8cc32984a5&app=forums&module=ajax§ion=topics&do=quote&t=6737&p=98109&md5check=ecba2a4d3033837a868480b442547b35&isRte=1,fjWlWhWKDj,true,false,CGt2VV3uMbk'); //]]></script>JnDWUuf.jpg&&0

 

b6bI2qG.jpg

 

ql3NS4x.jpg

 

42hJPGu.jpg

As always I suggest to check how the shaders were made for default player models (check the shader of jedi_hf's model hair )

Link to comment

Howdy again! Sorry I haven't put a response to anything for awhile! Was spending time with family and all that goodness.

 

So, to start off, this is the first time a shader I've put in a model has messed up royally, but it's also the first time I've tried with a hair texture- usually I'm using the transparency on clothes and such which works almost 100% of the time.

 

For the .png image, I posted the exact texture I'm using in a post up above, if you'd like to look at it I would be extremely thankful!

 

I also did look at the shaders in the base JA assets and tried putting some codes in from there recently, but that white area still stays there, mocking me!

 

Lastly, if anyone would like to check out the model themselves, I would be happy to send it your way! Just send a message to me and all that goodness. It's still something I'm working on, so the weighing in some areas might be a tad-bit wonky.

 

Thank you all again for responding!

Link to comment

Howdy again! Sorry I haven't put a response to anything for awhile! Was spending time with family and all that goodness.

 

So, to start off, this is the first time a shader I've put in a model has messed up royally, but it's also the first time I've tried with a hair texture- usually I'm using the transparency on clothes and such which works almost 100% of the time.

 

For the .png image, I posted the exact texture I'm using in a post up above, if you'd like to look at it I would be extremely thankful!

 

I also did look at the shaders in the base JA assets and tried putting some codes in from there recently, but that white area still stays there, mocking me!

 

Lastly, if anyone would like to check out the model themselves, I would be happy to send it your way! Just send a message to me and all that goodness. It's still something I'm working on, so the weighing in some areas might be a tad-bit wonky.

 

Thank you all again for responding!

 

Send me your file and I'll get it working.

Link to comment
  • Solution

Well, Jeff pointed out to me what the problem was... I'm a tad-bit of a dunce and didn't notice that I'd put a " / " before "model" in the .skin folder. I'm extremely thankful to EVERYONE who posted here and helped out! Thank you!

Link to comment

I know I'm late to the thread, but here's the shader I use for Luke:

models/players/dt_luke_ep7/hair_alpha
{
	cull	disable
    {
        map models/players/dt_luke_ep7/hair_alpha
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        depthWrite
        rgbGen lightingDiffuse
    }
}

I found that a few if not all the alphafunc's will give a blocky looking result. The above shader gives a smooth result. No idea if it makes a difference, but I use TGA and not PNG.

Langerd and RevanKnight like this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...