NOTE: This function only applies gamma.
| 43 | |
| 44 | // NOTE: This function only applies gamma. |
| 45 | uint32_t convert_sRGB(vec3 color) { |
| 46 | float r = color.x, g = color.y, b = color.z; |
| 47 | r = min(max(r, 0.0), 1.0); |
| 48 | g = min(max(g, 0.0), 1.0); |
| 49 | b = min(max(b, 0.0), 1.0); |
| 50 | // TODO: Is this correct? Validate |
| 51 | r = powf(r, 1.0f/2.2f); |
| 52 | g = powf(g, 1.0f/2.2f); |
| 53 | b = powf(b, 1.0f/2.2f); |
| 54 | uint8_t rb = floor(r * 255.0f); |
| 55 | uint8_t gb = floor(g * 255.0f); |
| 56 | uint8_t bb = floor(b * 255.0f); |
| 57 | return 0xFF000000|(bb<<16)|(gb<<8)|rb; |
| 58 | } |
| 59 | |
| 60 | inline vec3 camera_direction(float2 uv, int w, int h, float fov_horizontal_degrees) { |
| 61 | float aspect = float(h) / float(w); |
no test coverage detected