Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Multiple videos and transparent videos?

Author
Message
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 14th Jun 2017 14:53 Edited at: 14th Jun 2017 16:17
Works in Chrome.

Demo for the result I want to get in AGK.
http://simpl.info/videoalpha/
(video : http://simpl.info/videoalpha/video/soccer1.webm )

Under Windows:
you may need: https://xiph.org/dshow/

For getting the color from the video I used "Just Color Picker"
http://annystudio.com/software/colorpicker/#jcp-download


My code so far:



I am missing some in AGK.

Why is it not: vidID = LoadVideo() and PlayVideo(vidID) or PlayVideoToImage(vidID, imgID)

Also WebM has Alpha. But I don't understand, why the Image (video) has the gray background.

It could be interessting for Point-and-click-adventures e.g.

Or do I somehow has to create two! videos!. 2 ... more than one! And use SetImageMask() to create something like that
https://jakearchibald.com/scratch/alphavid/

But how? If I only have one video?
Jack
14
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 14th Jun 2017 18:15 Edited at: 14th Jun 2017 18:17
vidID = LoadVideo("soccer1.webm")

Nope, the LoadVideo breaks the standard logic. it does not return a vidID, you can only load one video at a time, so there is no video ID at all.

What you want is a special impementation.

Windows, Mac and Linux would work well with multiple alpha based videos. Mobile OS not.
For example the second video android has to handle will not be rendered on the GPU and has, depending on your resolution and bitrate, about 1-5 fps.
I am even not shure about alpha videos on mobile devices.

You can realize this in AppGameKit T1 by working out a seperate OpenGL Video command set.
Let me bet, you will already find your needed lib somewhere on github.
So the basic problem would be how to implement it into an AppGameKit plugin.

If you go for D3d with your plugin though, you will be bound to the windows platform,
so I would prefer to stay with OpenGL.

[/url]
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 16th Jun 2017 13:00
@jack

Okay, I could live with one video at a time. And maybe transparent video will not work on iOS with AGK. But WebM is a Google format and Android 4.4 supports it.

The question would be, would it be possible, to render a transparent video to maybe a memblock or image -> memblock -> save ... and preserve the transparent color for maybe later use.

I think, I stuck with some PNG sprites. But I testet days back in 2011 with my iPod and Flash Professional some FLV and F4V videos with transparent backgrounds. WebM and F4V are both some Sorenson V7/V8/V9 codec thingly.

The problem with video in apps is streaming/or not streaming.

Maybe I could do a PNG/JPEG checkerboard combination with right timing and create my own "video-format"

Thanks for help.
Jack
14
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 16th Jun 2017 16:06 Edited at: 16th Jun 2017 16:08
Quote: "The question would be, would it be possible, to render a transparent video to maybe a memblock or image -> memblock -> save ... and preserve the transparent color for maybe later use. "

Yes, it would. Or you could simply render your video out as a .png sequence and load them into a memblock.

Quote: "
Maybe I could do a PNG/JPEG checkerboard combination with right timing and create my own "video-format""


This is true, as you can request an image from your video and combine this image with a mask- sequence.
I would recommend to create a custom shader where the color (rgb) are taken from the video image and the alpha value is (r*g*b/3.) from the mask image.
Should be done in about two to four additional lines from the native AppGameKit shader example.

With a .PNG video sequence you would go faster.

[/url]
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 25th Oct 2018 13:42 Edited at: 25th Oct 2018 13:42
Maybe we could figure it out together.



I wanted to have only the person on the video. I created this video with DaVinci Resolve, so we have the Alpha-Mask also at the same time in the same video.
But what next? Shader? Memblock-Tricks?

Attachments

Login to view attachments
fubarpk
Moderator
14
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 25th Oct 2018 16:01 Edited at: 25th Oct 2018 16:05
In pixelated labrynth the flames are a video


code snippet the order is important
fubar
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 25th Oct 2018 18:02
Definition
SetSpriteTransparency( iSpriteIndex, mode )

Parameters
iSpriteIndex - The ID of the sprite to modify.
mode - The transparency mode for this sprite, 0=off, 1=alpha transparency, 2=additive blending

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

If I use mode 2 like in your example, the person gets white, the blackborder is transparent.
If I am using mode 1, I see no difference. I used a color-picker and the black color is 0, 0, 0 in the video.

So, I don't get the effect I wanted.
CJB
Valued Member
15
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Oct 2018 21:37 Edited at: 25th Oct 2018 21:38
Something like this (screenshot):



Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 26th Oct 2018 09:50
@CJB,

you are my hero. I thought about something like that, but didn't knew the commands. Was looking for "Blending" and "Texture Masking"
CJB
Valued Member
15
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 26th Oct 2018 13:27
It's not a very efficient way of doing things as you are re-creating a new image mask every frame, but it gets the job done.
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 26th Oct 2018 15:16
@CJB,

Could there be a better solution? I read that "This is a slow command and should not be called every frame."
But every frame the image mask would be another one.

And I guess, they also didn't do that realtime


I also was looking into that a little bit, handling MemBlocks, but I guess, it would also not faster
https://forum.thegamecreators.com/thread/213539

So what would be a more elegant solution, if money doesn't matter? But we still use AppGameKit I guess, I would 3D-scan the person, rig the person, have a low polycount, bake the textures and so on and make motion caputure for the same movement ...
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Oct 2018 21:07
I think a shader is the way to go with this.
CJB
Valued Member
15
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 27th Oct 2018 13:10
Good idea! Here's my first attempt:

alphavid.ps:


agk code:


Set _cutoff_level to the brightness level required of each pixel (in the range 0.0 to 1.0 (0 = rgb(0,0,0), 1 = rgb(255,255,255)) - the shader will only render pixels that have their r, g and b values above this level, otherwise the pixel is discarded.

Attachments

Login to view attachments
CJB
Valued Member
15
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 27th Oct 2018 17:35 Edited at: 27th Oct 2018 17:37
With a little tweak, it now blends in the dark areas by adding alpha inversely to the level of darkness below the _cutoff_level. Makes the edges smoother:

shader:


agk example:


We could use this same technique to create a chroma-keying shader

Attachments

Login to view attachments
Jack
14
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 28th Oct 2018 03:15
Xaby
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 16th Nov 2018 10:40
Could this method for Video-streaming "make" sense also for static JPEGs or could we use this for maybe Sprite-Animations as well, but with JPEG instead of PNG or would it loss its benefits?

I am often thinking about texture compression on 3D models and at this point I seperated transparent textures from non-transparent and compressed the non-transparend as JPEG (because no ATSC or DXT or so) and the transparent ones as PNGs.
In Memory, I guess, it's the same later, but PNG is also very slow in decompression.

Login to post a reply

Server time is: 2019-08-19 08:28:30
Your offset time is: 2019-08-19 08:28:30