Created
September 9, 2023 00:14
-
-
Save sjhalayka/44691424357ad97adfe05c82abe8c1ef to your computer and use it in GitHub Desktop.
Hue / refraction code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() | |
{ | |
const int steps = 10; | |
float max_hue = rgb2hsv(vec3(1.0, 0.0, 1.0)).x; | |
float min_hue = rgb2hsv(vec3(1.0, 0.0, 0.0)).x; | |
const float max_eta = 0.9; | |
const float min_eta = 0.6; | |
float hue_diff = max_hue - min_hue; | |
const float hue_step_size = hue_diff / (steps - 1); | |
float eta_diff = max_eta - min_eta; | |
const float eta_step_size = eta_diff / (steps - 1); | |
float curr_hue = min_hue; | |
float curr_eta = min_eta; | |
vec3 color = vec3(0.0); | |
for(int i = 0; i < steps; i++, curr_hue += hue_step_size, curr_eta += eta_step_size) | |
{ | |
const float f = get_ray0(curr_hue, curr_eta); | |
vec3 mask = hsv2rgb(vec3(curr_hue, 1.0, 1.0)); | |
color.r += f*mask.r; | |
color.g += f*mask.g; | |
color.b += f*mask.b; | |
} | |
color /= steps; | |
imageStore(color_image, pixel_pos, vec4(color, 0.0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment