User avatar
Paeryn
Posts: 2704
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sat Aug 10, 2019 3:14 pm

Gavinmc42 wrote:
Sat Aug 10, 2019 12:37 am
What gave you the impression that the VC4 didn't have shaders?
In Tim's Readme it says only works on Pi4's.
It looks like mesa is smart enough to figure that out and use the VC4 driver.
Dug out the VC4 manual, not much on shaders, need the VC6 manual, not that it will make much sense.

Think I need to look at the output of the shader compilers.
So far reading all the OpenGL books is leading me to conclude shaders are even more complex than just the 3D stuff.
It's likely that many of the shaders require features not available in the OpenGLES2 shaders. The VC4 manual tells you all about the QPUs (which are the processors that the shaders run on) and the texture units etc. albeit without telling you about any bugs in the implementations. It won't tell you how GLSL compiles into QPU code and register setups, for that read the Mesa source, though it compiles GLSL into an intermediary format or two (GLSL->hir->nir I think) before finally generating QPU code and register settings. It would be interesting to see the differences between VC4 and VC6 QPU code for the same shader, I assume VC6 has more instructions, I know it has more registers).
Gavinmc42 wrote:
Sat Aug 10, 2019 12:37 am
Been putting off learning 3D on Pi's, it has been playing with OpenGL on the Pi4 that all the pieces fell into place.
I wondered why there was nothing between triangles and cubes and full objects in OpenGLES.
There is no library like FreeGLUT for OpenGLES.

Then Tim comes along and throws shaders into the mix.
Another new world of learning.
In OpenGL polygons with four or more vertices have to be decomposed into triangles first (on the old 3dfx even lines were triangles, a line was drawn by drawing a triangle with two identical vertices), OpenGLES made the move to remove all higher order polygons from the start since it reduces complexity of the drivers and makes it the programmer's responsibility to convert higher order polygons into triangles. Those higher order polygons were then also removed from OpenGL as of version 3.1.

OpenGL3.1 was also the point where the fixed-function vertex and fragment sections were finally removed (they were deprecated in 3.0).

Shaders aren't all the complicated if you don't need them to be. Vertex shaders are just programs that transform vertices from object space to view space and fragment shaders are programs that generate the colour to use for each pixel of a triangle drawn.

It's impressive when you see everything drawn by shaders alone (the entire screen is just drawn as two triangles covering the window), just think how slow it would be if the CPU was drawing the scene pixel by pixel.
She who travels light — forgot something.

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sun Aug 11, 2019 12:52 am

In OpenGL polygons with four or more vertices have to be decomposed into triangles first
Yep that was in one of Eric's Anholt's first posts, breaking up quads into triangles.
It might be an OpenGL driver but it is running on OpenGLES 3.2 hardware.

GeeXLab has some more shader stuff and some debug utils.
I see great stuff happening on the screen but CPU usage is sitting on maybe 5%
Need some way to check GPU usage, the Geexlabs stuff has some on screen info.

I suppose the guys working on the mesa code will get around to making use of that GLES 3.2 hardware one day.
I'm particularly interested in using it for bare metal so I don't need to wait
But there is so much to learn about these shaders.

The Demoscene guys are the closest but not many use Pi's or hang out here?
It will be interesting to see what the Demoscene guys can do with the P4.
Especially in 4K, now with a decent and standard piece of hardware.
Dual screen Demoscene?

There is a standalone mesa compiler and it can dump the compiled code.
Check for VC4 and VC6 variations.
I also want to try this on Wayland instead of X11, but that 's more learning as well.
Eventually baremetal without any window managers, which I cannot do yet on a Pi4.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

pik33
Posts: 182
Joined: Thu Sep 10, 2015 4:26 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sun Aug 11, 2019 7:00 am

You cannot do bare metal in Pi4, but you still can do things without a window manager using Raspbian.

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sun Aug 11, 2019 9:07 am

You cannot do bare metal in Pi4
I can't because I don't have the skills, the time and enough info.
That won't always be the case ;)
but you still can do things without a window manager using Raspbian
I want to try Wayland first and then without a windows manager.
An accelerated non Linux windowing scripted GUI is my goal, preferably before the Pi5 comes out.

Depending on how hard to reverse engineer the boot EEPROM, lots of preset up could be done in that.
It is 512KB, that's a bunch of room. could a GLSL compiler fit in that?

So many possibilities and so much unknown.
The Pi4 will be very successful and end up it lots of hands, some might be able to figure it out.

Tim has shown us what can be done now, it still seems like magic to me.
I need another Pi4, this one has become my desktop developers box.
Perhaps try the OpenGLES 2.0 shaders on a Zero first.
Rewrite the GLSL compiler in Pascal :D
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Fri Aug 16, 2019 7:09 am

Worth double posting :D

Wireframe 20 had a bit on Livecoding
A mention of Kodelife - it just works :D
https://hexler.net/products/kodelife#_
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

OutsourcedGuru
Posts: 59
Joined: Mon Jun 19, 2017 11:15 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Fri Aug 16, 2019 5:49 pm

Tried this locally on Raspbian Buster Desktop 4.9 with Raspberry Pi 4B (4GB) and it works great (noting that I adjusted the `gpu_mem` to 128 as suggested). It brings up another window to display the graphical output. This is using a SunFounder 10.1" TFT display for what it's worth and it's attached to the first micro-HDMI connector.

Tried this locally again on Raspbian Buster Lite 4.9 on the same rig and although it logs each of the `INFO: Shader compiled successfully!` messages it does not otherwise create any output to the screen. I attempted to Ctl-Alt-F2, etc but this did not change to another session which had the output (if there were any). It seemed to ignore an attempt to Ctl-C out of it so it was necessary to `sudo pkill ShaderToy` via ssh.

pjbesl444
Posts: 4
Joined: Sat Aug 17, 2019 12:08 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sat Aug 17, 2019 12:52 am

Thank you for this demo example. Really excellent!

Pyeater
Posts: 7
Joined: Sun Apr 28, 2019 7:35 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Tue Sep 17, 2019 3:00 pm

Thanks all for the input.

I'm yet to purchase a Pi4 (own a Pi3) but would love to see what this looks like.

Is there any chance of somebody linking to a video of how any of these look? Preferably one that pushes the boundaries a little :)

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Wed Sep 18, 2019 12:09 am

Get a Pi4 and see for yourself. ;)
WebGL examples in a Browser pushes Pi4.
https://webglsamples.org/

There was a rolling hills demo with flocks of birds that impressed me.
But this is mostly unexplored terriitory for me.
Lots of videos out there but most can push normal PC boundaries.
Any demo that can run on a Pi4 will probably run on a PC.

If you only have a 3B put Gentoo64 on it, grab the mesa-demos and start coding.
I have found a few shader apps now that just work, in more than one language too.

The Gentoo64 browsers can also run those WebGL samples.
Even Raspbian Buster is better now but I think shaders are done by Chromium on the Pi3 Arm's not GPU?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Pyeater
Posts: 7
Joined: Sun Apr 28, 2019 7:35 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Wed Sep 18, 2019 11:16 am

tipam wrote:
Sat Jul 27, 2019 5:59 pm
Hi,

I've just written a small app that will render over 100+ OpenGL ES 3.0 shaders (pinched from ShaderToy.com) to give an idea of what can be done with the RPi 4 GPU.

Link: http://www.skillmanmedia.com/ShaderToyRPi4.zip

You will need to install the SDL2 libraries from a terminal window and reserve 128MB GPU mem ...

Code: Select all

sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-image-dev
sudo apt-get install libsdl2-ttf-dev
sudo apt-get install libsdl2-mixer-dev
You should be able to dbl-click the ShaderToy executable after unzipping the folder to try it out.
(You will need to set permissions first by selecting ShaderToy, right-click 'File Properties->Permissions->Execute' to 'Anyone')

Use the SPACEBAR to jump to the next shader and ESCAPE to exit.
There are some shaders that allow you to use the mouse (navigation/rotate etc..)

The 'options.txt' file allows you to change a few obvious settings.

Note - this will ONLY work on the Raspberry Pi 4!

Please let me know if you have any problems.

Have fun! :D

Wonderful stuff :)

What did you use to render the shaders? If you don't mind me asking ...

Pyeater
Posts: 7
Joined: Sun Apr 28, 2019 7:35 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Wed Sep 18, 2019 1:33 pm

Pyeater wrote:
Wed Sep 18, 2019 11:16 am
tipam wrote:
Sat Jul 27, 2019 5:59 pm
Hi,

I've just written a small app that will render over 100+ OpenGL ES 3.0 shaders (pinched from ShaderToy.com) to give an idea of what can be done with the RPi 4 GPU.

Link: http://www.skillmanmedia.com/ShaderToyRPi4.zip

You will need to install the SDL2 libraries from a terminal window and reserve 128MB GPU mem ...

Code: Select all

sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-image-dev
sudo apt-get install libsdl2-ttf-dev
sudo apt-get install libsdl2-mixer-dev
You should be able to dbl-click the ShaderToy executable after unzipping the folder to try it out.
(You will need to set permissions first by selecting ShaderToy, right-click 'File Properties->Permissions->Execute' to 'Anyone')

Use the SPACEBAR to jump to the next shader and ESCAPE to exit.
There are some shaders that allow you to use the mouse (navigation/rotate etc..)

The 'options.txt' file allows you to change a few obvious settings.

Note - this will ONLY work on the Raspberry Pi 4!

Please let me know if you have any problems.

Have fun! :D

Wonderful stuff :)

What did you use to render the shaders? If you don't mind me asking ...

Gosh, this is on a very old spec of Pi and they run really well!

Hopeful :D

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Thu Sep 19, 2019 5:53 am

Gosh, this is on a very old spec of Pi and they run really well!
Huh? Pi4 is the newest Pi.
The older Pi's only do OpenGLES 2.0, lower capability shaders.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Pyeater
Posts: 7
Joined: Sun Apr 28, 2019 7:35 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Thu Sep 19, 2019 9:19 am

Gavinmc42 wrote:
Thu Sep 19, 2019 5:53 am
Gosh, this is on a very old spec of Pi and they run really well!
Huh? Pi4 is the newest Pi.
The older Pi's only do OpenGLES 2.0, lower capability shaders.

Oh, I meant to include this link https://www.raspberrypi.org/forums/view ... hp?t=10246
Last edited by Pyeater on Thu Sep 19, 2019 12:15 pm, edited 1 time in total.

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Thu Sep 19, 2019 12:11 pm

Oh that old one :D
That's before my time?
So going to try that on the VC4 Pi's, thanks for the link.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
ksharindam
Posts: 139
Joined: Sat Jan 09, 2016 4:16 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Fri Sep 20, 2019 2:52 pm

tipam wrote:
Sat Jul 27, 2019 5:59 pm

Code: Select all

sudo apt-get install libsdl2-dev
sudo apt-get install libsdl2-image-dev
sudo apt-get install libsdl2-ttf-dev
sudo apt-get install libsdl2-mixer-dev
You should be able to dbl-click the ShaderToy executable after unzipping the folder to try it out.
You have done really very good job.

Here you are providing the precompiled binaries.So we need to install the libraries instead of the development files.

Code: Select all

sudo apt install libsdl2-2.0-0 
sudo apt install libsdl2-image-2.0-0
sudo apt install libsdl2-ttf-2.0-0
sudo apt install libsdl2-mixer-2.0-0

User avatar
patriciogv
Posts: 2
Joined: Tue Oct 08, 2019 9:18 pm
Contact: Website Twitter

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Tue Oct 08, 2019 10:14 pm

Hi I have been working on an app that allows you to edit 2D and 3D shaders on realtime call glslViewer ( https://github.com/patriciogonzalezvivo/glslViewer ) and it runs in all RaspberryPi. Here is running a GLTF 3D model running the default PBR shader at 47fps in a RaspberryPi Zero : )

https://twitter.com/patriciogv/status/1 ... 42976?s=20

Pyeater
Posts: 7
Joined: Sun Apr 28, 2019 7:35 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Wed Oct 09, 2019 8:57 am

patriciogv wrote:
Tue Oct 08, 2019 10:14 pm
Hi I have been working on an app that allows you to edit 2D and 3D shaders on realtime call glslViewer ( https://github.com/patriciogonzalezvivo/glslViewer ) and it runs in all RaspberryPi. Here is running a GLTF 3D model running the default PBR shader at 47fps in a RaspberryPi Zero : )

https://twitter.com/patriciogv/status/1 ... 42976?s=20

Interesting, thanks :)

What OS are you using for the Zero?



User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Wed Oct 09, 2019 11:30 am

Might need some help file reading, but I got this to compile on Gentoo64 and a Pi4 :D
Not sure if it is working properly, seemed to have compiled as GLFW?

Bookmarked your Book of Shaders too, bedtime reading.
47fps on a Pi Zero :o
Attachments
dragonobj.png
dragonobj.png (177.89 KiB) Viewed 1609 times
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Thu Oct 10, 2019 7:39 am

@tipam

Hello,
is the site http://www.skillmanmedia.com/ShaderToyRPi4.zip still online ?
I'm having problem accessing it.


User avatar
DougieLawson
Posts: 36321
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Thu Oct 17, 2019 7:57 pm

UglyMike wrote:
Thu Oct 17, 2019 7:52 pm
www.skillmanmedia.com still down apparently...
Looks like it's been dead for three years or more: https://web.archive.org/web/20160415195 ... media.com/
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Fri Oct 18, 2019 4:43 am

??? Can't understand... the opening post is dated july 2019...???


DougieLawson wrote:
Thu Oct 17, 2019 7:57 pm
UglyMike wrote:
Thu Oct 17, 2019 7:52 pm
www.skillmanmedia.com still down apparently...
Looks like it's been dead for three years or more: https://web.archive.org/web/20160415195 ... media.com/

User avatar
Gavinmc42
Posts: 3916
Joined: Wed Aug 28, 2013 3:31 am

Re: RPi 4 OpenGL ES 3.0 ShaderToy to download (100+ examples)

Sun Oct 20, 2019 11:22 am

The online Book of Shaders editor works quite well with the brownian example.
I am impressed that it is doing this via a Pi4 browser.
I tried it with Firefox and Chromium, with Chromium having the edge in smoothness.
But running both browsers with that animated smoke/cloud example, hardly any resources were used and not much heat generated, 47C.
So the VC6 is probably not working that hard.

Running the example in GLSLViewer at full screen slows things down to 3fps.
A bit less than full screen and Chromium looks a bit smoother than GLSLViewer.
Perhaps Chromium;s GLSL code is more optimised?

Running GLSL code like this at 4K at 30/60fps is going to be interesting to learn.
How far can Pi's be pushed?
Attachments
bookshaders.png
bookshaders.png (153.98 KiB) Viewed 1194 times
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “OpenGLES”