Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
| Show All 14 Lines | |||||
| /* Keep these in sync with GPU_basic_shader.h */ | /* Keep these in sync with GPU_basic_shader.h */ | ||||
| #define STIPPLE_HALFTONE 0 | #define STIPPLE_HALFTONE 0 | ||||
| #define STIPPLE_QUARTTONE 1 | #define STIPPLE_QUARTTONE 1 | ||||
| #define STIPPLE_CHECKER_8PX 2 | #define STIPPLE_CHECKER_8PX 2 | ||||
| #define STIPPLE_HEXAGON 3 | #define STIPPLE_HEXAGON 3 | ||||
| #define STIPPLE_DIAG_STRIPES 4 | #define STIPPLE_DIAG_STRIPES 4 | ||||
| #define STIPPLE_DIAG_STRIPES_SWAP 5 | #define STIPPLE_DIAG_STRIPES_SWAP 5 | ||||
| #define STIPPLE_S3D_INTERLACE_ROW 6 | |||||
| #define STIPPLE_S3D_INTERLACE_ROW_SWAP 7 | |||||
| #define STIPPLE_S3D_INTERLACE_COLUMN 8 | |||||
| #define STIPPLE_S3D_INTERLACE_COLUMN_SWAP 9 | |||||
| #define STIPPLE_S3D_INTERLACE_CHECKERBOARD 10 | |||||
| #define STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP 11 | |||||
| #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING) | #if defined(USE_SOLID_LIGHTING) || defined(USE_SCENE_LIGHTING) | ||||
| #if defined(USE_FLAT_NORMAL) | #if defined(USE_FLAT_NORMAL) | ||||
| varying vec3 eyespace_vert_pos; | varying vec3 eyespace_vert_pos; | ||||
| #else | #else | ||||
| varying vec3 varying_normal; | varying vec3 varying_normal; | ||||
| #endif | #endif | ||||
| #ifndef USE_SOLID_LIGHTING | #ifndef USE_SOLID_LIGHTING | ||||
| Show All 32 Lines | |||||
| #if defined(DRAW_LINE) | #if defined(DRAW_LINE) | ||||
| /* GLSL 1.3 */ | /* GLSL 1.3 */ | ||||
| if (!bool((1 << int(mod(t, 16))) & stipple_pattern)) | if (!bool((1 << int(mod(t, 16))) & stipple_pattern)) | ||||
| discard; | discard; | ||||
| #else | #else | ||||
| /* We have to use mod function and integer casting. | /* We have to use mod function and integer casting. | ||||
| * This can be optimized further with the bitwise operations | * This can be optimized further with the bitwise operations | ||||
| * when GLSL 1.3 is supported. */ | * when GLSL 1.3 is supported. */ | ||||
| if (stipple_id == STIPPLE_HALFTONE || | if (stipple_id == STIPPLE_HALFTONE) { | ||||
| stipple_id == STIPPLE_S3D_INTERLACE_CHECKERBOARD || | |||||
| stipple_id == STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP) | |||||
| { | |||||
| int result = int(mod(gl_FragCoord.x + gl_FragCoord.y, 2)); | int result = int(mod(gl_FragCoord.x + gl_FragCoord.y, 2)); | ||||
| bool dis = result == 0; | bool dis = result == 0; | ||||
| if (stipple_id == STIPPLE_S3D_INTERLACE_CHECKERBOARD_SWAP) | |||||
| dis = !dis; | |||||
| if (dis) | if (dis) | ||||
| discard; | discard; | ||||
| } | } | ||||
| else if (stipple_id == STIPPLE_QUARTTONE) { | else if (stipple_id == STIPPLE_QUARTTONE) { | ||||
| int mody = int(mod(gl_FragCoord.y, 4)); | int mody = int(mod(gl_FragCoord.y, 4)); | ||||
| int modx = int(mod(gl_FragCoord.x, 4)); | int modx = int(mod(gl_FragCoord.x, 4)); | ||||
| if (mody == 0) { | if (mody == 0) { | ||||
| if (modx != 2) | if (modx != 2) | ||||
| Show All 18 Lines | if ((16 - modx > mody && mody > 8 - modx) || mody > 24 - modx) | ||||
| discard; | discard; | ||||
| } | } | ||||
| else if (stipple_id == STIPPLE_DIAG_STRIPES_SWAP) { | else if (stipple_id == STIPPLE_DIAG_STRIPES_SWAP) { | ||||
| int mody = int(mod(gl_FragCoord.y, 16)); | int mody = int(mod(gl_FragCoord.y, 16)); | ||||
| int modx = int(mod(gl_FragCoord.x, 16)); | int modx = int(mod(gl_FragCoord.x, 16)); | ||||
| if (!((16 - modx > mody && mody > 8 - modx) || mody > 24 - modx)) | if (!((16 - modx > mody && mody > 8 - modx) || mody > 24 - modx)) | ||||
| discard; | discard; | ||||
| } | } | ||||
| else if (stipple_id == STIPPLE_S3D_INTERLACE_ROW || stipple_id == STIPPLE_S3D_INTERLACE_ROW_SWAP) { | |||||
| int result = int(mod(gl_FragCoord.y, 2)); | |||||
| bool dis = result == 0; | |||||
| if (stipple_id == STIPPLE_S3D_INTERLACE_ROW_SWAP) | |||||
| dis = !dis; | |||||
| if (dis) | |||||
| discard; | |||||
| } | |||||
| else if (stipple_id == STIPPLE_S3D_INTERLACE_COLUMN || stipple_id == STIPPLE_S3D_INTERLACE_COLUMN_SWAP) { | |||||
| int result = int(mod(gl_FragCoord.x, 2)); | |||||
| bool dis = result != 0; | |||||
| if (stipple_id == STIPPLE_S3D_INTERLACE_COLUMN_SWAP) | |||||
| dis = !dis; | |||||
| if (dis) | |||||
| discard; | |||||
| } | |||||
| else if (stipple_id == STIPPLE_HEXAGON) { | else if (stipple_id == STIPPLE_HEXAGON) { | ||||
| int mody = int(mod(gl_FragCoord.y, 2)); | int mody = int(mod(gl_FragCoord.y, 2)); | ||||
| int modx = int(mod(gl_FragCoord.x, 4)); | int modx = int(mod(gl_FragCoord.x, 4)); | ||||
| if (mody != 0) { | if (mody != 0) { | ||||
| if (modx != 1) | if (modx != 1) | ||||
| discard; | discard; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines | |||||