diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-06-27 08:32:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-27 08:36:28 +0300 |
commit | 5181f085eb67a8ea2e0c4009adbbe5ae82b61919 (patch) | |
tree | b3bbf1b3524e20fd1c979446917f3bbab80114c2 /source/blender | |
parent | 936c176a7137eb58900236e134c3ad5615e30b02 (diff) |
Fix T48733: World background fails in 3d-view
Missing from fix for T48555.
Unfortunately duplicates code.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_vertex.glsl | 6 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_vertex_world.glsl | 68 |
2 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl index 9a6537b4f09..db0068d2f3d 100644 --- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl +++ b/source/blender/gpu/shaders/gpu_shader_vertex.glsl @@ -14,6 +14,9 @@ varying vec3 varnormal; varying float gl_ClipDistance[6]; #endif + +/* Color, keep in sync with: gpu_shader_vertex_world.glsl */ + float srgb_to_linearrgb(float c) { if (c < 0.04045) @@ -76,6 +79,9 @@ void set_var_from_attr(vec4 attr, int info, out vec4 var) } } +/* end color code */ + + void main() { #ifndef USE_OPENSUBDIV diff --git a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl index 9dbcaeb7a32..d45a4b316a8 100644 --- a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl +++ b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl @@ -2,6 +2,74 @@ varying vec3 varposition; varying vec3 varnormal; + +/* Color, keep in sync with: gpu_shader_vertex.glsl */ + +float srgb_to_linearrgb(float c) +{ + if (c < 0.04045) + return (c < 0.0) ? 0.0 : c * (1.0 / 12.92); + else + return pow((c + 0.055) * (1.0 / 1.055), 2.4); +} + +void srgb_to_linearrgb(vec3 col_from, out vec3 col_to) +{ + col_to.r = srgb_to_linearrgb(col_from.r); + col_to.g = srgb_to_linearrgb(col_from.g); + col_to.b = srgb_to_linearrgb(col_from.b); +} + +void srgb_to_linearrgb(vec4 col_from, out vec4 col_to) +{ + col_to.r = srgb_to_linearrgb(col_from.r); + col_to.g = srgb_to_linearrgb(col_from.g); + col_to.b = srgb_to_linearrgb(col_from.b); + col_to.a = col_from.a; +} + +bool is_srgb(int info) +{ +#ifdef USE_NEW_SHADING + return (info == 1)? true: false; +#else + return false; +#endif +} + +void set_var_from_attr(float attr, int info, out float var) +{ + var = attr; +} + +void set_var_from_attr(vec2 attr, int info, out vec2 var) +{ + var = attr; +} + +void set_var_from_attr(vec3 attr, int info, out vec3 var) +{ + if (is_srgb(info)) { + srgb_to_linearrgb(attr, var); + } + else { + var = attr; + } +} + +void set_var_from_attr(vec4 attr, int info, out vec4 var) +{ + if (is_srgb(info)) { + srgb_to_linearrgb(attr, var); + } + else { + var = attr; + } +} + +/* end color code */ + + void main() { /* position does not need to be transformed, we already have it */ |