1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

UE1 - UT How to fade in a texture?

Discussion in 'Programming' started by Helen, Jan 29, 2011.

  1. Helen

    Helen Member

    Joined:
    Jan 23, 2010
    Messages:
    48
    Likes Received:
    0
    I wish to display a texture on the HUD and then have it fade out. How to do?

    Thanks.
     
  2. larafan25

    larafan25 New Member

    Joined:
    Oct 11, 2008
    Messages:
    75
    Likes Received:
    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.:/
     
  3. Helen

    Helen Member

    Joined:
    Jan 23, 2010
    Messages:
    48
    Likes Received:
    0
    In the PostRender method, I need some way to change the texture's degree of modulation, or something.
     
  4. War_Master

    War_Master Member

    Joined:
    May 27, 2005
    Messages:
    702
    Likes Received:
    0
    that would be transparency and I think you will need to decrease the color channel A for that effect.
     
  5. larafan25

    larafan25 New Member

    Joined:
    Oct 11, 2008
    Messages:
    75
    Likes Received:
    0
    Well I was clearly way off. O.O
     
  6. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    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.
     
  7. gopostal

    gopostal Active Member

    Joined:
    Jan 19, 2006
    Messages:
    848
    Likes Received:
    47
    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.
     
  8. AnthraX

    AnthraX New Member

    Joined:
    Aug 3, 2005
    Messages:
    20
    Likes Received:
    0
    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.
     
  9. Helen

    Helen Member

    Joined:
    Jan 23, 2010
    Messages:
    48
    Likes Received:
    0
    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.
     
  10. Helen

    Helen Member

    Joined:
    Jan 23, 2010
    Messages:
    48
    Likes Received:
    0
    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;
    }
    
     
  11. Gizzy

    Gizzy The Banhammer Cometh

    Joined:
    May 30, 2009
    Messages:
    195
    Likes Received:
    0
    *tiptoes into thread*

    227 does!

    *tiptoes out*
     
  12. Chopin

    Chopin New Member

    Joined:
    Aug 23, 2005
    Messages:
    174
    Likes Received:
    0
    When the 227 improvements are added to UT let us know...
     
  13. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    Indeed. I bet there are more people playing UT than Unreal, so why are most efforts concentrated on the smaller community?
     
  14. gopostal

    gopostal Active Member

    Joined:
    Jan 19, 2006
    Messages:
    848
    Likes Received:
    47
    Elitism.
     
  15. Chopin

    Chopin New Member

    Joined:
    Aug 23, 2005
    Messages:
    174
    Likes Received:
    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.
     
  16. War_Master

    War_Master Member

    Joined:
    May 27, 2005
    Messages:
    702
    Likes Received:
    0
    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?
     
  17. Chopin

    Chopin New Member

    Joined:
    Aug 23, 2005
    Messages:
    174
    Likes Received:
    0
    she wants a splash screen at the beginning of the game...
     
  18. H34DHUNT3R

    H34DHUNT3R New Member

    Joined:
    Dec 20, 2005
    Messages:
    16
    Likes Received:
    0
    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.


    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
     

Share This Page