Light on shaders

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
Toying around with shaders and Mojo2 graphics to see if I can learn something and I found something interesting and would like to ask about some details. I basically changed the shader example a bit and then mojo2 graphics, to look if I could understand anything.

I'basically come up with the shortest "flush" code that could restore the graphics for a managed image.

You only need to see one line for this, it's line 2935

_active = Self

What does that do? When executed, shaders can read managed images without any problem of updating them with flush.
If you also add line 2936 then graphics is updated everywhere as a normal flush (not only readable for shaders).

If this is interesting then I might post more content if I find useful solutions.



Screenshot 2021-01-03 at 12.40.30.png
 

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
First I was not even gonna try to explain the test as it's not finished, it's a mess so sorry about that.
Im basically connecting shaders & managed images while generating graphics continously invisibly of course as it does not flush.

You update using a "new managed flush" using a mouseclick and the up and down cursors change what kind of circular connection the shaders has.

That main thing here to take away is, I try and I think I succeeded, to read managed image without flushing them. Using shader.I also turn it upside down just to see that i can do it, but what i didn't expect was that it would flip horisontal too. I don't know why but that's not the focus here.

:active is a global variable of type canvas, I came that far.
 

Attachments

  • example.zip
    104 KB · Views: 2

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
I'm also positive now that managed images are performing well already in a way.

Just look it like this. The standard flush becomes expansive, so avoid it whenever you can. BUT it's still all there, under the surface, everything you draw IS updated quickly and it's really nice. So what you could do is,
draw twice. becuase drawing is cheap. Once to the canvas, and once to the managed image. Both are quick.

And when disaster hits, you have your graphics safe in the managed one. You can flush once a second no problem, and you can draw everything you can fill in the next coming second on top of that. Then you do the same over and over.

But still, I wanted to see if there's a way to get extreme performance, it would be nice, it could make Android games stand out on the marketplace a bit extra. So, in this thread I'm toying around with that idea.
 

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
Why this is good is, you get overal high performance and you get creative freedom of graphics as you can mix both

retained And immediate graphics

in the same display without any cost.
 

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
I run into a problem, is it possible to apply shader to the window canvas? As I understand it and the window canvas is tied to nul,l so there's no image to bind a shader to or am I missing something?

Also, is it possible to have a shader to read from TWO images/textures as input instead of just one?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,780
Edit: There is no way to apply a shader to the window framebuffer. What you have to do is to render everything to image canvas, apply a shader to it and then render that to the main canvas.

This page shows it well, using OpenGL directly. But the same methology can be used with an image canvas and an applied shader.
 

Jimmy

Active Member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
568
Okay I'm doing that and it works perfectly but I just wanted to make sure I understood everything, thanks for clearifying
 
Top Bottom