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

Updates for GeometryBasics refactor #4319

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Sep 4, 2024

Description

I.e. JuliaGeometry/GeometryBasics.jl#219

This is still in prototyping stage as I'm looking what things GeometryBasics is missing/should do.

TODO:

  • get Makie working
    • compiles
    • tests
  • get GLMakie working
  • get WGLMakie working
    • compiles
  • get CairoMakie working
    • compiles
    • tests pass
  • get RPRMakie working
    • compiles
    • tests pass

All RPRMakie examples run with JuliaGraphics/RadeonProRender.jl#22 except for:

  • datashader-rpr (the code is broken regardless of this pr)
  • material_x.jl (crashes julia)
  • sea_cables.jl (fails to download resources)

I'm not familiar enough with RPRMakie to say they look correct with confidence, but most look good to me. I'm not sure what to make of eat_topographie_sphere.jl (that's not a sphere?) and "volume.jl", they might be wrong.

Test failures:

  • FigureSpec step 5: This pr somehow generates a more transparent marker than the refimg, which is barely transparent. The code uses (:red, 0.5), so this seems more correct to me here. I'm just confused why it's different here at all
  • Scatter with FastPixel: red outline color looks more intense in 3D (maybe color change, maybe thickness change, maybe both
  • Triplot of a constained...: a line shifted from one diagonal to the other
  • shading of catmesh changed, seams visible
  • CairoMakie Merged color Mesh change but that's expected due to updates to vertex order
  • CairoMakie voxel clipping looks more odd because triangle faces have shifted orientation
  • CairoMakie voxels have a small shift in face intersections
  • GLMakie heatmap cells shifted a little
  • "FEM mesh 3D" is expected to fail due to vertex index merging not running on load anymore (i.e. the example no longer duplicates vertices unnecessarily and thus the color mapping changed)

Issues:

Type of change

  • Breaking change

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@ffreyer
Copy link
Collaborator Author

ffreyer commented Sep 14, 2024

The refactor now makes it easier to work with per-face attributes, so I added an example to the mesh docs:

using GeometryBasics

# Reduce quality of sphere
s = Tesselation(Sphere(Point3f(0), 1f0), 12)
ps = coordinates(s)
fs = faces(s)

# Use a FaceView to with a new set of faces which refer to one color per face.
# Each face must have the same length as the respective face in fs.
# (Using the same face type guarantees this)
FT = eltype(fs); N = length(fs)
cs = FaceView(rand(RGBf, N), [FT(i) for i in 1:N])

# generate normals per face (this creates a FaceView as well)
ns = face_normals(ps, fs)

# Create mesh
m = GeometryBasics.mesh(ps, fs, normal = ns, color = cs)

mesh(m)

image

(This still requires vertex duplication, it just happens automatically now.)

Related Issues: #1369, #3624, maybe #742

@ffreyer
Copy link
Collaborator Author

ffreyer commented Sep 15, 2024

a8a6120:

  • added support for setting mipmap via ShaderAbstractions.Sampler (together with a commit to ShaderAbstractions)
  • fixed N0f8 color types in WGLMakie
  • fixed minfilter getting overwritten when using a Sampler in GLMakie

Not really related to GeometryBasics but I didn't want to make another pr in ShaderAbstractions for a 2 line change.

@ffreyer ffreyer mentioned this pull request Sep 15, 2024
3 tasks
@ffreyer ffreyer added the breaking a PR with breaking changes label Sep 18, 2024
@MakieBot
Copy link
Collaborator

MakieBot commented Sep 18, 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 5.90s (5.69, 6.11) 0.13+- 433.50ms (410.08, 456.68) 14.29+- 403.71ms (389.72, 417.71) 9.18+- 8.69ms (8.34, 9.28) 0.35+- 26.35ms (26.00, 26.74) 0.26+-
master 6.43s (6.34, 6.62) 0.10+- 167.67ms (161.02, 184.01) 7.97+- 497.32ms (476.14, 527.62) 20.95+- 8.40ms (7.92, 9.03) 0.32+- 26.33ms (25.81, 26.80) 0.34+-
evaluation 1.09x faster✅, -0.53s (-4.70d, 0.00p, 0.11std) 0.39x slower❌, 265.82ms (22.98d, 0.00p, 11.13std) 1.23x faster✅, -93.61ms (-5.79d, 0.00p, 15.07std) 0.97x invariant, 0.28ms (0.84d, 0.14p, 0.34std) 1.00x invariant, 0.01ms (0.05d, 0.93p, 0.30std)
CairoMakie 5.59s (5.53, 5.69) 0.05+- 167.78ms (164.81, 171.30) 2.07+- 197.30ms (193.96, 204.27) 3.80+- 7.90ms (7.79, 8.29) 0.17+- 1.17ms (1.16, 1.18) 0.01+-
master 6.11s (6.03, 6.17) 0.05+- 163.27ms (160.61, 165.56) 1.92+- 199.62ms (196.43, 204.35) 3.05+- 7.94ms (7.79, 8.38) 0.20+- 1.21ms (1.20, 1.22) 0.01+-
evaluation 1.09x faster✅, -0.52s (-9.97d, 0.00p, 0.05std) 0.97x slower X, 4.5ms (2.26d, 0.00p, 1.99std) 1.01x invariant, -2.33ms (-0.68d, 0.23p, 3.42std) 1.01x invariant, -0.04ms (-0.22d, 0.68p, 0.19std) 1.03x faster ✓, -0.04ms (-5.15d, 0.00p, 0.01std)
WGLMakie 5.90s (5.82, 6.00) 0.06+- 175.93ms (167.13, 187.71) 8.75+- 6.06s (5.94, 6.20) 0.08+- 12.86ms (12.00, 14.94) 0.97+- 119.40ms (113.74, 123.18) 3.31+-
master 6.59s (6.47, 6.75) 0.10+- 174.35ms (159.44, 187.73) 12.37+- 6.27s (6.04, 6.42) 0.12+- 12.40ms (11.93, 12.95) 0.33+- 119.32ms (114.28, 123.16) 3.35+-
evaluation 1.12x faster✅, -0.69s (-8.10d, 0.00p, 0.08std) 0.99x invariant, 1.57ms (0.15d, 0.79p, 10.56std) 1.03x faster ✓, -0.2s (-2.05d, 0.00p, 0.10std) 0.96x invariant, 0.46ms (0.63d, 0.27p, 0.65std) 1.00x invariant, 0.08ms (0.02d, 0.96p, 3.33std)

@ffreyer ffreyer closed this Sep 19, 2024
@ffreyer ffreyer reopened this Sep 19, 2024

# For correct z-ordering we need to be in view/camera or screen space
model = copy(primitive.model[])
model = copy(primitive.model[])::Mat4d
Copy link
Member

Choose a reason for hiding this comment

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

It seems weird to copy an immutable? Not part of this PR, but still we may want to remove it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this may come from my first attempt to get 3D meshes working in CairoMakie where I didn't know what kind of types to expect. I guess technically you could do plot(..., model = rand(4, 4) and pass a Base.Matrix, but iirc this errored when copy(::Mat4d) was generating a Base.Matrix anyway...

@ffreyer ffreyer mentioned this pull request Sep 22, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking a PR with breaking changes
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

Some triangles are not rendered Order of decomposes coordinates is not counter/clockwise
4 participants