fuckingtech/public/assets/glsl/lygia/lighting/material/emissive.hlsl
Elias Rhouzlane bf76c6b086 fix: code
2025-04-06 17:23:52 +02:00

43 lines
No EOL
1.3 KiB
HLSL

#include "../../color/space/gamma2linear.hlsl"
#include "../../sampler.hlsl"
/*
contributors: Patricio Gonzalez Vivo
description: Get material emissive property from GlslViewer's defines https://github.com/patriciogonzalezvivo/glslViewer/wiki/GlslViewer-DEFINES#material-defines
use: float4 materialEmissive()
options:
- SAMPLER_FNC(TEX, UV): optional depending the target version of GLSL (texture2D(...) or texture(...))
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_EMISSIVE
#define FNC_MATERIAL_EMISSIVE
#ifdef MATERIAL_EMISSIVEMAP
uniform SAMPLER_TYPE MATERIAL_EMISSIVEMAP;
#endif
float3 materialEmissive() {
float3 emission = float3(0.0, 0.0, 0.0);
#if defined(MATERIAL_EMISSIVEMAP) && defined(MODEL_VERTEX_TEXCOORD)
float2 uv = v_texcoord.xy;
#if defined(MATERIAL_EMISSIVEMAP_OFFSET)
uv += (MATERIAL_EMISSIVEMAP_OFFSET).xy;
#endif
#if defined(MATERIAL_EMISSIVEMAP_SCALE)
uv *= (MATERIAL_EMISSIVEMAP_SCALE).xy;
#endif
emission = gamma2linear( SAMPLER_FNC(MATERIAL_EMISSIVEMAP, uv) ).rgb;
#elif defined(MATERIAL_EMISSIVE)
emission = MATERIAL_EMISSIVE;
#endif
return emission;
}
#endif