summaryrefslogtreecommitdiff
path: root/src/libs/ray/ray_gamma.c
blob: 21a9afc8714e168ed308b6d89f53a8eb3eb7cbec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <math.h>

#include "ray_gamma.h"

void ray_gamma_prepare(float gamma, ray_gamma_t *res_gamma)
{
	if (res_gamma->gamma == gamma)
		return;

	/* This is from graphics gems 2 "REAL PIXELS" */
	for (unsigned i = 0; i < 1024; i++)
		res_gamma->table[i] = 256.0f * powf((((float)i + .5f) / 1024.0f), 1.0f/gamma);

	res_gamma->gamma = gamma;
}
© All Rights Reserved