FlyingSpoon Posted April 18, 2019 Share Posted April 18, 2019 (edited) Using 50p's Masked Texture creator, I was trying to mess with it a little and was wondering if you could apply solid colors over the textures? I've given it a try below, but it doesn't work so therefore it's wrong. Can anyone help out? Lua File float red; float green; float blue; float alpha; texture ScreenTexture; sampler implicitInputTexture = sampler_state { Texture = <ScreenTexture>; }; texture MaskTexture; sampler implicitMaskTexture = sampler_state { Texture = <MaskTexture>; }; float4 MaskTextureMain( float2 uv : TEXCOORD0 ) : COLOR0 { float4 sampledTexture = tex2D( implicitInputTexture, uv ); float4 maskSampled = tex2D( implicitMaskTexture, uv ); sampledTexture.a = (maskSampled.r + maskSampled.g + maskSampled.b) / 3.0f; return sampledTexture; } technique Technique1 { pass Pass1 { MaterialAmbient = float4(red, green, blue, alpha); AlphaBlendEnable = true; SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; PixelShader = compile ps_2_0 MaskTextureMain(); } } Shader CMasker = { }; CMasker.__index = CMasker; function CMasker: create( texture, mask ) local cShader = { shader = dxCreateShader( "/files/50masktexture.fx" ), texture = dxCreateTexture( texture, "argb", true, "clamp" ), maskTexture = dxCreateTexture( mask, "argb", true, "clamp" ), }; dxSetShaderValue( cShader.shader, "ScreenTexture", cShader.texture ); dxSetShaderValue( cShader.shader, "MaskTexture", cShader.maskTexture ); self.__index = self; setmetatable( cShader, self ); return cShader; end function CMasker: draw( x, y, width, height ) if self.shader then dxDrawImage( x, y, width, height, self.shader ); end end function CMasker: color ( r, g, b ) if self.shader then dxSetShaderValue ( self.shader, 'red', r/255 ) dxSetShaderValue ( self.shader, 'green', g/255 ) dxSetShaderValue ( self.shader, 'blue', b/255 ) dxSetShaderValue ( self.shader, 'alpha', 255/255 ) end end function CMasker: destroy( ) if self.shader then destroyElement( self.shader ); end if self.texture then destroyElement( self.texture ); end if self.maskTexture then destroyElement( self.maskTexture ); end end Edited April 18, 2019 by ℓιgнт Link to comment
JustinMTA Posted April 19, 2019 Share Posted April 19, 2019 You could set render target as the objects texture that you're trying to color, and render the color on with ease.https://wiki.multitheftauto.com/wiki/DxCreateRenderTargethttps://wiki.multitheftauto.com/wiki/DxSetRenderTarget Link to comment
FlyingSpoon Posted April 19, 2019 Author Share Posted April 19, 2019 5 hours ago, JustinMTA said: You could set render target as the objects texture that you're trying to color, and render the color on with ease.https://wiki.multitheftauto.com/wiki/DxCreateRenderTargethttps://wiki.multitheftauto.com/wiki/DxSetRenderTarget Do you have an example? Link to comment
JustinMTA Posted April 20, 2019 Share Posted April 20, 2019 19 hours ago, ℓιgнт said: Do you have an example? There's an example in the quote above in my last post where that guy asks what a render target is, for your situation you can just change the render target. Link to comment
FlyingSpoon Posted April 20, 2019 Author Share Posted April 20, 2019 12 hours ago, JustinMTA said: There's an example in the quote above in my last post where that guy asks what a render target is, for your situation you can just change the render target. Nvm, thisdp gave me an easier solution 1 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