Dzsozi (h03) Posted November 10, 2016 Share Posted November 10, 2016 Hi! I was wondering if it is possible to make a black and a white CJ with shaders, so when a player creates a character he can decide to have a black or a white character, that would be good because players could make their characters more unique. Also, I was wondering if it is possible to change the faces of black and white CJ, so they could have not just different skin colour, but different faces. And one more thing, I was wondering if it is possible to replace clothes with shaders, so I could have more and custom clothes than the default ones, I believe there is a resource for that but I'm not sure and I don't know the name of it, and also, if I'm not mistaken, devGaming (a polish roleplay server/community) made it possible. Link to comment
pa3ck Posted November 11, 2016 Share Posted November 11, 2016 You can't have different models on the same ID but you can have different textures (like TXDs) on world elements using EngineApplyShaderToWorldTexture. Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 I know that I can't have different models, I'm talking about the textures. Link to comment
Captain Cody Posted November 11, 2016 Share Posted November 11, 2016 Yes it is possible. Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 (edited) Could somebody write an example on how to make a white and a black CJ skin at the same time please? I dont really understand shaders yet, but I would like to make this possible. Also, how can I apply the shader only to the player who has created a white character? How can I save that? How can I make unlimited clothes and faces with different textures? These things sound a little bit hard, maybe its because I dont know the shaders well, or maybe because it is hard. I would appreciate any resource if there is any out there or example or anything that helps me out with that. Edited November 11, 2016 by Dzsozi Link to comment
pa3ck Posted November 11, 2016 Share Posted November 11, 2016 (edited) It's actually not that hard as you would think. List of CJ parts you can replace with shader: "cj_ped_head", "cj_ped_hat", "cj_ped_torso", "cj_ped_legs", "cj_ped_feet", "cj_ped_glasses", "cj_ped_necklace", "cj_ped_watch" and "cj_ped_extra1". Code for replacing the torso: addCommandHandler("change", function(cmd, col) if not tonumber(col) or tonumber(col) < 0 or tonumber(col) > 3 then return end local texts = {"brown", "white", "black"} local texture = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. ".png" ) -- either export the default CJ TXD file then export the image with TXD Workshop to edit it with PhotoShop or download a custom part local shader = dxCreateShader( "files/shader.fx", 0, 0, false, "ped" ) -- this is the only shader you will need, don't need to edit anything here engineApplyShaderToWorldTexture ( shader, "cj_ped_torso", localPlayer, true ) -- this is where you specify which CJ part you want to replace, probably you will want to replace "cj_ped_head" as well dxSetShaderValue ( shader, "gTexture", texture ) -- same here, leave it as is end) I will attach a simple resource, which already has 3 "skin colors". In the resource, it only replaces the localPlayer, not every players' skin. You will need to do the same with "cj_ped_head" (at least I think that's what it's called) so you can have different faces. Saving them is quite simple, create a LUA table with all the texture file names you have, example: local skinTypes = { "white-1", "white-2", "white-3", "brown-1", "brown-2" -- etc etc } local headTypes = { "small-1", "small-2", "small-3", "med-1", "med-2" -- etc etc } And in the database you will have two columns which saves the table index of the skin and head example: 2, 5 which will be skinTypes[2] and headTypes[5], like: local texts = {"brown", "white", "black"} local texture = dxCreateTexture ( "files/" .. skinTypes[ Your_Value_From_Database ] .. ".png" ) local shader = dxCreateShader( "files/shader.fx", 0, 0, false, "ped" ) engineApplyShaderToWorldTexture ( shader, "cj_ped_torso", localPlayer, true ) dxSetShaderValue ( shader, "gTexture", texture ) [ Screenshot of the resource ] [ Download ] Edited November 11, 2016 by pa3ck 2 Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 Alright, this helps me a little bit thank you! But how can I add clothes on CJ? Because if I add for example a shirt on him, the shirt has the chosen torso texture. I would like to make it work like if you buy a shirt then your character will remain for example white (if you created a white character at the beginning of the game) and the shirt gets added on CJ but with the matching texture. I hope you can understand me. Link to comment
pa3ck Posted November 11, 2016 Share Posted November 11, 2016 engineApplyShader has this argument to let you apply more than one texture: appendLayers: allows two or more layered shaders to be applied in the same texture. You may want to modify the DepthBias in the technique pass to avoid Z-fighting artifacts when using this. Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 It is set to true in the script you sent me, but I don't really understand it. What is the DepthBias? And when I put on a shirt (a default shirt, I don't have modded shirts yet) I still see only the torso texture, not the texture of the shirt. It is kinda hard for me right now, since I don't really understand shaders as I already told you, sorry for asking much, I have never worked with shaders before. Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 Yes, but I would also like to do a skin colour change, so players could have a white and a black character (CJ) and also could change face textures. I already made the black and the white textures, but I have a little problem. Here's the script: local torsoType = "torso" addEventHandler("onClientRender", root, function() if getPedStat(localPlayer, 21) >= 500 then torsoType = "torso_fat" elseif getPedStat(localPlayer, 23) >= 500 then torsoType = "torso_ripped" elseif getPedStat(localPlayer, 21) >= 500 and getPedStat(localPlayer, 23) >= 500 then torsoType = "torso_fat" elseif getPedStat(localPlayer, 21) < 500 and getPedStat(localPlayer, 23) >= 500 then torsoType = "torso_ripped" elseif getPedStat(localPlayer, 21) >= 500 and getPedStat(localPlayer, 23) < 500 then torsoType = "torso_fat" elseif getPedStat(localPlayer, 21) < 500 and getPedStat(localPlayer, 23) < 500 then torsoType = "torso" else torsoType = "torso" end end) addCommandHandler("change", function(cmd, col) if not tonumber(col) or tonumber(col) < 0 or tonumber(col) > 2 then return end local shader = dxCreateShader( "files/shader.fx", 0, 0, false, "ped" ) local texts = {"black", "white"} local torso = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. "/" .. torsoType .. ".png" ) engineApplyShaderToWorldTexture ( shader, "cj_ped_torso", localPlayer, true ) dxSetShaderValue ( shader, "gTexture", torso ) local face = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. "/face.png" ) engineApplyShaderToWorldTexture ( shader, "cj_ped_head", localPlayer, true ) dxSetShaderValue ( shader, "gTexture", face ) local legs = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. "/legs.png" ) engineApplyShaderToWorldTexture ( shader, "cj_ped_legs", localPlayer, true ) dxSetShaderValue ( shader, "gTexture", legs ) local foot = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. "/foot.png" ) engineApplyShaderToWorldTexture ( shader, "cj_ped_feet", localPlayer, true ) dxSetShaderValue ( shader, "gTexture", foot ) end) And this is how my character looks like when I change between the skin colours: http://imgur.com/a/W8UDR I really don't understand this and the methods and ways of doing that. Link to comment
pa3ck Posted November 11, 2016 Share Posted November 11, 2016 As far as I know, all the clothing, tattoos etc are shaders as well. So basically when you apply something to the torso, you overwrite the existing shaders. A work around would be to not use addPedClothes but add them with shaders: addCommandHandler("change", function(cmd, col) if not tonumber(col) or tonumber(col) < 0 or tonumber(col) > 3 then return end local texts = {"brown", "white", "black"} local textSkin = dxCreateTexture ( "files/" .. texts[tonumber(col)] .. ".png" ) local textTshirt = dxCreateTexture ( "files/tshirt.png" ) local textFace = dxCreateTexture ( "files/nface.png" ) local skin = dxCreateShader( "files/shader.fx", 0, 0, true, "ped" ) local tshirt = dxCreateShader( "files/shader.fx", 0, 0, true, "ped" ) local face = dxCreateShader( "files/shader.fx", 0, 0, true, "ped" ) engineApplyShaderToWorldTexture ( skin, "cj_ped_torso", localPlayer ) engineApplyShaderToWorldTexture ( tshirt, "cj_ped_torso", localPlayer ) engineApplyShaderToWorldTexture ( face, "cj_ped_head", localPlayer ) dxSetShaderValue ( skin, "gTexture", textSkin ) dxSetShaderValue ( tshirt, "gTexture", textTshirt ) dxSetShaderValue ( face, "gTexture", textFace ) end) Try it, just export a t-shirt from player.img. It's also important, that that the model changes as well depending on the type of clothing, for example suits, hoodies have different models than t-shirts, so you should also use a "dummy" addPedClothes depending on the type. @Walid That's done using engineImportTXD probably, but even if they are shaders, they are only 1 layered. Link to comment
Dzsozi (h03) Posted November 11, 2016 Author Share Posted November 11, 2016 So that means that I have to replace every clothing I want to use with shaders? If so, what would be the most efficient way to do that? Or to do the whole script. Link to comment
pa3ck Posted November 11, 2016 Share Posted November 11, 2016 The thing is, I'm not that experienced with shaders, but that's how I would do it, yes. Somebody might come along and give you a better solution. The code in my previous post replaces the torso twice. Once the skin color then the t-shirt and the layers are being merged into one. You can do the same thing with the rest. Link to comment
Dzsozi (h03) Posted November 12, 2016 Author Share Posted November 12, 2016 And if I want for example 10 types of one t-shirt, so with different patterns for example, I should do a new texture 10 times and then set the shader value of the tshirt shader 10 times? If so, wouldn't it be possible to do that with tables? So if I want to make a new type of t-shirt then I could just add one more line to the table and that's it. Then I could even make a function to get the table so I could do the shops I guess. Link to comment
Walid Posted November 12, 2016 Share Posted November 12, 2016 (edited) 13 hours ago, pa3ck said: @Walid That's done using engineImportTXD probably, but even if they are shaders, they are only 1 layered. @pa3ck check this : CJ sutom clothes @Dzsozi all what you need: dxCreateTexture,dxCreateShader,dxSetShaderValue,engineApplyShaderToWorldTexture,engineRemoveShaderFromWorldTexture,destroyElement,addPedClothes,removePedClothes, tables (the most important thing). Edited November 12, 2016 by Walid Link to comment
pa3ck Posted November 12, 2016 Share Posted November 12, 2016 You still don't understand what he is trying to do. He wants to change the skin color, head shape etc and also use clothes/hats/glasses. The only way to replace the skin color is to replace the torso but when you replace the torso, you also replace the clothes that have been added with addPedClothes. Link to comment
Dzsozi (h03) Posted November 12, 2016 Author Share Posted November 12, 2016 How can I do that with tables? Could you help me with that please? Link to comment
Backsage Posted November 14, 2016 Share Posted November 14, 2016 I'm just curious. How do you make a shader.fx for CJ clothes? Link to comment
Dzsozi (h03) Posted November 14, 2016 Author Share Posted November 14, 2016 What do you mean by how? Link to comment
Backsage Posted November 15, 2016 Share Posted November 15, 2016 (edited) I mean like what do you have to write in the shader.fx file to ensure that the shader will work correctly with the textures? I mean, Brian (from CIT) once told me that all you have to do is write a simple shader.fx for like CJ clothes. I don't know much about shaders. But my other question is, where do these body part textures come from? Like "cj_ped_head", "cj_ped_hat", "cj_ped_torso", "cj_ped_legs", "cj_ped_feet", ect.? I know they're textures but where do they come from? Would I need to use SAMP Map Editor or MapEditor (MEd) to find out that information? Edited November 15, 2016 by Backsage Link to comment
Tekken Posted November 15, 2016 Share Posted November 15, 2016 Using shader_tex_names you can download it from here: https://wiki.multitheftauto.com/wiki/Shader_examples Link to comment
Dzsozi (h03) Posted November 15, 2016 Author Share Posted November 15, 2016 Could somebody help me with the tables? I would like to have a table where I have the model of the cloth defined, the original texture defined and a table inside the table with the custom textures for that cloth, and the clothing id, but I don't know how to do that and then replace/apply shaders to these things. Link to comment
pa3ck Posted November 15, 2016 Share Posted November 15, 2016 I'm not familiar with CJ clothes. Can you have more than one clothing on the torso? Like a t-shirt and a jacket as well? 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