Jump to content

bover

Members
  • Posts

    17
  • Joined

  • Last visited

Posts posted by bover

  1. Discord name: bover.
    Discord user ID: 613717481323757569
    Reason for ban: I don't really know, nobody wants tell me.
    Why should we remove your ban: I've got this ban probably because of mistake. Dutchman and the others thinks that im braver. AKA Norelock that is globally banned from MTA including Discord, but I'm not him. bover. and braver. are other guys.

     

    Last appeal has been checked as I'm not banned on MTA Discord server, but I'm pretty sure that I am actually banned

    spacer.png

  2. On 24/12/2022 at 17:34, Shady1 said:

    thanks for trying to add comments but your code is not working i think you need to improve this code or i can do it for you...

    bindKey has the same name as your function

     

    local isRendering
    
    function renderImage()
    
    end 
    
    function bindRender() --change this
        isRendering = not isRendering
        outputDebugString(isRendering)
        if (isRendering) then 
            addEventHandler('onClientRender', root, renderImage)
            return true 
        end 
        removeEventHandler('onClientRender', root, renderImage)
    end
    bindKey('o', 'down', bindRender) 

     

    Oh, my bad. Didn't think about this

  3. 3 hours ago, Shady1 said:

    hi, thanks for tagging me and asking for help, I have prepared a line of code to help you, I hope it will be useful for you.

    you can do this using a variable and bindKey

    local isImage = false
    
    addEventHandler("onClientRender", root,
        function()
           if(isImage) then
              dxDrawImage(...) -- draw image if isImage true
           end
        end
    )
    
    bindKey("o", "down",
        function()
           if(isImage) then
              isImage = false
           else
                 isImage = true
           end
        end
    )

     

    Better to remove event handler while not using. Also watch out for a pyramids if and else

    local isRendering
    
    function renderImage()
    	dxDrawImage(...)
    end 
    
    function bindKey()
    	isRendering = not isRendering
    
    	if (isRendering) then 
    		addEventHandler('onClientRender', root, renderImage)
    		return true 
    	end 
    
    	removeEventHandler('onClientRender', root, renderImage)
    end
    bindKey('o', 'down', bindKey)

     

    • Like 1
  4. Hi, im using hudmask shader from https://wiki.multitheftauto.com/wiki/Shader_examples, also have a blur shader that i found somewhere on internet. I want to join those both shaders to make a shader that blurs screen source and clamp that on mask that i provide. Already connected both shaders, blur works but mask not. I were trying a lot of things but I'm not specialist of HLSL. Anyone can help?

    Shader:

    #include "tex_matrix.fx"
    
    texture screenSource;
    texture maskTexture;
    float factor;
    
    float2 gUVPrePosition = float2( 0, 0 );
    float2 gUVScale = float( 1 );
    float2 gUVScaleCenter = float2( 0.5, 0.5 );
    float gUVRotAngle = float( 0 );
    float2 gUVRotCenter = float2( 0.5, 0.5 );
    float2 gUVPosition = float2( 0, 0 );
    
    float3x3 getTextureTransform() {
        return makeTextureTransform(gUVPrePosition, gUVScale, gUVScaleCenter, gUVRotAngle, gUVRotCenter, gUVPosition);
    };
    
    sampler Sampler0 = sampler_state {
        Texture = screenSource;
        AddressU = Clamp;
        AddressV = Clamp;
    };
    
    struct PSInput {
        float2 TexCoord : TEXCOORD0;
    };
    
    float4 PixelShader_Background(PSInput PS) : COLOR0 {
    	float4 sum = tex2D(Sampler0, PS.TexCoord);
    	for (float i = 1; i < 3; i++) {
    		sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y + (i * factor)));
    		sum += tex2D(Sampler0, float2(PS.TexCoord.x, PS.TexCoord.y - (i * factor)));
    		sum += tex2D(Sampler0, float2(PS.TexCoord.x - (i * factor), PS.TexCoord.y));
    		sum += tex2D(Sampler0, float2(PS.TexCoord.x + (i * factor), PS.TexCoord.y));
    	}
    	sum /= 9;
    	sum.a = 1.0;
    	return sum;
    }
    
    technique complercated {
        pass P0 {
            PixelShader = compile ps_2_0 PixelShader_Background();
        }
    }
    
    technique simple {
        pass P0 {
            Texture[0] = screenSource;
            
            TextureTransform[0] = getTextureTransform();
            TextureTransformFlags[0] = Count2;
            AddressU[0] = Clamp;
            AddressV[0] = Clamp;
    
            ColorOp[0] = Modulate;
            ColorArg1[0] = Texture;
            ColorArg2[0] = Diffuse;
    
            AlphaOp[0] = Modulate;
            AlphaArg1[0] = Texture;
            AlphaArg2[0] = Diffuse;
         
            Texture[1] = maskTexture;
            TexCoordIndex[1] = 0;
            AddressU[1] = Clamp;
            AddressV[1] = Clamp;
    
            ColorOp[1] = SelectArg1;
            ColorArg1[1] = Current;
    
            AlphaOp[1] = Modulate;
            AlphaArg1[1] = Current;
            AlphaArg2[1] = Texture;
    
            ColorOp[2] = Disable;
            AlphaOp[2] = Disable;
        }
    }

    tex_matrix.fx:

    //
    // tex_matrix.fx
    //
    
    
    //-------------------------------------------
    // Returns a translation matrix
    //-------------------------------------------
    float3x3 makeTranslationMatrix ( float2 pos )
    {
        return float3x3(
                        1, 0, 0,
                        0, 1, 0,
                        pos.x, pos.y, 1
                        );
    }
    
    
    //-------------------------------------------
    // Returns a rotation matrix
    //-------------------------------------------
    float3x3 makeRotationMatrix ( float angle )
    {
        float s = sin(angle);
        float c = cos(angle);
        return float3x3(
                        c, s, 0,
                        -s, c, 0,
                        0, 0, 1
                        );
    }
    
    
    //-------------------------------------------
    // Returns a scale matrix
    //-------------------------------------------
    float3x3 makeScaleMatrix ( float2 scale )
    {
        return float3x3(
                        scale.x, 0, 0,
                        0, scale.y, 0,
                        0, 0, 1
                        );
    }
    
    
    //-------------------------------------------
    // Returns a combined matrix of doom
    //-------------------------------------------
    float3x3 makeTextureTransform ( float2 prePosition, float2 scale, float2 scaleCenter, float rotAngle, float2 rotCenter, float2 postPosition )
    {
        float3x3 matPrePosition = makeTranslationMatrix( prePosition );
        float3x3 matToScaleCen = makeTranslationMatrix( -scaleCenter );
        float3x3 matScale = makeScaleMatrix( scale );
        float3x3 matFromScaleCen = makeTranslationMatrix( scaleCenter );
        float3x3 matToRotCen = makeTranslationMatrix( -rotCenter );
        float3x3 matRot = makeRotationMatrix( rotAngle );
        float3x3 matFromRotCen = makeTranslationMatrix( rotCenter );
        float3x3 matPostPosition = makeTranslationMatrix( postPosition );
    
        float3x3 result =
                        mul(
                        mul(
                        mul(
                        mul(
                        mul(
                        mul(
                        mul(
                            matPrePosition
                            ,matToScaleCen)
                            ,matScale)
                            ,matFromScaleCen)
                            ,matToRotCen)
                            ,matRot)
                            ,matFromRotCen)
                            ,matPostPosition)
                        ;
        return result;
    }
    

     

    Shader usage:

    local screenSource = dxCreateScreenSource(1920, 1080)
    local shader = dxCreateShader("blurMask.fx")
    local texture = dxCreateTexture("panel.png")
    local renderTarget = dxCreateRenderTarget(539, 539, true)
    dxSetShaderValue(shader, 'screenSource', screenSource)
    dxSetShaderValue(shader, 'factor', 0.007)
    dxSetShaderValue(shader, 'maskTexture', texture)
    
    function renderScreen()
        dxUpdateScreenSource(screenSource)
    
        dxSetRenderTarget(renderTarget, true)
            dxDrawImage(-(1920/2-(539/2)), -(1080/2-(539/2)), 1920, 1080, screenSource)
        dxSetRenderTarget()
    
        dxDrawImage(0, 0, 539, 539, texture)
        dxSetShaderValue(shader, 'screenSource', renderTarget)
        
        for intensity = 0, 4 do
            dxSetShaderValue(shader, 'factor', 0.0080 * 1 + (intensity / 4 * 0.001 * 1));
        end
    
        dxDrawImage(1920/2-(539/2), 1080/2-(539/2), 539, 539, shader)
    end 
    addEventHandler('onClientRender', root, renderScreen)

     

    Effect I've got:

    QFCXKCg.png

    Expected effect should mask the blur for a texture i provide (this circle that is rendered on the left top side of screen)

×
×
  • Create New...