Changeset View
Changeset View
Standalone View
Standalone View
intern/opencolorio/gpu_shader_display_transform.glsl
| Show All 10 Lines | |||||
| #ifdef USE_CURVE_MAPPING | #ifdef USE_CURVE_MAPPING | ||||
| /* Curve mapping parameters | /* Curve mapping parameters | ||||
| * | * | ||||
| * See documentation for OCIO_CurveMappingSettings to get fields descriptions. | * See documentation for OCIO_CurveMappingSettings to get fields descriptions. | ||||
| * (this ones pretyt much copies stuff from C structure.) | * (this ones pretyt much copies stuff from C structure.) | ||||
| */ | */ | ||||
| uniform sampler1D curve_mapping_texture; | uniform sampler1D curve_mapping_texture; | ||||
| uniform int curve_mapping_lut_size; | uniform int curve_mapping_lut_size; | ||||
| uniform ivec4 use_curve_mapping_extend_extrapolate; | uniform int use_curve_mapping_extend_extrapolate; | ||||
| uniform vec4 curve_mapping_mintable; | uniform vec4 curve_mapping_mintable; | ||||
| uniform vec4 curve_mapping_range; | uniform vec4 curve_mapping_range; | ||||
| uniform vec4 curve_mapping_ext_in_x; | uniform vec4 curve_mapping_ext_in_x; | ||||
| uniform vec4 curve_mapping_ext_in_y; | uniform vec4 curve_mapping_ext_in_y; | ||||
| uniform vec4 curve_mapping_ext_out_x; | uniform vec4 curve_mapping_ext_out_x; | ||||
| uniform vec4 curve_mapping_ext_out_y; | uniform vec4 curve_mapping_ext_out_y; | ||||
| uniform vec4 curve_mapping_first_x; | uniform vec4 curve_mapping_first_x; | ||||
| uniform vec4 curve_mapping_first_y; | uniform vec4 curve_mapping_first_y; | ||||
| Show All 9 Lines | float read_curve_mapping(int table, int index) | ||||
| */ | */ | ||||
| float texture_index = float(index) / float(curve_mapping_lut_size - 1); | float texture_index = float(index) / float(curve_mapping_lut_size - 1); | ||||
| return texture(curve_mapping_texture, texture_index)[table]; | return texture(curve_mapping_texture, texture_index)[table]; | ||||
| } | } | ||||
| float curvemap_calc_extend(int table, float x, vec2 first, vec2 last) | float curvemap_calc_extend(int table, float x, vec2 first, vec2 last) | ||||
| { | { | ||||
| if (x <= first[0]) { | if (x <= first[0]) { | ||||
| if (use_curve_mapping_extend_extrapolate[table] == 0) { | if (use_curve_mapping_extend_extrapolate == 0) { | ||||
| /* no extrapolate */ | /* horizontal extrapolation */ | ||||
| return first[1]; | return first[1]; | ||||
| } | } | ||||
| else { | else { | ||||
| if (curve_mapping_ext_in_x[table] == 0.0) | if (curve_mapping_ext_in_x[table] == 0.0) | ||||
| return first[1] + curve_mapping_ext_in_y[table] * 10000.0; | return first[1] + curve_mapping_ext_in_y[table] * 10000.0; | ||||
| else | else | ||||
| return first[1] + | return first[1] + | ||||
| curve_mapping_ext_in_y[table] * (x - first[0]) / curve_mapping_ext_in_x[table]; | curve_mapping_ext_in_y[table] * (x - first[0]) / curve_mapping_ext_in_x[table]; | ||||
| } | } | ||||
| } | } | ||||
| else if (x >= last[0]) { | else if (x >= last[0]) { | ||||
| if (use_curve_mapping_extend_extrapolate[table] == 0) { | if (use_curve_mapping_extend_extrapolate == 0) { | ||||
| /* no extrapolate */ | /* horizontal extrapolation */ | ||||
| return last[1]; | return last[1]; | ||||
| } | } | ||||
| else { | else { | ||||
| if (curve_mapping_ext_out_x[table] == 0.0) | if (curve_mapping_ext_out_x[table] == 0.0) | ||||
| return last[1] - curve_mapping_ext_out_y[table] * 10000.0; | return last[1] - curve_mapping_ext_out_y[table] * 10000.0; | ||||
| else | else | ||||
| return last[1] + | return last[1] + | ||||
| curve_mapping_ext_out_y[table] * (x - last[0]) / curve_mapping_ext_out_x[table]; | curve_mapping_ext_out_y[table] * (x - last[0]) / curve_mapping_ext_out_x[table]; | ||||
| ▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines | |||||