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

39 lines
1.5 KiB
YAML

# PBR effect with direct roughness texture control
# This effect allows roughness textures to directly control roughness values
# instead of multiplying with material roughness value
fragment:
defines: |
#define USE_DIRECT_ROUGHNESS_TEXTURE 1
inout: |
uniform sampler2D p3d_Texture3; // Roughness texture (direct control)
material: |
// Direct roughness texture control
#if USE_DIRECT_ROUGHNESS_TEXTURE
// Sample roughness value directly from texture
float sampled_roughness = texture(p3d_Texture3, texcoord).x;
// Use texture value directly instead of multiplying
// This allows the texture to have full control over roughness values
m.roughness = sampled_roughness;
// Ensure minimum roughness to avoid rendering issues
m.roughness = max(m.roughness, 0.01);
// Debug: Ensure we're using the texture value
// White areas = 1.0 (fully rough)
// Gray areas = 0.5 (semi-rough)
// Black areas = 0.01 (smooth, but not zero to avoid issues)
#else
// Fallback to material roughness value
m.roughness = mInput.roughness;
#endif
// Keep all other properties unchanged for stability
m.basecolor = mInput.color;
m.metallic = mInput.metallic;
m.specular_ior = mInput.specular_ior;
m.shading_model_param0 = mInput.arbitrary0;