38 lines
1.6 KiB
YAML
38 lines
1.6 KiB
YAML
# Enhanced PBR effect with metallic texture support
|
|
# This effect extends the default PBR to support metallic textures
|
|
# Avoids redeclaring textures that are already in the base template
|
|
|
|
fragment:
|
|
defines: |
|
|
#define USE_METALLIC_TEXTURE 1
|
|
|
|
inout: |
|
|
uniform sampler2D p3d_Texture5; // Metallic texture (not in default template)
|
|
|
|
material: |
|
|
// Enhanced material with metallic texture support
|
|
#if USE_METALLIC_TEXTURE
|
|
// Sample metallic texture
|
|
float sampled_metallic = texture(p3d_Texture5, texcoord).x;
|
|
|
|
// Apply all material properties
|
|
// Use the sampled values from the base template for other textures
|
|
m.basecolor = mInput.color * sampled_diffuse.xyz;
|
|
m.specular_ior = blend_ior(mInput.specular_ior, sampled_ior);
|
|
m.roughness = mInput.roughness * sampled_roughness;
|
|
m.metallic = mInput.metallic * sampled_metallic; // Now with metallic texture support!
|
|
|
|
// Ensure valid ranges
|
|
m.roughness = max(m.roughness, 0.01);
|
|
m.metallic = clamp(m.metallic, 0.0, 1.0);
|
|
|
|
#else
|
|
// Fallback to standard material processing
|
|
m.basecolor = mInput.color * sampled_diffuse.xyz;
|
|
m.specular_ior = blend_ior(mInput.specular_ior, sampled_ior);
|
|
m.roughness = mInput.roughness * sampled_roughness;
|
|
m.metallic = mInput.metallic; // No metallic texture
|
|
#endif
|
|
|
|
m.shading_model_param0 = mInput.arbitrary0;
|