mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 02:48:25 -05:00
a4a528375b
- Added hack in VolumeRaycasteBox for SGCT Left/Right clearing - Fixed quad dimensions to depend on viewport size - Updated RenderableVolumeExpert to render correctly - Small changes to SceneGraph to make it easier to switch between volume rendering and Earth
29 lines
750 B
Common Lisp
29 lines
750 B
Common Lisp
|
|
float3 CartesianToSpherical(float3 _cartesian);
|
|
float intensityNormalizer(float intensity, float iMin, float iMax);
|
|
|
|
float3 CartesianToSpherical(float3 _cartesian) {
|
|
// Put cartesian in [-1..1] range first
|
|
_cartesian = (float3)(-1.0) + 2.0f* _cartesian;
|
|
float r = length(_cartesian);
|
|
float theta, phi;
|
|
if (r == 0.0) {
|
|
theta = phi = 0.0;
|
|
} else {
|
|
theta = acospi(_cartesian.z/r);
|
|
phi = (M_PI + atan2(_cartesian.y, _cartesian.x)) / (2.0*M_PI);
|
|
}
|
|
r = r / native_sqrt(3.0f);
|
|
// Sampler ignores w component
|
|
return (float3)(r, theta, phi);
|
|
}
|
|
|
|
float intensityNormalizer(float intensity, float iMin, float iMax) {
|
|
float i = clamp(intensity, iMin, iMax);
|
|
i = (i - iMin) / (iMax - iMin);
|
|
return clamp(i, 0.0f, 1.0f);
|
|
}
|
|
|
|
|
|
|