Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Shadertoy and shader plot types #4025

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

SimonDanisch
Copy link
Member

adds:

shadertoy(rect2d, frag_shader)

To run shadertoy shaders like this:
image
image

TODOs:

  • map arbitrary uniforms to shader (using ShaderAbstractions)
  • allow geometry and vertex shader (using a new plot type)
  • clean up and docs

@SimonDanisch SimonDanisch changed the base branch from master to ff/render_tick July 13, 2024 14:00
Base automatically changed from ff/render_tick to master August 9, 2024 13:22
@MakieBot
Copy link
Collaborator

MakieBot commented Oct 21, 2024

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 6.37s (6.29, 6.45) 0.06+- 162.49ms (160.12, 167.03) 2.40+- 472.46ms (468.66, 479.51) 3.94+- 8.26ms (8.19, 8.35) 0.06+- 26.29ms (25.99, 26.62) 0.19+-
master 6.39s (6.30, 6.49) 0.06+- 168.35ms (160.56, 182.78) 7.44+- 480.73ms (467.00, 511.27) 14.71+- 8.21ms (8.11, 8.31) 0.07+- 26.22ms (25.80, 26.63) 0.27+-
evaluation 1.00x invariant, -0.01s (-0.19d, 0.72p, 0.06std) 1.04x invariant, -5.85ms (-1.06d, 0.09p, 4.92std) 1.02x invariant, -8.27ms (-0.77d, 0.19p, 9.32std) 0.99x invariant, 0.06ms (0.89d, 0.12p, 0.06std) 1.00x invariant, 0.07ms (0.28d, 0.61p, 0.23std)
CairoMakie 6.15s (6.07, 6.19) 0.06+- 168.12ms (162.97, 181.00) 6.49+- 205.73ms (196.45, 222.33) 9.47+- 8.07ms (7.88, 8.35) 0.18+- 1.21ms (1.20, 1.23) 0.01+-
master 6.11s (5.98, 6.31) 0.10+- 163.37ms (159.93, 168.28) 2.68+- 199.33ms (196.53, 201.57) 1.91+- 7.98ms (7.86, 8.12) 0.10+- 1.22ms (1.21, 1.24) 0.01+-
evaluation 0.99x invariant, 0.04s (0.55d, 0.33p, 0.08std) 0.97x invariant, 4.75ms (0.96d, 0.11p, 4.58std) 0.97x invariant, 6.41ms (0.94d, 0.13p, 5.69std) 0.99x invariant, 0.09ms (0.62d, 0.27p, 0.14std) 1.01x invariant, -0.01ms (-0.72d, 0.20p, 0.01std)
WGLMakie 6.74s (6.70, 6.77) 0.03+- 168.60ms (164.71, 176.39) 5.09+- 5.72s (5.66, 5.87) 0.08+- 13.17ms (12.42, 15.51) 1.06+- 134.36ms (127.13, 140.59) 5.27+-
master 6.78s (6.71, 6.90) 0.06+- 170.10ms (165.54, 176.37) 3.30+- 5.98s (5.95, 6.03) 0.03+- 12.69ms (12.42, 12.81) 0.14+- 134.09ms (129.01, 138.08) 3.27+-
evaluation 1.01x invariant, -0.04s (-0.82d, 0.16p, 0.05std) 1.01x invariant, -1.5ms (-0.35d, 0.53p, 4.19std) 1.04x faster ✓, -0.25s (-4.11d, 0.00p, 0.05std) 0.96x invariant, 0.48ms (0.64d, 0.28p, 0.60std) 1.00x invariant, 0.26ms (0.06d, 0.91p, 4.27std)

@lazarusA
Copy link
Contributor

any plans to merge this on the near future. @asinghvi17 and I are exploring spherical volumetric shaders, and according to him this would make things easier 😄 .
Waves

@SimonDanisch
Copy link
Member Author

I tried cleaning it up to merge it, but somehow run again into a very frustrating OpenGL bug, where the screen just stays blank without any error and I have no idea where to look for the problem...
I fixed that before, as can be seen by the screenshots, so I have no idea how it came back...Was frustrating enough to find it in the first place, and I dont really remember what it was in the end :( Something small and stupid like a uniform type mismatch or so...
Maybe it's platform dependent, I can try to see what my nvidia gpu says about this.

@ffreyer
Copy link
Collaborator

ffreyer commented Dec 15, 2024

Fixed the blank screen thing (caused by transparency = true which changes what the shader outputs are).

Btw, my thoughts with adding a "glplot" type were more manual than this. I wanted something that would allow you to set all shader types and have arbitrary vertex inputs and uniforms. Conceptually something like

glplot!(scene, 
    vertex_inputs...; # 1+ arrays mapping to buffers
    shader = [vertex_shader, fragment_shader], # 1+ vertex shader, 1+ fragment shader (0+ other types?)
    uniforms... # any number of uniforms as kwargs
)

that just does some boilerplate and integration stuff in the background. E.g. include "fragment_output" and handle outputs, conversions to gl types (maybe difficult for 1d textures?), mesh conversion paths, add and handle a few core attributes (visible, ssao, fxaa, transparency). (That doesn't mean I want this pr to change. Just wanted to say I had something else in mind)

@MakieBot
Copy link
Collaborator

Benchmark Results

SHA: e5dee7539263d94d494dd372689ec96946f4e0d8

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@@ -1087,7 +1087,7 @@ function draw_atomic(screen::Screen, scene::Scene, plot::Makie.ShaderToy)
view=templates)
end
get!(uniforms, :ssao, Observable(false))
get!(uniforms, :transparency, Observable(true))
get!(uniforms, :transparency, Observable(false))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

4 participants