Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Dzsozi (h03)

  1. This is not an outline, just scaled up textures which is not the same. I already tested it.
  2. I know about this resource and I get it, but | | V And I guess I would have to edit the .fx file, but I don't know what to do, edit where and what? I have no idea.
  3. Hello! I would like to make a shader which creates an outline for an element I choose to. Similar to this effect on the image (look at the right bottom corner and the desk, you can see a blue and a yellow outline for the objects): One more example: I have a .fx file and a few lines of code, but I am not sure what should I do with the shader file, I just started learning HLSL language and I almost know nothing about it. I found this shader on a tutorial website for HLSL, here: http://rbwhitaker.wikidot.com/toon-shader and I just copied the parts that I think I need, the outline part of the shader. But my script doesn't seem to work, I don't know what could be the problem and how to solve it, and also, debugscript 3 doesn't output any errors. It would be awesome if somebody could help me out with this one. Here's my current client side script: local outlineShader function createElementOutline(element, thickness, r,g,b,a) if element and isElement(element) then for _,name in ipairs(engineGetModelTextureNames(tostring(getElementModel(element)))) do dxSetShaderValue(outlineShader, "Texture", name) engineApplyShaderToWorldTexture(outlineShader, name, element) end dxSetShaderValue(outlineShader, "LineThickness", thickness) dxSetShaderValue(outlineShader, "LineColor", r/255, g/255, b/255, a/255) end end addEventHandler("onClientResourceStart", resourceRoot, function() if getVersion().sortable < "1.5" then outputChatBox("Resource is not compatible with this client.") return else outlineShader = dxCreateShader("shaders/outline.fx") createElementOutline(localPlayer, 1, 255,255,255,255) if (not outlineShader) then outputChatBox("Could not create Outline shader. Please use debugscript 3.") end end end) And the shader file: // The world transformation float4x4 World; // The view transformation float4x4 View; // The projection transformation float4x4 Projection; // The transpose of the inverse of the world transformation, // used for transforming the vertex's normal float4x4 WorldInverseTranspose; // The color to draw the lines in. Black is a good default. float4 LineColor = float4(0, 0, 0, 1); // The thickness of the lines. This may need to change, depending on the scale of // the objects you are drawing. float LineThickness = .03; // The texture being used for the object texture Texture; // The texture sampler, which will get the texture color sampler2D textureSampler = sampler_state { Texture = (Texture); MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; struct AppToVertex { float4 Position : POSITION0; // The position of the vertex float3 Normal : NORMAL0; // The vertex's normal float2 TextureCoordinate : TEXCOORD0; // The texture coordinate of the vertex }; // The structure used to store information between the vertex shader and the // pixel shader struct VertexToPixel { float4 Position : POSITION0; float2 TextureCoordinate : TEXCOORD0; float3 Normal : TEXCOORD1; }; // The vertex shader that does the outlines VertexToPixel OutlineVertexShader(AppToVertex input) { VertexToPixel output = (VertexToPixel)0; // Calculate where the vertex ought to be. This line is equivalent // to the transformations in the CelVertexShader. float4 original = mul(mul(mul(input.Position, World), View), Projection); // Calculates the normal of the vertex like it ought to be. float4 normal = mul(mul(mul(input.Normal, World), View), Projection); // Take the correct "original" location and translate the vertex a little // bit in the direction of the normal to draw a slightly expanded object. // Later, we will draw over most of this with the right color, except the expanded // part, which will leave the outline that we want. output.Position = original + (mul(LineThickness, normal)); return output; } // The pixel shader for the outline. It is pretty simple: draw everything with the // correct line color. float4 OutlinePixelShader(VertexToPixel input) : COLOR0 { return LineColor; } // The entire technique for doing toon shading technique Toon { // The first pass will go through and draw the back-facing triangles with the outline shader, // which will draw a slightly larger version of the model with the outline color. Later, the // model will get drawn normally, and draw over the top most of this, leaving only an outline. pass Pass1 { VertexShader = compile vs_2_0 OutlineVertexShader(); PixelShader = compile ps_2_0 OutlinePixelShader(); CullMode = CW; } } I guess I will need to use mta-helper.fx to get some positions, maybe the camera position, I am not sure, I don't really understand yet how shaders work. Thank you for your reply in advance!
  4. I have been trying to change the values, but these doesn't seem to work, well I can't make them functioning the way I would like to. But I have one more idea, I don't know if it is possibble, but is there any way to get the surface rotation or anything like this? I'm thinking about the default headlight shadow's functionality, is there any way to recreate the way it is working?
  5. Hello! I really need some math experts' help, I can't figure out what should I do. I am using the dxDrawMaterialLine3D function to draw light shadows on the ground, and these are attached to a vehicle. My only problem is that I don't know how should I make the light always face up, even when the vehicle is rotated and keep the rotation, so I won't experience problems like this: So as you can see, when I'm not on an even surface, the "light" goes through the ground, that's why I would like to make the image face upwards depending on the vehicle's rotation, or at least adjust it and not make it face always up. I hope you understand what I am trying to do. Here's what it should look like (it is on an even surface): So, I don't really know how should I calculate these numbers to make it work with the faceTowardX, faceTowardY and faceTowardZ parameters. Could somebody help me out with the calculations? local x, y, z = getElementPosition(matching.element) local rx, ry, rz = getElementRotation(matching.element) local faceX, faceY, faceZ = --?, ?, ? dxDrawMaterialLine3D(worldX, worldY-1, fixedGroundPosition, worldX, worldY+1, fixedGroundPosition, data.renderTarget, 2, tocolor(lightColor[1],lightColor[2],lightColor[3],lightColor[4]), faceX, faceY, faceZ) Thank you for your reply in advance!
  6. Hello! I have a simple question for people experienced with shaders. This might not be hard to do, but I am no expert when it comes to shaders. I would like to make a shader which allows me to add a texture on top of an existing texture. For example, let's say I want to make CJ's clothes dirty without replacing the actual clothing texture, but instead I could apply the shader on the player_torso (I guess), and if it is possibble, I could create a new texture which could be placed on the player_torso texture, but not replacing it, just adding the custom texture on top. I hope you understand me. So the question is, how can I make something like this possibble? If it's not a big favor, could somebody help me out with writing the fx shader file? I have 0 HLSL knowledge, so that would be really helpful. Thank you for your reply in advance!
  7. Yes I agree and I was also thinking about it.
  8. https://community.multitheftauto.com/index.php?p=resources&s=details&id=12903 This may help you out with the rotations.
  9. It works, thank you so much! I didn't even think about this kind of solution. Thanks again!
  10. Hello! I would like to make dxDrawTexts draw after each other with a little offset between them, like a horizontal menu thing. But I keep failing, I have been trying to solve this for hours now but I can't get the result I want. What am I doing wrong? local defaultButtonColor = tocolor(180,180,180,255) local normal = dxCreateFont("files/fonts/normal.ttf", 24, true, "antialiased") local buttonSize = 0.5 local marginOffset = 10 local menuButtons = { {"SADSADASWQETSADASG", defaultButtonColor, hover = false}, {"QRWRQW", defaultButtonColor, hover = false}, {"GDADSSASDFSASD", defaultButtonColor, hover = false}, {"FHDJRSDAD", defaultButtonColor, hover = false}, } function draw() for i=1, #menuButtons do if menuButtons[i] then local menuButtonTextWidth = dxGetTextWidth(menuButtons[i][1], buttonSize, normal) local menuButtonTextHeight = dxGetRealFontHeight(normal) local step = 50 + ((i - 1) * (menuButtonTextWidth + marginOffset)) -- problem is probably here somewhere, I guess dxDrawText(menuButtons[i][1], step, 400, 0, 0, menuButtons[i].hover and tocolor(255,255,255,255) or menuButtons[i][2], buttonSize, normal, "left", "top", false, false) end end end addEventHandler("onClientRender", root, draw) For some reason, this is the result I get: And this is what I would like to have: What is the problem, how should I do it?
  11. Check the modded vehicle's txd file if it has any light textures and replace them as well.
  12. addEventHandler("onClientResourceStart", resourceRoot, function() local shader1 = dxCreateShader("texreplace.fx") local lightsoff = dxCreateTexture("vehiclelights128.png") engineApplyShaderToWorldTexture(shader1,"vehiclelights128") dxSetShaderValue(shader1, "gTexture", lightsoff) local shader2 = dxCreateShader("texreplace.fx") local lightson = dxCreateTexture("vehiclelightson128.png") engineApplyShaderToWorldTexture(shader2,"vehiclelightson128") dxSetShaderValue(shader2, "gTexture", lightson) end) Try this and make sure that the paths for the textures in the script are correct. Also, did you add the textures in the meta file? What does the debugscript say?
  13. Hello! Today I am bringing you a new part/update of the Advanced Vehicle System project I am currently working on. This part of the project contains a simple, yet nice and effective reverse light system. It is not fully finished yet, still need some improvements and features, but I managed to get it done "partially", so I can show it to you. This is compatible with every vehicle that has the "vehiclelightson128" texture, which most of the time happens with modded vehicles. But it definitely does with default vehicles. [RED] = Unaffected lights [GREEN] = Affected lights In action: Currently this script has 3 custom functions and 2 custom events, these are: setVehicleLightsOn(vehicle, state) - This is a workaround for the default setVehicleOverrideLights function. [server] setVehicleReverseTexture(vehicle, state) - With this function you can toggle the reverse light texture on/off. [shared] isVehicleReversing(vehicle) - Returns true if the vehicle is reversing, false otherwise. [currently server only] onVehicleStartReverse - Parameters: driver, lightState [server] onVehicleStopReverse - Parameters: driver, lightState [server] driver: The player who drives the vehicle lightState: The light state of the vehicle (true/false). This returns the value set by setVehicleLightsOn function. Always returns something. The source of these events is the vehicle that starts/stops reversing. These events are triggered when a vehicle starts/stops reversing. More updates coming soon! I always like to read suggestions, so feel free to comment your thoughts and what should I add/remove! Thank you for reading, hope you like it! Part of the Advanced Vehicle System project.
  14. I think this resource has a pretty good and easy example for a dx scroll bar, this might help, I would take a look and give it a try if I was you. https://community.multitheftauto.com/index.php?p=resources&s=details&id=14403
  15. I think this would do the trick. https://community.multitheftauto.com/index.php?p=resources&s=details&id=7545 Or maybe just draw a barely visible vignette like, white (so you can set the color via script) image?
  16. Amit en javasolnek az az lenne hogy probald meg az egesz GTA SA-t ujra rakni, esetleg masik verziot letolteni es azzal megprobalni vagy esetleg masik meghajtora/mappaba telepiteni, miutan teljesen letoroltel minden MTA-hoz es GTA SA-hoz fuzodo dolgot. En ezt probalnam meg ha vegkepp semmi informaciot es segitseget nem talalnek errol neten.
  17. Information for the resource: Shared custom functions: int getVehicleDirtLevel(element vehicle) - Returns a number representing the dirt level of the vehicle. 1 is the lowest (fully clean) and 5 is the highest (most dirty). int getVehicleDirtProgress(element vehicle) - Returns a number representing the dirt progress of the vehicle. See the script files for better understanding! int getNextDirtTime(element vehicle) - Returns a number representing the time limit when the vehicle gets dirty again. See the script files for better understanding! bool setVehicleDirtLevel(element vehicle, int level) - Returns true if set succesfully, false otherwise. IMPORTANT: Using this on client side won't make the vehicle "globally" dirty, only for the client, use this on server side mostly, since this is where other things like dirt progress and other datas are being set. Also, it will only work for other clients (by that I mean that they will see the effects of the shader) if you use this function on server side. Server side custom functions: bool setVehicleDirtProgress(element vehicle, int progress) - Returns true if set succesfully, false otherwise. Sets the dirt progress of a vehicle. See the script files for better understanding! bool setVehicleDirtTime(element vehicle, int time) - Returns true if set succesfully, false otherwise. Sets the dirt time of a vehicle. This is a limit which checks if a vehicle has to get a dirt level or not. See the script files for better understanding! Server side custom events: onVehicleDirtLevelChange - Parameters: int oldLevel int newLevel oldLevel: The old dirt level of the vehicle, before the event was triggered. newLevel: The new dirt level of the vehicle, after the event was triggered. The source of this event is the vehicle that got its dirt level changed. This event is called when a vehicle got its dirt level changed. For example a vehicle was washed in a carwash. Client side custom events: onClientVehicleDirtLevelChange - Parameters: int oldLevel int newLevel oldLevel: The old dirt level of the vehicle, before the event was triggered. newLevel: The new dirt level of the vehicle, after the event was triggered. The source of this event is the vehicle that got its dirt level changed. This event is called when a vehicle got its dirt level changed. For example a vehicle was washed in a carwash.
  18. Released! Check the post for download link! Sorry for making it that long, I didn't have enough energy to work with MTA in the last few days. Anyways, enjoy the resource, hope you like it! Note that it might contain bugs or glitches, if that's the case please report them and I will try to fix it as soon as possible! You can edit the resource based on your needs, all I ask for is to leave the credits for me! Have fun!
  19. It's my own remastered version of Jayceon's radar mod that can be found on the community. https://community.multitheftauto.com/index.php?p=resources&s=details&id=12641 This one. But unfortunately I don't have the one on the pictures.
  20. New update! This resource is almost done, I will do a few more testing and improvements and I might release it, don't know for sure yet, first of all I would like to make sure it's flawless. Note that I don't spend my whole days sitting in front of my PC, scripting MTA. Don't expect me to finish this / any other project(s) I have posted in 2 days.
  21. Thank you, I fixed everything you mentioned, works perfectly now. Thank you again!
  22. Yes, I also noticed that the effectDestroyTimer was global, I already fixed it, this doesn't seem to be the problem. Here's how I call the function: local waterSplash = {} function waterSplashEffect() for k, vehicle in pairs(getElementsByType("vehicle")) do if isElementStreamedIn(vehicle) then if not isVehicleBlown(vehicle) then if isVehicleOnGround(vehicle) and not isVehicleOnRoof(vehicle) then if getVehicleSpeed(vehicle) >= 10 then waterSplash[vehicle] = createEffectAtWheels(vehicle, "water_splash", 1000) end end end end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() setTimer(function() waterSplashEffect() end, 50, 0) end )
  23. I already did that before posting, I added it later while trying to fix the problem. Here's my current code: function createEffectAtWheels(vehicle, effect, duration) if not tostring(effect) then return false end if vehicle and isElement(vehicle) and getElementType(vehicle) == "vehicle" then local vehicleType = getVehicleType(vehicle) if vehiclesWithWheels[vehicleType] then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicle) local _, _, vehicleRotation = getElementRotation(vehicle) local effectAtWheels = {} local effectDestroyTimer if isTimer(effectDestroyTimer) then killTimer(effectDestroyTimer) effectDestroyTimer = nil end for component in pairs(getVehicleComponents(vehicle)) do if wheelComponents[component] then local wheelX, wheelY, wheelZ = getVehicleComponentPosition(vehicle, component, "world") local groundZ = getGroundPosition(wheelX, wheelY, wheelZ) outputChatBox(tostring(component)) if wheelZ <= groundZ+0.5 then effectAtWheels[component] = createEffect(effect, wheelX, wheelY, wheelZ-0.275, 0, 0, vehicleRotation, 150, false) end effectDestroyTimer = setTimer(function() if effectAtWheels[component] and isElement(effectAtWheels[component]) then destroyElement(effectAtWheels[component]) effectAtWheels[component] = nil end end, duration, 1) if effectAtWheels[component] and isElement(effectAtWheels[component]) then return effectAtWheels[component] end end end end end end wheelComponents = { ["wheel_lf_dummy"] = true, ["wheel_lb_dummy"] = true, ["wheel_rf_dummy"] = true, ["wheel_rb_dummy"] = true, ["wheel_front"] = true, ["wheel_rear"] = true, } And the problem is the same, the effect is being created only at the right front wheel, and it changes to another wheel if the right front wheel doesn't touch the ground, but as soon as it touches the ground the effect is being created only at that wheel again.
  24. What would be the right way to do it then, could you help me out? I can't solve it.
  25. Any help? I think I am doing something wrong at the loop section, but I don't know what and I can't fix it.
×
×
  • Create New...