Jump to content

Set a shaderValue for one object


Gordon_G

Recommended Posts

Hi,

I have a shader (here) that replace an object's texture and here is my code : (red.png ; blue.png)

local o = createObject( 2121, 1418.1678466797,-1595.0837402344,13.366353988647 )  
dxSetShaderValue( shaderForImageLoading, "gTexture", dxCreateTexture( "red.png" ) )  
engineApplyShaderToWorldTexture( shaderForImageLoading, "cj_red_leather", o )

local o1 = createObject( 2121, 1411.8753662109,-1591.5054931641,13.360206604004 ) 
dxSetShaderValue( shaderForImageLoading, "gTexture", dxCreateTexture( "blue.png" ) )  
engineApplyShaderToWorldTexture( shaderForImageLoading, "cj_red_leather", o1 )

So, the prob is that I'd like that the first object to have the texture red.png but it gets the blue.png one

Is it possible to "freeze" the shader for a worldTexture ?

Or... Am I supposed to create a shader for each object I want to replace the texture of ? It will take a lot of the client vram if I have a lot of objects isn't it ?

Link to comment
local o = createObject( 2121, 1418.1678466797,-1595.0837402344,13.366353988647 )  
shader1 = dxCreateShader("texReplace.fx", 0, 0 , false, "object")
red = dxCreateTexture("red.png")
dxSetShaderValue( shader1, "gTexture", red )  
engineApplyShaderToWorldTexture( shader1, "gTexture", o )

local o1 = createObject( 2121, 1411.8753662109,-1591.5054931641,13.360206604004 ) 
shader2 = dxCreateShader("texReplace.fx", 0, ,0, false, "object")
blue = dxCreateTexture("blue.png")
dxSetShaderValue( shader2, "gTexture",blue)  
engineApplyShaderToWorldTexture( shader2, "gTexture", o1 )

 

Edited by Dimos7
  • Like 1
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...