Blitz3D and PNG's

Started by Steve Elliott, March 09, 2018, 17:46:20

Previous topic - Next topic

Steve Elliott

Just ran Blitz3D and loaded a png.  The alpha isn't showing, so I get a white block around the sprite.  A blend mode needs to be set? 
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

RemiD

#1
i use the flag 2 or flag 1+2 (and of course your image must be "clean" (=no progressive outlines))

if you want to be sure, you can use one or several mask colors, and identify each mask color in Blitz3d, and rewrite the alpha value that you want.

See my code examples here :
https://www.syntaxbomb.com/index.php/topic,1962.msg2951.html#msg2951

Steve Elliott

Quote
i use the flag 2 or flag 1+2

And the command to do this is?  I'm not a Blitz3D user.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

RemiD

#3
Texture = LoadTexture("filename.png",flags) (1 = color | 1+2 = color+alpha | 1+4 = color+mask (hide black texels) )

add flag 256 if you want to write alpha on a texture, it prevents bugs on some computers...
so LoadTexture("filename.png",1+2+256) or CreateTexture(Width,Height,1+2+256)

Steve Elliott

LoadTexture??  That sounds like a 3D command, not a 2D one.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

RemiD

Oh, there is no alpha on images in Blitz3d, only masking of black pixels... You have to use a texture if you want a variable transparency...

Steve Elliott

Oh, so Blitz3D doesn't really support 2D PNG then?  Just old skool hard edge (pick a colour to be transparent)?
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

RemiD

#7
For images (2D), the pixels with a black color (000,000,000) will be masked (fully transparent)

For textures loaded with the alpha flag, the texels with an alpha value less than 255 will have the defined transparency
For textures loaded with the mask flag, the texels with a black color (000,000,000), will be masked (fully transparent)

Note that you can produce pixel perfect "images" using quads and textures if you disable bilinear filtering... So you can have alpha on "images" (but they would be quads + textures)

Steve Elliott

Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb