Jump to content

Question about shaders


Gordon_G

Recommended Posts

You'll have to use

engineApplyShaderToWorldTexture

there is now no such function as engineApplyShaderToWorldModel. :(

You'll have to get the texture's name which you would like to change (eg. vehiclegrunge256). There is a good way to find out the texture's name tho, download this.

After you got the texture's name, you can get the element you wish to replace, and just do

engineApplyShaderToWorldTexture(shaderElement, textureName, elementVar)

and it's done. EZPZ. :D

Link to comment

 

client

tabla = {
--  YourPNGName    Textura name
    {"YourPNGName", "prolaps01"},
    {"YourPNGName", "heat_01"}
}


addEventHandler( "onClientResourceStart", resourceRoot,
function()
    for i = 1, #tabla do
        local shader, tec = dxCreateShader ( "texreplace.fx" )
        local tex = dxCreateTexture ( "files/"..tabla[i][1]..".png" )
        engineApplyShaderToWorldTexture ( shader, tabla[i][2] )
        engineApplyShaderToWorldTexture ( shader, tabla[i][2].."lod" )
        dxSetShaderValue ( shader, "gTexture", tex )
    end
end)

 

texreplace.fx

texture gTexture;

technique TexReplace
{
    pass P0
    {
        Texture[0] = gTexture;
    }
}

 

meta:


 

<meta>   

 <script src="sourceC.lua" type="client"></script>
    <file src="texreplace.fx"></file>
    
    <!-- Files -->
    <file src="YourPNGName.png"/>

</meta>

 

Edited by TheMOG
Link to comment

Ii finally did it :

addEventHandler("onClientResourceStart", resourceRoot,
    function()
      
        myShader,tecName = dxCreateShader( "shader.fx"  )
        myImage = dxCreateTexture( "image.png" )
        if myShader and myImage then
            dxSetShaderValue( myShader, "tex0", myImage )
            engineApplyShaderToWorldTexture( myShader, "ws_dickgoblinmural" )
        else
            outputChatBox( "Problem - use: debugscript 3" )
        end
    end
)

And, need those files : shader.fx and mta-helper.fx

EDIT : I did not see your post TheMOG, sorry, but thanks

Edited by Gordon_G
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...