Skip to content

Conversation

@querielo
Copy link
Contributor

@querielo querielo commented Sep 25, 2025

PR adds read support for SOG. Previously, SOG could only be written via writeSog. This enables round‑trip conversion

input.ply -> output.sog -> restored.ply

or combining multiple .sog into one

input1.sog + input2.sog -> output.sog

What’s Included

  • read-sog.ts: Reconstructs a DataTable
  • zip-reader.ts: Minimal ZIP parser (STORE method + data descriptor) connected to .sog archives with no extra dependencies (no fflate).
  • webp-decode.ts: WASM-backed WebP decoder (mirrors existing encoder approach) with no extra dependencies (no sharp).

Inverse Transforms

  • logTransform (writer): sign(v) * ln(|v| + 1)
  • Inverse (reader): inv = sign(v) * (exp(|v|) - 1)
  • Opacity:
    • Writer stores sigmoid(opacity) → uint8
    • Reader applies logit(y) = ln(y / (1 - y))
  • Quaternion:
    • Writer packs 3 scaled components + dominant index (alpha 252–255)
    • Reader restores missing component via unit-length constraint

Fixes #62

Copilot AI review requested due to automatic review settings September 25, 2025 00:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds read support for SOG (Super-compressed Splat) format to enable round-trip conversion between PLY and SOG files. Previously, SOG could only be written but not read.

  • Implements SOG reading functionality with inverse transforms for position, quaternion, and opacity
  • Adds a minimal ZIP reader for parsing bundled .sog archives without external dependencies
  • Includes a WASM-backed WebP decoder for texture decompression

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/readers/read-sog.ts Main SOG reader implementing inverse transforms and data reconstruction
src/serialize/zip-reader.ts Minimal ZIP parser supporting STORE method and data descriptors
src/utils/webp-decode.ts WebP decoder wrapper using WASM module
src/index.ts Updated file reader to support .sog and meta.json input
lib/webp_decode.mjs Compiled WASM module for WebP decoding
lib/webp_decode.c C source for WebP decoder WASM module
lib/BUILD.md Updated build instructions for both encoder and decoder
README.md Updated documentation to reflect SOG read support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@slimbuck
Copy link
Member

Hey @querielo,

May I ask what your use-case is for combining multiple SOG into another SOG?

SOG is really a lossy compressed format and so decompressing->recompressing will result in overall quality loss.

@willeastcott willeastcott added the enhancement New feature or request label Sep 25, 2025
@slimbuck slimbuck changed the title Support for reading bundled sog Support reading sog Sep 29, 2025
@willeastcott willeastcott changed the title Support reading sog Support reading SOG Sep 29, 2025
@slimbuck
Copy link
Member

Hey @querielo I pushed some updates directly to your branch, hope that's ok :)

Thanks so much for this PR!!

@slimbuck slimbuck merged commit 6876641 into playcanvas:main Sep 29, 2025
2 checks passed
@querielo
Copy link
Contributor Author

You are right.

Thank you!

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for reading bundled sog

3 participants