I need a description of what each constant does:
#PB_Sprite_BlendZero: ?
#PB_Sprite_BlendOne: ?
#PB_Sprite_BlendSourceColor: ?
#PB_Sprite_BlendInvertSourceColor: ?
#PB_Sprite_BlendDestinationColor: ?
#PB_Sprite_BlendInvertDestinationColor: ?
#PB_Sprite_BlendSourceAlpha: ?
#PB_Sprite_BlendInvertSourceAlpha: ?
#PB_Sprite_BlendDestinationAlpha: ?
#PB_Sprite_BlendInvertDestinationAlpha: ?
I need your help. Thank you
I need Description for SpriteBlendingMode constants
Re: I need Description for SpriteBlendingMode constants
It depends on the graphic engine.
For OpenGL: https://registry.khronos.org/OpenGL-Ref ... Func.xhtml
For DirectX: https://learn.microsoft.com/en-us/windo ... 9/d3dblend
For OpenGL: https://registry.khronos.org/OpenGL-Ref ... Func.xhtml
For DirectX: https://learn.microsoft.com/en-us/windo ... 9/d3dblend
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: I need Description for SpriteBlendingMode constants
Thank you
But there is no explanation of what that means, just values e.g. (1 - Rₛ, 1 - Gₛ, 1 - Bₛ, 1 - Aₛ).
I need an understandable explanation. Example:
#PB_Sprite_BlendOne (GL_ONE / D3DBLEND_ONE): The colors become brighter.
But there is no explanation of what that means, just values e.g. (1 - Rₛ, 1 - Gₛ, 1 - Bₛ, 1 - Aₛ).
I need an understandable explanation. Example:
#PB_Sprite_BlendOne (GL_ONE / D3DBLEND_ONE): The colors become brighter.
Re: I need Description for SpriteBlendingMode constants
SpriteBlendingMode defines, how the new color is calculated, when a Sprite (source) is displayed on the background (destination).
The equation is: color_new = color_source * factor_source + color_destination * factor_destination
If you now use e.g. SpriteBlendingMode(#PB_Sprite_BlendOne, #PB_Sprite_BlendZero), factor_source is 1 and factor_destination is 0.
color_new = color_source * 1 + color_destination * 0
Meaning, the Sprite is render without interaction with the background.
The default mode is: SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)
So factor_source is the alpha value of each pixel and factor_destination is 1 minus the alpha value of each pixel.
color_new = color_source * alpha_source + color_destination * (1-alpha_sources).
Meaning, the Sprite is shown, where the alpha is high and the background is shown, where the alpha is low.
Here is an example:
The equation is: color_new = color_source * factor_source + color_destination * factor_destination
If you now use e.g. SpriteBlendingMode(#PB_Sprite_BlendOne, #PB_Sprite_BlendZero), factor_source is 1 and factor_destination is 0.
color_new = color_source * 1 + color_destination * 0
Meaning, the Sprite is render without interaction with the background.
The default mode is: SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)
So factor_source is the alpha value of each pixel and factor_destination is 1 minus the alpha value of each pixel.
color_new = color_source * alpha_source + color_destination * (1-alpha_sources).
Meaning, the Sprite is shown, where the alpha is high and the background is shown, where the alpha is low.
Here is an example:
Code: Select all
Enumeration
#Window
#Sprite
#Font
EndEnumeration
InitSprite()
UsePNGImageDecoder()
OpenWindow(#Window, 0, 0, 1600, 800, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window), 0, 0, 0)
LoadFont(#Font, "Arial", 8)
CatchSprite(#Sprite, ?Particle, #PB_Sprite_AlphaBlending)
Dim Sprite_Blend.s(10)
Sprite_Blend(#PB_Sprite_BlendDestinationAlpha) = "DestAlpha"
Sprite_Blend(#PB_Sprite_BlendDestinationColor) = "DestColor"
Sprite_Blend(#PB_Sprite_BlendInvertDestinationAlpha) = "InvDestAlpha"
Sprite_Blend(#PB_Sprite_BlendInvertDestinationColor) = "InvDestColor"
Sprite_Blend(#PB_Sprite_BlendSourceAlpha) = "SourAlpha"
Sprite_Blend(#PB_Sprite_BlendSourceColor) = "SourColor"
Sprite_Blend(#PB_Sprite_BlendInvertSourceAlpha) = "InvSourAlpha"
Sprite_Blend(#PB_Sprite_BlendInvertSourceColor) = "InvSourColor"
Sprite_Blend(#PB_Sprite_BlendOne) = "One"
Sprite_Blend(#PB_Sprite_BlendZero) = "Zero"
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
End
Case #Null
Break
EndSelect
ForEver
ClearScreen($404040)
For Y = 0 To 9
For X = 0 To 9
SpriteBlendingMode(X+i, Y+I)
RandomSeed(6)
For n = 1 To 30
D = Random(100)
DisplayTransparentSprite(#Sprite, X*160+10+D, Y*80+15+Random(15), 255, RGB(D*2+25, 230-D*2, 64))
Next
Next
Next
If StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(#Font))
For Y = 0 To 9
For X = 0 To 9
DrawText(X*160, Y*80, Sprite_Blend(X)+" & "+Sprite_Blend(Y))
Next
Next
StopDrawing()
EndIf
FlipBuffers()
ForEver
DataSection
Particle:
Data.q $0A1A0A0D474E5089,$524448490D000000,$2000000020000000,$7A7A730000000608,$47527301000000F4
Data.q $0000E91CCEAE0042,$FF0044474B620600,$93A7BDA0FF00FF00,$7359487009000000,$130B0000130B0000
Data.q $000000189C9A0001,$03DC07454D497407,$0AC1E8501D21140C,$54414449F7070000,$C7248ACB578DC358
Data.q $D665666446F73D15,$043CC31A535ABBB3,$5E37834211A17FC2,$D6F03FA98B48C31B,$C18F50619FC0830B
Data.q $AD668123108304FE,$E9BA6B211B465785,$3332B32BD74F7557,$33DAA7688E8BD71E,$8DEE2B22922084E0
Data.q $4F9E3BC25CE738FB,$7C00063BE6F8F63F,$018888800497E5F9,$8000222600108890,$BB70078004888088
Data.q $E4FE2F800173E7CF,$EEE876ADF99FC5F1,$57CBC000789F4F0F,$55FF9B3E3C4FA78C,$75161C6B1BA28889
Data.q $EF79710382444416,$66596491E8F47FBD,$7CBF678923E8FA3F,$E1E1C1FBA076EFC5,$445800C59D500321
Data.q $DCE97FF97FD5E298,$1C1FC4924F888BDE,$87F8FF6AB56AC81C,$A09C7FE8CE9FFBDF,$7F367C113E9FC6BB
Data.q $8D144450034444A1,$CF14D2E6F9EDCEAB,$638889C00039B790,$FDB9F0EDFDC00766,$9FE35DD09D2FD5E6
Data.q $D200A87E7B3C113E,$29886908118EB0C1,$37FDDB9CE86A5280,$870DC4642E001018,$001BAC4DD7AF5A43
Data.q $765EE20085FCF9F4,$A17F3E7C14DDD09C,$D2772488B0D1D200,$59117DEB5AC32310,$4456222D6667888B
Data.q $71B366EC8896005A,$E7C968C428849CCC,$43DAB1413AE817F3,$52226B8C1D41A3CE,$22227B0B2889A222
Data.q $8C6B6631998A28AA,$005B318C2D34D269,$006FBDEB66658006,$005800E444711118,$EE7CF999110C4456
Data.q $22EF26EEF9BF8001,$B9444A401C66DEA2,$007D222FA888F488,$A0007249241A2223,$FA00E7DEF7DEB5AF
Data.q $E48889FDFBF45222,$B0163446DD129222,$06B6E90F0F0FA002,$1D7316C58C3F3D9E,$1640885EE183499D
Data.q $2D34D349322287DE,$8895999F799992CB,$DB779F721768896C,$22276E7391924934,$493C14B562C48895
Data.q $200E4004F79DD2C2,$000A8890C01C9117,$060F1D34D28F3329,$3264D1C5C5C5F183,$88A5002B9B366D99
Data.q $2EFDEF2A0094012C,$F5D75E79E7971249,$655217600B76B5B5,$2511161401DD1800,$8894B62859CCCC22
Data.q $A94A7BF333EA2232,$6A52A9739C56B589,$89E662294AFBCCC6,$9985C22E63195AD6,$A9AD69D8F1E3FB99
Data.q $8A5444673305EBAE,$BA0EE9C00F696C48,$A8695294F64924A9,$25AEDDBB65113187,$934C9249A4889EA2
Data.q $DF6B585BB76D1924,$889F492497BF5AD7,$8A28B8889E4521FA,$B1BED6B5B1E3C7F7,$4D9A69AE739D2ED6
Data.q $C22D0EB2922ECB40,$659CCCC56D6B0222,$15E91103D34D24D9,$E972E5E8C6303145,$A94A87A3468F5998
Data.q $9CEFBC78F18F7BDC,$44B4B2CA4B2CB24B,$AECB2CE3D9B367E4,$366CD5555459A69B,$7BDE24016E66739B
Data.q $DE04444A94AC4443,$E7179C468343AB7B,$C9BCC632BAEBAD9C,$468D1BD7AF5EFCF3,$F5F5C57B7B7BFBA3
Data.q $F83E0F936EDDBA75,$7BFBF7EDA5965660,$FAAD5AB560F0E1C3,$8CF70783C1EEFEFD,$2E5CB16AD5ABE731
Data.q $5145273315739CAF,$AD6B5CE75AA4428C,$1DF5A8015DB6DAAD,$001B6B59CE738558,$CCA65965976DB6BB
Data.q $BBDDEFAFC993276C,$56BAEB4C183068F7,$F7F7F6AFE1F87E1F,$26F65E5E5D35AD53,$C9F5E8E8E8E0C993
Data.q $0F07A8993276C9C9,$CBB9CE7BE6663C1E,$9A68B9A69B4FAEBA,$1135F7BD2DAD6D66,$44E8A2220A3D0A19
Data.q $B6DB4BDEF600094C,$3CCC172CB29A4446,$FDFEFF7FB8264C9A,$00E4183074838383,$58FE3F8FF19B3664
Data.q $1F8FC7E3E1C3870D,$07F4F4F4F6CB972F,$00D600378009ED6B,$B83AC764026444B6,$8B3D3B7CB69B81C1
Data.q $B5A074D34EB33108,$DF5B6DB4BD7AF41E,$EB31A69A60068FF9,$FBDE97972E5CBAF5,$2E73B952949AD68D
Data.q $C43B577DEF2BDEF5,$FBAF2EB4F10236FD,$DA6DCE72A60A10B0,$F2F2F4E9D3A7CDB6,$ECECE111335AD1B2
Data.q $26596597669A6AAC,$444A98C6B7BDE422,$DC172368025444D6,$8D23868D2A1DF5DD,$911314A563D7AF4A
Data.q $92797AF5EEB6DB6D,$B76EDCBF3F3F3824,$23D7AF4DABABABC3,$145A7A7A7A7D5CE7,$2E068D1D55555B45
Data.q $DD0222B2F74A6788,$D6B4A52941715191,$598C637DEF691119,$76DB6AA9D3A74801,$797159659A659651
Data.q $49255EBEBEB8B979,$FE060C1B38F1E342,$1EB0E1C35FECECEC,$DAD616AAAAC3870E,$46C95BA5245EA036
Data.q $94A2222F011BBE44,$B1111D98C6311162,$83060C5A69A4D6B5,$A283F7BC9FAAAAA2,$23939393D3003228
Data.q $56AD5D2CB2CB9CE7,$93EF78587C3E1E6F,$79E758037FABABAB,$0221B6080454442E,$618F8B941D697BBE
Data.q $B434914CCC35CE72,$78F6DB6BB5AD33D6,$DBB7F74D349B5EBD,$7BDE9FF8F8F8EF6D,$6A69A6DAEBA8444D
Data.q $1BEBDBDBDB858B17,$F5D75A7D7AF5F263,$3EE31DC5489A8896,$807C503A6FAF1788,$A40EA1E0DAA728D1
Data.q $CE98A28A2E596542,$41FE7F9FE7FCB366,$44F4C90D888A9D6B,$51A94A97B76EDBD4,$69A6B36DB6A7DFBF
Data.q $368EB90103A800DE,$E888ADD9053A8DB8,$FA8481D0F0830596,$7A1A6205E8005AD6,$45BD37F0AA5295EF
Data.q $06E5294EDA885C00,$CD9B37AFBDE64183,$364443488B5C8885,$C6DCF9F384C8960A,$4497AA8FEA9DF436
Data.q $AD45EA2219CE76A4,$DC1D97DEF53BAA17,$CC636294A739CE70,$4FD468D1A95AB576,$776661BAEBADA492
Data.q $F63F4FC0B0B91947,$C0FDDA950D840308,$88A9113B222B4888,$84075FDE055002A8,$544496E73A57288B
Data.q $5A4FE5CB97AFEF79,$486DFF874294AD6B,$3E0B96474B438BB1,$7ACC21FC31D0BF9B,$AFAF492492F41830
Data.q $D12BAAA63EF7ADAF,$6623A29DB69D13E3,$6222B2222BB5AC4E,$78D51B73E7CEC889,$1F9ECFB100139647
Data.q $F7EAA9D3A65EF78A,$34D573CF25998AFB,$8A89B84DB76ED98D,$0BBB8C0239201E9C,$FEE0071A2ADAD666
Data.q $E594BFE605B9E2FE,$EE2C408AF97B0C71,$34DACB2C82FECF77,$D3F6BAEAE739C94D,$43844565555754E9
Data.q $B4EA32777AE2293E,$3E4C1C7B8DBB0BB5,$39DF3B9865E3D8FD,$3C78C9F7FDFF7D9A,$62D7AF5A2B56AFEE
Data.q $A94A36BF5FAFD5AD,$DD3383F7AB7A80EE,$773E7CDC5A4E973E,$7F6FDFB2B7DE8777,$3A383E6FAF8FF1E3
Data.q $E82C58BE6D6B623A,$999EE7E7E702E2E2,$09DD2C74EEEA92BB,$F3E34E1BFFFC63A9,$E1B7C27C9F0EB7ED
Data.q $98F8F8E8AFABEAFD,$7162014038EFEDE3,$038CBBF0D1F73C67,$BBF977A3CA007FC0,$4900000000EF166D
Data.q $00826042AE444E45
EndDataSection
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: I need Description for SpriteBlendingMode constants
Also keep in mind that this isn't pixel perfect and you will get different results on different systems. We had a really large thread somewhere showing the differences.
bye,
Daniel
Daniel
Re: I need Description for SpriteBlendingMode constants
Thank you STARGÅTE! Perfect example!
Re: I need Description for SpriteBlendingMode constants
Thank you very much for the example @STARGÅTE, it is very helpful.
This should be added to the PB help!
This should be added to the PB help!
Re: I need Description for SpriteBlendingMode constants
Hi STARGÅTE,
thank you for this nice example, which runs perfectly on Windows 11.
On my 2016 Intel MacBook Pro running Monterey, all I get is a nice green screen, nothing more. A bit odd, as nothing in your code indicates that you used Windows specific stuff...
As I'm able to see your example on Windows, I'm happy with it.
thank you for this nice example, which runs perfectly on Windows 11.
On my 2016 Intel MacBook Pro running Monterey, all I get is a nice green screen, nothing more. A bit odd, as nothing in your code indicates that you used Windows specific stuff...
As I'm able to see your example on Windows, I'm happy with it.
