tjheldna Posted June 26, 2015 Share Posted June 26, 2015 Hi All, I'm trying my hand at modifying the diffuse_normal shader to do a particular task. Basicly I want to texture cars using rgb values with a decal texture overlay. Doing this I can easily change the color of the cars paintwork using rgb values but keep things like lights, damage, interior the same. This does work but one thing I can't do is get a nice alpha fade off, blended by the alpha value on the texture with the rgb value. float textureAlpha = texture(texture0,ex_texcoords0).a; if(textureAlpha > 0.0) { outcolor = texture(texture0,ex_texcoords0); } else { outcolor = (ex_color * (1.0 - texture(texture0,ex_texcoords0).a)); } If I change the 0.0 value I get various results but always a hard line around the decals where I'm trying to blend with the texture alpha. Any insight into this would be great! Thanks Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 27, 2015 Share Posted June 27, 2015 Essentially you are just doing what the alphatest shader performs - ignore anything below (or above) a fixed alpha limit which will always give a hard line if you have varying alpha in your texture. In LE2, we had the alphablend shader but this only worked when the object was drawn in the transparency world. I would try to combine the color with the texture via a mix() without regards to an alpha limit. It would probably be easier for others to test if you supplied an example object, the full shader, and an example decal texture. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
tjheldna Posted June 27, 2015 Author Share Posted June 27, 2015 Thanks macklebee, I'll try mix. I'll also put something together for testing. Just wondering where can a find a good list of functions available to me for shaders in LE? Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 27, 2015 Share Posted June 27, 2015 Just wondering where can a find a good list of functions available to me for shaders in LE? This is the official reference card: https://www.opengl.org/sdk/docs/reference_card/opengl44-quick-reference-card.pdf Edit- theres a new one for 4.5 but LE projects appear to be still using 4.4 since 4.5 was just released a month ago (also the built-in functions essentially havent changed much in years). Also, in the previous post i suggested to do a mix without regards to the alpha - actually i would try to use the texture's alpha as the interpolation step value in the mix() function to determine if the color or the texture would be more prevalent. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
tjheldna Posted June 27, 2015 Author Share Posted June 27, 2015 Thanks Macklebee for pointing me in the right direction. I got it working in one line. //Decals outcolor = mix(ex_color, texture(texture0, ex_texcoords0), texture(texture0,ex_texcoords0).a) Summer Games Tournament Truck01 thanks you! 4 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.