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

34 lines
1.2 KiB
YAML

# Stable PBR effect with roughness texture support
# Simplified version to avoid rendering issues and flickering
fragment:
defines: |
#define USE_STABLE_ROUGHNESS_TEXTURE 1
inout: |
uniform sampler2D p3d_Texture3; // Roughness texture only
material: |
// Simple and stable roughness texture handling
#if USE_STABLE_ROUGHNESS_TEXTURE
// Sample roughness from texture
float sampled_roughness = texture(p3d_Texture3, texcoord).x;
// Use simple multiplication - stable and predictable
// This ensures the texture effect is always visible
m.roughness = mInput.roughness * sampled_roughness;
// Ensure minimum roughness to avoid rendering issues
m.roughness = max(m.roughness, 0.01);
#else
// Fallback to material roughness
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;