Announcement

Collapse
No announcement yet.

How to Trans a color from Texure

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Trans a color from Texure



    like this pic.how to trans the color(255,0,255)?

    and how to get a source x,y to the texture2d?

    make the pic is 5*5

    #2
    Split it up if you want animations or do it by code. Translucency should really be done with alpha channels, not mask colors.

    Comment


      #3
      thank you,i get it.

      Comment


        #4
        You can really set up a material that adds the Red, Blue channels, Subtracts the green. Then set up an If statement that says if this end-result color = 2 (or 510 in the case of 0-255, unreal uses 0-1) then blend transparent, else blend normal.

        Comment


          #5
          Sure, you could do it, but an alpha channel is way more efficient.

          Comment


            #6
            PHP Code:
            class AnimTexBase extends Actor;
            var 
            Texture            AnimTexture;          //AnimTexture
            var float           AnimWidth;            //a animation width
            var float           AnimHeight;           //a animation height
            var float           AnimDrawIndex;        //play which group
            var int             AnimIndex;            //play which animation
            var float           PlayDelay;            //play delay time
            var float           MaxIndex;             //max animation numbers;

            //Start
            simulated event PostBeginPlay()
            {
                
            super.PostBeginPlay();
            }

            //draw Anim
            simulated function DrawAnimTex(vector2D Pos,Canvas c)
            {
                
            local float sourceX,sourceY;
                
            c.SetDrawColor(255255255);

                
            //set pos
                
            c.SetPos(Pos.XPos.Y);

                
            //get Texture source
                
            sourceX AnimIndex AnimWidth;
                
            sourceY AnimDrawIndex AnimHeight;

                
            //draw it.
                
            c.DrawTile(AnimTextureAnimWidthAnimHeightsourceXsourceYAnimWidthAnimHeight);

                return;
            }

            //change play AnimIndex
            simulated function ChangeDrawIndex(float mouseIndex)
            {
                
            AnimDrawIndex mouseIndex;   //set play which group
                
            AnimIndex 0;                //again head.
            }

            //start timer to change AnimIndex
            simulated function StartDraw()
            {
                if(!
            IsTimerActive(nameof(ChangeAnimImage)))
                {
                    
            SetTimer(PlayDelaytruenameof(ChangeAnimImage));
                }
            }

            //stop timer to change AnimIndex
            simulated function StopDraw()
            {
                if(
            IsTimerActive(nameof(ChangeAnimImage)))
                {
                    
            ClearTimer(nameof(ChangeAnimImage));
                }
            }

            //Timer
            function ChangeAnimImage()
            {
                
            AnimIndex++;    
                if(
            AnimIndex == MaxIndex)  AnimIndex 0;
            }

            DefaultProperties
            {
                
            AnimWidth 26
                AnimHeight 
            26
                AnimDrawIndex 
            1
                AnimIndex 
            0
                PlayDelay 
            0.1
                MaxIndex 
            5
                AnimTexture
            =Texture2D'Effect.UI.Mouse0001tex'

            i was complete.so i share it.

            in the HUD PostBeginPlay()
            to StartDraw()
            and in the HUD PostRender
            to DrawAnimTex(Pos,Canvas);

            Comment

            Working...
            X