"""Quick test of Minecraft PBR conversion without running full model.""" import torch from chord.minecraft_pbr import convert_to_labpbr, convert_to_bedrock from chord.normal_utils import derive_ao_and_height # Create dummy tensors (simulating model output) h, w = 256, 256 basecolor = torch.rand(3, h, w) normal = torch.rand(3, h, w) * 0.5 + 0.25 # Center around 0.5 roughness = torch.rand(1, h, w) metalness = torch.rand(1, h, w) print("Testing AO and height derivation from normal map...") ao, height = derive_ao_and_height(normal) print(f" AO shape: {ao.shape}, range: [{ao.min():.3f}, {ao.max():.3f}]") print(f" Height shape: {height.shape}, range: [{height.min():.3f}, {height.max():.3f}]") print("\nTesting Minecraft PBR (LabPBR format) conversion...") result = convert_to_labpbr( basecolor=basecolor, normal=normal, roughness=roughness, metalness=metalness, derive_ao_height=True, ) print(f" Albedo: {result['albedo'].size} {result['albedo'].mode}") print(f" Specular: {result['specular'].size} {result['specular'].mode}") print(f" Normal: {result['normal'].size} {result['normal'].mode}") # Save LabPBR test outputs result['albedo'].save('test_albedo.png') result['specular'].save('test_specular_s.png') result['normal'].save('test_normal_n.png') print("Saved: test_albedo.png, test_specular_s.png, test_normal_n.png") print("\nTesting Minecraft PBR (Bedrock RTX format) conversion...") bedrock_result = convert_to_bedrock( basecolor=basecolor, normal=normal, roughness=roughness, metalness=metalness, compute_sss=True, compute_emission=True, ) print(f" Albedo: {bedrock_result['albedo'].size} {bedrock_result['albedo'].mode}") print(f" MER: {bedrock_result['mer'].size} {bedrock_result['mer'].mode}") print(f" Normal: {bedrock_result['normal'].size} {bedrock_result['normal'].mode}") # Save Bedrock test outputs bedrock_result['albedo'].save('test_bedrock_albedo.png') bedrock_result['mer'].save('test_bedrock_mer.png') bedrock_result['normal'].save('test_bedrock_normal.png') print("Saved: test_bedrock_albedo.png, test_bedrock_mer.png, test_bedrock_normal.png") print("\nAll tests passed!")