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

[BUG] Colors not showing in Isaacsim #480

Closed
JonathanKuelz opened this issue Jan 31, 2025 · 1 comment
Closed

[BUG] Colors not showing in Isaacsim #480

JonathanKuelz opened this issue Jan 31, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@JonathanKuelz
Copy link

JonathanKuelz commented Jan 31, 2025

Bug Description

Rigid bodies made from meshes all appear grey when written to USD in warp and loaded in Isaacsim.

Reason: USD seems to expect one color per vertex, warp gives one color per mesh.

Solution: Changing this line to

mesh.GetDisplayColorAttr().Set(colors * (len(indices) // 3), self.time)

fixes the issue for me. Probably, similar adaptions for primitives with multiple vertices would also be necessary.

Screenshots show before and after in Isaacsim.

Image

Image

Edit: The hotfix is problematic bc. for large meshes, creating a list with duplicated colors like that will cause high memory consumption.

@JonathanKuelz JonathanKuelz added the bug Something isn't working label Jan 31, 2025
@christophercrouzet
Copy link
Member

Hi @JonathanKuelz,

Commit 15d1842 should address this issue and stores the colour using a constant interpolation to avoid taking up more memory than necessary.

Here's a repro I've used that should be similar to your use case and that showcases using both constant and per-vertex colours:

import numpy as np
import pyglet
import warp as wp
import warp.render


BOX_POINTS = np.array(
    (
        ( 0.853553, -0.146446,  0.0     ), ( 0.146446, -0.853553,  0.0     ),
        ( 0.353553,  0.353553,  0.707106), (-0.353553, -0.353553,  0.707106),
        (-0.353553, -0.353553, -0.707106), ( 0.353553,  0.353553, -0.707106),
        (-0.853553,  0.146446,  0.0     ), (-0.146446,  0.853553,  0.0     ),
    ),
    dtype=np.float32,
)

BOX_FACE_VERTEX_INDICES = np.array(
    (
        0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 6, 2, 7, 6, 3, 2,
        5, 1, 4, 5, 0, 1, 5, 2, 0, 5, 7, 2, 1, 6, 4, 1, 3, 6,
    ),
    dtype=np.int32,
)

SPHERE_POINTS = (
    ( 0.0     ,  0.0     , -0.5     ), ( 0.0     ,  0.28656 , -0.425325),
    ( 0.249999,  0.081230, -0.425325), ( 0.0     ,  0.447213, -0.223606),
    ( 0.249999,  0.344095, -0.262865), ( 0.425325,  0.138196, -0.223606),
    ( 0.154508, -0.212662, -0.425325), ( 0.404508, -0.131432, -0.262865),
    ( 0.262865, -0.361803, -0.223606), (-0.154508, -0.212662, -0.425325),
    ( 0.0     , -0.425325, -0.262865), (-0.262865, -0.361803, -0.223606),
    (-0.249999,  0.081230, -0.425325), (-0.404508, -0.131432, -0.262865),
    (-0.425325,  0.138196, -0.223606), (-0.249999,  0.344095, -0.262865),
    (-0.154508,  0.475528,  0.0     ), (-0.404508,  0.293892,  0.0     ),
    (-0.262865,  0.361803,  0.223606), (-0.5     ,  0.0     ,  0.0     ),
    (-0.404508, -0.293892,  0.0     ), (-0.425325, -0.138196,  0.223606),
    (-0.154508, -0.475528,  0.0     ), ( 0.154508, -0.475528,  0.0     ),
    ( 0.0     , -0.447213,  0.223606), ( 0.404508, -0.293892,  0.0     ),
    ( 0.5     ,  0.0     ,  0.0     ), ( 0.425325, -0.138196,  0.223606),
    ( 0.404508,  0.293892,  0.0     ), ( 0.154508,  0.475528,  0.0     ),
    ( 0.262865,  0.361803,  0.223606), ( 0.0     ,  0.425325,  0.262865),
    (-0.404508,  0.131432,  0.262865), (-0.249999, -0.344095,  0.262865),
    ( 0.249999, -0.344095,  0.262865), ( 0.404508,  0.131432,  0.262865),
    ( 0.0     ,  0.0     ,  0.5     ), ( 0.154508,  0.212662,  0.425325),
    (-0.154508,  0.212662,  0.425325), ( 0.249999, -0.081230,  0.425325),
    ( 0.0     , -0.262865,  0.425325), (-0.249999, -0.081230,  0.425325),
)

SPHERE_FACE_VERTEX_INDICES = (
     2,  0,  1,  4,  1,  3,  5,  2,  4,  2,  1,  4,  6,  0,  2,  7,
     2,  5,  8,  6,  7,  6,  2,  7,  9,  0,  6, 10,  6,  8, 11,  9,
    10,  9,  6, 10, 12,  0,  9, 13,  9, 11, 14, 12, 13, 12,  9, 13,
     1,  0, 12, 15, 12, 14,  3,  1, 15,  1, 12, 15, 16,  3, 15, 17,
    15, 14, 18, 16, 17, 16, 15, 17, 19, 14, 13, 20, 13, 11, 21, 19,
    20, 19, 13, 20, 22, 11, 10, 23, 10,  8, 24, 22, 23, 22, 10, 23,
    25,  8,  7, 26,  7,  5, 27, 25, 26, 25,  7, 26, 28,  5,  4, 29,
     4,  3, 30, 28, 29, 28,  4, 29, 29,  3, 16, 31, 16, 18, 30, 29,
    31, 29, 16, 31, 17, 14, 19, 32, 19, 21, 18, 17, 32, 17, 19, 32,
    20, 11, 22, 33, 22, 24, 21, 20, 33, 20, 22, 33, 23,  8, 25, 34,
    25, 27, 24, 23, 34, 23, 25, 34, 26,  5, 28, 35, 28, 30, 27, 26,
    35, 26, 28, 35, 38, 36, 37, 31, 37, 30, 18, 38, 31, 38, 37, 31,
    37, 36, 39, 35, 39, 27, 30, 37, 35, 37, 39, 35, 39, 36, 40, 34,
    40, 24, 27, 39, 34, 39, 40, 34, 40, 36, 41, 33, 41, 21, 24, 40,
    33, 40, 41, 33, 41, 36, 38, 32, 38, 18, 21, 41, 32, 41, 38, 32,
)


resolution = (512, 384)
num_frames = 480
fps = 24
camera_pos = (0.0, 2.5, 5.0)
camera_front = (0.0, -0.5, -1.0)

renderer = warp.render.UsdRenderer("colors.usda")

box_color_base = np.array(
    (
        (1.0, 1.0, 1.0), (0.0, 0.0, 0.0),
        (1.0, 0.0, 0.0), (0.0, 0.0, 1.0),
        (0.0, 1.0, 0.0), (1.0, 0.0, 1.0),
        (1.0, 1.0, 0.0), (0.0, 1.0, 1.0),
    ),
)

for frame in range(num_frames):
    color = wp.sin(float(frame) * 0.05) * 0.5 + 0.5

    renderer.begin_frame(frame / num_frames)
    renderer.render_mesh(
        "box",
        BOX_POINTS,
        BOX_FACE_VERTEX_INDICES,
        pos=(-1.0, 0.0, 0.0),
        colors=box_color_base * ((color * 0.1, color * 0.1, color * 0.1),) * len(BOX_POINTS),
    )
    renderer.render_mesh(
        "sphere",
        SPHERE_POINTS,
        SPHERE_FACE_VERTEX_INDICES,
        pos=(1.0, 0.0, 0.0),
        colors=((0.5, 0.5, color),) * len(SPHERE_POINTS),
    )
    renderer.end_frame()

renderer.save()

Image

Please let us know if you get a chance to build Warp from main and confirm whether it’s working for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants