Jump to content

enzoDs

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by enzoDs

  1. VS.Position = float3(1, 2, 3); how i can "unpack" VS.Position? I need make this: (but in .fx language) VsPosition = {1,2,3} x, y, z = unpack( VsPosition )
  2. This is actually solved I haven't found a way to delete the post
  3. enzoDs

    Shader help :D

    This is actually solved I haven't found a way to delete the post
  4. Hello, i have this shader: I reuse it from another script and I want to use it to change the width of the wheels. (I have no idea how the shader works).) How can I make the texture of the wheel not change? https://imgur.com/a/dcSmzsD.png // // Example shader - ped_morph.fx // //--------------------------------------------------------------------- // Ped morph settings //--------------------------------------------------------------------- float3 sMorphSize = float3(0,0,0); float sCamber = 0; float sWidth = 0.2; float sRotationX = 0; float sRotationZ = 0; float3 sAxis = float3(0, 0, 0); float4 sColor = float4(0, 0, 0, 1); texture sReflectionTexture; float gFilmDepth = 1; float gFilmIntensity = 0.25; bool gFilmDepthEnable = true; //--------------------------------------------------------------------- // Include some common stuff //--------------------------------------------------------------------- #include "mta-helper.fx" sampler Sampler0 = sampler_state { Texture = (gTexture0); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; }; samplerCUBE ReflectionSampler = sampler_state { Texture = (sReflectionTexture); MAGFILTER = LINEAR; MINFILTER = LINEAR; MIPFILTER = LINEAR; MIPMAPLODBIAS = 0.000000; }; //--------------------------------------------------------------------- // Structure of data sent to the vertex shader //--------------------------------------------------------------------- struct VSInput { float3 Position : POSITION0; float3 Normal : NORMAL0; 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; float3 Tangent : TEXCOORD1; float3 Binormal : TEXCOORD2; float3 Normal : TEXCOORD3; float3 NormalSurf : TEXCOORD4; float3 View : TEXCOORD5; float4 BottomColor : TEXCOORD6; float3 SparkleTex : TEXCOORD7; float4 Diffuse2 : COLOR1; }; ////////////////////////////////////////////////////////////////////////// // Function to Index this texture - use in vertex or pixel shaders /////// ////////////////////////////////////////////////////////////////////////// float calc_view_depth(float NDotV,float Thickness) { return (Thickness / NDotV); } float4 quat_from_axis_angle(float3 axis, float angle) { float4 qr; float half_angle = (angle * 0.5) * 3.14159 / 180.0; qr.x = axis.x * sin(half_angle); qr.y = axis.y * sin(half_angle); qr.z = axis.z * sin(half_angle); qr.w = cos(half_angle); return qr; } float4 quat_conj(float4 q) { return float4(-q.x, -q.y, -q.z, q.w); } float4 quat_mult(float4 q1, float4 q2) { float4 qr; qr.x = (q1.w * q2.x) + (q1.x * q2.w) + (q1.y * q2.z) - (q1.z * q2.y); qr.y = (q1.w * q2.y) - (q1.x * q2.z) + (q1.y * q2.w) + (q1.z * q2.x); qr.z = (q1.w * q2.z) + (q1.x * q2.y) - (q1.y * q2.x) + (q1.z * q2.w); qr.w = (q1.w * q2.w) - (q1.x * q2.x) - (q1.y * q2.y) - (q1.z * q2.z); return qr; } float3 rotate_vertex_position(float3 position, float3 axis, float angle) { float4 qr = quat_from_axis_angle(axis, angle); float4 qr_conj = quat_conj(qr); float4 q_pos = float4(position.x, position.y, position.z, 0); float4 q_tmp = quat_mult(qr, q_pos); qr = quat_mult(q_tmp, qr_conj); return float3(qr.x, qr.y, qr.z); } //------------------------------------------------------------------------------------------ // VertexShaderFunction // 1. Read from VS structure // 2. Process // 3. Write to PS structure //------------------------------------------------------------------------------------------ PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection); VS.Position *= float3(1 + sWidth, 1, 1); VS.Position = rotate_vertex_position(VS.Position, float3(1, 0, 0), float3(sRotationX, 0, 0)); VS.Position = rotate_vertex_position(VS.Position, float3(0, 1, 0), float3(sCamber, 0, 0)); VS.Position = rotate_vertex_position(VS.Position, float3(0, 0, 1), float3(sRotationZ, 0, 0)); // Рассчитать позицию вершины на экране PS.Position = MTACalcScreenPosition(VS.Position); // Передать tex coords PS.TexCoord = VS.TexCoord; VS.Normal = rotate_vertex_position(VS.Normal, float3(1, 0, 0), float3(sRotationX, 0, 0)); VS.Normal = rotate_vertex_position(VS.Normal, float3(0, 1, 0), float3(sCamber, 0, 0)); VS.Normal = rotate_vertex_position(VS.Normal, float3(0, 0, 1), float3(sRotationZ, 0, 0)); float3 worldNormal = mul(VS.Normal, (float3x3)gWorld); // ------------------------------- PAINT ---------------------------------------- float3 worldPosition = MTACalcWorldPosition( VS.Position ); PS.View = normalize(gCameraPosition - worldPosition); // Fake tangent and binormal float3 Tangent = VS.Normal.yxz; Tangent.xz = VS.TexCoord.xy; float3 Binormal = normalize( cross(Tangent, VS.Normal) ); Tangent = normalize( cross(Binormal, VS.Normal) ); // Transfer some stuff PS.TexCoord = VS.TexCoord; PS.Tangent = normalize(mul(Tangent, gWorldInverseTranspose).xyz); PS.Binormal = normalize(mul(Binormal, gWorldInverseTranspose).xyz); PS.Normal = normalize( mul(VS.Normal, (float3x3)gWorld) ); PS.NormalSurf = VS.Normal; PS.SparkleTex.x = fmod( VS.Position.x, 10 ) * 4.0; PS.SparkleTex.y = fmod( VS.Position.y, 10 ) * 4.0; PS.SparkleTex.z = fmod( VS.Position.z, 10 ) * 4.0; PS.Diffuse = MTACalcGTABuildingDiffuse(VS.Diffuse) + float4(0.2, 0.2, 0.2, 0); return PS; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { float4 OutColor = 1; float4 paintColor = sColor; float4 maptex = tex2D(Sampler0,PS.TexCoord.xy); float4 delta = maptex - float4(0, 0, 0, 1); if (dot(delta,delta) < 0.2) { float4 Color = maptex * PS.Diffuse * 1; Color.a = PS.Diffuse.a; return Color; } // Some settings for something or another float microflakePerturbation = 1.00; float normalPerturbation = 1.00; float microflakePerturbationA = 0.10; // Compute paint colors float4 base = gMaterialAmbient; // Get the surface normal float3 vNormal = PS.Normal; // Micro-flakes normal map is a high frequency normalized // vector noise map which is repeated across the surface. // Fetching the value from it for each pixel allows us to // compute perturbed normal for the surface to simulate // appearance of micro-flakes suspended in the coat of paint: // This shader simulates two layers of micro-flakes suspended in // the coat of paint. To compute the surface normal for the first layer, // the following formula is used: // Np1 = ( a * Np + b * N ) / || a * Np + b * N || where a << b // float3 vNp1 = normalPerturbation * vNormal ; // To compute the surface normal for the second layer of micro-flakes, which // is shifted with respect to the first layer of micro-flakes, we use this formula: // Np2 = ( c * Np + d * N ) / || c * Np + d * N || where c == d float3 vNp2 = vNormal; // The view vector (which is currently in world space) needs to be normalized. // This vector is normalized in the pixel shader to ensure higher precision of // the resulting view vector. For this highly detailed visual effect normalizing // the view vector in the vertex shader and simply interpolating it is insufficient // and produces artifacts. float3 vView = normalize( PS.View ); // Transform the surface normal into world space (in order to compute reflection // vector to perform environment map look-up): float3x3 mTangentToWorld = transpose( float3x3( PS.Tangent, PS.Binormal, PS.Normal ) ); float3 vNormalWorld = normalize( mul( mTangentToWorld, vNormal )); // Compute reflection vector resulted from the clear coat of paint on the metallic // surface: float fNdotV = saturate(dot( vNormalWorld, vView)); // Count reflection vector float3 vReflection = reflect(PS.View,PS.Normal); // Hack in some bumpyness vReflection.x+= vNp2.x * 0.1; vReflection.y+= vNp2.y * 0.1; // Sample environment map using this reflection vector: float4 envMap = texCUBE( ReflectionSampler, -vReflection.xzy ); // Premultiply by alpha: envMap.rgb = envMap.rgb * envMap.rgb * envMap.rgb; // Brighten the environment map sampling result: envMap.rgb *= 0.8; envMap.rgb += PS.BottomColor.rgb; // Sample dust texture: // Combine result of environment map reflection with the paint color: float fEnvContribution = 1.0 - 0.5 * fNdotV; float4 finalColor = envMap * fEnvContribution + base * 0.1; finalColor.rgb += PS.Diffuse2.rgb * 0.75; finalColor.a = 1.0; // Bodge in the car colors float4 Color = 0.15 + finalColor / 1 * 0.33 + PS.Diffuse * 0.9; //Color.rgb += finalColor * PS.Diffuse; Color *= maptex * paintColor; Color.a = PS.Diffuse.a; return Color; } //------------------------------------------------------------------------------------------ // Techniques //------------------------------------------------------------------------------------------ technique tec0 { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } } // Fallback technique fallback { pass P0 { // Just draw normally } }
  5. That function changes everything at the same time, I need to change only the width
  6. Hello I want to modify the width of the wheels of a vehicle, how can I do it? I can't do it with setVehicleComponentScale
  7. (29) MTA Los Santos Life Full inventory system - YouTube Hello :D,I want to make it possible to see the model of the character on the screen, how can I do it?
  8. Hello, how i can set this walkstyle? https://youtu.be/Je-bxrXtoW0?t=264
  9. enzoDs

    Clear table

    Im stupid ??? Thank you bro!
  10. enzoDs

    Clear table

    tabla = {} function iniciar () for _, object in ipairs(aclGroupListObjects(aclGetGroup( "RSPD" )) or {}) do nombre = object:gsub("user.","") table.insert( tabla, nombre..", "..getJugadorPermiso(getAccount(nombre))..", "..getJugadorPuesto(getAccount(nombre))..", "..getJugadorSueldo(getAccount(nombre))) end return tabla end I need clear the table to so that every time the function is executed, no added elements are added (google translate english xd)
  11. enzoDs

    Clear table

    i need clear table, thanks
  12. Hello, i need convert a string to 3 variables x,y,z = "15,20,18" -----------> x = 15 y = 20 z = 18 Thanks
  13. Hello, i deleted a object with removeWorldObject, but i can't delete de "other part" of the object ubicated down Normal: https://imgur.com/gGuwIgo With removeWorldObject: https://imgur.com/GPU4fpA I need empty it Thanks and sorry for the google translate
  14. WARNING: Empresas/client.Lua:71: Bad argument @ "outputChatBox" [Expected string ar argument 1, got none] I solve it, thanks!
  15. function crearEmpresa ( stringNombre, stringEmpresa ) aclCreateGroup ( tostring((stringEmpresa):gsub(" ", "-")) ) aclGroupAddObject ( aclGetGroup(tostring((stringEmpresa):gsub(" ", "-"))), "user."..getAccountName(getPlayerAccount(getPlayerFromName(stringNombre)) )) setAccountData ( getPlayerAccount(getPlayerFromName(stringNombre)), "Empresa", tostring((stringEmpresa):gsub(" ", "-")) ) outputChatBox("(( EMPRESAS: "..stringNombre.." creo un empresa llamada "..stringEmpresa.." ))") addAccount ( tostring((stringEmpresa):gsub(" ", "-")), "*******" ) a = setAccountData ( getAccount(tostring((stringEmpresa):gsub(" ", "-"))), "Puestos", toJSON(defaultPuestos) ) outputChatBox(tostring(stringTabla)) end addEvent( "crearEmpresa", true ) addEventHandler( "crearEmpresa", resourceRoot, crearEmpresa ) --outputChatBox(tostring(("Hola XD"):gsub(" ", "-"))) function TablaEmpresa (jugador) empresajugador = getAccountData(getPlayerAccount(getPlayerFromName(jugador)), "Empresa") tabla = aclGroupListObjects(aclGetGroup(empresajugador)) dataPuestos = getAccountData ( getAccount(tostring((empresajugador):gsub(" ", "-"))), "Puestos" ) outputChatBox(dataPuestos) triggerClientEvent ( getPlayerFromName(jugador), "onPanelAbierto", getPlayerFromName(jugador), tabla,dataPuestos ) end addEvent( "onPanelAbierto", true ) addEventHandler( "onPanelAbierto", resourceRoot, TablaEmpresa ) function llenarGrid (tablaEmpleados,dataPuesto) dataPuestos = fromJSON(dataPuesto) DGS:dgsGridListClear( Egrid ) outputChatBox(unpack(dataPuestos,1)) for objects,name in pairs(tablaEmpleados)do local row = DGS:dgsGridListAddRow ( Egrid ) DGS:dgsGridListSetItemText ( Egrid, row, 1, tostring((name):gsub("user.", ""))) end end addEvent( "onPanelAbierto", true ) addEventHandler( "onPanelAbierto", localPlayer, llenarGrid ) [21:13:55] WARNING: Empresas\server.Lua:71: Bad argument @ 'toJSON' [Expected bool at argument 2, got string 'none'] ? i cant unpack the table
  16. defaultPuestos = { [1] = "Jefe", [2] = "Jefe", [3] = "500", [4] = "Lider", [5] = "Lider", [6] = "400", [7] = "Empleado", [8] = "Empleado", [9] = "107", [10] = "7", [11] = "Empleado", [12] = "106", [13] = "6", [14] = "Empleado", [15] = "105", [16] = "5", [17] = "Empleado", [18] = "104", [19] = "4", [20] = "Empleado", [21] = "103", [22] = "3", [23] = "Empleado", [24] = "102", [25] = "2", [26] = "Empleado", [27] = "101", [28] = "1", [29] = "Empleado", [30] = "100", } stringTable = toJson(defaultPuestos ) defautPuestos2 = fromJson(stringTable) In this case defautPuestos2 would be a table value?
  17. Hello i need convert string to table and table to string! Thanks With de toJson o other metod
  18. How to set debugscript in console to 0?
  19. I need the gsub format to filter color codes, Thanks!
  20. Hello, i need transform R,G,B color to alphanumeric code (EX: 255,255,255 to #FFFFFF) with a function Thanks :D!
×
×
  • Create New...