From 7050f9d54fc4603a952c12efbab2e3331413865f Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 3 Jul 2007 08:37:09 +0000 Subject: some tweaking of transparency handling for PNGs to make it look more as expected git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@272 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UTexture.pas | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Game/Code') diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas index da603ec9..275f0748 100644 --- a/Game/Code/Classes/UTexture.pas +++ b/Game/Code/Classes/UTexture.pas @@ -206,6 +206,7 @@ var TempA: integer; Error: integer; SkipX: integer; + myAlpha: Real; begin Log.BenchmarkStart(4); Mipmapping := true; @@ -399,7 +400,16 @@ begin TextureD32[Pet*TexNewW + Pet2+1, 3] := Pix div (256*256); // transparent png hack start (part 2 of 2) if (Format = 'PNG') and (length(TextureAlpha) <> 0) then begin - TextureD32[Pet*TexNewW+Pet2+1,4]:=TextureAlpha[Pet*TexOrygW+Pet2]; + myAlpha:=TextureAlpha[Pet*TexOrygW+Pet2]; + + // the following calculations tweak transparency so that it really looks transparent + myAlpha:=myAlpha-75; + if myAlpha < 0 then myAlpha:=0; + myAlpha:=myAlpha/180; + myAlpha:=myAlpha*myAlpha*myAlpha; + myAlpha:=myAlpha*255; + + TextureD32[Pet*TexNewW+Pet2+1,4]:=floor(myAlpha); end else // transparent png hack end TextureD32[Pet*TexNewW + Pet2+1, 4] := 255; -- cgit v1.2.3