diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/draw/engines/eevee/shaders/default_world_frag.glsl | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/default_world_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/default_world_frag.glsl | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl index 7c00c9f3b73..0be2a8d6a12 100644 --- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl @@ -13,50 +13,51 @@ uniform sampler2D image; uniform float studioLightBackground = 1.0; in vec3 viewPosition; -#define M_PI 3.14159265358979323846 +# define M_PI 3.14159265358979323846 vec3 background_transform_to_world(vec3 viewvec) { - vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); - vec4 co_homogenous = (ProjectionMatrixInverse * v); + vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); + vec4 co_homogenous = (ProjectionMatrixInverse * v); - vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0); - return (ViewMatrixInverse * co).xyz; + vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0); + return (ViewMatrixInverse * co).xyz; } float hypot(float x, float y) { - return sqrt(x * x + y * y); + return sqrt(x * x + y * y); } vec4 node_tex_environment_equirectangular(vec3 co, sampler2D ima) { - vec3 nco = normalize(co); - float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5; - float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5; - - /* Fix pole bleeding */ - float width = float(textureSize(ima, 0).x); - float texel_width = 1.0 / width; - v = clamp(v, texel_width, 1.0 - texel_width); - - /* Fix u = 0 seam */ - /* This is caused by texture filtering, since uv don't have smooth derivatives - * at u = 0 or 2PI, hardware filtering is using the smallest mipmap for certain - * texels. So we force the highest mipmap and don't do anisotropic filtering. */ - return textureLod(ima, vec2(u, v), 0.0); + vec3 nco = normalize(co); + float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5; + float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5; + + /* Fix pole bleeding */ + float width = float(textureSize(ima, 0).x); + float texel_width = 1.0 / width; + v = clamp(v, texel_width, 1.0 - texel_width); + + /* Fix u = 0 seam */ + /* This is caused by texture filtering, since uv don't have smooth derivatives + * at u = 0 or 2PI, hardware filtering is using the smallest mipmap for certain + * texels. So we force the highest mipmap and don't do anisotropic filtering. */ + return textureLod(ima, vec2(u, v), 0.0); } #endif -void main() { - vec3 background_color; +void main() +{ + vec3 background_color; #ifdef LOOKDEV - vec3 worldvec = background_transform_to_world(viewPosition); - background_color = node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image).rgb; - background_color = mix(color, background_color, studioLightBackground); + vec3 worldvec = background_transform_to_world(viewPosition); + background_color = node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image).rgb; + background_color = mix(color, background_color, studioLightBackground); #else - background_color = color; + background_color = color; #endif - FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), 1.0) * backgroundAlpha; + FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), 1.0) * backgroundAlpha; } |