lygia
/v1.1.6
/sample
/triplanar
)triplanar mapping
Dependencies:
Use:
<vec4> sample2DCube(in <SAMPLER_TYPE> lut, in <vec3> xyz)
#ifndef SAMPLE_TRIPLANAR_FNC
#define SAMPLE_TRIPLANAR_FNC(TEX, UV) SAMPLER_FNC(TEX, UV)
#endif
#ifndef FNC_SAMPLETRIPLANAR
#define FNC_SAMPLETRIPLANAR
vec3 sampleTriplanar(SAMPLER_TYPE tex, in vec3 d) {
vec3 colx = SAMPLE_TRIPLANAR_FNC(tex, d.yz).xyz;
vec3 coly = SAMPLE_TRIPLANAR_FNC(tex, d.zx).xyz;
vec3 colz = SAMPLE_TRIPLANAR_FNC(tex, d.xy).xyz;
vec3 n = d*d;
return (colx*n.x + coly*n.y + colz*n.z)/(n.x+n.y+n.z);
}
// iq's cubemap function
vec3 sampleTriplanar(SAMPLER_TYPE tex, in vec3 d, in float s) {
vec3 colx = SAMPLE_TRIPLANAR_FNC(tex, 0.5 + s*d.yz/d.x).xyz;
vec3 coly = SAMPLE_TRIPLANAR_FNC(tex, 0.5 + s*d.zx/d.y).xyz;
vec3 colz = SAMPLE_TRIPLANAR_FNC(tex, 0.5 + s*d.xy/d.z).xyz;
vec3 n = d*d;
return (colx*n.x + coly*n.y + colz*n.z)/(n.x+n.y+n.z);
}
#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