User avatar
paddyg
Posts: 2612
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Fri Jan 15, 2021 10:30 pm

Yes, of course. Well spotted. If you look in PictureFrame2020 you will see that the alpha value of the text_bkg Shape is set to a value varying from 0 to 0.6 then back to 0. That alpha setting changes a uniform variable unif[17] that is passed to the shader (where it is interpreted as a 2D array unif[5][2] and multiplied by the alpha value looked up from our Texture.

I apologise for the rather cryptic formula for changing the text and background alpha and the way that the shaders are built from a series of #include files that makes them rather hard to unpick.

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
jgodfrey
Posts: 12
Joined: Wed Jan 13, 2021 10:21 pm
Location: MO, USA

Re: Image viewer with transition between images

Fri Jan 15, 2021 11:04 pm

Ah, yes, I see that the alpha value is artificially capped as you pointed out. So, I think that changing this:

Code: Select all

text_bkg.set_alpha(alpha * 0.6)
to this:

Code: Select all

text_bkg.set_alpha(alpha)
should allow me to get a more "as expected" scrim transparency (which seems to be the case). With the above change, I can put the scrim's max alpha value back at 50% instead of 100%. So, from this:

Code: Select all

text_bkg_array[:,:,3] = np.linspace(0, 255, bkg_ht).reshape(-1, 1)
to this:

Code: Select all

text_bkg_array[:,:,3] = np.linspace(0, 127, bkg_ht).reshape(-1, 1)
... which seems to approximate the result I get when I do this manually in something like Photoshop.

User avatar
jgodfrey
Posts: 12
Joined: Wed Jan 13, 2021 10:21 pm
Location: MO, USA

Re: Image viewer with transition between images

Sun Jan 17, 2021 11:26 pm

I've made some additions to PictureFrame2020.py optionally display Portrait images in pairs (side-by-side). @paddyg, you may have missed my previous ask (in an earlier message), but do you (potentially) accept pull-requests to the PictureFrame2020.py script? If so, I may have a few things available for review sometime soon - including this Portrait feature, a few bug fixes, and some general clean up.

Thanks.

User avatar
paddyg
Posts: 2612
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Image viewer with transition between images

Sun Jan 17, 2021 11:40 pm

*Definitely* accept any form of contribution! Sometimes the modifications are a bit specific so I might not include them in entirety. Also the develop branch might have evolved with other changes so the pull might relate to a version from which the code has now diverged - in which case I manually integrate the changes...

However if you look at the issues and discussion https://github.com/pi3d/pi3d_demos/disc ... ent-268838 you will see that (partly because of all the excellent contributions over the years) the picture frame code is in serious need of refactoring, probably along the lines of github.com/helgeerbe which I hope to do over the next few weeks. But by all means send in pull requests!

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
jgodfrey
Posts: 12
Joined: Wed Jan 13, 2021 10:21 pm
Location: MO, USA

Re: Image viewer with transition between images

Mon Jan 18, 2021 12:39 am

*Definitely* accept any form of contribution!
Good to know - thanks! And I fully agree that a major refactor is in order. In fact, I almost started doing that myself, but didn't want to veer too far from the original project for fear that I'd always have to play catch-up with interesting changes.

I'll submit one or more PRs soon and see where it goes.

Thanks again for all your work on the project.

Return to “General discussion”