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

WGLMakie cannot draw Mesh with Float64 normals. #3804

Open
3 tasks done
jacobleft opened this issue Apr 25, 2024 · 2 comments
Open
3 tasks done

WGLMakie cannot draw Mesh with Float64 normals. #3804

jacobleft opened this issue Apr 25, 2024 · 2 comments
Labels
bug good first issue WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@jacobleft
Copy link

jacobleft commented Apr 25, 2024

  • are you running newest version (version from docs) ?
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
(jl_MuWt8Y) pkg> st
Status `/private/var/folders/n0/367fnn5x0rg8p83b918ltdph0000gn/T/jl_MuWt8Y/Project.toml`
  [5c1252a2] GeometryBasics v0.4.10
  [ee78f7c6] Makie v0.20.9
  [276b4fcb] WGLMakie v0.9.9
  • What platform + GPU are you on?
In [7]: versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Construct the mesh of a cube using GeometryBasics.jl, explicitly computing the normals, and draw it with WGLMakie

using WGLMakie
import GeometryBasics

rect = Rect(Vec(0.0, 0.0, 0.0 ), Vec(1.0, 1.0, 1.0))
rect_faces = decompose(GeometryBasics.TriangleFace{Int}, rect)
rect_vertices = decompose(Point{3, Float64}, rect)
T = Float64 # Bug
## T = Float32 # OK
nls = GeometryBasics.normals(rect_vertices,rect_faces;normaltype=Vec{3,T})
rect_mesh = GeometryBasics.Mesh(GeometryBasics.meta(rect_vertices,normals=nls),rect_faces)

mesh(rect_mesh)

With T = Float64, the above example code gives the following errors:

┌ Warning: Error in Javascript: THREE.WebGLProgram: Shader Error No error - VALIDATE_STATUS false
│ 
│ Program Info Log:
│ Vertex shader is not compiled.
│ 
│ VERTEX
│ 
│ ERROR: 0:16: 'dvec3' : Illegal use of reserved word
│ ERROR: 0:16: 'dvec3' : syntax error
│ 
│ 
│   11: precision mediump usampler2D;
│   12: precision mediump usampler3D;
│   13: // Instance inputs: 
│   14: in vec3 position;
│   15: vec3 get_position(){return position;}
│ > 16: in dvec3 normals;
│   17: dvec3 get_normals(){return normals;}
│   18: 
│   19: // Uniforms: 
│   20: uniform uint object_id;
│   21: uint get_object_id(){return object_id;}
│   22: uniform vec3 specular;
│ 
│ Fragment log:
│ Vertex log:
│ ERROR: 0:16: 'dvec3' : Illegal use of reserved word
│ ERROR: 0:16: 'dvec3' : syntax error
│ 
│ )
└ @ Bonito ~/.julia/packages/Bonito/AipWx/src/serialization/protocol.jl:41
An exception was thrown in JS: Error: WebGL error: Invalid operation
Additional message: error initializing scene
Stack trace:
    Error: WebGL error: Invalid operation
        at eval (eval at <anonymous> (http://localhost:9385/assets/288836015a0b0c5d9685d3d72ba7c90f399308c9-Bonito.bundled.js:3563:27), <anonymous>:12:19)
┌ Warning: error while processing received msg
│   exception =
│    Three object should be ready after init, but isn't - connection interrupted? Session: Session{Bonito.SubConnection}:
│      id: 3b3ca2ec-d242-4da5-9ff0-ff51f5305dce
│      parent: Bonito.Session{Bonito.WebSocketConnection}
│      connection: open
│      isready: true
│      asset_server: Bonito.ChildAssetServer
│      queued messages: 0
│    , initialized: false
└ @ Bonito ~/.julia/packages/Bonito/AipWx/src/connection/websocket.jl:103

If T=Float32 or using GLMakie, the example code runs fine without errors.

@jacobleft jacobleft added the bug label Apr 25, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Apr 26, 2024

This should get fixed in 0.21 with lines like

mesh = GeometryBasics.pointmeta(mesh; normals=decompose(Vec3f, n))

Ref #3650

@t-bltg t-bltg added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Apr 27, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented May 24, 2024

This still errors so at least one conversion paths is not converting the normals. Should be fairly easy to fix by checking which ones get called and adding the decompose(Vec3f, n)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

No branches or pull requests

3 participants