diff options
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_wavelength.glsl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_wavelength.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_wavelength.glsl new file mode 100644 index 00000000000..2c5d38eabbe --- /dev/null +++ b/source/blender/gpu/shaders/material/gpu_shader_material_wavelength.glsl @@ -0,0 +1,15 @@ +void node_wavelength(float wavelength, + sampler1DArray spectrummap, + float layer, + vec3 xyz_to_r, + vec3 xyz_to_g, + vec3 xyz_to_b, + out vec4 color) +{ + mat3 xyz_to_rgb = mat3(xyz_to_r, xyz_to_g, xyz_to_b); + float t = (wavelength - 380.0) / (780.0 - 380.0); + vec3 xyz = texture(spectrummap, vec2(t, layer)).rgb; + vec3 rgb = xyz * xyz_to_rgb; + rgb *= 1.0 / 2.52; /* Empirical scale from lg to make all comps <= 1. */ + color = vec4(clamp(rgb, 0.0, 1.0), 1.0); +} |