Dzsozi (h03) Posted October 8, 2018 Share Posted October 8, 2018 Hello! I am making a custom CJ system and I am using custom clothes. I would like to make colorable clothes as well, where the player can define the color of the clothing or even the hair color for example. I am using dxCreateTexture to make the custom clothes' textures. My question is how can I change the color of the custom textures? Let's say I have a white T-shirt, and I want to use a colorpicker to change its color. Could somebody help me out with that please? Link to comment
JustinMTA Posted October 8, 2018 Share Posted October 8, 2018 You've asked this question before just throwing that out there not trying to be an ass xDDD You need to find a modeler to help you/teach you, or Youtube can be your best friend like how I mostly learned. Man sharpens man. You'll need to use zModeler or 3DS Max or Blender to either separate the textures into multiple pieces, (shirts, shoes, skin, etc) Or you can search through the 100+ thousand GTA SA custom ped models on the internet, and try to find peds with the textures already separated (which I've seen many like this). If you have questions add me on Skype and ask me (I won't do anything for you but I can teach you) Good luck bro. Link to comment
Dzsozi (h03) Posted October 8, 2018 Author Share Posted October 8, 2018 No I don't have to do what you wrote. I already did the system and it works perfectly without even using 3ds max or zmodeler or custom ped models. I am using only the CJ skin, clothes, clothing textures and texture replacing shaders. By the way I am asking how can I change the color of a texture created by dxCreateTexture, and I don't remember asking it before. Link to comment
Jayceon Posted October 9, 2018 Share Posted October 9, 2018 You need a color shader, or a renderTarget -> draw the texture image then draw one rectangle with the selected color -> create texture from the renderTarget pixels then destroy renderTarget. What did I say before? function changeTextureColor(textureElement, red, green, blue, alpha) local textureWidth, textureHeight = dxGetMaterialSize(textureElement) -- get the texture size local tempRenderTarget = dxCreateRenderTarget(textureWidth, textureHeight) -- create render target with texture size dxSetRenderTarget(tempRenderTarget) -- start rt dxDrawImage(0, 0, textureWidth, textureHeight, textureElement) -- draw the texture image to the rt dxDrawRectangle(0, 0, textureWidth, textureHeight, tocolor(red, green, blue, alpha)) -- draw the selected color rectangle to the rt -- you can add custom texts to texture etc.. dxSetRenderTarget() -- end rt local rt_pixels = dxConvertPixels(dxGetTexturePixels(tempRenderTarget), "png") -- get the rt pixels and convert to png destroyElement(tempRenderTarget) -- destroy rt because I converted to texture return dxCreateTexture(rt_pixels) -- return the new texture element end Or the shader way (I dont tested the shader): float red; float green; float blue; float alpha; technique colorChange { pass P0 { MaterialAmbient = float4(red, green, blue, alpha); } } -- You need to divide the r/g/b with 255 because shader color float range is 0-1. local selectedRed = 128 local selectedGreen = 64 local selectedBlue = 32 local selectedAlpha = 200 dxSetShaderValue(colorChangeShader, "red", selectedRed / 255) dxSetShaderValue(colorChangeShader, "green", selectedGreen / 255) dxSetShaderValue(colorChangeShader, "blue", selectedBlue / 255) dxSetShaderValue(colorChangeShader, "alpha", selectedAlpha / 255) -- then apply the shader to the world texture 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now