Page 1 of 1

PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Jun 20, 2013 3:27 pm
by STARGÅTE
I don't understand the color parameter.
It doese not worke like vertex color in DirectX 9:

Code: Select all

InitSprite()
UsePNGImageDecoder()

OpenWindow(1, 0, 0, 800, 600, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

CatchSprite(1, ?_Window_1_, #PB_Sprite_AlphaBlending)

Repeat
	
	Repeat
		Select WindowEvent()
			Case #PB_Event_CloseWindow
				End
			Case #Null
				Break
		EndSelect
	ForEver
	
	ClearScreen($FFFFFF)
	
	DisplayTransparentSprite(1, 50, 50, 255)
	DisplayTransparentSprite(1, 150, 50, 255, $80FFC0)
	
	FlipBuffers()
	
ForEver

DataSection
	_Window_1_:
	Data.q $0A1A0A0D474E5089,$524448490D000000,$4000000040000000,$7169AA0000000608,$47527301000000DE
	Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
	Data.q $000000189C9A0001,$08DA07454D497407,$5F29C112161B151C,$5441444959020000,$30C26E7D9BEDDA78
	Data.q $F7636C413F5FC50C,$E0970A3D28E0971A,$D368A7D92760DC06,$DD2851337B51FD96,$DA0AD592D8B250D8
	Data.q $22017814DD8BF78A,$E94A651931C2648F,$C800AFE51D94F463,$ED0899210C941400,$BBB286F164A0719A
	Data.q $F02AE4A732294004,$1C88D94B7E8F0011,$1549644CDAF1DC8D,$AC6F16016E7C10C0,$73E124A003BFAAC1
	Data.q $D1C8056BE004820B,$D5B9095630F39F97,$0DA214212E10A5F3,$8FC5B7D189D0047C,$0CFDF44280251CDE
	Data.q $B2A610C7AAAAACC0,$E213EBD4A81EAAAA,$8085CA31320073DB,$76EDF8B5E56AD580,$1CDE00F600F7000B
	Data.q $ADC866739348616D,$B6DB400059173EB9,$A1D3916852C11421,$0809E90031B2C19C,$2DB696E00084C630
	Data.q $00B58E9F10E341B5,$B0154059915238DF,$92D49B83C52F11A0,$3F73EF29EB00039C,$2D29E9AA4F900A90
	Data.q $F80A90228E841F53,$1DFC054810059C71,$BA00D44015EFBE80,$EF400A00500AD3AE,$006E24924802F101
	Data.q $0532CB200DC79E79,$05B400A015A02DA0,$E2EDDBB0056202B4,$D9B016BDAF5EB006,$00A1E4453F3A2E6C
	Data.q $01400A0050028014,$02801400A0050028,$07BF90C6200A0050,$DBEFD2FF68FAEBB0,$A9D03FB1C6B60A57
	Data.q $0DC01CD7BFFC15C5,$30EE00176F15B706,$900B68AC18971098,$015E00EFF133CC7B,$BDAF42F00278033C
	Data.q $02AA7F76F24F3063,$7C49D35915B69FA4,$B4F7224D4014F19C,$5C05AC7EAEB0352F,$062DA7ED8C5D0DE2
	Data.q $565F06E9668F9E1F,$0028C20BBB3E9AD9,$F0B94CE72DB5A9E9,$08D992C18BD9C6F0,$5EDC2CE2DC130610
	Data.q $BB77CF7E7476C219,$3A059D9C41810DBC,$4C1690E1301B17B8,$2707400029BA10D8,$00B1A664B6870B8E
	Data.q $01B17249D0002A60,$E6CBA5345CBFFE8F,$686A4E17AFF31C26,$0555541F1D446868,$0000000B4E3C66FF
	Data.q $6042AE444E454900,$0000000000000082
EndDataSection
PB 5.20 result:
Image

result in my DX9 include:
Image

Is the result of PB right?

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Jun 20, 2013 5:34 pm
by Fred
Yes, it's the intended result: render your sprite as a single color (for flashing effect for example). It's like the old DisplaySolidSprite().

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Fri Jun 21, 2013 5:30 pm
by STARGÅTE
Would it be possible to set the color directly to the vertices, just as I would do it in DX9:

Code: Select all

Structure DirectX9_Sprite3D_Vertex
	X.f
	Y.f
	Z.f
	RHW.f
	Color.l  ; <-- here
	U.f
	V.f
EndStructure
I use it for coloring.
But now I can't get the DirectX9 buffer with IsSprite3D for Sprite3D/Sprite.

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Mon Jun 24, 2013 10:53 pm
by em_uk
So you now have to do this :

Code: Select all

InitSprite()
UsePNGImageDecoder()

OpenWindow(1, 0, 0, 800, 600, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

CatchSprite(1, ?_Window_1_,#PB_Sprite_AlphaBlending)

Repeat
   
   Repeat
      Select WindowEvent()
         Case #PB_Event_CloseWindow
            End
         Case #Null
            Break
      EndSelect
   ForEver
   
   ClearScreen($FFFFFF)
   
   DisplayTransparentSprite(1, 50, 50, 255)
   DisplayTransparentSprite(1, 150, 50, 255,$80FFC0)
   DisplayTransparentSprite(1, 150, 50, 145) ; AN ADDITIONAL LINE NEEDED?

   FlipBuffers()
   
ForEver

DataSection
   _Window_1_:
   Data.q $0A1A0A0D474E5089,$524448490D000000,$4000000040000000,$7169AA0000000608,$47527301000000DE
   Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
   Data.q $000000189C9A0001,$08DA07454D497407,$5F29C112161B151C,$5441444959020000,$30C26E7D9BEDDA78
   Data.q $F7636C413F5FC50C,$E0970A3D28E0971A,$D368A7D92760DC06,$DD2851337B51FD96,$DA0AD592D8B250D8
   Data.q $22017814DD8BF78A,$E94A651931C2648F,$C800AFE51D94F463,$ED0899210C941400,$BBB286F164A0719A
   Data.q $F02AE4A732294004,$1C88D94B7E8F0011,$1549644CDAF1DC8D,$AC6F16016E7C10C0,$73E124A003BFAAC1
   Data.q $D1C8056BE004820B,$D5B9095630F39F97,$0DA214212E10A5F3,$8FC5B7D189D0047C,$0CFDF44280251CDE
   Data.q $B2A610C7AAAAACC0,$E213EBD4A81EAAAA,$8085CA31320073DB,$76EDF8B5E56AD580,$1CDE00F600F7000B
   Data.q $ADC866739348616D,$B6DB400059173EB9,$A1D3916852C11421,$0809E90031B2C19C,$2DB696E00084C630
   Data.q $00B58E9F10E341B5,$B0154059915238DF,$92D49B83C52F11A0,$3F73EF29EB00039C,$2D29E9AA4F900A90
   Data.q $F80A90228E841F53,$1DFC054810059C71,$BA00D44015EFBE80,$EF400A00500AD3AE,$006E24924802F101
   Data.q $0532CB200DC79E79,$05B400A015A02DA0,$E2EDDBB0056202B4,$D9B016BDAF5EB006,$00A1E4453F3A2E6C
   Data.q $01400A0050028014,$02801400A0050028,$07BF90C6200A0050,$DBEFD2FF68FAEBB0,$A9D03FB1C6B60A57
   Data.q $0DC01CD7BFFC15C5,$30EE00176F15B706,$900B68AC18971098,$015E00EFF133CC7B,$BDAF42F00278033C
   Data.q $02AA7F76F24F3063,$7C49D35915B69FA4,$B4F7224D4014F19C,$5C05AC7EAEB0352F,$062DA7ED8C5D0DE2
   Data.q $565F06E9668F9E1F,$0028C20BBB3E9AD9,$F0B94CE72DB5A9E9,$08D992C18BD9C6F0,$5EDC2CE2DC130610
   Data.q $BB77CF7E7476C219,$3A059D9C41810DBC,$4C1690E1301B17B8,$2707400029BA10D8,$00B1A664B6870B8E
   Data.q $01B17249D0002A60,$E6CBA5345CBFFE8F,$686A4E17AFF31C26,$0555541F1D446868,$0000000B4E3C66FF
   Data.q $6042AE444E454900,$0000000000000082
EndDataSection
Is that what you mean?

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Wed Jul 03, 2013 5:40 pm
by X
Is there an update on this? It would be nice to be able to have colored sprites.

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Jul 04, 2013 6:32 am
by Kruno
X wrote:Is there an update on this? It would be nice to be able to have colored sprites.
You can have coloured sprites as the user above you has posted.

Code: Select all

Alpha.i = 128

DisplayTransparentSprite(ASpriteNo, 0, 0, Alpha, #Red) ; Set the colour here
DisplayTransparentSprite(ASpriteNo, 0, 0, Alpha) ; Draw the sprite here
"Alpha" is what controls how intense a colour is. In this example:
Alpha -> 255 = Red
Alpha -> 0 = Whatever colour is in the background

You need two calls to "DisplayTransparentSprite". One call will create the colour for the second call to blend into.

I really love the 5.2 Beta of PB. Beautiful work PB Team.

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Fri Jul 05, 2013 11:41 am
by eesau
I agree that it would be nice to have colored sprites without calling DisplayTransparentSprite() twice. That's not very efficient.

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Fri Jul 05, 2013 6:52 pm
by X
I should have rephrased. Right now, we can set the color for the whole sprite. How do we set a different color for each corner?

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Aug 01, 2013 1:21 pm
by STARGÅTE
I solved the problem.

By default is SpriteBlendingMode inactiv (bug?).
If i write SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha), the color parameter works right.

Code: Select all

InitSprite()
UsePNGImageDecoder()

OpenWindow(1, 0, 0, 800, 600, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

CatchSprite(1, ?_Window_1_, #PB_Sprite_AlphaBlending)

Repeat
   
   Repeat
      Select WindowEvent()
         Case #PB_Event_CloseWindow
            End
         Case #Null
            Break
      EndSelect
   ForEver
   
   ClearScreen($FFFFFF)
   
   DisplayTransparentSprite(1, 50, 50, 255)
   SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)
   DisplayTransparentSprite(1, 150, 50, 255, $80FFC0)
   
   FlipBuffers()
   
ForEver

DataSection
   _Window_1_:
   Data.q $0A1A0A0D474E5089,$524448490D000000,$4000000040000000,$7169AA0000000608,$47527301000000DE
   Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
   Data.q $000000189C9A0001,$08DA07454D497407,$5F29C112161B151C,$5441444959020000,$30C26E7D9BEDDA78
   Data.q $F7636C413F5FC50C,$E0970A3D28E0971A,$D368A7D92760DC06,$DD2851337B51FD96,$DA0AD592D8B250D8
   Data.q $22017814DD8BF78A,$E94A651931C2648F,$C800AFE51D94F463,$ED0899210C941400,$BBB286F164A0719A
   Data.q $F02AE4A732294004,$1C88D94B7E8F0011,$1549644CDAF1DC8D,$AC6F16016E7C10C0,$73E124A003BFAAC1
   Data.q $D1C8056BE004820B,$D5B9095630F39F97,$0DA214212E10A5F3,$8FC5B7D189D0047C,$0CFDF44280251CDE
   Data.q $B2A610C7AAAAACC0,$E213EBD4A81EAAAA,$8085CA31320073DB,$76EDF8B5E56AD580,$1CDE00F600F7000B
   Data.q $ADC866739348616D,$B6DB400059173EB9,$A1D3916852C11421,$0809E90031B2C19C,$2DB696E00084C630
   Data.q $00B58E9F10E341B5,$B0154059915238DF,$92D49B83C52F11A0,$3F73EF29EB00039C,$2D29E9AA4F900A90
   Data.q $F80A90228E841F53,$1DFC054810059C71,$BA00D44015EFBE80,$EF400A00500AD3AE,$006E24924802F101
   Data.q $0532CB200DC79E79,$05B400A015A02DA0,$E2EDDBB0056202B4,$D9B016BDAF5EB006,$00A1E4453F3A2E6C
   Data.q $01400A0050028014,$02801400A0050028,$07BF90C6200A0050,$DBEFD2FF68FAEBB0,$A9D03FB1C6B60A57
   Data.q $0DC01CD7BFFC15C5,$30EE00176F15B706,$900B68AC18971098,$015E00EFF133CC7B,$BDAF42F00278033C
   Data.q $02AA7F76F24F3063,$7C49D35915B69FA4,$B4F7224D4014F19C,$5C05AC7EAEB0352F,$062DA7ED8C5D0DE2
   Data.q $565F06E9668F9E1F,$0028C20BBB3E9AD9,$F0B94CE72DB5A9E9,$08D992C18BD9C6F0,$5EDC2CE2DC130610
   Data.q $BB77CF7E7476C219,$3A059D9C41810DBC,$4C1690E1301B17B8,$2707400029BA10D8,$00B1A664B6870B8E
   Data.q $01B17249D0002A60,$E6CBA5345CBFFE8F,$686A4E17AFF31C26,$0555541F1D446868,$0000000B4E3C66FF
   Data.q $6042AE444E454900,$0000000000000082
EndDataSection

Re: [solved] PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Aug 01, 2013 1:27 pm
by Fred
True, it works, but the wanted behaviour is a full solid color for the sprite so it's no bug.

Re: PB 5.20 - Color in DisplayTransparentSprite()

Posted: Thu Jun 19, 2014 12:39 am
by STARGÅTE
With the update of 5.30 you have fix the blending mode bug (thx for that) but ...

now my "colorize" doesn't work like other engines.

I know, the color parameter in DisplayTransparentSprite is a full solid color,
but can you add a flag to use this color as normal vertex color like in other engines
or like ambient material color in Ogre?