Alfa value for colours

Started by Pfaber11, September 05, 2019, 19:46:53

Previous topic - Next topic

Pfaber11

Could somebody please explain to me what the alfa value does ( red green blue alfa ) what is alfa.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Steve Elliott

The alpha value is the amount of transparency.  So a value of 255 is solid and 0 would be invisible, something inbetween for a 'ghost-like' look so the background shows through.
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

Pfaber11

Thanks for the reply . Learnt something new today.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

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

Pfaber11

Well I tried it
setobjectcolor(2,0,100,0,255)
and
setobjectcolor(2,0,100,0,1)
and it had no effect. I think I'll just leave it at one for now.
At least now I know what it means .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Steve Elliott

#5
Use SetSpriteColor.  So this is 3D? I've not used AGK 3D.
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

Pfaber11

#6
steve I've been at the 3d stuff about 6 months now and I love it . I'm no expert but it's great fun . Finished a few games with it so far and am ready to start a new project . Just got to figure out what that project is going to be . Got to grips with textures and am now working on the shaders side of things as in terrain.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Qube

Quote from: Pfaber11 on September 05, 2019, 22:38:29
Well I tried it
setobjectcolor(2,0,100,0,255)
and
setobjectcolor(2,0,100,0,1)
and it had no effect. I think I'll just leave it at one for now.
At least now I know what it means .

Are you sure that your object has an ID of 2?. Have you tried this example?
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Pfaber11

yes quite sure . I created a sphere with the id of 2 . I'm just playing around at the moment as inbetween games. Here's the code I'm fooling around with.
Project: hm12 shader
// Created: 2019-09-04

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "hm12 shader" )
SetWindowSize( 1366, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1366, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts



loadimage(2,"skin12.png")
CreateObjectFromHeightMap(1,"hm12.png",2048,2000,2048,1,0)
setobjectimage(1, 2,1)
CreateObjectSphere(2,30,20,20)
SetObjectColor(2,0,200,0,200)
SetObjectPosition( 1,0,00,100)
setobjectposition(2,1000,400,1000)
  setcamerarange(1,10,5000)
  SetCameraPosition(1,1000,300,1000)
  setcamerarotation(1,0,30,0)
 
 
sync()
do
if GetRawKeystate(65)=1
RotateCameraGlobaly(1,-2)
endif
if GetRawKeystate(68)=1
RotateCameraGlobaly(1,2)
endif
if GetRawKeystate(83)=1
MoveCameraLocalZ(1,-10)
endif
if GetRawKeystate(87)=1
MoveCameraLocalZ(1,10)
endif


    Print( ScreenFPS() )
    Sync()
loop///[code]
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

When I change the value of the alfa in setobject color it makes no difference . 1 or 101 it's the same. Had an idea for a game using it was thinking of a crystal maze where you can see through the walls .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

TomToad

you need to turn on transparency with SetObjectTransparency(2,1)
------------------------------------------------
8 rabbits equals 1 rabbyte.

Pfaber11

#11
Brilliant thanks Tom Toad . Would of never worked that out . Gonna go and have a play with it .
   Just tried it and it appears 1 is invisible 2 is so you can see through it and 3 is solid color. Excellent thank you.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Rick Nasher

#12
Actually I think no.

With 0 you turn off transparency(default opaque mode) and with the values 1, 2 or 3 you just set transparency on, but with different modes/effects.
The alpha value in the SetObjectColor sets the actual level of transparency. For instance I used below code for creating window glass like effects. But mode 2 can also be useful for that.


// Windows..
wr# as float, wg# as float, wb# as float, wt# as float

wr#=100    // set red, green, blue values..
wg#=100
wb#=100
wt#=100    // and the transparency value

window as integer
window=CreateObjectBox( 340, 200 ,.20 )

SetObjectPosition(window,0,0,0)
SetObjectPosition(  window, -210,100,2220) // you would have to adjust the position and sizes for my world is a bit large.
SetObjectColor (window , wr#, wg#,wb#, wt#) 
SetObjectTransparency(window,1) // turn on transparency in mode 1 = alpha blended.


See also:
Quote
SetObjectTransparency

Description

Sets the transparency mode for this object, 0 is opaque, 1 is alpha blended, 2 is additive blended, 3 is custom blending. Using a transprency value greater than 0 will slow down rendering, it also doesn't write transparent objects to the Z buffer so it might cause some depth ordering problems. There is an alternative form of transparency called Alpha Masking that is useful if you only need fully transparent or fully opaque pixels but no blending in between. See SetObjectAlphaMask for more details.

When using mode 3 (custom) the blend values must be specified with SetObjectBlendModes otherwise the object will not be transparent.


Definition

SetObjectTransparency( objID, mode )


Btw:
You can find the command descriptions online from here:
https://www.appgamekit.com/documentation/search.html

Just enter the command or topic into the search box.

_______________________________________
B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Pfaber11

Thanks for that info very useful .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Rick Nasher

_______________________________________
B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________