39 lines
No EOL
1.3 KiB
HLSL
39 lines
No EOL
1.3 KiB
HLSL
#include "../../sampler.hlsl"
|
|
|
|
/*
|
|
contributors: Patricio Gonzalez Vivo
|
|
description: Get material specular property from GlslViewer's defines https://github.com/patriciogonzalezvivo/glslViewer/wiki/GlslViewer-DEFINES#material-defines
|
|
use: float4 materialMetallic()
|
|
options:
|
|
- SAMPLER_FNC(TEX, UV): optional depending the target version of GLSL (texture2D(...) or texture(...))
|
|
- MATERIAL_SPECULARMAP
|
|
license:
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
*/
|
|
|
|
#ifndef FNC_MATERIAL_SPECULAR
|
|
#define FNC_MATERIAL_SPECULAR
|
|
|
|
#ifdef MATERIAL_SPECULARMAP
|
|
uniform SAMPLER_TYPE MATERIAL_SPECULARMAP;
|
|
#endif
|
|
|
|
float3 materialSpecular() {
|
|
float3 spec = float3(0.04, 0.04, 0.04);
|
|
#if defined(MATERIAL_SPECULARMAP) && defined(MODEL_VERTEX_TEXCOORD)
|
|
float2 uv = v_texcoord.xy;
|
|
#if defined(MATERIAL_SPECULARMAP_OFFSET)
|
|
uv += (MATERIAL_SPECULARMAP_OFFSET).xy;
|
|
#endif
|
|
#if defined(MATERIAL_SPECULARMAP_SCALE)
|
|
uv *= (MATERIAL_SPECULARMAP_SCALE).xy;
|
|
#endif
|
|
spec = SAMPLER_FNC(MATERIAL_SPECULARMAP, uv).rgb;
|
|
#elif defined(MATERIAL_SPECULAR)
|
|
spec = MATERIAL_SPECULAR;
|
|
#endif
|
|
return spec;
|
|
}
|
|
|
|
#endif |