Author Topic: Drop shadow layout, may be turned into something useful?  (Read 19179 times)

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #15 on: January 20, 2019, 03:03:03 PM »
Would be cool if you could also show how to do a white glow behind wheel art :)

This together with the conveyor module would be gold!  :)

I think if you change his set_rgb() call to set_rgb(255, 255, 255) and change the offsets for x and y to 0, you can get something like that. Maybe even set the blend_mode to BlendMode.Screen.

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #16 on: January 20, 2019, 08:10:20 PM »
All right, @zpaolo11x, I took your code and wrapped it in a class (attached). It works for me...the typical way it should, I think, but in the grander scheme of things, it doesn't work for my purposes! I think it has to do with how the first image (a video in my case) doesn't come up on layout start: you have to navigate through the list to trigger things. I think if I can solve this issue (which I still have no idea how to do!), I'd be good to go.

For those with less ridiculous layouts than me, here's how to instantiate the wrapped drop-shadow (there's better "documentation" in the .nut):

Code: [Select]
fe.do_nut( "drop-shadow.nut" );

local myPic = fe.add_artwork( "snap", 100, 100 ); // Arbitrary placement

local myPicDS = DropShadow( myPic, 25, 0, 10, 153 ); // Shadowed object, blur size, x-offset, y-offset, alpha (0~255)

You'll need zpaolo11x's gauss_kernsigma_o.glsl file for any of this to work!

If anyone has any idea why my layout isn't showing a snap when it first loads, I'm all ears! Thanks!

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #17 on: January 21, 2019, 01:15:24 AM »
Would be cool if you could also show how to do a white glow behind wheel art :)

This together with the conveyor module would be gold!  :)

I think if you change his set_rgb() call to set_rgb(255, 255, 255) and change the offsets for x and y to 0, you can get something like that. Maybe even set the blend_mode to BlendMode.Screen.

If you do like that you get a sort of "ambi-light" effect where the glow is the same color as the picture, but if your picture is dark, you'll get a dark glow, which is not very nice. The best way to solve the issue is to add a shader to pic1 and change there the color, I'm working on it right now so you can choose the exact color of the shadow :)
« Last Edit: January 21, 2019, 01:50:29 AM by zpaolo11x »

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #18 on: January 21, 2019, 02:12:36 AM »
Changed it a bit so you can actually chose the color of the shadow, and with a white shadow it looks like a glow.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #19 on: January 21, 2019, 02:27:21 AM »
All right, @zpaolo11x, I took your code and wrapped it in a class (attached). It works for me...the typical way it should, I think, but in the grander scheme of things, it doesn't work for my purposes! I think it has to do with how the first image (a video in my case) doesn't come up on layout start: you have to navigate through the list to trigger things. I think if I can solve this issue (which I still have no idea how to do!), I'd be good to go.

Yep, I saw your code and here is what to change: in the resizeVideoBox function, add this to the case statement:

Code: [Select]
case Transition.ToNewList:
because you have put there Transition.StartLayout but when StartLayout is triggered there's no artwork yet on the layout. "ToNewList" will solve your issue

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #20 on: January 21, 2019, 06:59:24 AM »
All right, @zpaolo11x, I took your code and wrapped it in a class (attached).

I see in the code that the _parent only works if it's set to fe, this is expected because of the way the original drop shadow layout was created. Things are a bit complicated: to avoid frame delays the two surfaces _surfA and _surfB must always be created on the fe, then stacked and repositioned using a "reshuffling" code based on self clones. If you want to place everything on another surface (or better, if the item you want to add drop shadows is on a surface itself, which is probably the "_parent") you should create _surfA and _surfB on fe, then once you have done the "reshuffling":

Code: [Select]
        _surfA.visible = false;
        _surfA = _surfB.add_clone( _surfA );
        _surfA.visible = true;

you should do another suffling like this:


Code: [Select]
        _surfB.visible = false;
        _surfB = _parent.add_clone( _surfB );
        _surfB.visible = true;

This SHOULD work, and place the whole shadow stack on the proper level. But bear in mind this is probably going to break the zorder trick :D

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #21 on: January 21, 2019, 07:05:16 AM »
Thanks for the elucidation. Squirrel's display stack is different from what I'm used to (from a prior life). When I have an opportunity, I'll see if I can convince it to work on an arbitrary surface.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #22 on: January 21, 2019, 10:28:16 PM »
A simple variation of the previous layout tuned to obtain an "ambilight" effect... now the black shadow is not present and the luminosity is boosted... The perfect evolution would be that parts of the image with black color would bleed white light, but if you want to obtain a "old CRT halo in night room" effect instead of a "modern TV backlighting ambient light" effect this is perfect :D

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Drop shadow layout, may be turned into something useful?
« Reply #23 on: January 26, 2019, 10:28:29 AM »
As always thanks Z.  By any chance you can do one for texts?  :)

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Drop shadow layout, may be turned into something useful?
« Reply #24 on: January 26, 2019, 11:00:01 AM »
Awesome stuff zpaolo11x! Can you add the latest updates into the class that Bgoulette wrote? :P
« Last Edit: January 26, 2019, 12:39:15 PM by calle81 »

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #25 on: January 26, 2019, 12:27:02 PM »
As always thanks Z.  By any chance you can do one for texts?  :)

Sure, I already have the code, just let me clean it up a bit

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #26 on: January 26, 2019, 04:11:24 PM »
Awesome stuff zpaolo11x! Can you add the latest updates into the class that Bgoulette wrote? :P

I'm attaching a new module that incorporates the ambilight plus flatcolor stuff. Warning: somehow, I ruined how the drop shadow works, because now it doesn't! Uggh! Gonna have to go back to zpaolo11x's original and see what I did wrong. Unless someone else can spot it more quickly than I. Been looking at it for too long! :(

Just include fe.load_module("shadow-glow") in your layouts (after placing the contents of the attached zip in your modules folder!), then call 'em like this:

Code: [Select]
// Drop shadow:
local ds = DropShadow( pic, radius, offset_x, offset_y, alpha ) // Broken for now. Grr! Also, alpha is insane...

// Flat color:
local fc = FlatColor( pic, radius, offset_x, offset_y, alpha )
fc.set_fc_rgb( r, g, b );

// Ambi-glow:
local ag = AmbiGlow( pic, radius, offset_x, offset_y, alpha ) // I renamed it AmbiGlow. Sorry!

The included layout-shadow-glow.zip had examples. There's no config, so to change what displays, open the layout.nut and change the "show" value to 1, 2, or 3.

You have no idea how much it's bugging me that DropShadow doesn't work anymore! Why?! It's the same code! Arglebarglesnarflarfglubbernugz...
« Last Edit: January 28, 2019, 06:27:48 AM by Bgoulette »

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #27 on: January 28, 2019, 06:26:58 AM »
I looked a little more closely at the actual shaders zpaolo11x used for his effects and discovered differences in how the alpha was applied with his background glow versus his drop shadow. I've made what I believe to be the requisite changes in the shader-glow module, and I think DropShadow should work like it used to. I'd check first, but I can't, because I'm at work on a machine without AM installed. I'll check when I get home, though!

Usage should be the same as above: the change(s) are minor and should be transparent to the user. Just update modules/shader-glow with the attached code (delete the old code first).

Edit: zip moved to this post.
« Last Edit: January 29, 2019, 03:14:16 AM by Bgoulette »

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1233
    • View Profile
    • My deviantart page
Re: Drop shadow layout, may be turned into something useful?
« Reply #28 on: January 28, 2019, 08:40:45 AM »
I looked a little more closely at the actual shaders zpaolo11x used for his effects and discovered differences in how the alpha was applied with his background glow versus his drop shadow.

Ops, sorry I forgot to rename the shader to stress the difference :D It's the way alpha channel is recalculated which is more fit for glow effects.

Bgoulette

  • Sr. Member
  • ****
  • Posts: 116
  • I wrote a book.
    • View Profile
    • BlakeGoulette.com
Re: Drop shadow layout, may be turned into something useful?
« Reply #29 on: January 28, 2019, 09:02:20 AM »
Ops, sorry I forgot to rename the shader to stress the difference :D It's the way alpha channel is recalculated which is more fit for glow effects.

Ha! Not your fault. I shouldn't have assumed! In the zip I posted above, I renamed the glsl files: gauss_kernsigma_ds.glsl for the drop shadow, and gauss_kernsigma_ag.glsl for the ambient glow (or flat color glow) effect.

I'm looking forward to testing them out tonight when I get home! Thanks for making your stuff available to the masses! It's my hope that my module-ized files will be of benefit to others as well.