Skip to content

Conversation

SimonDanisch
Copy link
Member

No description provided.


### Custom Attributes

Meshes support arbitrary custom attributes beyond the standard position, normal, and UV coordinates. You can attach per-vertex or per-face data like material properties, identifiers, or computed values. These are stored in `mesh.vertex_attributes` and accessed using the same interface.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like using material as a faceview example. That's not something that changes on such a low level imo. Like a loaf of bread is gonna be made out of bread no matter where you look at it, even if details like color, roughness, reflectivity etc change. Material details changing per face also seems odd to me.

Maybe we can just remove the association with materials here and directly have reflectivity etc as vertex/face attributes? Or use something else as an example, e.g. color?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The way I envisioned materials to be used is to mark sections of the mesh with views and have corresponding materials in a metamesh. E.g.:

using GeometryBasics
using Colors

struct Material
    color::RGB{Float32}
    diffuse::Float32
    specular::Float32
    shininess::Float32
end

head = GeometryBasics.mesh(Sphere(Point3f(0), 0.3))
needle = GeometryBasics.mesh(Cone(Point3f(0, 0, -0.2), Point3f(0, 0, -2.0), 0.1))

pin = MetaMesh(
    merge([head, needle]),
    materials = [
        Material(RGB(1, 0, 0), 0.8, 0.4, 4.0),
        Material(RGB(0.8, 0.8, 0.8), 0.4, 2.0, 64.0),
    ]
)

# contains two ranges, one for the faces from sphere, the other for faces from cone
pin.views
pin[:materials]

using GLMakie
f = Figure()
a = LScene(f[1, 1])
# This basically undoes the merge, could also pass pisitions, normals etc as usual and faces as `faces(pin)[pin.views[i]]`
submeshes = GeometryBasics.split_mesh(pin.mesh)
for (m, material) in zip(submeshes, pin[:materials])
    Makie.mesh!(
        a, m, color = material.color, diffuse = material.diffuse, 
        specular = material.specular, shininess = material.shininess
    )
end
f

Iirc obj/mtl loading has another step of indirection here, where views correspond to material names which are used to look up materials in a dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants