Draw Manager: Created a general fullscreen shader.
This commit is contained in:
parent
cf62424e47
commit
8cad48df28
|
@ -169,6 +169,7 @@ void DRW_framebuffer_blit(struct GPUFrameBuffer *fb_read, struct GPUFrameBuffer
|
|||
struct GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *frag, const char *defines);
|
||||
struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines);
|
||||
struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines);
|
||||
struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines);
|
||||
struct GPUShader *DRW_shader_create_3D_depth_only(void);
|
||||
void DRW_shader_free(struct GPUShader *shader);
|
||||
|
||||
|
|
|
@ -251,30 +251,26 @@ static VertexBuffer *sphere_wire_vbo(const float rad)
|
|||
Batch *DRW_cache_fullscreen_quad_get(void)
|
||||
{
|
||||
if (!SHC.drw_fullscreen_quad) {
|
||||
float v1[2] = {-1.0f, -1.0f};
|
||||
float v2[2] = { 1.0f, -1.0f};
|
||||
float v3[2] = {-1.0f, 1.0f};
|
||||
float v4[2] = { 1.0f, 1.0f};
|
||||
float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {-1.0f, 1.0f}, { 1.0f, 1.0f}};
|
||||
float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, { 0.0f, 1.0f}, { 1.0f, 1.0f}};
|
||||
|
||||
/* Position Only 2D format */
|
||||
static VertexFormat format = { 0 };
|
||||
static unsigned pos_id;
|
||||
static unsigned pos_id, uvs_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
pos_id = add_attrib(&format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
uvs_id = add_attrib(&format, "uvs", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
}
|
||||
|
||||
VertexBuffer *vbo = VertexBuffer_create_with_format(&format);
|
||||
VertexBuffer_allocate_data(vbo, 6);
|
||||
VertexBuffer_allocate_data(vbo, 4);
|
||||
|
||||
setAttrib(vbo, pos_id, 0, v1);
|
||||
setAttrib(vbo, pos_id, 1, v2);
|
||||
setAttrib(vbo, pos_id, 2, v3);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
setAttrib(vbo, pos_id, i, pos[i]);
|
||||
setAttrib(vbo, uvs_id, i, uvs[i]);
|
||||
}
|
||||
|
||||
setAttrib(vbo, pos_id, 3, v2);
|
||||
setAttrib(vbo, pos_id, 4, v3);
|
||||
setAttrib(vbo, pos_id, 5, v4);
|
||||
|
||||
SHC.drw_fullscreen_quad = Batch_create(GL_TRIANGLES, vbo, NULL);
|
||||
SHC.drw_fullscreen_quad = Batch_create(GL_TRIANGLE_STRIP, vbo, NULL);
|
||||
}
|
||||
return SHC.drw_fullscreen_quad;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
extern char datatoc_gpu_shader_2D_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
|
||||
|
||||
/* Structures */
|
||||
typedef enum {
|
||||
|
@ -315,6 +316,11 @@ GPUShader *DRW_shader_create_3D(const char *frag, const char *defines)
|
|||
return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines, 0, 0, 0);
|
||||
}
|
||||
|
||||
GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines)
|
||||
{
|
||||
return GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, frag, NULL, NULL, defines, 0, 0, 0);
|
||||
}
|
||||
|
||||
GPUShader *DRW_shader_create_3D_depth_only(void)
|
||||
{
|
||||
return GPU_shader_get_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY);
|
||||
|
|
|
@ -166,8 +166,7 @@ static void EDIT_MESH_engine_init(void)
|
|||
datatoc_edit_overlay_facedot_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_mix_sh) {
|
||||
overlay_mix_sh = DRW_shader_create(datatoc_edit_overlay_mix_vert_glsl, NULL,
|
||||
datatoc_edit_overlay_mix_frag_glsl, NULL);
|
||||
overlay_mix_sh = DRW_shader_create_fullscreen(datatoc_edit_overlay_mix_frag_glsl, NULL);
|
||||
}
|
||||
if (!overlay_facefill_sh) {
|
||||
overlay_facefill_sh = DRW_shader_create(datatoc_edit_overlay_facefill_vert_glsl, NULL,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
in vec4 uvcoordsvar;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D wireColor;
|
||||
|
@ -8,10 +10,9 @@ uniform float alpha;
|
|||
|
||||
void main()
|
||||
{
|
||||
ivec2 co = ivec2(gl_FragCoord.xy);
|
||||
float wire_depth = texelFetch(wireDepth, co, 0).r;
|
||||
float scene_depth = texelFetch(sceneDepth, co, 0).r;
|
||||
vec4 wire_color = texelFetch(wireColor, co, 0).rgba;
|
||||
float wire_depth = texelFetch(wireDepth, uvcoordsvar, 0).r;
|
||||
float scene_depth = texelFetch(sceneDepth, uvcoordsvar, 0).r;
|
||||
vec4 wire_color = texelFetch(wireColor, uvcoordsvar, 0).rgba;
|
||||
|
||||
FragColor = wire_color;
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
}
|
|
@ -78,7 +78,7 @@ set(SRC
|
|||
shaders/gpu_shader_fx_dof_hq_frag.glsl
|
||||
shaders/gpu_shader_fx_dof_hq_vert.glsl
|
||||
shaders/gpu_shader_fx_dof_hq_geo.glsl
|
||||
shaders/gpu_shader_fx_vert.glsl
|
||||
shaders/gpu_shader_fullscreen_vert.glsl
|
||||
shaders/gpu_shader_material.glsl
|
||||
shaders/gpu_shader_sep_gaussian_blur_frag.glsl
|
||||
shaders/gpu_shader_sep_gaussian_blur_vert.glsl
|
||||
|
@ -202,7 +202,7 @@ data_to_c_simple(shaders/gpu_shader_vertex.glsl SRC)
|
|||
data_to_c_simple(shaders/gpu_shader_vertex_world.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_vsm_store_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_vsm_store_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_fx_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_fullscreen_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_fx_ssao_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_fx_dof_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_fx_dof_vert.glsl SRC)
|
||||
|
|
|
@ -126,7 +126,7 @@ extern char datatoc_gpu_shader_vsm_store_vert_glsl[];
|
|||
extern char datatoc_gpu_shader_vsm_store_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_sep_gaussian_blur_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_sep_gaussian_blur_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_fx_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_fx_ssao_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_fx_dof_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_fx_dof_vert_glsl[];
|
||||
|
@ -827,7 +827,7 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effect, bool persp)
|
|||
|
||||
switch (effect) {
|
||||
case GPU_SHADER_FX_SSAO:
|
||||
shader = GPU_shader_create(datatoc_gpu_shader_fx_vert_glsl, datatoc_gpu_shader_fx_ssao_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
|
||||
shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_ssao_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_ONE:
|
||||
|
@ -872,7 +872,7 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effect, bool persp)
|
|||
break;
|
||||
|
||||
case GPU_SHADER_FX_DEPTH_RESOLVE:
|
||||
shader = GPU_shader_create(datatoc_gpu_shader_fx_vert_glsl, datatoc_gpu_shader_fx_depth_resolve_glsl, NULL, NULL, defines, 0, 0, 0);
|
||||
shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_depth_resolve_glsl, NULL, NULL, defines, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue