megaman54 Posted September 16, 2014 Share Posted September 16, 2014 So i want to create a shader which takes an image file (.png etc) and checks for specified pixel color and makes those pixels totally transparent. I kinda know how i would write the lua script but the HLSL language for shader is pretty much new to me so i was hoping if someone more experienced in HLSL would guide me a little. Thx Link to comment
MTA Team botder Posted September 18, 2014 MTA Team Share Posted September 18, 2014 texture texture0; sampler Sampler0 = sampler_state { Texture = (texture0); }; struct PSInput { float2 TexCoord : TEXCOORD0; }; float4 PixelShader_Background(PSInput PS) : COLOR0 { float4 colors = tex2D(Sampler0, PS.TexCoord); if (colors.g == 1 && colors.r == 0 && colors.b == 0) { colors.a = 0; } return colors; } technique complercated { pass P0 { PixelShader = compile ps_2_0 PixelShader_Background(); } } technique simple { pass P0 { Texture[0] = texture0; } } Link to comment
megaman54 Posted September 18, 2014 Author Share Posted September 18, 2014 texture texture0; sampler Sampler0 = sampler_state { Texture = (texture0); }; struct PSInput { float2 TexCoord : TEXCOORD0; }; float4 PixelShader_Background(PSInput PS) : COLOR0 { float4 colors = tex2D(Sampler0, PS.TexCoord); if (colors.g == 1 && colors.r == 0 && colors.b == 0) { colors.a = 0; } return colors; } technique complercated { pass P0 { PixelShader = compile ps_2_0 PixelShader_Background(); } } technique simple { pass P0 { Texture[0] = texture0; } } Thanks for the shader code! Now i can get this script started properly Link to comment
Ren_712 Posted September 27, 2014 Share Posted September 27, 2014 Png with an alpha channel should work nicely as is. If you add the shader to world texture then don't forget to add AlphaRef = 1; AlphaBlendEnable = True; to your pass. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now