Attract-Mode Support Forum

Attract-Mode Support => General => Topic started by: jedione on July 20, 2018, 05:28:12 PM

Title: new BlendMode...
Post by: jedione on July 20, 2018, 05:28:12 PM
does any one know how to implement the new Blend Modes....

 this is what i tryed.....   but dont do anything

Code: [Select]
local bg = fe.add_artwork( "snap", flx*0.200, 200, flw*0.500, flh*0.500 );
bg.BlendMode.Screen;

info from latouts.txt.

* `blend_mode` - Get/set the blend mode for this image.  Can have one of the
     following values:
      - `BlendMode.Alpha`
      - `BlendMode.Add`
      - `BlendMode.Screen`
      - `BlendMode.Multiply`
      - `BlendMode.Overlay`
      - `BlendMode.Premultiplied`
      - `BlendMode.None`


thats all the give us...no example?       Thanks.. :)


Title: Re: new BlendMode...
Post by: iOtero on July 21, 2018, 01:40:45 AM
Yes, it would not be bad to have an example that shows the new options.  :-[
Title: Re: new BlendMode...
Post by: Oomek on July 25, 2018, 12:55:26 PM
It’s the same as in Photoshop.
Add an image1 as a background then another smaller image2 on top and set the image2.blend_mode = BlendMode.Add for example. You won’t see any effect change if there is only black background underneath the image you are applying a blend mode to.

I can post some example code next week if it’s still not clear enough.
Title: Re: new BlendMode...
Post by: jedione on July 25, 2018, 07:06:55 PM
ok i think i found out why im looking for...it's the blur that u have in your un released theem...
it is a shader not blend...
but with some tweeking.... and a opacity overlay its looking the wat i need
thanks for your help .. im glag your so active

not the best...looking forward to your release to see your code..

(http://i65.tinypic.com/2u8867p.png)
Title: Re: new BlendMode...
Post by: dukpoki on July 25, 2018, 07:23:42 PM
I didn't know you could do this!  What a game changer!  More info on the blur shader and where it's located please!
Title: Re: new BlendMode...
Post by: zpaolo11x on July 25, 2018, 11:28:21 PM
I'd really like some hints on how to use the blur shader too, this would fit my Arcadeflow theme without having to generate blurred thumbnails in a separate art category :)
Title: Re: new BlendMode...
Post by: Oomek on July 26, 2018, 02:36:46 AM
Remind me please when and where did I post the blur shader? It’s still unfinished and requires some tweaking.
Title: Re: new BlendMode...
Post by: zpaolo11x on July 26, 2018, 02:47:32 AM
Remind me please when and where did I post the blur shader? It’s still unfinished and requires some tweaking.

:O I inferred from that screenshot that the blur shader was already available :D

I found a nice trick though, if you place a large image (say 640x480) on a small surface (say 160x120), and then resize the surface using set_pos to enlarge it, with mipmap enabled you get a pretty nice "blur" effect. Sadly for my intent this is not smooth enough :/
Title: Re: new BlendMode...
Post by: Oomek on July 26, 2018, 03:42:51 AM
You have to wait until I finish moving to a new house, then I'll wrap it into some neat module so it's easy to use, because now it's entangled with the rest of the files.
Title: Re: new BlendMode...
Post by: iOtero on July 26, 2018, 06:11:55 AM
One blend mode example, Oomek, please...
Title: Re: new BlendMode...
Post by: jedione on July 26, 2018, 06:52:33 AM
ok here is a blur layout for everyone to play with.

(https://media.giphy.com/media/1qcknvpZhmGxnzWM4E/giphy.gif)

the layout, is set up so in layout options you can choose fanart, snap, or videos.enjoy

and last.  a thanks to arcadebliss..for this code that has been siting right under are noses, since late 2015
hellow.

blur-layout download =
https://mir.cr/5BZ8NEIJ (https://mir.cr/5BZ8NEIJ)
Title: Re: new BlendMode...
Post by: jedione on July 26, 2018, 07:00:50 AM
of corse it will be better when Oomek, makes a setup for us all to use
module ,or plugin?
cant wait..
Title: Re: new BlendMode...
Post by: dukpoki on July 26, 2018, 08:33:39 PM
I'd really like some hints on how to use the blur shader too, this would fit my Arcadeflow theme without having to generate blurred thumbnails in a separate art category :)

I was thinking the same thing when I originally saw this thread.  I thought of your theme and Oomek's current WIP.  Btw.  I really think your theme is amazing and I would like to use it but that separate blur thumbnails part is what kills it for me (not to mention the requirement of thumbnails on top of videosnaps).  Basically/i.e. steep requirements.  If you can implement a blur shader, perhaps the one Oomek is working on, then I think more and more people will be able to use your theme.  It's really a shame though, because I think (purely my speculation) a lot of people are daunted in using your theme when it's actually an amazing coded work of art.

ok here is a blur layout for everyone to play with.

Cool.  Just checked it out.  I think the blur needs to be waaaay more aggressive though to achieve the effect we are looking for.  I think we all better wait for Oomek's future shader.

You have to wait until I finish moving to a new house, then I'll wrap it into some neat module so it's easy to use, because now it's entangled with the rest of the files.

Can't freaking wait for Ambience!  Thanks for all your hard work my friend!  And congrats on the new house!
Title: Re: new BlendMode...
Post by: zpaolo11x on July 26, 2018, 10:13:37 PM
I was thinking the same thing when I originally saw this thread.  I thought of your theme and Oomek's current WIP.  Btw.  I really think your theme is amazing and I would like to use it but that separate blur thumbnails part is what kills it for me (not to mention the requirement of thumbnails on top of videosnaps). 

What do you mean with video snaps? It should work ok if you have your thumbs and videos in the same folder... anyway I think you are right and to be honest yesterday I managed to add blurred backgrounds with a trick using three nested scaled surfaces. It will be implemented in 2.0 but not until the end of August because I’m going on vacation :D

Oh and thank you for the comments! I think with a proper blur shader (or my trick) and blend modes I could also get rid of blurred title shadows artwork!
Title: Re: new BlendMode...
Post by: dukpoki on July 27, 2018, 11:02:43 AM
What do you mean with video snaps? It should work ok if you have your thumbs and videos in the same folder...

I mean you need jpg/png screenshots of the videosnap along with the video file itself.  At least i think that's how it works?  So in essence, you would need for all your roms.. 1) a full set of "video" snaps 2) a full set of screenshotted "picture" snaps and 3) a full set of "blurred picture" snaps of the screenshot.
Title: Re: new BlendMode...
Post by: zpaolo11x on July 27, 2018, 12:55:55 PM
I mean you need jpg/png screenshots of the videosnap along with the video file itself.  At least i think that's how it works?  So in essence, you would need for all your roms.. 1) a full set of "video" snaps 2) a full set of screenshotted "picture" snaps and 3) a full set of "blurred picture" snaps of the screenshot.

it’s true that you need a full set of thumbnail snaps, but this is something that is easy to find for MAME, and if the videos set is not complete the theme will work with thumbs instead. And yes you need to generate blurred thumbs but if you have the normal thumbs you can generate them with my xnview scripts (included in the theme).

you’d like AF to work with videos only?
Title: Re: new BlendMode...
Post by: Oomek on July 27, 2018, 03:10:50 PM
I thought having snaps and videos is a standard, a lot of layouts/themes rely on it. If you have only videos you will see a lot of black rectangles. Sorry for stating the obvoius.
Title: Re: new BlendMode...
Post by: dukpoki on July 27, 2018, 08:34:05 PM
I had complete picture snap sets for Mame and Snes in the past.  Then I decided to delete them because there is no point in keeping those snaps (being unused) if i'm going to use videosnaps instead.  I've since collected purely videosnaps.  I have zero need for picture snaps because I have a videosnap for every rom.  (any missing vsnaps I simply create myself with fraps+avidemux)  I have a massive and completely thorough collection of videosnaps, flyers/boxart, wheels, etc spanning 17 systems.  Keeping a set of image snap sets is not really a problem except  I just figured it wasn't necessary to waste space on unused assets and thus deleted them. I was really hoping there was a way to read a single key frame from a videosnap and display that.  Kind of how Windows Explorer creates thumbs.  But if that's not possible then I understand.  And judging from Oomek's post, i'm going to assume his Ambience theme will also require screenshot snaps.  In that case, then there's really nothing to it except I need to keep dual sets or miss out on certain themes.

I thought having snaps and videos is a standard, a lot of layouts/themes rely on it.

I honestly have not run into a theme thus far that required a dual set.  The only one so far is zpaolo11x's and I assume your WIP.
Title: Re: new BlendMode...
Post by: Oomek on July 27, 2018, 10:24:28 PM
There are 2 types of themes: snap and list based. The former divide into ones that play a video of the selected game and ones that play all the videos at the same time. Personally I’m not a fan of that last category, hence the requirement of snaps and videos.

Clarification:
The ”list based” type includes a listbox of titles and a conveyor of game marquees/wheels

Preferences aside, I do not see any reason of not including an option to allow all the videos playing simultaneously.
Title: Re: new BlendMode...
Post by: zpaolo11x on July 28, 2018, 12:13:05 AM
most of my videosnaps start with a fade from black, therefore I can’t just use the first frame to show as a fixed thumb. Although it would be great to be able to tell AM from what timw to start the video, there is still the issue that a theme like Arcadeflow preloads around 25 thumbs. preloading video snaps and updatimg them is not as fast as fixed images, that’s why my theme has a precise timing for video loading that hides the moment so that it doesnt make the scrolling stutter (this doesn’t happen on my workstation ssd which costs around 600 euros, but on most drives it does, on my macbook it does stutter when the video is loaded).

Besides, my whole mame thumbs archive takes up less than 1Gb, I rescaled all to 320x240 as it’s faster and looks equally good on screen.

If there was a way to chose the fixed thumb to show when a videomis not playing I would put it as an option but afaik it doesn’t
Title: Re: new BlendMode...
Post by: Oomek on July 28, 2018, 05:57:32 AM
If you don’t mind I’ll continue hijacking the thread and ask for your suggestions you snapless people.
Title: Re: new BlendMode...
Post by: dukpoki on July 28, 2018, 10:06:37 AM
most of my videosnaps start with a fade from black, therefore I can’t just use the first frame to show as a fixed thumb. Although it would be great to be able to tell AM from what timw to start the video, there is still the issue that a theme like Arcadeflow preloads around 25 thumbs. preloading video snaps and updatimg them is not as fast as fixed images, that’s why my theme has a precise timing for video loading that hides the moment so that it doesnt make the scrolling stutter (this doesn’t happen on my workstation ssd which costs around 600 euros, but on most drives it does, on my macbook it does stutter when the video is loaded).

Yeah the preloading/updating speed makes sense especially for Arcadeflow even with a beefy rig.  All my videos have fade in from black as well.

Besides, my whole mame thumbs archive takes up less than 1Gb, I rescaled all to 320x240 as it’s faster and looks equally good on screen.

True.  It's not really a big deal, but to be fair, it does scale with more systems you have.  Plus it's time consuming to make which again scales.  Again though, not really a big deal.  It's mostly because i'm ocd about keeping files that are important/useful and deleting files that are erroneous and redundant.  xD

If there was a way to chose the fixed thumb to show when a videomis not playing I would put it as an option but afaik it doesn’t

No worries.   I'm not saying you guys should do this or that.  I'm simply stating that currently, there is a high pre-requisite for running the theme, which is true when compared to other themes, that's all.  Not saying necessarily that's a bad thing (though some users may be daunted by it).  For the gains in speed, it's well worth it.
Title: Re: new BlendMode...
Post by: zpaolo11x on August 11, 2018, 12:01:44 AM
Since this thread has detoured to blurred backgrounds and other tricks, I'll post here this code snippet: It's a trick to have a blurred background from the game snaps without having to use shaders, it works by rescaling the picture three times and leveraging bilinear filtering from the graphics card. Of course it works only if you want a very "wild" blur...

Code: [Select]
local flw = fe.layout.width
local flh = fe.layout.height

local xsize1 = 32
local xsize2 = 4
local xsize3 = 16
local xsize9 = flw

local xsurf1 = fe.add_surface (xsize1,xsize1)
local xsurf2 = fe.add_surface (xsize2,xsize2)
local xsurf3 = fe.add_surface (xsize3,xsize3)

local snapbg1 = xsurf1.add_artwork ("snap",0,0,xsize1,xsize1)
snapbg1.alpha = 255
snapbg1.video_flags = Vid.ImagesOnly

xsurf2.visible = false
xsurf2 = xsurf3.add_clone(xsurf2)
xsurf2.visible=true
xsurf2.set_pos (0,0,xsize3,xsize3)

xsurf1.visible = false
xsurf1 = xsurf2.add_clone(xsurf1)
xsurf1.visible=true
xsurf1.set_pos (0,0,xsize2,xsize2)

xsurf3.set_pos (0,0,flw*0.5,flw*0.5)

fe.add_text(xsize1 + " " + xsize2 + " " + xsize3 ,0,50,flw*0.5,50)
local snap0 = fe.add_artwork("snap",flw*0.5,0,flw*0.5,flw*0.5)
snap0.video_flags = Vid.ImagesOnly

fe.add_text("[Title]",0,flw*0.5,flw,50)
Title: Re: new BlendMode...
Post by: jedione on August 11, 2018, 07:32:37 AM
tanks for posting the code,   i think this is a great look.....good work

wow...it works for video two!   yay ;D
Title: Re: new BlendMode...
Post by: zpaolo11x on August 11, 2018, 11:32:51 AM
tanks for posting the code,   i think this is a great look.....good work

It's not bad but still a bit slower... I also managed to use the blur-layout shader for game title shadows, in the attached picture on the left the shader generated one, on the right the xnview version...

The idea is to implement both in version 2.0 of my layout :D

Title: Re: new BlendMode...
Post by: jedione on August 12, 2018, 11:20:48 AM
can you share this "shader"  for the artwork.. ::)
Title: Re: new BlendMode...
Post by: zpaolo11x on August 12, 2018, 01:01:37 PM
can you share this "shader"  for the artwork.. ::)

It's the same code from blur-layout that you linked, but I'll pack a layout as soon as possible... There are more shaders in that layout but I don't know how to call them :(
Title: Re: new BlendMode...
Post by: jedione on August 12, 2018, 01:20:09 PM
cool thanks bro...
Title: Re: new BlendMode...
Post by: zpaolo11x on August 14, 2018, 01:20:47 AM
This is the code I used for the "drop shadow" effect:

Code: [Select]

local sizew = 280
local sizeh = 160

local bgpic = fe.add_text("",0,0,sizew,sizeh)
bgpic.set_bg_rgb (200,50,0)

local surf2 = fe.add_surface(sizew,sizeh)
local logox = surf2.add_artwork("wheel",20,20,240,120)
logox.preserve_aspect_ratio = true
logox.set_rgb(0,0,0)
logox.alpha=150

local surf1 = fe.add_surface(sizew,sizeh)

surf2.visible = false
surf2 = surf1.add_clone(surf2)
surf2.visible = true

local shaderH = fe.add_shader( Shader.Fragment, "frag.txt" )
shaderH.set_texture_param( "source")
shaderH.set_param("offsetFactor", 0.008, 0.0)
surf1.shader = shaderH

local shaderV = fe.add_shader( Shader.Fragment, "frag.txt" )
shaderV.set_texture_param( "source")
shaderV.set_param("offsetFactor", 0.0000, 0.008)
surf2.shader = shaderV

local logo00 = fe.add_artwork ("wheel",20,20-10,240,120)
logo00.preserve_aspect_ratio = true

and it uses the shader from that lauout in the file "frag.txt":

Code: [Select]
uniform sampler2D source;
uniform vec2 offsetFactor;

void main() {
    vec2 sourceCoordinates = gl_TexCoord[0].xy;
    vec4 color = vec4(0.0);
    color += texture2D(source, sourceCoordinates - 10.0 * offsetFactor) * 0.0012;
    color += texture2D(source, sourceCoordinates - 9.0 * offsetFactor) * 0.0015;
    color += texture2D(source, sourceCoordinates - 8.0 * offsetFactor) * 0.0038;
    color += texture2D(source, sourceCoordinates - 7.0 * offsetFactor) * 0.0087;
    color += texture2D(source, sourceCoordinates - 6.0 * offsetFactor) * 0.0180;
    color += texture2D(source, sourceCoordinates - 5.0 * offsetFactor) * 0.0332;
    color += texture2D(source, sourceCoordinates - 4.0 * offsetFactor) * 0.0547;
    color += texture2D(source, sourceCoordinates - 3.0 * offsetFactor) * 0.0807;
    color += texture2D(source, sourceCoordinates - 2.0 * offsetFactor) * 0.1065;
    color += texture2D(source, sourceCoordinates - offsetFactor) * 0.1258;
    color += texture2D(source, sourceCoordinates) * 0.1330;
    color += texture2D(source, sourceCoordinates + offsetFactor) * 0.1258;
    color += texture2D(source, sourceCoordinates + 2.0 * offsetFactor) * 0.1065;
    color += texture2D(source, sourceCoordinates + 3.0 * offsetFactor) * 0.0807;
    color += texture2D(source, sourceCoordinates + 4.0 * offsetFactor) * 0.0547;
    color += texture2D(source, sourceCoordinates + 5.0 * offsetFactor) * 0.0332;
    color += texture2D(source, sourceCoordinates + 6.0 * offsetFactor) * 0.0180;
    color += texture2D(source, sourceCoordinates - 7.0 * offsetFactor) * 0.0087;
    color += texture2D(source, sourceCoordinates - 8.0 * offsetFactor) * 0.0038;
    color += texture2D(source, sourceCoordinates - 9.0 * offsetFactor) * 0.0015;
    color += texture2D(source, sourceCoordinates - 10.0 * offsetFactor) * 0.0012;
    gl_FragColor = color;
}

The script works like this: you need to create two nested surfaces, place the image you want to blur on the topmost surface and add an horizontal blur to the first, vertical blur to the second.

It's not sufficient to use one surface and add horizontal to the surface, vertical to the image, because the blur will get clipped, you need all this safeguard area around the logo image.

This is a neat shader, it would be great for creating automatically drop shadows for thumbnails too, accurate in aspect ratio etc, but it's a bit heavy since it already needs two nested surfaces to work. Anyway that's the code :D
Title: Re: new BlendMode...
Post by: iOtero on August 14, 2018, 02:17:29 AM
And all this what processor do you need?
Could a raspi 3 with it?
Title: Re: new BlendMode...
Post by: Oomek on August 14, 2018, 05:38:22 AM
I don’t have any experience with RPI, but from what I know it does not support shaders.
Title: Re: new BlendMode...
Post by: zpaolo11x on August 14, 2018, 06:25:06 AM
And all this what processor do you need?
Could a raspi 3 with it?

Honestly I have no idea... my Arcadeflow theme is already struggling on RPi even with "pre-baked" blurred backgrounds and shadows so I don't think it will be suited for this approach
Title: Re: new BlendMode...
Post by: iOtero on August 14, 2018, 08:44:06 AM
I do not have pi. I said the raspberry pi because it is the closest thing to an N270 atom of my Samsung N120, where I have the emulation that needs less processor. As much, the playstation...

But I do not think I can handle the shaders ...