48 const int size[2] = {(int)viewport_size[0], (
int)viewport_size[1]};
51 float winmat[4][4], viewmat[4][4], viewinv[4][4];
68 float *pix_z = (rpass_z_src) ? rpass_z_src->
rect :
NULL;
69 float *pix_col = (rpass_col_src) ? rpass_col_src->
rect :
NULL;
71 if (!pix_z || !pix_col) {
73 "Warning: To render grease pencil, enable Combined and Z passes.");
80 int pix_ct = rpass_z_src->
rectx * rpass_z_src->
recty;
83 for (
int i = 0; i < pix_ct; i++) {
84 pix_z[i] = (-winmat[3][2] / -pix_z[i]) - winmat[2][2];
85 pix_z[i] =
clamp_f(pix_z[i] * 0.5f + 0.5f, 0.0f, 1.0f);
92 float range_inv = 1.0f /
fabsf(far - near);
93 for (
int i = 0; i < pix_ct; i++) {
94 pix_z[i] = (pix_z[i] + near) * range_inv;
95 pix_z[i] =
clamp_f(pix_z[i], 0.0f, 1.0f);
101 const bool do_clear_z = !pix_z || do_region;
102 const bool do_clear_col = !pix_col || do_region;
122 GPU_framebuffer_ensure_config(&fbl->
render_fb,
124 GPU_ATTACHMENT_TEXTURE(txl->render_depth_tx),
125 GPU_ATTACHMENT_TEXTURE(txl->render_color_tx),
128 if (do_clear_z || do_clear_col) {
132 const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
133 GPU_framebuffer_clear_color(fbl->
render_fb, clear_col);
136 GPU_framebuffer_clear_depth(fbl->
render_fb, 1.0f);
170 const char *viewname,
195 for (
int i = 0; i < pix_ct; i++) {
196 if (rp->
rect[i] == 1.0f) {
200 rp->
rect[i] = rp->
rect[i] * 2.0f - 1.0f;
201 rp->
rect[i] = winmat[3][2] / (rp->
rect[i] + winmat[2][2]);
209 float range =
fabsf(far - near);
211 for (
int i = 0; i < pix_ct; i++) {
212 if (rp->
rect[i] == 1.0f) {
216 rp->
rect[i] = rp->
rect[i] * range - near;
224 const char *viewname,
General operations, lookup, etc. for blender objects.
MINLINE float clamp_f(float value, float min, float max)
bool invert_m4_m4(float R[4][4], const float A[4][4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
struct Depsgraph Depsgraph
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define RE_PASSNAME_COMBINED
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void GPU_texture_update_sub(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const Depsgraph * depsgraph
void DRW_render_instance_buffer_finish(void)
int DRW_object_visibility_in_active_context(const Object *ob)
const DRWContextState * DRW_context_state_get(void)
const float * DRW_viewport_size_get(void)
void DRW_render_object_iter(void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph, void(*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph))
float DRW_view_near_distance_get(const DRWView *view)
bool DRW_view_is_persp_get(const DRWView *view)
void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse)
DRWView * DRW_view_create(const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4], DRWCallVisibilityFn *visibility_fn)
float DRW_view_far_distance_get(const DRWView *view)
void DRW_view_default_set(DRWView *view)
void DRW_view_set_active(DRWView *view)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
void GPENCIL_cache_populate(void *ved, Object *ob)
void GPENCIL_draw_scene(void *ved)
void GPENCIL_cache_init(void *ved)
void GPENCIL_cache_finish(void *ved)
void GPENCIL_engine_init(void *ved)
static void GPENCIL_render_result_combined(struct RenderLayer *rl, const char *viewname, GPENCIL_Data *vedata, const rcti *rect)
static void GPENCIL_render_result_z(struct RenderLayer *rl, const char *viewname, GPENCIL_Data *vedata, const rcti *rect)
void GPENCIL_render_init(GPENCIL_Data *vedata, RenderEngine *engine, struct RenderLayer *render_layer, const Depsgraph *depsgraph, const rcti *rect)
static void GPENCIL_render_cache(void *vedata, struct Object *ob, struct RenderEngine *UNUSED(engine), Depsgraph *UNUSED(depsgraph))
void GPENCIL_render_to_image(void *ved, RenderEngine *engine, struct RenderLayer *render_layer, const rcti *rect)
void GPU_framebuffer_read_color(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
void GPU_framebuffer_read_depth(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, eGPUDataFormat format, void *data)
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4])
void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_modelmat[4][4])
struct Object * RE_GetCamera(Render *re)
void *(* MEM_dupallocN)(const void *vmemh)
RenderPass * RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, const char *viewname)
const char * RE_GetActiveRenderView(Render *re)
struct Depsgraph * depsgraph
struct ViewLayer * view_layer
struct GPENCIL_TextureList * txl
struct GPENCIL_StorageList * stl
struct GPENCIL_FramebufferList * fbl
struct GPUFrameBuffer * render_fb
struct GPENCIL_PrivateData * pd
struct GPUTexture * render_depth_tx
struct GPUTexture * render_color_tx