September 23, 2019, 03:11:29 PM

Author Topic: Alfa value for colours  (Read 269 times)

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Alfa value for colours
« on: September 05, 2019, 07:46:53 PM »
Could somebody please explain to me what the alfa value does ( red green blue alfa ) what is alfa.

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2000
Re: Alfa value for colours
« Reply #1 on: September 05, 2019, 07:51:01 PM »
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.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #2 on: September 05, 2019, 09:19:56 PM »
Thanks for the reply . Learnt something new today.

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2000
Re: Alfa value for colours
« Reply #3 on: September 05, 2019, 09:30:18 PM »
Cool.  No problem.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #4 on: September 05, 2019, 10:38:29 PM »
Well I tried it
Code: [Select]
setobjectcolor(2,0,100,0,255)and
Code: [Select]
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 .

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2000
Re: Alfa value for colours
« Reply #5 on: September 05, 2019, 10:43:56 PM »
Use SetSpriteColor.  So this is 3D? I've not used AGK 3D.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #6 on: September 05, 2019, 11:12:50 PM »
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.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2115
Re: Alfa value for colours
« Reply #7 on: September 05, 2019, 11:22:05 PM »
Well I tried it
Code: [Select]
setobjectcolor(2,0,100,0,255)and
Code: [Select]
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?
Until the next time...

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #8 on: September 06, 2019, 10:20:21 AM »
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.
Code: [Select]
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]

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #9 on: September 06, 2019, 10:24:06 AM »
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 .

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 429
Re: Alfa value for colours
« Reply #10 on: September 06, 2019, 11:47:09 AM »
you need to turn on transparency with SetObjectTransparency(2,1)
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #11 on: September 06, 2019, 11:55:36 AM »
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.

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 776
Re: Alfa value for colours
« Reply #12 on: September 08, 2019, 11:41:16 AM »
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.

Code: [Select]
// 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
_______________________________________

Offline Pfaber11

  • Sr. Member
  • ****
  • Posts: 280
    • FABERS GAMES
Re: Alfa value for colours
« Reply #13 on: September 08, 2019, 12:17:52 PM »
Thanks for that info very useful .

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 776
Re: Alfa value for colours
« Reply #14 on: September 08, 2019, 01:19:52 PM »
You're welcome.  ;)
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________