Adding blur effect to guilib
#1
I've seen some discussion in various threads about the possibility of having a blur effect in guilib.

Seeing as I could do with something to tinker with I thought I'd have a bash at adding it in. Smile

But before I get stuck in I wanted to open a discussion and get some input, from those who know the code much better than I do, about possible ways to implement it and where exactly it could go.

To get started, these are some of the questions I've been asking myself about how it could work...

Should it just be applicable to an image/texture, or to a "control" as a whole?
Could it potentially be hooked up to an animation?
Could it be as "simple" as having some properties on a texture which control how much blur is applied?
Could the result be a framework that can be used to apply other effects (whatever they might be) as well as just blur?
Where in the rendering pipeline should it be applied?

I'll likely start with the windows code, as that's the dev environment I have setup and I'm also more familiar with Direct3D than I am OpenGL, although I am as rusty as a rusty thing on a rusty day in rusty town!
Reply
#2
Can't say on which components it has to be applied, but ideally it's implemented as some sort of effects framework that'll allow other effects (sepia, greyscale, ...) aswell. And I think these effects should be done via shaders in order to outsource the computation to the GPU which will be of great benefit on low power devices IMO.
Also it should probably be possible to use these effects in animations in a way that you define the timespan and amount to blur (so something like "blur everything below current dialog window from 0 to 30% strength over 2 seconds". Animation support can also be done in a second step though, so getting the basics in place would already be awesome enough IMO.
Reply
#3
Yes, implementing effects though GL ES shaders is essential for arm platforms.
No way that arm cpu based effects would have acceptable performance, but the GPUs have a lot of processing power.

Definite +1 on the idea though.
Reply
#4
most use for this will be blur-behind-the-dialog. that means neither controls, gui-textures nor animations suffice. it will operate on the (partially finished) rendered output. i don't really know the render code but i believe layering is done through multi-pass rendering (i.e. render in z order). which means you'd have to run the shader at the end of the appropriate render pass.
Reply
#5
(2015-03-06, 13:27)Carcharius Wrote: I'll likely start with the windows code, as that's the dev environment I have setup and I'm also more familiar with Direct3D than I am OpenGL
(2015-03-06, 14:27)popcornmix Wrote: Yes, implementing effects though GL ES shaders is essential for arm platforms.
An alternative and possible better method could be to write all your shaders for Kodi in GLSL now from the start and then integrate a conversion engine such as libANGLE from Google's ANGLE inside Kodi to convert GLSL shaders into HLSL shader objects on-the-fly at runtime on Windows only, since it is the only platform for Kodi not supporting GLSL. That way you do not need to write any specific HLSL shaders for Windows at all.

https://github.com/google/angle
https://chromium.googlesource.com/angle/angle
https://code.google.com/p/angleproject/
http://www.seas.upenn.edu/~pcozzi/OpenGL...-ANGLE.pdf

HLSLParser could possibly do something similar for converting HLSL shader code to GLSL, or just be used initially if you prefer to write HLSL shaders to begin with.

https://github.com/unknownworlds/hlslparser
https://github.com/Thekla/hlslparser


If you otherwise choose to go the other route then one thing probably worth keeping in mind is that Kodi for Windows currently uses DirectX 9 / Direct3D 9 but I read that there is ongoing work to upgrade it to DirectX 11 / Direct3D 11. However while DirectX 11 introduce D3D11 HLSL Shader Model 5 it could still be worth writing shaders for the older D3D9 HLSL Shader Model 3 because they should be more portable if you later want to convert them to GLSL shaders for OpenGL and OpenGL ES 2.0 compatible GPUs.

http://forum.kodi.tv/showthread.php?tid=218274

Writing shaders for the older D3D9 HLSL Shader Model 3 it might be possible to write shaders that will be less work to port from D3D9 HLSL shaders into GLSL/ESSL shaders for OpenGL/OpenGLES. At least there are more convention tools and port documentation out there for converting D3D9 HLSL shaders to GLSL/ESSL and vice verse than there are tools for converting newer D311 HLSL shaders, with perhaps most popular tools being HLSLParser and a fork of ATI's HLSL2GLSL, or at least they used to be.

https://code.google.com/p/hlsl2glslfork/
http://the-witness.net/news/2014/08/hlslparser/


Edit: Thinking a little bit outside the box, if implemented into Kodi's libgui as per the ideas here, could a such effects framework also be used by python script WindowXML GUI addons? Maybe even by python screensavers and visualizations for Kodi which would open that development area up for python script developers?
Reply
#6
Anything new on this? I think many skins would benefit greatly from getting a blur effect. It's my number one anticipated function as of now.. Sorry for the shameless bump. Sad
Reply
#7
Been trying a few bits and pieces, haven't really gotten anywhere yet though, just been playing around seeing what should go where. I had been working from a Windows build purely because that's the dev environment I have set up already. But with the work going on to move to DX11, which impacts the area I was working in (i.e. rendering) I've decided to leave Windows alone for now and see if I can get something together under Linux or (most likely) Android in the first instance.

But at the moment I haven't got a Linux or Android build system in place, I need to get on that! I also don't know GL or GLES shader stuff so I've got to do some reading there as well.

It's not fully fleshed out but my current thinking is to allow a skin to specify, for a control, one or more RenderEffect (working name) elements. One of those effects would be blur but hopefully it'll be possible to have others - maybe a sepia, or black and white effect for example. Possibly there could also be a custom type where a skinner could specify a custom shader name to use. But first I'm working on blur.

Later on it might be possible to combine the RenderEffects with existing animations but I don't know about that yet.

If any of the Kodi team who know the ins and outs of the rendering system have any thoughts please chime in.
Reply
#8
Great to hear that someone is working on this! Take your time man, just good to hear that it's being looked at.. Hopefully someone aids you in your quest for the Kodi blur shader.
Reply
#9
Just in case this acts as an incentive, we occasionally invite non-team members to devcon each year. Adding blur and other shaders would be so wildly useful to Kodi across a number of different areas that an invite might be warranted, just so we can buy you a beer. No promises or anything, but boy would this be nice.
Reply
#10
Anything new on this? I think that Kodi and it's skins would benefit greatly from adding a blur effect.
Reply
#11
I would love to write some shaders. There are a lot of possibilities achievable with simple math, and a sufficient blur mode is one of it. I would even port them to HLSL/GLSL ES.

Unfortunately, I don't have the knowledge to dive into this kind of project. I would need a lot of preporations (for example the source/target texture) to do this. An add-on based system would be phenominal.
Reply

Logout Mark Read Team Forum Stats Members Help
Adding blur effect to guilib0