lygia
/lighting
/material
/metallic
)Get material metalic property from GlslViewer's defines https://github.com/patriciogonzalezvivo/glslViewer/wiki/GlslViewer-DEFINES#material-defines
Dependencies:
lygia
/lighting
/toMetallic
.glsl
lygia
/lighting
/material
/albedo
.glsl
lygia
/lighting
/material
/specular
.glsl
lygia
/sampler
.glsl
Use:
vec4 materialMetallic()
#ifndef FNC_MATERIAL_METALLIC
#define FNC_MATERIAL_METALLIC
#ifdef MATERIAL_METALLICMAP
uniform SAMPLER_TYPE MATERIAL_METALLICMAP;
#endif
#if defined(MATERIAL_ROUGHNESSMETALLICMAP) && !defined(MATERIAL_ROUGHNESSMETALLICMAP_UNIFORM)
#define MATERIAL_ROUGHNESSMETALLICMAP_UNIFORM
uniform SAMPLER_TYPE MATERIAL_ROUGHNESSMETALLICMAP;
#endif
#if defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP) && !defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP_UNIFORM)
#define MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP_UNIFORM
uniform SAMPLER_TYPE MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP;
#endif
float materialMetallic() {
float metallic = 0.0;
#if defined(MATERIAL_METALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
vec2 uv = v_texcoord.xy;
#if defined(MATERIAL_METALLICMAP_OFFSET)
uv += (MATERIAL_METALLICMAP_OFFSET).xy;
#endif
#if defined(MATERIAL_METALLICMAP_SCALE)
uv *= (MATERIAL_METALLICMAP_SCALE).xy;
#endif
metallic = SAMPLER_FNC(MATERIAL_METALLICMAP, uv).b;
#elif defined(MATERIAL_ROUGHNESSMETALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
vec2 uv = v_texcoord.xy;
metallic = SAMPLER_FNC(MATERIAL_ROUGHNESSMETALLICMAP, uv).b;
#elif defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
vec2 uv = v_texcoord.xy;
metallic = SAMPLER_FNC(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP, uv).b;
#elif defined(MATERIAL_METALLIC)
metallic = MATERIAL_METALLIC;
#else
vec3 diffuse = materialAlbedo().rgb;
vec3 specular = materialSpecular();
metallic = toMetallic(diffuse, specular);
#endif
return metallic;
}
#endif
Dependencies:
lygia
/lighting
/toMetallic
.glsl
lygia
/lighting
/material
/albedo
.glsl
lygia
/lighting
/material
/specular
.glsl
lygia
/sampler
.glsl
Use:
float4 materialMetallic()
#ifdef MATERIAL_METALLICMAP
uniform SAMPLER_TYPE MATERIAL_METALLICMAP;
#endif
#if defined(MATERIAL_ROUGHNESSMETALLICMAP) && !defined(MATERIAL_ROUGHNESSMETALLICMAP_UNIFORM)
#define MATERIAL_ROUGHNESSMETALLICMAP_UNIFORM
uniform SAMPLER_TYPE MATERIAL_ROUGHNESSMETALLICMAP;
#endif
#if defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP) && !defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP_UNIFORM)
#define MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP_UNIFORM
uniform SAMPLER_TYPE MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP;
#endif
#ifndef FNC_MATERIAL_METALLIC
#define FNC_MATERIAL_METALLIC
float materialMetallic() {
float metallic = 0.0;
#if defined(MATERIAL_METALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
float2 uv = v_texcoord.xy;
#if defined(MATERIAL_METALLICMAP_OFFSET)
uv += (MATERIAL_METALLICMAP_OFFSET).xy;
#endif
#if defined(MATERIAL_METALLICMAP_SCALE)
uv *= (MATERIAL_METALLICMAP_SCALE).xy;
#endif
metallic = SAMPLER_FNC(MATERIAL_METALLICMAP, uv).b;
#elif defined(MATERIAL_ROUGHNESSMETALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
float2 uv = v_texcoord.xy;
metallic = SAMPLER_FNC(MATERIAL_ROUGHNESSMETALLICMAP, uv).b;
#elif defined(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP) && defined(MODEL_VERTEX_TEXCOORD)
float2 uv = v_texcoord.xy;
metallic = SAMPLER_FNC(MATERIAL_OCCLUSIONROUGHNESSMETALLICMAP, uv).b;
#elif defined(MATERIAL_METALLIC)
metallic = MATERIAL_METALLIC;
#else
float3 diffuse = materialAlbedo().rgb;
float3 specular = materialSpecular();
metallic = toMetallic(diffuse, specular);
#endif
return metallic;
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository