diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-03-22 23:26:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-03-22 23:29:23 +0300 |
commit | 26c140fbc85c6cee4ce7548873c38e6ce2f24c8b (patch) | |
tree | 2162a3ee3c74d1394b14efc79ceb64c458d95139 /source/blender/draw/modes | |
parent | 4646ecf74917d5cee0a4f0d330a1306acd086a61 (diff) |
Draw Module: Move the Global Ubo block definition to it's own file.
Diffstat (limited to 'source/blender/draw/modes')
9 files changed, 96 insertions, 323 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index e1016c87c1d..45d32d70bbc 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -49,6 +49,7 @@ extern char datatoc_edit_overlay_facefill_vert_glsl[]; extern char datatoc_edit_overlay_facefill_frag_glsl[]; extern char datatoc_edit_normals_vert_glsl[]; extern char datatoc_edit_normals_geom_glsl[]; +extern char datatoc_common_globals_lib_glsl[]; extern char datatoc_gpu_shader_uniform_color_frag_glsl[]; @@ -138,58 +139,69 @@ static void EDIT_MESH_engine_init(void) tex, 2); if (!e_data.overlay_tri_sh) { - e_data.overlay_tri_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_tri_glsl, - datatoc_edit_overlay_frag_glsl, "#define EDGE_FIX\n"); + e_data.overlay_tri_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_tri_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, "#define EDGE_FIX\n"); } if (!e_data.overlay_tri_fast_sh) { - e_data.overlay_tri_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_tri_glsl, - datatoc_edit_overlay_frag_glsl, NULL); + e_data.overlay_tri_fast_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_tri_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, NULL); } if (!e_data.overlay_tri_vcol_sh) { - e_data.overlay_tri_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_tri_glsl, - datatoc_edit_overlay_frag_glsl, "#define EDGE_FIX\n" - "#define VERTEX_SELECTION\n"); + e_data.overlay_tri_vcol_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_tri_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, "#define EDGE_FIX\n" + "#define VERTEX_SELECTION\n"); } if (!e_data.overlay_tri_vcol_fast_sh) { - e_data.overlay_tri_vcol_fast_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_tri_glsl, - datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n"); + e_data.overlay_tri_vcol_fast_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_tri_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, "#define VERTEX_SELECTION\n"); } if (!e_data.overlay_edge_sh) { - e_data.overlay_edge_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_edge_glsl, - datatoc_edit_overlay_frag_glsl, NULL); + e_data.overlay_edge_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_edge_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, NULL); } if (!e_data.overlay_edge_vcol_sh) { - e_data.overlay_edge_vcol_sh = DRW_shader_create(datatoc_edit_overlay_vert_glsl, - datatoc_edit_overlay_geom_edge_glsl, - datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n"); + e_data.overlay_edge_vcol_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_vert_glsl, + datatoc_edit_overlay_geom_edge_glsl, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, "#define VERTEX_SELECTION\n"); } if (!e_data.overlay_vert_sh) { - e_data.overlay_vert_sh = DRW_shader_create(datatoc_edit_overlay_loosevert_vert_glsl, NULL, - datatoc_edit_overlay_frag_glsl, "#define VERTEX_SELECTION\n"); + e_data.overlay_vert_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_loosevert_vert_glsl, NULL, + datatoc_edit_overlay_frag_glsl, + datatoc_common_globals_lib_glsl, "#define VERTEX_SELECTION\n"); } if (!e_data.overlay_facedot_sh) { - e_data.overlay_facedot_sh = DRW_shader_create(datatoc_edit_overlay_facedot_vert_glsl, NULL, - datatoc_edit_overlay_facedot_frag_glsl, NULL); + e_data.overlay_facedot_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_facedot_vert_glsl, NULL, + datatoc_edit_overlay_facedot_frag_glsl, + datatoc_common_globals_lib_glsl, NULL); } if (!e_data.overlay_mix_sh) { e_data.overlay_mix_sh = DRW_shader_create_fullscreen(datatoc_edit_overlay_mix_frag_glsl, NULL); } if (!e_data.overlay_facefill_sh) { - e_data.overlay_facefill_sh = DRW_shader_create(datatoc_edit_overlay_facefill_vert_glsl, NULL, - datatoc_edit_overlay_facefill_frag_glsl, NULL); + e_data.overlay_facefill_sh = DRW_shader_create_with_lib(datatoc_edit_overlay_facefill_vert_glsl, NULL, + datatoc_edit_overlay_facefill_frag_glsl, + datatoc_common_globals_lib_glsl, NULL); } if (!e_data.normals_face_sh) { - e_data.normals_face_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl, "#define FACE_NORMALS\n"); + e_data.normals_face_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, + datatoc_edit_normals_geom_glsl, + datatoc_gpu_shader_uniform_color_frag_glsl, "#define FACE_NORMALS\n"); } if (!e_data.normals_sh) { - e_data.normals_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, datatoc_edit_normals_geom_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl, NULL); + e_data.normals_sh = DRW_shader_create(datatoc_edit_normals_vert_glsl, + datatoc_edit_normals_geom_glsl, + datatoc_gpu_shader_uniform_color_frag_glsl, NULL); } if (!e_data.depth_sh) { e_data.depth_sh = DRW_shader_create_3D_depth_only(); diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl new file mode 100644 index 00000000000..579a5f5089b --- /dev/null +++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl @@ -0,0 +1,55 @@ + +/* keep in sync with GlobalsUboStorage */ +layout(std140) uniform globalsBlock { + vec4 colorWire; + vec4 colorWireEdit; + vec4 colorActive; + vec4 colorSelect; + vec4 colorTransform; + vec4 colorGroupActive; + vec4 colorGroup; + vec4 colorLamp; + vec4 colorSpeaker; + vec4 colorCamera; + vec4 colorEmpty; + vec4 colorVertex; + vec4 colorVertexSelect; + vec4 colorEditMeshActive; + vec4 colorEdgeSelect; + vec4 colorEdgeSeam; + vec4 colorEdgeSharp; + vec4 colorEdgeCrease; + vec4 colorEdgeBWeight; + vec4 colorEdgeFaceSelect; + vec4 colorFace; + vec4 colorFaceSelect; + vec4 colorNormal; + vec4 colorVNormal; + vec4 colorLNormal; + vec4 colorFaceDot; + + vec4 colorDeselect; + vec4 colorOutline; + vec4 colorLampNoAlpha; + + vec4 colorBackground; + + vec4 colorGrid; + vec4 colorGridEmphasise; + vec4 colorGridAxisX; + vec4 colorGridAxisY; + vec4 colorGridAxisZ; + + float sizeLampCenter; + float sizeLampCircle; + float sizeLampCircleShadow; + float sizeVertex; + float sizeEdge; + float sizeEdgeFix; + float sizeFaceDot; + + float gridDistance; + float gridResolution; + float gridSubdivisions; + float gridScale; +}; diff --git a/source/blender/draw/modes/shaders/edit_overlay_facedot_frag.glsl b/source/blender/draw/modes/shaders/edit_overlay_facedot_frag.glsl index 316f532ab1e..9b3fe6286e8 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_facedot_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_facedot_frag.glsl @@ -1,46 +1,4 @@ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - flat in int isSelected; out vec4 FragColor; diff --git a/source/blender/draw/modes/shaders/edit_overlay_facedot_vert.glsl b/source/blender/draw/modes/shaders/edit_overlay_facedot_vert.glsl index 76c6cadc988..2e541fa75e6 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_facedot_vert.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_facedot_vert.glsl @@ -1,46 +1,4 @@ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - uniform mat4 ModelViewProjectionMatrix; in vec3 pos; diff --git a/source/blender/draw/modes/shaders/edit_overlay_facefill_vert.glsl b/source/blender/draw/modes/shaders/edit_overlay_facefill_vert.glsl index 7c51f4108d9..5755ba40951 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_facefill_vert.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_facefill_vert.glsl @@ -1,48 +1,6 @@ uniform mat4 ModelViewProjectionMatrix; -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - in vec3 pos; in ivec4 data; diff --git a/source/blender/draw/modes/shaders/edit_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_overlay_frag.glsl index a08be7ec502..cca1a2cc8e5 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_frag.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_frag.glsl @@ -5,48 +5,6 @@ /* This shader follows the principles of * http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - uniform float faceAlphaMod; flat in vec3 edgesCrease; diff --git a/source/blender/draw/modes/shaders/edit_overlay_geom_edge.glsl b/source/blender/draw/modes/shaders/edit_overlay_geom_edge.glsl index 44971a5dd2d..ddeecf12bd6 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_geom_edge.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_geom_edge.glsl @@ -5,48 +5,6 @@ /* This shader follows the principles of * http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - layout(lines) in; layout(triangle_strip, max_vertices=6) out; diff --git a/source/blender/draw/modes/shaders/edit_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_overlay_geom_tri.glsl index 5310d12f3b5..41aade3d3c7 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_geom_tri.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_geom_tri.glsl @@ -5,48 +5,6 @@ /* This shader follows the principles of * http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - layout(triangles) in; #ifdef EDGE_FIX diff --git a/source/blender/draw/modes/shaders/edit_overlay_loosevert_vert.glsl b/source/blender/draw/modes/shaders/edit_overlay_loosevert_vert.glsl index 5ffaf02297d..3ff76a77da2 100644 --- a/source/blender/draw/modes/shaders/edit_overlay_loosevert_vert.glsl +++ b/source/blender/draw/modes/shaders/edit_overlay_loosevert_vert.glsl @@ -5,48 +5,6 @@ /* This shader follows the principles of * http://developer.download.nvidia.com/SDK/10/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf */ -/* keep in sync with GlobalsUboStorage */ -layout(std140) uniform globalsBlock { - vec4 colorWire; - vec4 colorWireEdit; - vec4 colorActive; - vec4 colorSelect; - vec4 colorTransform; - vec4 colorGroupActive; - vec4 colorGroup; - vec4 colorLamp; - vec4 colorSpeaker; - vec4 colorCamera; - vec4 colorEmpty; - vec4 colorVertex; - vec4 colorVertexSelect; - vec4 colorEditMeshActive; - vec4 colorEdgeSelect; - vec4 colorEdgeSeam; - vec4 colorEdgeSharp; - vec4 colorEdgeCrease; - vec4 colorEdgeBWeight; - vec4 colorEdgeFaceSelect; - vec4 colorFace; - vec4 colorFaceSelect; - vec4 colorNormal; - vec4 colorVNormal; - vec4 colorLNormal; - vec4 colorFaceDot; - - vec4 colorDeselect; - vec4 colorOutline; - vec4 colorLampNoAlpha; - - float sizeLampCenter; - float sizeLampCircle; - float sizeLampCircleShadow; - float sizeVertex; - float sizeEdge; - float sizeEdgeFix; - float sizeFaceDot; -}; - uniform mat4 ModelViewProjectionMatrix; uniform vec2 viewportSize; |