EG/RenderPipelineFile/effects/pbr_with_metallic.yaml
2025-12-12 16:16:15 +08:00

41 lines
1.6 KiB
YAML

# PBR effect with metallic texture support
# This effect extends the default PBR pipeline to support metallic textures
# Provides both multiplicative and direct control modes
fragment:
defines: |
#define USE_METALLIC_TEXTURE 1
#define METALLIC_CONTROL_MODE 0 // 0=multiply, 1=direct, 2=additive
inout: |
uniform sampler2D p3d_Texture5; // Metallic texture
material: |
// Add metallic texture support to the default material processing
// Note: Don't override the default material processing, just extend it
#if USE_METALLIC_TEXTURE
// Sample metallic texture
float sampled_metallic = texture(p3d_Texture5, texcoord).x;
// Apply metallic texture based on control mode
#if METALLIC_CONTROL_MODE == 0
// Multiplicative mode (original behavior)
m.metallic = mInput.metallic * sampled_metallic;
#elif METALLIC_CONTROL_MODE == 1
// Direct control mode
m.metallic = sampled_metallic;
#elif METALLIC_CONTROL_MODE == 2
// Additive mode
m.metallic = clamp(mInput.metallic + sampled_metallic, 0.0, 1.0);
#else
// Fallback to multiplicative
m.metallic = mInput.metallic * sampled_metallic;
#endif
// Ensure valid range
m.metallic = clamp(m.metallic, 0.0, 1.0);
#endif
// Note: Other material properties (basecolor, roughness, etc.) are handled by the default template
// We don't override them here to avoid conflicts