Jump to content

Problem Shader View Image


yasin0

Recommended Posts

hello i don't know why don't work but don't debugscript error

my code

addEventHandler("onClientResourceStart", resourceRoot, function()
myShader = dxCreateShader( "shader/shader.fx" )
aT = dxCreateTexture ("img/1.png")
dxSetShaderValue(myShader,"gTexture",aT)
engineApplyShaderToWorldTexture(myShader,"alleydoor9b")
end )

shader

texture gTexture;

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

 

Edited by yasin0
Link to comment

So I can't see anything wrong with it on the first look, however if you use myShader somewhere else in your resource it could conflict.
To solve that you will have to make the variables local, like this:

addEventHandler("onClientResourceStart", resourceRoot, function()
local myShader = dxCreateShader( "shader/shader.fx" )
local myTexture = dxCreateTexture( "img/1.png" )

dxSetShaderValue( myShader, "gTexture", myTexture )
engineApplyShaderToWorldTexture( myShader, "alleydoor9b" )
end )

Do note that I changed the textures variable name, it's always helpful to stick with speaking variable names :)

Another thing that I could imagine to go wrong would be the texture name, did you use shader_tex_names to find it?

Edit: It's also worth mentioning that you should include some error handling, as the creation of the shader is not guaranteed.

Edited by 3aGl3
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...