Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/shaders/common_view_lib.glsl
- This file was moved from source/blender/draw/modes/shaders/common_view_lib.glsl.
| Show All 18 Lines | |||||
| }; | }; | ||||
| #ifdef world_clip_planes_calc_clip_distance | #ifdef world_clip_planes_calc_clip_distance | ||||
| # undef world_clip_planes_calc_clip_distance | # undef world_clip_planes_calc_clip_distance | ||||
| # define world_clip_planes_calc_clip_distance(p) \ | # define world_clip_planes_calc_clip_distance(p) \ | ||||
| _world_clip_planes_calc_clip_distance(p, clipPlanes) | _world_clip_planes_calc_clip_distance(p, clipPlanes) | ||||
| #endif | #endif | ||||
| #ifdef COMMON_GLOBALS_LIB | |||||
| float mul_project_m4_v3_zfac(in vec3 co) | |||||
| { | |||||
| return pixelFac * ((ViewProjectionMatrix[0][3] * co.x) + (ViewProjectionMatrix[1][3] * co.y) + | |||||
| (ViewProjectionMatrix[2][3] * co.z) + ViewProjectionMatrix[3][3]); | |||||
| } | |||||
| #endif | |||||
| /* Not the right place but need to be common to all overlay's. | |||||
| * TODO Split to an overlay lib. */ | |||||
| mat4 extract_matrix_packed_data(mat4 mat, out vec4 dataA, out vec4 dataB) | |||||
| { | |||||
| const float div_a = 1.0; | |||||
| const float div_b = 1.0 / 255.0; | |||||
| dataA = vec4(fract(mat[0][3]), mat[0][3] * div_b, fract(mat[1][3]), mat[1][3] * div_b); | |||||
| dataB = vec4(fract(mat[2][3]), mat[2][3] * div_b, fract(mat[3][3]), mat[3][3] * div_b); | |||||
| mat[0][3] = mat[1][3] = mat[2][3] = 0.0; | |||||
| mat[3][3] = 1.0; | |||||
| return mat; | |||||
| } | |||||
| uniform int resourceChunk; | uniform int resourceChunk; | ||||
| #ifdef GPU_VERTEX_SHADER | #ifdef GPU_VERTEX_SHADER | ||||
| # ifdef GL_ARB_shader_draw_parameters | # ifdef GL_ARB_shader_draw_parameters | ||||
| # define baseInstance gl_BaseInstanceARB | # define baseInstance gl_BaseInstanceARB | ||||
| # else /* no ARB_shader_draw_parameters */ | # else /* no ARB_shader_draw_parameters */ | ||||
| uniform int baseInstance; | uniform int baseInstance; | ||||
| # endif | # endif | ||||
| # ifdef IN_PLACE_INSTANCES | # if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTRIB) | ||||
| /* When drawing instances of an object at the same position. */ | /* When drawing instances of an object at the same position. */ | ||||
| # define instanceId 0 | # define instanceId 0 | ||||
| # elif defined(GPU_DEPRECATED_AMD_DRIVER) | # elif defined(GPU_DEPRECATED_AMD_DRIVER) | ||||
| /* A driver bug make it so that when using an attribute with GL_INT_2_10_10_10_REV as format, | /* A driver bug make it so that when using an attribute with GL_INT_2_10_10_10_REV as format, | ||||
| * the gl_InstanceID is incremented by the 2 bit component of the attrib. | * the gl_InstanceID is incremented by the 2 bit component of the attrib. | ||||
| * Ignore gl_InstanceID then. */ | * Ignore gl_InstanceID then. */ | ||||
| # define instanceId 0 | # define instanceId 0 | ||||
| # else | # else | ||||
| Show All 21 Lines | |||||
| # define PASS_RESOURCE_ID(i) resourceIDFrag = resource_id[i]; | # define PASS_RESOURCE_ID(i) resourceIDFrag = resource_id[i]; | ||||
| #endif | #endif | ||||
| #ifdef GPU_FRAGMENT_SHADER | #ifdef GPU_FRAGMENT_SHADER | ||||
| flat in int resourceIDFrag; | flat in int resourceIDFrag; | ||||
| # define resource_id resourceIDFrag | # define resource_id resourceIDFrag | ||||
| #endif | #endif | ||||
| #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) | #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && \ | ||||
| !defined(INSTANCED_ATTRIB) | |||||
| struct ObjectMatrices { | struct ObjectMatrices { | ||||
| mat4 drw_modelMatrix; | mat4 drw_modelMatrix; | ||||
| mat4 drw_modelMatrixInverse; | mat4 drw_modelMatrixInverse; | ||||
| }; | }; | ||||
| layout(std140) uniform modelBlock | layout(std140) uniform modelBlock | ||||
| { | { | ||||
| ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN]; | ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN]; | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| /* Due to some shader compiler bug, we somewhat need to access gl_VertexID | /* Due to some shader compiler bug, we somewhat need to access gl_VertexID | ||||
| * to make vertex shaders work. even if it's actually dead code. */ | * to make vertex shaders work. even if it's actually dead code. */ | ||||
| #ifdef GPU_INTEL | #ifdef GPU_INTEL | ||||
| # define GPU_INTEL_VERTEX_SHADER_WORKAROUND gl_Position.x = float(gl_VertexID); | # define GPU_INTEL_VERTEX_SHADER_WORKAROUND gl_Position.x = float(gl_VertexID); | ||||
| #else | #else | ||||
| # define GPU_INTEL_VERTEX_SHADER_WORKAROUND | # define GPU_INTEL_VERTEX_SHADER_WORKAROUND | ||||
| #endif | #endif | ||||
| #define DRW_BASE_SELECTED (1 << 1) | |||||
| #define DRW_BASE_FROM_DUPLI (1 << 2) | |||||
| #define DRW_BASE_FROM_SET (1 << 3) | |||||
| #define DRW_BASE_ACTIVE (1 << 4) | |||||