User avatar
Paeryn
Posts: 2632
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: 3603
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: 173
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: 3603
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: 3603
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: 51
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!

Return to “OpenGLES”