• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code How do you manipulate Textures from code?

Dark Light

Grizzled Veteran
Jul 11, 2012
55
0
I am wanting to draw a texture to the HUD, the texture I want to use is already in the game, I am managed to get it displaying fine. But I would like to change the black background to transparent and only leave the red channel. So I would like to do something like, new red = red, new green = 0, new blue = 0, new alpha = 255 - red.


Does anyone know how I can manipulate textures in this way?
 
Canvas.SetDrawColor(Canvas.DrawColor.R, 0, 0, 255);



All that will do it remove the green and blue channels, and set it to non-transparent. What I am wanting is to set the pixels that have no red in them to completely transparent, and the pixels that have some red in them to be semi transparent. So a pixel is no red is transparent, a pixel with 127 red is half transparent and a pixel with 255 red not transparent.
 
Upvote 0
If the texture has an alpha channel, you'll need it to be:
Code:
C.Style = ERenderStyle.STY_Alpha;
If it doesn't and you just want to make it so that it says full black is full opacity and white is no opacity, you'll need it to be:
Code:
C.Style = ERenderStyle.STY_Brighten;
EDIT:
or
Code:
C.Style = ERenderStyle.STY_Translucent;
Hope this helps!
 
Last edited:
Upvote 0