lygia
/lighting
/fakeCube
)Creates a fake cube and returns the value giving a normal direction
Dependencies:
Use:
<vec3> fakeCube(<vec3> _normal [, <float> _shininnes])
#ifndef FAKECUBE_LIGHT_AMOUNT
#define FAKECUBE_LIGHT_AMOUNT 0.005
#endif
#ifndef FNC_FAKECUBE
#define FNC_FAKECUBE
vec3 fakeCube(const in vec3 _normal, const in float _shininnes) {
#if defined(FAKECUBE_TEXTURE2D)
return sampleTriplanar(FAKECUBE_TEXTURE2D, _normal);
#elif defined(FAKECUBE_ONLYXWALL)
return vec3( powFast(saturate(_normal.x) + FAKECUBE_LIGHT_AMOUNT, _shininnes) );
#elif defined(FAKECUBE_ONLYYWALL)
return vec3( powFast(saturate(_normal.y) + FAKECUBE_LIGHT_AMOUNT, _shininnes) );
#elif defined(FAKECUBE_ONLYZWALL)
return vec3( powFast(saturate(_normal.z) + FAKECUBE_LIGHT_AMOUNT, _shininnes) );
#else
vec3 rAbs = abs(_normal);
return vec3( powFast(max(max(rAbs.x, rAbs.y), rAbs.z) + FAKECUBE_LIGHT_AMOUNT, _shininnes)
#ifdef FAKECUBE_NOFLOOR
* smoothstep(-1.0, 0., _normal.y)
#endif
#ifdef FAKECUBE_NOROOF
* smoothstep(1.0, 0., _normal.y)
#endif
#ifdef FAKECUBE_NOXWALL
* smoothstep(1.0, 0.0, _normal.x)
#endif
#ifdef FAKECUBE_NONXWALL
* smoothstep(-1.0, 0., _normal.x)
#endif
#ifdef FAKECUBE_NOZWALL
* smoothstep(-1.0, 0., _normal.z)
#endif
#ifdef FAKECUBE_NONZWALL
* smoothstep(1.0, 0., _normal.z)
#endif
);
#endif
}
vec3 fakeCube(const in vec3 _normal) {
return fakeCube(_normal, materialShininess() );
}
#endif
Dependencies:
Use:
<float3> fakeCube(<float3> _normal [, <float> _shininnes])
#ifndef FNC_FAKECUBE
#define FNC_FAKECUBE
float3 fakeCube(float3 _normal, float _shininnes) {
float3 rAbs = abs(_normal);
float v = powFast(max(max(rAbs.x, rAbs.y), rAbs.z) + 0.005, _shininnes );
return float3(v, v, v);
}
float3 fakeCube(float3 _normal) {
return fakeCube(_normal, materialShininess() );
}
#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