lygia
/v1.1.6
/lighting
/raymarch
/camera
)set a camera for raymarching
Dependencies:
Use:
<mat3> raymarchCamera(in <vec3> ro, [in <vec3> ta [, in <vec3> up] ])
#ifndef FNC_RAYMARCHCAMERA
#define FNC_RAYMARCHCAMERA
mat3 raymarchCamera( in vec3 ro, in vec3 ta, in vec3 up ) {
vec3 cw = normalize(ta-ro);
vec3 cp = up;
vec3 cu = normalize( cross(cw,cp) );
vec3 cv = normalize( cross(cu,cw) );
return mat3( cu, cv, cw );
}
mat3 raymarchCamera( in vec3 ro, in vec3 ta, float cr ) {
vec3 cw = normalize(ta-ro);
vec3 cp = vec3(sin(cr), cos(cr),0.0);
vec3 cu = normalize( cross(cw,cp) );
vec3 cv = ( cross(cu,cw) );
return mat3( cu, cv, cw );
}
mat3 raymarchCamera( in vec3 ro, in vec3 ta ) {
return raymarchCamera( ro, ta, vec3(0.0, 1.0, 0.0) );
}
mat3 raymarchCamera( in vec3 ro ) {
return raymarchCamera( ro, vec3(0.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0) );
}
#endif
Dependencies:
Use:
<float3x3> raymarchCamera(in <float3> ro, [in <float3> ta [, in <float3> up] ])
#ifndef FNC_RAYMARCHCAMERA
#define FNC_RAYMARCHCAMERA
float3x3 raymarchCamera( in float3 ro, in float3 ta, in float3 up ) {
float3 cw = normalize(ta-ro);
float3 cp = up;
float3 cu = normalize( cross(cw,cp) );
float3 cv = normalize( cross(cu,cw) );
return float3x3( cu, cv, cw );
}
float3x3 raymarchCamera( in float3 ro, in float3 ta, float cr ) {
float3 cw = normalize(ta-ro);
float3 cp = float3(sin(cr), cos(cr),0.0);
float3 cu = normalize( cross(cw,cp) );
float3 cv = ( cross(cu,cw) );
return float3x3( cu, cv, cw );
}
float3x3 raymarchCamera( in float3 ro, in float3 ta ) {
return raymarchCamera( ro, ta, float3(0.0, 1.0, 0.0) );
}
float3x3 raymarchCamera( in float3 ro ) {
return raymarchCamera( ro, float3(0.0, 0.0, 0.0), float3(0.0, 1.0, 0.0) );
}
#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