Files
tinyusdz/tests/usda/usdlux_basic_lights.usda
Syoyo Fujita ab0ef8900c Add comprehensive UsdLux parsing and conversion system with test suite
Implements complete UsdLux light parsing and conversion pipeline:

Core Infrastructure:
- RenderLight data structure supporting 6 UsdLux light types (Point/Sphere, Directional, Rect, Disk, Cylinder, Dome)
- MeshLightAPI support for emissive geometry lights
- Full property extraction: color, intensity, exposure, shadows, shaping, IES profiles
- Color temperature support with Kelvin-based specification

JSON Serialization:
- Complete light data serialization in material-serializer.cc
- Geometry light mesh references with geometryMeshId
- Material sync mode for mesh lights

Three.js Exporter:
- Light type conversion to Three.js equivalents
- Shadow map configuration
- Directional/Point/Spot/Rect/Hemisphere light export

WASM Bindings:
- numLights() API for light count
- getLightWithFormat() supporting JSON/YAML output
- Node.js CLI tool (dump-usdlux-cli.js) for testing

Test Suite:
- Comprehensive test files in tests/usda/:
  * usdlux_basic_lights.usda - 6 light types
  * usdlux_advanced_features.usda - IES, shaping, textures
  * usdlux_mesh_lights_simple.usda - MeshLightAPI
- Automated test suite (test-usdlux-parsing.js)
- npm test:usdlux script for CI/CD integration
- All tests passing (4/4)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 03:27:19 +09:00

127 lines
4.0 KiB
Plaintext

#usda 1.0
(
doc = "Basic UsdLux light types test - Point, Directional, Rect, Disk, Cylinder, Dome"
defaultPrim = "World"
metersPerUnit = 1
upAxis = "Y"
)
def Xform "World"
{
def Scope "Lights"
{
# 1. Point Light (Sphere Light) - Omnidirectional
def SphereLight "KeyLight"
{
color3f inputs:color = (1.0, 0.95, 0.85)
float inputs:intensity = 100.0
float inputs:exposure = 1.0
float inputs:radius = 0.5
bool inputs:normalize = true
# Shadow properties
bool inputs:shadow:enable = true
color3f inputs:shadow:color = (0.0, 0.0, 0.0)
double3 xformOp:translate = (-3, 4, 3)
uniform token[] xformOpOrder = ["xformOp:translate"]
}
# 2. Directional Light (Distant Light) - Sun-like
def DistantLight "SunLight"
{
color3f inputs:color = (1.0, 1.0, 0.95)
float inputs:intensity = 50.0
float inputs:exposure = 0.5
float inputs:angle = 0.53 # Sun's angular diameter in degrees
# Enable color temperature
bool inputs:enableColorTemperature = true
float inputs:colorTemperature = 5800 # Sun temperature
double3 xformOp:rotateXYZ = (-45, 30, 0)
uniform token[] xformOpOrder = ["xformOp:rotateXYZ"]
}
# 3. Rect Light - Area light
def RectLight "SoftBox"
{
color3f inputs:color = (0.9, 0.95, 1.0)
float inputs:intensity = 200.0
float inputs:width = 2.0
float inputs:height = 1.5
bool inputs:normalize = false
double3 xformOp:translate = (0, 3, 5)
double3 xformOp:rotateXYZ = (-30, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]
}
# 4. Disk Light - Circular area light
def DiskLight "RimLight"
{
color3f inputs:color = (1.0, 0.9, 0.8)
float inputs:intensity = 150.0
float inputs:radius = 0.75
double3 xformOp:translate = (4, 2, -2)
double3 xformOp:rotateXYZ = (0, -135, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]
}
# 5. Cylinder Light with shaping (Spotlight)
def CylinderLight "Spotlight"
{
color3f inputs:color = (1.0, 1.0, 1.0)
float inputs:intensity = 300.0
float inputs:radius = 0.2
float inputs:length = 0.5
# Shaping for spotlight cone
float inputs:shaping:cone:angle = 45.0
float inputs:shaping:cone:softness = 0.2
# Shadow properties
bool inputs:shadow:enable = true
float inputs:shadow:falloff = 1.0
double3 xformOp:translate = (0, 5, 0)
double3 xformOp:rotateXYZ = (-90, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]
}
# 6. Dome Light - Environment lighting
def DomeLight "EnvironmentLight"
{
color3f inputs:color = (0.4, 0.5, 0.6)
float inputs:intensity = 0.5
float inputs:exposure = -1.0
# Optional: Reference to HDR environment map
# asset inputs:texture:file = @./environment.hdr@
token inputs:texture:format = "latlong"
}
}
# Reference geometry to show lighting
def Xform "Geometry"
{
def Sphere "TestSphere"
{
double radius = 1.0
double3 xformOp:translate = (0, 1, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}
def Mesh "GroundPlane"
{
int[] faceVertexCounts = [4]
int[] faceVertexIndices = [0, 1, 2, 3]
point3f[] points = [(-10, 0, -10), (10, 0, -10), (10, 0, 10), (-10, 0, 10)]
normal3f[] normals = [(0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] (
interpolation = "vertex"
)
}
}
}