UE1 - UT How to fade in a texture?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Helen

Member
Jan 23, 2010
48
0
6
I wish to display a texture on the HUD and then have it fade out. How to do?

Thanks.
 

larafan25

New Member
Oct 11, 2008
75
0
0
I'm not sure how to do much with the HUD however if you create the appearance of this HUD in photoshop or something wouldn't you make a gradient with the colour you choose over a transparent background. Then save the image in a format which recognizes the transparency and the editor will recognize it too?

I could be way wrong though.:/
 

Helen

Member
Jan 23, 2010
48
0
6
In the PostRender method, I need some way to change the texture's degree of modulation, or something.
 

War_Master

Member
May 27, 2005
702
0
16
that would be transparency and I think you will need to decrease the color channel A for that effect.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
UE1 does not support alpha channels. To fade textures you need to gradually fade the draw color towards black. For normal style this really fades to solid black, for translucent style this fades to fully transparent, while for modulated style this doesn't work out anywhere near the intended effect.
 

gopostal

Active Member
Jan 19, 2006
848
47
28
Code:
// Set your texture to HUD
Canvas.Style = ERenderStyle.STY_Translucent;
Canvas.DrawColor.R = 225 - (225 * (DrawTime/FadeOutTime));
Canvas.DrawColor.G = 225 - (225 * (DrawTime/FadeOutTime));
Canvas.DrawColor.B = 225 - (225 * (DrawTime/FadeOutTime));

then just plug in your vars as you need them. This will allow you to control the fade time very exactly. It's not a great way of doing it but I don't know of a better.
 

AnthraX

New Member
Aug 3, 2005
20
0
0
39
Ghent (Belgium)
Take a look at either ServerLogo or MODOSUtils. Both of these mods do exactly what you want to do. MODOSUtils is probably a bit more lightweight though.
 

Helen

Member
Jan 23, 2010
48
0
6
Hey all, thanks for the replies, I wasn't getting notifications despite having email notification on. Once I'm able to get to this I'll let you know how I made out with the suggestions.
 

Helen

Member
Jan 23, 2010
48
0
6
fade in example

Hello. Thanks for the examples. So here's my example of what I did (roughly). I made a subroutine called GetFadeColor. It uses a 'fade factor' that is merely a value that slowly goes from 0 to 1 to fade in, or vice versa to fade out. Here is code if someone else needs it. Thanks.

Code:
// This value of mFadeFactor will range from 0 to 1. You will need
// code somewhere that is slowly changing this value from 0 up to 1.
// The closer to zero it is, the more faded the text or texture will
// be. As it gets closer to one, the text/texture becomes more solid.
// The code that updates this value is not present in this example.
var float mFadeFactor;

simulated function PostRender(canvas Canvas)
{
	local color myColor;
	local texture myTexture;

	// Style must be translucent for both text and texture fading.
	Canvas.Style = ERenderStyle.STY_Translucent;

	// Fading in text...

	// Set up the base color of the text.
	// Choose whatever color you want, except black.
	myColor.R = 255;
	myColor.G = 128;
	myColor.B = 51;

	// Set canvas translucency
	Canvas.DrawColor = GetFadeColor(myColor, mFadeFactor);

	// Set position and draw text (the position used here is just an example)
	Canvas.SetPos(Canvas.clipX/2, Canvas.ClipY/2);
	Canvas.DrawText("some text...");

	// Fading in a texture...

	// Just use white as the base color
	myColor.R = 255;
	myColor.G = 255;
	myColor.B = 255;

	// Set canvas translucency
	Canvas.DrawColor = GetFadeColor(myColor, mFadeFactor);

	myTexture = ...  // You must set your own texture

	// Set position (the position used here is just an example)
	Canvas.SetPos((Canvas.clipX*2)/3, (Canvas.ClipY*2)/3);

	// Draw Texture (the numbers used here are just an example)
	Canvas.DrawTileClipped(myTexture, 64, 64, 0, 0, 64, 64);
}

simulated function color GetFadeColor(color ABaseColor, float AFadeFactor)
{
	local color aColor;

	// AFadeFactor must be from 0 to 1.
	if((AFadeFactor < 0) || (AFadeFactor > 1))
		return ABaseColor;

	aColor.R = ABaseColor.R * AFadeFactor;
	aColor.G = ABaseColor.G * AFadeFactor;
	aColor.B = ABaseColor.B * AFadeFactor;

	return aColor;
}
 

Chopin

New Member
Aug 23, 2005
174
0
0
You could make it an animated texture, with say 32 frames, just make 32 copies of your texture in photoshop and decrease the brightness incrementally for each one until the last one is completely black. Name them YourTexture_A00.pcx - YourTexture_A31.pcx respectively and import them into a new package in ued. Make sure the framerate of the animation (can be set in the texture properties of the first texture) is low enough (32 fps will play the animation in 1 second, 16 will play it in 2 seconds...) Then in your script #EXEC OBJ LOAD FILE YourPackage.utx and you need only draw the first YourTexture_A00 on the canvas and the animation will play automatically, if you set it to translucent it will fade out.
 

War_Master

Member
May 27, 2005
702
0
16
You could make it an animated texture, with say 32 frames, just make 32 copies of your texture in photoshop and decrease the brightness incrementally for each one until the last one is completely black. Name them YourTexture_A00.pcx - YourTexture_A31.pcx respectively and import them into a new package in ued. Make sure the framerate of the animation (can be set in the texture properties of the first texture) is low enough (32 fps will play the animation in 1 second, 16 will play it in 2 seconds...) Then in your script #EXEC OBJ LOAD FILE YourPackage.utx and you need only draw the first YourTexture_A00 on the canvas and the animation will play automatically, if you set it to translucent it will fade out.

and make a file size an average of 3.2MB instead of 100kb to pull the same or worse effect?... makes no sense. What if she wanted to do that with 20 textures? 3200*20=64000/64MB instead of 2MB with all 20 textures. See the point there?
 
Wormbo said:
Indeed. I bet there are more people playing UT than Unreal, so why are most efforts concentrated on the smaller community?

A glance at their respective server browsers (Players/Servers):
Unreal Tournament - 641/1100
Unreal (Gold 227g) - 17/50

The spread is probably the same when comparing offline players.


SilentKoala said:
When the 227 improvements are added to UT let us know...

Off-Topic maybe, but this might explain why improvements that require access to non-public native source won't make it to UT anytime soon:
http://www.ut99.org/viewtopic.php?f=1&t=2841&hilit=smirftsch&start=75#p27753