lygia
/lighting
/light
/new
)Dependencies:
#ifndef FNC_LIGHT_NEW
#define FNC_LIGHT_NEW
#if defined(LIGHT_DIRECTION)
void lightNew(out LightDirectional _L) {
#ifdef LIGHT_DIRECTION
_L.direction = normalize(LIGHT_DIRECTION);
#elif defined(LIGHT_POSITION)
_L.direction = normalize(LIGHT_POSITION);
#else
_L.direction = normalize(vec3(0.0, 1.0, -1.0));
#endif
#ifdef LIGHT_COLOR
_L.color = LIGHT_COLOR;
#else
_L.color = vec3(1.0);
#endif
#ifdef LIGHT_INTENSITY
_L.intensity = LIGHT_INTENSITY;
#else
_L.intensity = 1.0;
#endif
#if defined(LIGHT_SHADOWMAP) && defined(LIGHT_SHADOWMAP_SIZE) && defined(LIGHT_COORD)
_L.intensity *= shadow(LIGHT_SHADOWMAP, vec2(LIGHT_SHADOWMAP_SIZE), (LIGHT_COORD).xy, (LIGHT_COORD).z);
#endif
}
LightDirectional LightDirectionalNew() { LightDirectional l; lightNew(l); return l; }
#endif
#if defined(LIGHT_POSITION)
void lightNew(out LightPoint _L) {
#if defined(SURFACE_POSITION)
_L.position = LIGHT_POSITION - SURFACE_POSITION.xyz;
#else
_L.position = LIGHT_POSITION;
#endif
#ifdef LIGHT_COLOR
_L.color = LIGHT_COLOR;
#else
_L.color = vec3(1.0);
#endif
#ifdef LIGHT_INTENSITY
_L.intensity = LIGHT_INTENSITY;
#else
_L.intensity = 1.0;
#endif
#ifdef LIGHT_FALLOFF
_L.falloff = LIGHT_FALLOFF;
#else
_L.falloff = 0.0;
#endif
#if defined(LIGHT_SHADOWMAP) && defined(LIGHT_SHADOWMAP_SIZE) && defined(LIGHT_COORD)
_L.intensity *= shadow(LIGHT_SHADOWMAP, vec2(LIGHT_SHADOWMAP_SIZE), (LIGHT_COORD).xy, (LIGHT_COORD).z);
#endif
}
LightPoint LightPointNew() {
LightPoint l;
lightNew(l);
return l;
}
#endif
#endif
Dependencies:
#ifndef FNC_LIGHT_NEW
#define FNC_LIGHT_NEW
#if defined(LIGHT_DIRECTION)
void lightNew(out LightDirectional _L) {
#ifdef LIGHT_DIRECTION
_L.direction = normalize(LIGHT_DIRECTION);
#elif defined(LIGHT_POSITION)
_L.direction = normalize(LIGHT_POSITION);
#else
_L.direction = normalize(float3(0.0, 1.0, -1.0));
#endif
#ifdef LIGHT_COLOR
_L.color = LIGHT_COLOR;
#else
_L.color = float3(1.0, 1.0, 1.0);
#endif
#ifdef LIGHT_INTENSITY
_L.intensity = LIGHT_INTENSITY;
#else
_L.intensity = 1.0;
#endif
#if defined(LIGHT_SHADOWMAP) && defined(LIGHT_SHADOWMAP_SIZE) && defined(LIGHT_COORD)
_L.intensity *= shadow(LIGHT_SHADOWMAP, float2(LIGHT_SHADOWMAP_SIZE), (LIGHT_COORD).xy, (LIGHT_COORD).z);
#endif
}
LightDirectional LightDirectionalNew() { LightDirectional l; lightNew(l); return l; }
#endif
#if defined(LIGHT_POSITION)
void lightNew(out LightPoint _L) {
#if defined(SURFACE_POSITION)
_L.position = LIGHT_POSITION - SURFACE_POSITION.xyz;
#else
_L.position = LIGHT_POSITION;
#endif
#ifdef LIGHT_COLOR
_L.color = LIGHT_COLOR;
#else
_L.color = float3(1.0, 1.0, 1.0);
#endif
#ifdef LIGHT_INTENSITY
_L.intensity = LIGHT_INTENSITY;
#else
_L.intensity = 1.0;
#endif
#ifdef LIGHT_FALLOFF
_L.falloff = LIGHT_FALLOFF;
#else
_L.falloff = 0.0;
#endif
#if defined(LIGHT_SHADOWMAP) && defined(LIGHT_SHADOWMAP_SIZE) && defined(LIGHT_COORD)
_L.intensity *= shadow(LIGHT_SHADOWMAP, float2(LIGHT_SHADOWMAP_SIZE), (LIGHT_COORD).xy, (LIGHT_COORD).z);
#endif
}
LightPoint LightPointNew() {
LightPoint l;
lightNew(l);
return l;
}
#endif
#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