Jump to content

Krokara

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by Krokara

  1. Animation video I want to walk this animation
  2. 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 It's working a lot, thank you The_GTA
  3. // // 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. that Russian lightning effect I couldn't make it work so for now I'm not touching it this is another shader object is not working like the image I made a video https://drive.google.com/file/d/1XV588GBdFpLUXZksPVjZSoPfpI5ss4Z1/view?usp=sharing
  5. 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. More other players would not see the same thing in the same player world position.
  7. 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
  8. You misunderstood I want the object to be visible even with the player in front of the object
  9. i want to give visual priority to make my object appear first than the player when the player is in front of the object it is no longer visible i want to change it
  10. 3d round object is already done
  11. if create an object how will do those effects?
  12. Thank you the role follows the character's camera a how I can make the vertices be round? exemple: can be done using: dxDrawImage3D?
  13. 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 )
  14. In this video the power to maintain a shape even if you change angle exemple:
  15. 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
  16. 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)
  17. how can I make these powers in the character's hand exemple: https://www.youtube.com/watch?v=X_RwBv_7IWE
  18. 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" />
  19. https://ru.wikipedia.org/wiki/HLSL 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
  20. That was it 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);
  21. 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(); } }
  22. 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...