camera (`lygia`/`lighting`/`raymarch`/`camera`)

set a camera for raymarching

Dependencies:

Use:

``````<mat3> raymarchCamera(in <vec3> ro, [in <vec3> ta [, in <vec3> up] ])
``````

Check it on Github

``````

#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] ])
``````

Check it on Github

``````

#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
``````