35 const int size[2] = {
int(viewport_size[0]),
int(viewport_size[1])};
38 float winmat[4][4], viewmat[4][4], viewinv[4][4];
58 if (!pix_z || !pix_col) {
60 "Warning: To render grease pencil, enable Combined and Z passes.");
67 int pix_num = rpass_z_src->
rectx * rpass_z_src->
recty;
70 for (
int i = 0; i < pix_num; i++) {
71 pix_z[i] = (-winmat[3][2] / -pix_z[i]) - winmat[2][2];
72 pix_z[i] =
clamp_f(pix_z[i] * 0.5f + 0.5f, 0.0f, 1.0f);
79 float range_inv = 1.0f /
fabsf(far - near);
80 for (
int i = 0; i < pix_num; i++) {
81 pix_z[i] = (pix_z[i] + near) * range_inv;
82 pix_z[i] =
clamp_f(pix_z[i], 0.0f, 1.0f);
87 const bool do_region = (scene->r.mode &
R_BORDER) != 0;
88 const bool do_clear_z = !pix_z || do_region;
89 const bool do_clear_col = !pix_col || do_region;
111 GPU_ATTACHMENT_TEXTURE(txl->render_depth_tx),
112 GPU_ATTACHMENT_TEXTURE(txl->render_color_tx),
115 if (do_clear_z || do_clear_col) {
119 const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
157 const char *viewname,
188 for (
int i = 0; i < pix_num; i++) {
189 if (ro_buffer_data[i] == 1.0f) {
190 ro_buffer_data[i] = 1e10f;
193 ro_buffer_data[i] = ro_buffer_data[i] * 2.0f - 1.0f;
194 ro_buffer_data[i] = winmat[3][2] / (ro_buffer_data[i] + winmat[2][2]);
202 float range =
fabsf(far - near);
204 for (
int i = 0; i < pix_num; i++) {
205 if (ro_buffer_data[i] == 1.0f) {
206 ro_buffer_data[i] = 1e10f;
209 ro_buffer_data[i] = ro_buffer_data[i] * range - near;
216 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 inverse[4][4], const float mat[4][4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define RE_PASSNAME_COMBINED
void GPU_framebuffer_read_depth(GPUFrameBuffer *framebuffer, int x, int y, int width, int height, eGPUDataFormat data_format, void *r_data)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_read_color(GPUFrameBuffer *framebuffer, int x, int y, int width, int height, int channels, int slot, eGPUDataFormat data_format, void *r_data)
void GPU_framebuffer_clear_color(GPUFrameBuffer *fb, const float clear_col[4])
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_framebuffer_clear_depth(GPUFrameBuffer *fb, float clear_depth)
void GPU_texture_update_sub(GPUTexture *texture, 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 *texture, eGPUDataFormat data_format, const void *data)
Contains defines and structs used throughout the imbuf module.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const Depsgraph * depsgraph
const float * DRW_viewport_size_get()
void DRW_render_instance_buffer_finish()
int DRW_object_visibility_in_active_context(const Object *ob)
const DRWContextState * DRW_context_state_get()
void DRW_render_object_iter(void *vedata, RenderEngine *engine, Depsgraph *depsgraph, void(*callback)(void *vedata, Object *ob, RenderEngine *engine, 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)
float DRW_view_far_distance_get(const DRWView *view)
void DRW_view_default_set(const DRWView *view)
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)
void DRW_view_set_active(const DRWView *view)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void GPENCIL_engine_init(void *vedata)
void GPENCIL_cache_init(void *vedata)
void GPENCIL_cache_finish(void *vedata)
void GPENCIL_cache_populate(void *vedata, struct Object *ob)
void GPENCIL_draw_scene(void *vedata)
void GPENCIL_render_to_image(void *ved, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect)
static void GPENCIL_render_cache(void *vedata, Object *ob, RenderEngine *, Depsgraph *)
static void GPENCIL_render_result_combined(RenderLayer *rl, const char *viewname, GPENCIL_Data *vedata, const rcti *rect)
void GPENCIL_render_init(GPENCIL_Data *vedata, RenderEngine *engine, RenderLayer *render_layer, const Depsgraph *depsgraph, const rcti *rect)
static void GPENCIL_render_result_z(RenderLayer *rl, const char *viewname, GPENCIL_Data *vedata, const rcti *rect)
void RE_GetCameraModelMatrix(const Render *re, const Object *camera, float r_modelmat[4][4])
void RE_GetCameraWindow(Render *re, const Object *camera, float r_winmat[4][4])
Object * RE_GetCamera(Render *re)
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
void *(* MEM_dupallocN)(const void *vmemh)
RenderPass * RE_pass_find_by_name(RenderLayer *rl, const char *name, const char *viewname)
const char * RE_GetActiveRenderView(Render *re)
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
ImBufFloatBuffer float_buffer