forked from Rowland/EG
52 lines
2.2 KiB
YAML
52 lines
2.2 KiB
YAML
# Extended PBR effect with support for additional texture types
|
|
# This effect supports metallic, emission, AO, detail, and gloss textures
|
|
|
|
fragment:
|
|
defines: |
|
|
#define USE_EXTENDED_TEXTURES 1
|
|
|
|
inout: |
|
|
uniform sampler2D p3d_Texture5; // Metallic texture
|
|
uniform sampler2D p3d_Texture6; // Emission texture
|
|
uniform sampler2D p3d_Texture7; // AO texture
|
|
uniform sampler2D p3d_Texture8; // Alpha texture
|
|
uniform sampler2D p3d_Texture9; // Detail texture
|
|
uniform sampler2D p3d_Texture10; // Gloss texture
|
|
|
|
material: |
|
|
#if USE_EXTENDED_TEXTURES
|
|
|
|
// Metallic texture (p3d_Texture5)
|
|
float sampled_metallic = texture(p3d_Texture5, texcoord).x;
|
|
m.metallic = mInput.metallic * sampled_metallic;
|
|
|
|
// Emission texture (p3d_Texture6)
|
|
vec3 sampled_emission = texture(p3d_Texture6, texcoord).xyz;
|
|
if (mInput.shading_model == SHADING_MODEL_EMISSIVE) {
|
|
m.basecolor += sampled_emission * 2.0; // Boost emission intensity
|
|
}
|
|
|
|
// AO texture (p3d_Texture7) - multiply with base color
|
|
float sampled_ao = texture(p3d_Texture7, texcoord).x;
|
|
m.basecolor *= sampled_ao;
|
|
|
|
// Alpha texture (p3d_Texture8) - for transparency
|
|
float sampled_alpha = texture(p3d_Texture8, texcoord).x;
|
|
if (mInput.shading_model == SHADING_MODEL_TRANSPARENT) {
|
|
// Apply alpha testing
|
|
if (sampled_alpha < 0.5) discard;
|
|
}
|
|
|
|
// Detail texture (p3d_Texture9) - blend with base color
|
|
vec3 sampled_detail = texture(p3d_Texture9, texcoord * 4.0).xyz; // Tiled detail
|
|
m.basecolor = mix(m.basecolor, m.basecolor * sampled_detail, 0.5);
|
|
|
|
// Gloss texture (p3d_Texture10) - affects roughness
|
|
float sampled_gloss = texture(p3d_Texture10, texcoord).x;
|
|
m.roughness = m.roughness * (1.0 - sampled_gloss); // Gloss is inverse of roughness
|
|
|
|
#else
|
|
// Standard behavior when extended textures are not used
|
|
m.metallic = mInput.metallic;
|
|
#endif
|