#include "shaders/scene/material_getTexel.glsl" #include "shaders/scene/material_normalmap.glsl" struct Material { vec4 Base; vec4 Bright; vec4 Glow; vec3 Normal; vec3 Specular; float Glossiness; float SpecularLevel; float Metallic; float Roughness; float AO; }; vec4 Process(vec4 color); void SetupMaterial(inout Material mat); vec3 ProcessMaterialLight(Material material, vec3 color); vec2 GetTexCoord(); // These get Or'ed into uTextureMode because it only uses its 3 lowermost bits. const int TEXF_Brightmap = 0x10000; const int TEXF_Detailmap = 0x20000; const int TEXF_Glowmap = 0x40000; Material CreateMaterial() { Material material; material.Base = vec4(0.0); material.Bright = vec4(0.0); material.Glow = vec4(0.0); material.Normal = vec3(0.0); material.Specular = vec3(0.0); material.Glossiness = 0.0; material.SpecularLevel = 0.0; material.Metallic = 0.0; material.Roughness = 0.0; material.AO = 0.0; SetupMaterial(material); return material; } void SetMaterialProps(inout Material material, vec2 texCoord) { #ifdef NPOT_EMULATION if (uNpotEmulation.y != 0.0) { float period = floor(texCoord.t / uNpotEmulation.y); texCoord.s += uNpotEmulation.x * floor(mod(texCoord.t, uNpotEmulation.y)); texCoord.t = period + mod(texCoord.t, uNpotEmulation.y); } #endif material.Base = getTexel(texCoord.st); material.Normal = ApplyNormalMap(texCoord.st); // OpenGL doesn't care, but Vulkan pukes all over the place if these texture samplings are included in no-texture shaders, even though never called. #ifndef NO_LAYERS if ((uTextureMode & TEXF_Brightmap) != 0) material.Bright = desaturate(texture(brighttexture, texCoord.st)); if ((uTextureMode & TEXF_Detailmap) != 0) { vec4 Detail = texture(detailtexture, texCoord.st * uDetailParms.xy) * uDetailParms.z; material.Base.rgb *= Detail.rgb; } if ((uTextureMode & TEXF_Glowmap) != 0) material.Glow = desaturate(texture(glowtexture, texCoord.st)); #endif }