Differential D17089 Diff 60052 source/blender/draw/engines/overlay/shaders/overlay_background_frag.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/overlay_background_frag.glsl
| #pragma BLENDER_REQUIRE(common_math_lib.glsl) | #pragma BLENDER_REQUIRE(common_math_lib.glsl) | ||||
| /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ | /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ | ||||
| #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) | #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) | ||||
| float dither(void) | |||||
| { | |||||
| /* NOTE(Metal): Declaring constant array in function scope to avoid increasing local shader | |||||
| * memory pressure. */ | |||||
| const vec4 dither_mat4x4[4] = vec4[4](vec4(P(0.0), P(8.0), P(2.0), P(10.0)), | const vec4 dither_mat4x4[4] = vec4[4](vec4(P(0.0), P(8.0), P(2.0), P(10.0)), | ||||
| vec4(P(12.0), P(4.0), P(14.0), P(6.0)), | vec4(P(12.0), P(4.0), P(14.0), P(6.0)), | ||||
| vec4(P(3.0), P(11.0), P(1.0), P(9.0)), | vec4(P(3.0), P(11.0), P(1.0), P(9.0)), | ||||
| vec4(P(15.0), P(7.0), P(13.0), P(5.0))); | vec4(P(15.0), P(7.0), P(13.0), P(5.0))); | ||||
| float dither(void) | |||||
| { | |||||
| ivec2 co = ivec2(gl_FragCoord.xy) % 4; | ivec2 co = ivec2(gl_FragCoord.xy) % 4; | ||||
| return dither_mat4x4[co.x][co.y]; | return dither_mat4x4[co.x][co.y]; | ||||
| } | } | ||||
| void main() | void main() | ||||
| { | { | ||||
| /* The blend equation is: | /* The blend equation is: | ||||
| * `result.rgb = SRC.rgb * (1 - DST.a) + DST.rgb * (SRC.a)` | * `result.rgb = SRC.rgb * (1 - DST.a) + DST.rgb * (SRC.a)` | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||