mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
motion blur
This commit is contained in:
@@ -55,16 +55,37 @@ void gl::framebuffer::clear(GLbitfield mask)
|
||||
glClear(mask);
|
||||
}
|
||||
|
||||
void gl::framebuffer::blit_to(framebuffer &other, int w, int h, GLbitfield mask)
|
||||
void gl::framebuffer::blit_to(framebuffer &other, int w, int h, GLbitfield mask, GLenum attachment)
|
||||
{
|
||||
other.clear(mask);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, *this);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other);
|
||||
if (mask & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glReadBuffer(attachment);
|
||||
glDrawBuffer(attachment);
|
||||
}
|
||||
glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, mask, GL_NEAREST);
|
||||
unbind();
|
||||
}
|
||||
|
||||
void gl::framebuffer::blit_from(framebuffer &other, int w, int h, GLbitfield mask)
|
||||
void gl::framebuffer::blit_from(framebuffer &other, int w, int h, GLbitfield mask, GLenum attachment)
|
||||
{
|
||||
other.blit_to(*this, w, h, mask);
|
||||
other.blit_to(*this, w, h, mask, attachment);
|
||||
}
|
||||
|
||||
void gl::framebuffer::setup_drawing(int attachments)
|
||||
{
|
||||
bind();
|
||||
GLenum a[8] =
|
||||
{
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_COLOR_ATTACHMENT1,
|
||||
GL_COLOR_ATTACHMENT2,
|
||||
GL_COLOR_ATTACHMENT3,
|
||||
GL_COLOR_ATTACHMENT4,
|
||||
GL_COLOR_ATTACHMENT5,
|
||||
GL_COLOR_ATTACHMENT6,
|
||||
GL_COLOR_ATTACHMENT7
|
||||
};
|
||||
glDrawBuffers(std::min(attachments, 8), &a[0]);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@ namespace gl
|
||||
void attach(const opengl_texture &tex, GLenum location);
|
||||
void attach(const cubemap &tex, int face, GLenum location);
|
||||
void attach(const renderbuffer &rb, GLenum location);
|
||||
void setup_drawing(int attachments);
|
||||
void detach(GLenum location);
|
||||
void clear(GLbitfield mask);
|
||||
|
||||
bool is_complete();
|
||||
void blit_to(framebuffer &other, int w, int h, GLbitfield mask);
|
||||
void blit_from(framebuffer &other, int w, int h, GLbitfield mask);
|
||||
void blit_to(framebuffer &other, int w, int h, GLbitfield mask, GLenum attachment);
|
||||
void blit_from(framebuffer &other, int w, int h, GLbitfield mask, GLenum attachment);
|
||||
|
||||
using bindable::bind;
|
||||
static void bind(GLuint id);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace gl
|
||||
mat3 modelviewnormal;
|
||||
vec4 param[MAX_PARAMS];
|
||||
|
||||
vec3 velocity;
|
||||
mat4 future;
|
||||
float opacity;
|
||||
float emission;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,11 @@ gl::postfx::postfx(const shader &s)
|
||||
}
|
||||
|
||||
void gl::postfx::apply(opengl_texture &src, framebuffer *dst)
|
||||
{
|
||||
apply({&src}, dst);
|
||||
}
|
||||
|
||||
void gl::postfx::apply(std::vector<opengl_texture *> src, framebuffer *dst)
|
||||
{
|
||||
if (dst)
|
||||
{
|
||||
@@ -33,8 +38,12 @@ void gl::postfx::apply(opengl_texture &src, framebuffer *dst)
|
||||
|
||||
program.bind();
|
||||
vao->bind();
|
||||
src.bind(0);
|
||||
|
||||
size_t unit = 0;
|
||||
for (opengl_texture *tex : src)
|
||||
tex->bind(unit++);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace gl
|
||||
public:
|
||||
postfx(const std::string &s);
|
||||
postfx(const shader &s);
|
||||
|
||||
void attach();
|
||||
void apply(opengl_texture &src, framebuffer *dst);
|
||||
void apply(std::vector<opengl_texture*> src, framebuffer *dst);
|
||||
};
|
||||
}
|
||||
|
||||
4
gl/ubo.h
4
gl/ubo.h
@@ -52,7 +52,7 @@ namespace gl
|
||||
glm::mat3x4 modelviewnormal;
|
||||
glm::vec4 param[MAX_PARAMS];
|
||||
|
||||
glm::vec3 velocity;
|
||||
glm::mat4 future;
|
||||
float opacity;
|
||||
float emission;
|
||||
UBS_PAD(12);
|
||||
@@ -64,7 +64,7 @@ namespace gl
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(model_ubs) == 144 + 16 * MAX_PARAMS, "bad size of ubs");
|
||||
static_assert(sizeof(model_ubs) == 196 + 16 * MAX_PARAMS, "bad size of ubs");
|
||||
|
||||
struct light_element_ubs
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user