Jump to content

Krokara

Members
  • Posts

    27
  • Joined

  • Last visited

Posts posted by Krokara

  1. Just now, The_GTA said:

    Hmm. Maybe the combination of render-states is wrong after all. How about this?

    technique energyField
    {
        pass P0
        {
            ZEnable = true;
            ZWriteEnable = true;
            ZFunc = NEVER;
            VertexShader = compile vs_3_0 VertexShaderFunction();
            PixelShader  = compile ps_3_0 PixelShaderFunction();
        }
    }

     

    It looks like ZEnable false only works with image and ZEnable true for objects, technique 
     

    technique energyField
    {
        pass P0
        {
            ZEnable = true;
            //ZWriteEnable = true;
            VertexShader = compile vs_3_0 VertexShaderFunction();
            PixelShader  = compile ps_3_0 PixelShaderFunction();
        }
    
    }

    Result
    spacer.png
    It's working a lot, thank you The_GTA

  2. Just now, The_GTA said:

    You are rendering two passes, one without depth and one with depth. By disabling depth in the first pass you should be drawing nothing at the position of your sphere. Try merging both of the passes like this:

    ...
    
    PS_OUT PixelShaderFunction(PSInput PS)
    {
        PS_OUT psout;
        
        // Get TexCoord
        float2 position = PS.TexCoord;
        float timer = gTime;
    	
    	// correction
        position.xy = position.yx;
       
        float3 lineColor1 = float3( 2.3, 0.5, .5 );
        float3 lineColor2 = float3( 0.3, 0.5, 2.5 );
    
        // main effect	
        float3 finalColor = float3(0,0,0);
    	
        float t = sin( timer ) * 0.5 + 0.5;
        float pulse = lerp( 0.10, 0.20, t);
        
        finalColor += drawLines( position, float3( 1.0, 20.0, 30.0), lineColor1, lineColor2, timer ) * pulse;
        finalColor += drawLines( position, float3( 1.0, 2.0, 4.0), lineColor1, lineColor2, timer );
    	
        psout.color = float4(finalColor.rgb,1);
        psout.depth = 0;
        
        return psout;
    }
    //------------------------------------------------------------------------------------------
    // Techniques
    //------------------------------------------------------------------------------------------
    technique energyField
    {
        pass P0
        {
            ZEnable = false;
            VertexShader = compile vs_3_0 VertexShaderFunction();
            PixelShader  = compile ps_3_0 PixelShaderFunction();
        }
    }
    
    ...

     

    object keeps disappearing

  3. 4 hours ago, The_GTA said:

    Have you tried assigning the shader that I adjusted for you to the object? What is the effect?

    //
    // energyField.fx
    // By: Brandon Fogerty 
    // http://glslsandbox.com/e#25448.3
    // glsl to hlsl translation by Ren712
    
    // bfogerty at gmail dot com 
    // xdpixel.com
    // Special thanks to Inigo Quilez for noise!
    
    
    //------------------------------------------------------------------------------------------
    // //-- These two are set by MTA
    //------------------------------------------------------------------------------------------//
    matrix gProjectionMainScene : PROJECTION_MAIN_SCENE;
    
    
    //------------------------------------------------------------------------------------------
    // Shader settings
    //------------------------------------------------------------------------------------------
    float2 sTexSize = float2(800,600);
    float2 sScale = float2(0.5,0.5);
    float2 sCenter = float2(0.5,0.5);
    
    //------------------------------------------------------------------------------------------
    // These parameters are set by MTA whenever a shader is drawn
    //------------------------------------------------------------------------------------------
    float4x4 gWorld : WORLD;
    float4x4 gView : VIEW;
    float4x4 gProjection : PROJECTION;
    float gTime : TIME;
    #define PI 3.1415926535897
    
    //------------------------------------------------------------------------------------------
    // Structure of data sent to the vertex shader
    //------------------------------------------------------------------------------------------//
    
    struct VSInput
    {
        float3 Position : POSITION0;
        float4 Diffuse : COLOR0;
        float2 TexCoord : TEXCOORD0;
    };
    
    //------------------------------------------------------------------------------------------
    // Structure of data sent to the pixel shader ( from the vertex shader )
    //------------------------------------------------------------------------------------------
    struct PSInput
    {
        float4 Position : POSITION0;
        float4 Diffuse : COLOR0;
        float2 TexCoord: TEXCOORD0;
    };
    
    struct VS_IN
    {
        float4 position : POSITION;
        float2 texcoord : TEXCOORD;
    };
    
    struct VS_OUT
    {
        float4 position : SV_POSITION;
        float2 texcoord : TEXCOORD0;
    };
    
    struct PS_OUT
    {
        float4 color : COLOR0;
        float depth : DEPTH0;
    };
    
    VS_OUT VS(VS_IN input)
    {
        VS_OUT output = (VS_OUT)0;
    
        output.position = input.position;
        output.texcoord = input.texcoord;
    
        return output;
    }
    
    PS_OUT PS(VS_OUT input)
    {
        PS_OUT output = (PS_OUT)0;
    
        // Now that output.depth is defined with SV_Depth, and you have depth-write enabled,
        // this should write to the depth buffer.
        output.depth = 0;
    
        return output;
    }
    
    //-----------------------------------------------------------------------------
    //-- Get value from the depth buffer
    //-- Uses define set at compile time to handle RAWZ special case (which will use up a few more slots)
    //-----------------------------------------------------------------------------
    float FetchDepthBufferValue( float2 uv )
    {
        float4 texel = tex2D(SamplerDepth, uv);
    #if IS_DEPTHBUFFER_RAWZ
        float3 rawval = floor(255.0 * texel.arg + 0.5);
        float3 valueScaler = float3(0.996093809371817670572857294849, 0.0038909914428586627756752238080039, 1.5199185323666651467481343000015e-5);
        return dot(rawval, valueScaler / 255.0);
    #else
        return texel.r;
    #endif
    }
    
    //-----------------------------------------------------------------------------
    //-- Use the last scene projecion matrix to linearize the depth value a bit more
    //-----------------------------------------------------------------------------
    float Linearize(float posZ)
    {
        return gProjectionMainScene[3][2] / (posZ - gProjectionMainScene[2][2]);
    }
    
    
    
    PSInput VertexShaderFunction(VSInput VS)
    {
        PSInput PS = (PSInput)0;
    
        // Calculate screen pos of vertex
        float4 posWorld = mul(float4(VS.Position.xyz,1), gWorld);
        float4 posWorldView = mul(posWorld, gView);
        PS.Position = mul(posWorldView, gProjection);
    	
        // Pass through color and tex coord
        PS.Diffuse = VS.Diffuse;
    
        // Translate TexCoord
        float2 position = float2(VS.TexCoord.x,1 - VS.TexCoord.y);
        float2 center = 5 + (sCenter + 0.6);
        position += float2(1 - center.x, center.y) - 0.5;
        position = (position - 0.5) * float2(sTexSize.x/sTexSize.y,1) / sScale + 0.5;
        position -= 0.5;
        PS.TexCoord = position;
    
        return PS;
    }
    
    //------------------------------------------------------------------------------------------
    // PixelShaderFunction
    //------------------------------------------------------------------------------------------
    float hash( float n ) { return frac(sin(n)*753.5453123); }
    
    // Slight modification of iq's noise function.
    float noise( float2 x )
    {
        float2 p = floor(x);
        float2 f = frac(x);
        f = f*f*(5.0-2.0*f);
        
        float n = p.x + p.y*157.0;
        return lerp(
                        lerp( hash(n+  0.0), hash(n+  1.0),f.x),
                        lerp( hash(n+157.0), hash(n+158.0),f.x),
                f.y);
    }
    
    float fbm(float2 p, float3 a)
    {
         float v = 0.0;
         v += noise(p*a.x)*.5;
         v += noise(p*a.y)*.25;
         v += noise(p*a.z)*.125;
         return v;
    }
    
    float3 drawLines( float2 uv, float3 fbmOffset, float3 color1, float3 color2, float timer )
    {
        float timeVal = timer * 0.1;
        float3 finalColor = float3( 0.0,0.0,0.0 );
        for( int i=0; i < 3; ++i )
        {
            float indexAsFloat = float(i);
            float amp = 40.0 + (indexAsFloat*5.0);
            float period = 2.0 + (indexAsFloat+2.0);
            float thickness = lerp( 0.9, 1.0, noise(uv*10.0) );
            float t = abs( 0.9 / (sin(uv.x + fbm( uv + timeVal * period, fbmOffset )) * amp) * thickness );
            
            finalColor +=  t * color1;
        }
        
        for( int j=0; j < 5; ++j )
        {
            float indexAsFloat = float(j);
            float amp = 40.0 + (indexAsFloat*7.0);
            float period = 2.0 + (indexAsFloat+8.0);
            float thickness = lerp( 0.7, 1.0, noise(uv*10.0) );
            float t = abs( 0.8 / (sin(uv.x + fbm( uv + timeVal * period, fbmOffset )) * amp) * thickness );
            
            finalColor +=  t * color2 * 0.6;
        }
        
        return finalColor;
    }
    
    float4 PixelShaderFunction(PSInput PS) : COLOR0
    {
        // Get TexCoord
        float2 position = PS.TexCoord;
        float timer = gTime;
    	
    	// correction
        position.xy = position.yx;
       
        float3 lineColor1 = float3( 2.3, 0.5, .5 );
        float3 lineColor2 = float3( 0.3, 0.5, 2.5 );
    
        // main effect	
        float3 finalColor = float3(0,0,0);
    	
        float t = sin( timer ) * 0.5 + 0.5;
        float pulse = lerp( 0.10, 0.20, t);
        
        finalColor += drawLines( position, float3( 1.0, 20.0, 30.0), lineColor1, lineColor2, timer ) * pulse;
        finalColor += drawLines( position, float3( 1.0, 2.0, 4.0), lineColor1, lineColor2, timer );
    	
        return float4(finalColor.rgb,1);
    
    }
    //------------------------------------------------------------------------------------------
    // Techniques
    //------------------------------------------------------------------------------------------
    technique energyField
    {
        pass P0
        {
    		zEnable = false;
            VertexShader = compile vs_3_0 VS();
            PixelShader  = compile ps_3_0 PS();
        }
        pass P1
        {
            VertexShader = compile vs_3_0 VertexShaderFunction();
            PixelShader  = compile ps_3_0 PixelShaderFunction();
        }
    }
    
    // Fallback
    technique fallback
    {
        pass P0
        {
            // Just draw normally
        }
    }

    I don't understand why it is not modifying depth

  4. Just now, The_GTA said:

    Why didn't you start out with a clean HLSL pixel shader file? I don't even understand what weird ... things you wrote in that HLSL file. Did you have a HLSL file prior to this mess or did you just take this from the MTA wiki? You really should not have taken anything without me telling you to.

    Texture2D m_TextureColor;
    
    SamplerState g_samPoint
    {
        Filter = MIN_MAG_MIP_POINT;
        AddressU = Wrap;
        AddressV = Wrap;
    };
    
    
    
    struct VS_IN
    {
        float4 position : POSITION;
        float2 texcoord : TEXCOORD;
    };
    
    struct VS_OUT
    {
        float4 position : SV_POSITION;
        float2 texcoord : TEXCOORD0;
    };
    
    struct PS_OUT
    {
        float4 color : COLOR0;
        float depth : DEPTH0;
    };
    
    VS_OUT VS(VS_IN input)
    {
        VS_OUT output = (VS_OUT)0;
    
        output.position = input.position;
        output.texcoord = input.texcoord;
    
        return output;
    }
    
    PS_OUT PS(VS_OUT input)
    {
        PS_OUT output = (PS_OUT)0;
    
        // Now that output.depth is defined with SV_Depth, and you have depth-write enabled,
        // this should write to the depth buffer.
        output.depth = 0;
    
        return output;
    }
    technique depthh
    {
        pass P0
        {
            VertexShader = compile vs_3_0 VS();
            PixelShader  = compile ps_3_0 PS();
        }
    }

    You still have to add things like the color output as well as the render-state adjustment to the pass.

    that Russian lightning effect I couldn't make it work so for now I'm not touching it this is another shader
     

    spacer.png
    object is not working like the image

    I made a video
    https://drive.google.com/file/d/1XV588GBdFpLUXZksPVjZSoPfpI5ss4Z1/view?usp=sharing

  5. 1 hour ago, The_GTA said:

    Take a look at https://docs.microsoft.com/de-de/windows/win32/direct3d9/effect-states

    There you can find the RenderState property "ZEnable". Try to set ZEnable = FALSE; for your pass inside of your technique to disable depth testing.

    If you want to know how to write to the depth in a pixel shader take a look at this:

    c# - HLSL modify depth in pixel shader - Stack Overflow

    spacer.png

    I, couldn't change the depth

    texture gDepthBuffer : DEPTHBUFFER;
    Texture2D m_TextureColor;
    
    sampler SamplerDepth = sampler_state
    {
        Texture     = (gDepthBuffer);
        AddressU    = Clamp;
        AddressV    = Clamp;
    };
    
    SamplerState g_samPoint
    {
        Filter = MIN_MAG_MIP_POINT;
        AddressU = Wrap;
        AddressV = Wrap;
    };
    
    
    
    struct VS_IN
    {
        float4 position : POSITION;
        float2 texcoord : TEXCOORD;
    };
    
    struct VS_OUT
    {
        float4 position : SV_POSITION;
        float2 texcoord : TEXCOORD0;
    };
    
    struct PS_OUT
    {
        float4 color : COLOR0;
        float depth : DEPTH0;
    };
    
    VS_OUT VS(VS_IN input)
    {
        VS_OUT output = (VS_OUT)0;
    
        output.position = input.position;
        output.texcoord = input.texcoord;
    
        return output;
    }
    
    PS_OUT PS(VS_OUT input)
    {
        PS_OUT output = (PS_OUT)0;
    
        // Now that output.depth is defined with SV_Depth, and you have depth-write enabled,
        // this should write to the depth buffer.
        output.depth = m_TextureColor.SampleLevel(g_samPoint, input.texcoord, 0);
    
        return output;
    }
    technique depthh
    {
        pass P0
        {
            VertexShader = compile vs_3_0 VS();
            PixelShader  = compile ps_3_0 PS();
        }
    }

    ZEnable, it worked on the image correctly, but I think that the object did not work due to the depth that I could not modfy and it keeps disappearing object at times

  6. Just now, The_GTA said:

    Hello Krokara,

    nice to see that you got that spherical 3D object into the game! You have made a nice looking effect with it, too. If you want to have a 3D object be always visible to the camera then I recommend you to set the depth value of each pixel inside of an assigned HLSL pixel shader to a very small value (close to 0 like 0.001). Also disable depth testing for all those pixels. Then your object is guaranteed to be in front of any other 3D object because it will be treated as closest 3D data to the game camera.

    Hope this helps!

    https://wiki.multitheftauto.com/wiki/DepthBuffer

    float4 PS_Example( PSInput In ) : COLOR
    {
        float BufferValue = FetchDepthBufferValue( In.TexCoord.xy );
        float Depth = Linearize( BufferValue );
        
        Depth = 0.0f;
        return Depth;
    }

    so far is everything alright?

    now i don't know how i can disable depth testing

  7. Just now, IIYAMA said:

    If the object doesn't need collision, you can create it with a lowLOD appearance.

    https://wiki.multitheftauto.com/wiki/CreateObject

    Syntax createObject function:

    object createObject ( int modelId, float x, float y, float z, [ float rx, float ry, float rz, bool isLowLOD = false ] )

    Set lowLOD to true.

    That will increase draw distance.

     

    You misunderstood I want the object to be visible even with the player in front of the object

     

  8. 23 hours ago, The_GTA said:

    You could attach a shader onto the object and animate it like that. There are several approaches but you need a "round" 3D model first which is a set of vertices that make things look round.

    Else you will always face the problem of billboards that they are just an oriented sheet of paper in 3D space. If you to draw a circle then you should just modify the texture into a circle.

    3d round object is already done

  9. 18 hours ago, The_GTA said:

    How about you create this textured sphere in a DFF model editor and then import it into the game? Once you are finished then we can talk about how to display it.

    if create an object how will do those effects?

  10. 2 hours ago, The_GTA said:

    @Krokara  @Mkl I have adjusted the scaling in the function because I forgot to half it. The scale_w and scale_h parameters are meant to be the world-coordinate units size of the texture.

    Thank you the role follows the character's camera a how I can make the vertices be round?
    exemple:

    spacer.png
    can be done using: dxDrawImage3D?

  11. how can i be implementing this function?
    function: get_billboard_vertices

    addEventHandler("onClientRender", root, function()
        pos = {getElementPosition(localPlayer)}
        primitive = {
            {pos[1]+5, pos[2], pos[3]+5,  2, 2},
            {pos[1]-5, pos[2]-5, pos[3]+5, 2 , 3},
            {pos[1]-5, pos[2], pos[3]+5,  3,4 },
            {pos[1], pos[2], pos[3], 4,5}
        }
        dxDrawMaterialPrimitive3D ("trianglestrip", dxCreateTexture("images/kame-ball2.png"), false, unpack(primitive))
    end
    )

     

  12. Just now, Mkl said:

    Hello, here a little test I just made to draw a triangle on the ped :

    local primitive = {}
    local pos = {}
    
    addEventHandler("onClientRender", root, function()
    
        pos = {getElementPosition(localPlayer)}
    
        primitive = {
            {pos[1]-2, pos[2], pos[3], tocolor(255,0,0)},
            {pos[1]+2, pos[2], pos[3], tocolor(0,255,0)},
            {pos[1], pos[2], pos[3]+2, tocolor(0,0,255)}
        }
    
        dxDrawPrimitive3D("trianglefan", false, unpack(primitive))
    end
    )

    Hope it can help :)

    In this video the power to maintain a shape even if you change angle

    exemple: 

    spacer.pngspacer.pngxxWXolc.png

     

  13. 4 hours ago, The_GTA said:

    You need to put the triangle coordinates into a 3-tuple { x, y, z }, then pass the vertices as 4th+ arguments to dxDrawMaterialPrimitive3D. Do not forget to define the z-coordinate of the second coordinate!

    Also, you need to draw this as triangles. If you have attended school then you know that a triangle consists of 3 points. By using the "trianglelist" primitive type you need to define 3 points for each triangle, thus you need to push 6 vertices to dxDrawMaterialPrimitive3D!

    There is an example using a different primitive type inside of the wiki documentation of dxDrawPrimitive3D.

    I managed to make a triangle with this function: DrawPrimitive 3D, using but its width is thin and it has no width the triangle is without shape
    spacer.png

  14. 9 hours ago, The_GTA said:

    Hello Krokara,

    this is actually not a very difficult task, if you have all the texture files to cycle through and knowledge of MTA drawing functions. For this task I recommend you to use the dx family of drawing functions.

    1. First you need to register an onClientRender event handler.
    2. Inside of it you use getPedBonePosition to find the 3D world coordinates of the ped's hand.
    3. While applying some custom layout-logic, use the dxDrawMaterialPrimitive3D function to draw two triangles forming a quad with the desired dimensions and texture animation frame at the world position of the ped's hand.
    4. Do not forget to cycle through the animation frames so the sparkly image changes depending on the elapsed time!

    How about you try your hands at some code? If you have any further trouble about the implementation then feel free to ask! ?

    I can't draw it

      	cx, cy, cz    =  getPositionFromElementOffset(localPlayer,0.1, 0.5, 1) 
      	dxDrawMaterialPrimitive3D ( "trianglelist", texturas[math.ceil(img)], false, cx, cy, cz, cx+5, cy+20)

     

  15. Just now, The_GTA said:
    • Please do not create textures or shaders every onClientRender event call (put the shader creation outside of the drawing routine)
    • Make sure you put dxDrawImage and related drawing functions inside of an onClientRender event handler (dxCreateTexture is not considered a drawing but a resource allocation function!)
    • Have you put the .jpg file into your meta.xml file so it gets downloaded by connected clients?
    myShader = dxCreateShader( "models/Arashi.fx" )  -- Create shader
    function dxshader( )
      	dxDrawImage( 100, 350, 300, 350, myShader )
    end
    addCommandHandler("ts", function(commandName)
     addEventHandler("onClientRender", root, dxshader)
     myTexture = dxCreateTexture( "models/electricity_effect.jpg" )
     dxSetShaderValue( myShader, "noiseTex", myTexture ) 
    end)

    mta.xml
     

     <file src="models/electricity_effect.jpg" />

     

  16. 3 hours ago, Ren_712 said:

    @Krokara I'd suggest analyzing shader examples from wiki (screen space ones to be exact) and see what You are missing here. Because just copying and pasting stuff will not do. The code you posted is compatible with Dx9 HLSL. The only thing i'd need would be the 3d noise texture (that should be somewhere you got the code from)

    https://ru.wikipedia.org/wiki/HLSL

     

    spacer.png

    3 hours ago, The_GTA said:

    Well, he seems to have issues writing HLSL in general. @Krokara You are missing the { at the following construct...

    ...
      
    float4 PS_Electricity(float2 texCoord: TEXCOORD) : COLOR 
    { // HERE
       float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);
    ...

     

    that was it thank, is the code right?
     

      	myShader = dxCreateShader( "models/Arashi.fx" )  -- Create shader
        myTexture = dxCreateTexture( "models/electricity_effect.jpg" )
        dxSetShaderValue( myShader, "noiseTex", myTexture ) 
      	dxDrawImage( 100, 350, 300, 350, myShader )

    not give an error but also does not display the shader

  17. 35 minutes ago, The_GTA said:

    Take at the following HLSL construct by you:

    sampler Noise = sampler_state { 
        Texture = ; 
    }; 

    You seem to have forgotten to type the texture variable name and have left a blank instead. If you want to make use of a sampler, then I recommend you to feed the shader with an actual texture to sample from, like this:

    texture noiseTex;
    sampler Noise = sampler_state { 
        Texture = noiseTex; 
    }; 

    Then you can assign a texture to the shader using the "noiseTex" shader variable (dxSetShaderValue function).

     

    36 minutes ago, The_GTA said:

    Take at the following HLSL construct by you:

    sampler Noise = sampler_state { 
        Texture = ; 
    }; 

    You seem to have forgotten to type the texture variable name and have left a blank instead. If you want to make use of a sampler, then I recommend you to feed the shader with an actual texture to sample from, like this:

    texture noiseTex;
    sampler Noise = sampler_state { 
        Texture = noiseTex; 
    }; 

    Then you can assign a texture to the shader using the "noiseTex" shader variable (dxSetShaderValue function).

    That was it
    spacer.png

    Presented something new is not recognizing float2 in line 37,4
     

    float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);

     

  18. 16 hours ago, The_GTA said:

    I think that you have not properly applied my code to your shader. Since you are using XNA you might have overwritten the file again and the technique definition is missing. Try creating the newest .fx file and putting in the technique definition.

    The error message you have provided above does not happen if you put the technique definition inside of the file. Please try giving us the actual, most recent error message!

    spacer.png
    Truth seems like I hadn't updated the file, do you know what the problem is now?

    struct VS_OUTPUT 
    {
       float4 Pos: POSITION;
       float2 texCoord: TEXCOORD;
    };
    
    VS_OUTPUT VS_Electricity(float4 Pos: POSITION)
    {
       VS_OUTPUT Out;
    
       // Clean up inaccuracies
       Pos.xy = sign(Pos.xy);
    
       Out.Pos = float4(Pos.xy, 0, 1);
       Out.texCoord = Pos.xy;
    
       return Out;
    }
    
    float4 color = float4(0, 0, 0, 0);
    float glowStrength = 6;
    float height = 5;
    float glowFallOff = 1;
    float speed = 2;
    float sampleDist = 0;
    float ambientGlow = 1;
    float ambientGlowHeightScale = 0;
    float vertNoise = 6;
    float time_0_X = 0;
    sampler Noise = sampler_state { 
        Texture = ; 
    }; 
      
    float4 PS_Electricity(float2 texCoord: TEXCOORD) : COLOR 
    
       float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);
       // Sample at three positions for some horizontal blu
       // The shader should blur fine by itself in vertical directio
       float xs0 = texCoord.x - sampleDist;
       float xs1 = texCoord.x;
       float xs2 = texCoord.x + sampleDist;
       // Noise for the three sample
       float noise0 = tex3D(Noise, float3(xs0, t));
       float noise1 = tex3D(Noise, float3(xs1, t));
       float noise2 = tex3D(Noise, float3(xs2, t));
       // The position of the flas
       float mid0 = height * (noise0 * 2 - 1) * (1 - xs0 * xs0);
       float mid1 = height * (noise1 * 2 - 1) * (1 - xs1 * xs1);
       float mid2 = height * (noise2 * 2 - 1) * (1 - xs2 * xs2);
       // Distance to flas
       float dist0 = abs(texCoord.y - mid0);
       float dist1 = abs(texCoord.y - mid1);
       float dist2 = abs(texCoord.y - mid2);
       // Glow according to distance to flas
       float glow = 1.0 - pow(0.25 * (dist0 + 2 * dist1 + dist2), glowFallOff);
       // Add some ambient glow to get some power in the air feeling
       float ambGlow = ambientGlow * (1 - xs1 * xs1) * (1 - abs(ambientGlowHeightScale * texCoord.y));
    
       return (glowStrength * glow * glow + ambGlow) * color;
    }
    
    technique TS
    {
        pass P0
        {
            VertexShader = compile vs_2_0 VS_Electricity();
            PixelShader = compile ps_3_0 PS_Electricity();
        }
    }

     

  19. Just now, The_GTA said:

    Hello Krokara,

    have you looked at the MTA wiki documentation for the HLSL shaders? The error message should point you at a very specific detail of Direct3D9 effect files: the technique definition. Inside of a technique you define passes. In each pass you define the associated render-states and shader functions.

    For example, you could define the following technique in your effect file:

    technique TS
    {
        pass P0
        {
            VertexShader = compile vs_2_0 VS_Electricity();
            PixelShader = compile ps_3_0 PS_Electricity();
        }
    }

    Good luck!

    spacer.png
    Hi, thank you very much hope to get it too, I think the technique is not being loaded yet
     

    struct VS_OUTPUT 
    {
       float4 Pos: POSITION;
       float2 texCoord: TEXCOORD;
    };
    
    VS_OUTPUT VS_Electricity(float4 Pos: POSITION)
    {
       VS_OUTPUT Out;
    
       // Clean up inaccuracies
       Pos.xy = sign(Pos.xy);
    
       Out.Pos = float4(Pos.xy, 0, 1);
       Out.texCoord = Pos.xy;
    
       return Out;
    }
    
    float4 color = float4(0, 0, 0, 0);
    float glowStrength = 6;
    float height = 5;
    float glowFallOff = 1;
    float speed = 2;
    float sampleDist = 0;
    float ambientGlow = 1;
    float ambientGlowHeightScale = 0;
    float vertNoise = 6;
    float time_0_X = 0;
    sampler Noise = sampler_state { 
       Texture = ;
    }; 
      
    float4 PS_Electricity(float2 texCoord: TEXCOORD) : COLOR 
    
       float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);
       // Sample at three positions for some horizontal blu
       // The shader should blur fine by itself in vertical directio
       float xs0 = texCoord.x - sampleDist
       float xs1 = texCoord.x
       float xs2 = texCoord.x + sampleDist;
       // Noise for the three sample
       float noise0 = tex3D(Noise, float3(xs0, t))
       float noise1 = tex3D(Noise, float3(xs1, t))
       float noise2 = tex3D(Noise, float3(xs2, t));
       // The position of the flas
       float mid0 = height * (noise0 * 2 - 1) * (1 - xs0 * xs0)
       float mid1 = height * (noise1 * 2 - 1) * (1 - xs1 * xs1)
       float mid2 = height * (noise2 * 2 - 1) * (1 - xs2 * xs2);
       // Distance to flas
       float dist0 = abs(texCoord.y - mid0)
       float dist1 = abs(texCoord.y - mid1)
       float dist2 = abs(texCoord.y - mid2);
       // Glow according to distance to flas
       float glow = 1.0 - pow(0.25 * (dist0 + 2 * dist1 + dist2), glowFallOff);
       // Add some ambient glow to get some power in the air feeling
       float ambGlow = ambientGlow * (1 - xs1 * xs1) * (1 - abs(ambientGlowHeightScale * texCoord.y));
    
       return (glowStrength * glow * glow + ambGlow) * color;
    }
    
    technique TS
    {
        pass P0
        {
            VertexShader = compile vs_2_0 VS_Electricity();
            PixelShader = compile ps_3_0 PS_Electricity();
        }
    }

    Maybe it's a mistake I made converting to mta shader
    file in hsls xna FX
     

    struct VS_OUTPUT 
    {
       float4 Pos: POSITION;
       float2 texCoord: TEXCOORD;
    };
    
    VS_OUTPUT VS_Electricity(float4 Pos: POSITION)
    {
       VS_OUTPUT Out;
    
       // Clean up inaccuracies
       Pos.xy = sign(Pos.xy);
    
       Out.Pos = float4(Pos.xy, 0, 1);
       Out.texCoord = Pos.xy;
    
       return Out;
    }
    
    float4 color: register(c1);
    float glowStrength: register(c2);
    float height: register(c3);
    float glowFallOff: register(c4);
    float speed: register(c5);
    float sampleDist: register(c6);
    float ambientGlow: register(c7);
    float ambientGlowHeightScale: register(c8);
    float vertNoise: register(c9);
    float time_0_X: register(c0);
    sampler Noise: register(s0);
    
    float4 PS_Electricity(float2 texCoord: TEXCOORD) : COLOR 
    {
       float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);
    
       // Sample at three positions for some horizontal blur
       // The shader should blur fine by itself in vertical direction
       float xs0 = texCoord.x - sampleDist;
       float xs1 = texCoord.x;
       float xs2 = texCoord.x + sampleDist;
    
       // Noise for the three samples
       float noise0 = tex3D(Noise, float3(xs0, t));
       float noise1 = tex3D(Noise, float3(xs1, t));
       float noise2 = tex3D(Noise, float3(xs2, t));
    
       // The position of the flash
       float mid0 = height * (noise0 * 2 - 1) * (1 - xs0 * xs0);
       float mid1 = height * (noise1 * 2 - 1) * (1 - xs1 * xs1);
       float mid2 = height * (noise2 * 2 - 1) * (1 - xs2 * xs2);
    
       // Distance to flash
       float dist0 = abs(texCoord.y - mid0);
       float dist1 = abs(texCoord.y - mid1);
       float dist2 = abs(texCoord.y - mid2);
    
       // Glow according to distance to flash
       float glow = 1.0 - pow(0.25 * (dist0 + 2 * dist1 + dist2), glowFallOff);
    
       // Add some ambient glow to get some power in the air feeling
       float ambGlow = ambientGlow * (1 - xs1 * xs1) * (1 - abs(ambientGlowHeightScale * texCoord.y));
    
       return (glowStrength * glow * glow + ambGlow) * color;
    }

    I'm learning to work with shaders now if you can help me or specify me a specific tutorial, or even defining the technique does not compile something missing?

    current code:

    struct VS_OUTPUT 
    {
       float4 Pos: POSITION;
       float2 texCoord: TEXCOORD;
    };
    
    VS_OUTPUT VS_Electricity(float4 Pos: POSITION)
    {
       VS_OUTPUT Out;
    
       // Clean up inaccuracies
       Pos.xy = sign(Pos.xy);
    
       Out.Pos = float4(Pos.xy, 0, 1);
       Out.texCoord = Pos.xy;
    
       return Out;
    }
    
    float4 color = float4(0, 0, 0, 0);
    float glowStrength = 6;
    float height = 5;
    float glowFallOff = 1;
    float speed = 2;
    float sampleDist = 0;
    float ambientGlow = 1;
    float ambientGlowHeightScale = 0;
    float vertNoise = 6;
    float time_0_X = 0;
    sampler Noise = sampler_state { 
        Texture = (gTexture0);
    }; 
      
    float4 PS_Electricity(float2 texCoord: TEXCOORD) : COLOR 
    
       float2 t = float2(speed * time_0_X * 0.5871 - vertNoise * abs(texCoord.y), speed * time_0_X);
       // Sample at three positions for some horizontal blu
       // The shader should blur fine by itself in vertical directio
       float xs0 = texCoord.x - sampleDist
       float xs1 = texCoord.x
       float xs2 = texCoord.x + sampleDist;
       // Noise for the three sample
       float noise0 = tex3D(Noise, float3(xs0, t))
       float noise1 = tex3D(Noise, float3(xs1, t))
       float noise2 = tex3D(Noise, float3(xs2, t));
       // The position of the flas
       float mid0 = height * (noise0 * 2 - 1) * (1 - xs0 * xs0)
       float mid1 = height * (noise1 * 2 - 1) * (1 - xs1 * xs1)
       float mid2 = height * (noise2 * 2 - 1) * (1 - xs2 * xs2);
       // Distance to flas
       float dist0 = abs(texCoord.y - mid0)
       float dist1 = abs(texCoord.y - mid1)
       float dist2 = abs(texCoord.y - mid2);
       // Glow according to distance to flas
       float glow = 1.0 - pow(0.25 * (dist0 + 2 * dist1 + dist2), glowFallOff);
       // Add some ambient glow to get some power in the air feeling
       float ambGlow = ambientGlow * (1 - xs1 * xs1) * (1 - abs(ambientGlowHeightScale * texCoord.y));
    
       return (glowStrength * glow * glow + ambGlow) * color;
    }
    
    technique TS
    {
        pass P0
        {
            VertexShader = compile vs_2_0 VS_Electricity();
            PixelShader = compile ps_3_0 PS_Electricity();
        }
    }

     

×
×
  • Create New...