Skip to content

Commit

Permalink
compress textures
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsleaf committed Jan 13, 2025
1 parent f413650 commit 5e98e81
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/IsaacSim/gallery/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def design_scene() -> tuple[dict, list[list[float]]]:
prim_path="/World/scene",
init_state=AssetBaseCfg.InitialStateCfg(pos=[0.0, 0.0, 0.0], rot=[1.0, 0.0, 0.0, 0.0]),
spawn=UsdFileCfg(
usd_path=f"{Path(__file__).parent.as_posix()}/warehouse.usd",
usd_path=f"{Path(__file__).parent.as_posix()}/simple_room.usd",
),
)
scene_asset_cfg.spawn.func(scene_asset_cfg.prim_path, scene_asset_cfg.spawn)
Expand Down
Binary file added demos/IsaacSim/gallery/simple_room.usd
Binary file not shown.
16 changes: 12 additions & 4 deletions simpub/parser/isaacsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,21 @@ def parse_prim_material(
with self.timer.start("parse_prim_material_4.2"):
if image is not None:
image = image.convert("RGB")
image = np.array(image).astype(np.uint8)
image, height, width = SimTexture.compress_image(image, height=image.shape[0], width=image.shape[1])
# sim_mat.texture = SimTexture.create_texture(
# np.array(image),
# height=image.height,
# width=image.width,
# scene=self.sim_scene,
# )
bin_data = image.tobytes()
assert len(bin_data) == image.width * image.height * 3
tex_hash = md5(bin_data).hexdigest()
# assert len(bin_data) == image.width * image.height * 3
tex_hash = SimTexture.generate_hash(bin_data)
sim_mat.texture = SimTexture(
hash=tex_hash,
width=image.width,
height=image.height,
width=image.shape[1],
height=image.shape[0],
textureType="2D",
textureScale=(1, 1),
)
Expand Down

0 comments on commit 5e98e81

Please sign in to comment.