Jump to content

[SHADER] Problem


ma2med

Recommended Posts

Hello, I have this shader script :

texture Tex0; 
float red; 
float green; 
float blue; 
float alpha; 
      
technique hello 
{ 
    pass P0 
    { 
    Texture[0] = Tex0; 
    MaterialAmbient = float4(red, green, blue, alpha); 
    } 
} 

When I put color values and texture it works but if I put only colors values it's making it completely black or white.

  
-- Working example 
dxSetShaderValue(shader, 'Tex0', texture) 
dxSetShaderValue(shader, 'red', r) 
dxSetShaderValue(shader, 'green', g) 
dxSetShaderValue(shader, 'blue', b) 
dxSetShaderValue(shader, 'alpha', a) 
engineApplyShaderToWorldTexture(shader, 'texture', element) 
  

  
-- Not working example 
dxSetShaderValue(shader, 'Tex0', nil) 
dxSetShaderValue(shader, 'red', r) 
dxSetShaderValue(shader, 'green', g) 
dxSetShaderValue(shader, 'blue', b) 
dxSetShaderValue(shader, 'alpha', a) 
engineApplyShaderToWorldTexture(shader, 'texture', element) 
  

Please help me with this issue :fadein:

Link to comment
  • Discord Moderators

You may need to set the texture state 0 to its default value instead of simply nil'ing it. To get the default texture for a certain state, use this (copied straight away from mta-helper.fx):

texture gTexture0           < string textureState="0,Texture"; >; 

If you don't want your object to have a texture, you will probably need to create a dummy one which is all white or something like that.

Link to comment
You may need to set the texture state 0 to its default value instead of simply nil'ing it. To get the default texture for a certain state, use this (copied straight away from mta-helper.fx):

texture gTexture0           < string textureState="0,Texture"; >; 

Yes, this is what I wanted to do :D Thanks for the answer but I don't know where to put it, I tried to set Tex0 value to 0 but it's not working.

Link to comment
  • Discord Moderators

I don't really know how to help you further properly. I could tell you what experiments I would do, but providing that HLSL documentation out there is rather misleading and that I do not have an advanced knowledge of the language I think that letting a more experienced person help you is more appropiate, unless you want to try countless modifications to your code until we find a working solution that will probably be not very efficient.

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...