32 const int size[2] = {(int)viewport_size[0], (
int)viewport_size[1]};
35 float winmat[4][4], viewmat[4][4], viewinv[4][4];
52 float *pix_z = (rpass_z_src) ? rpass_z_src->
rect :
NULL;
53 float *pix_col = (rpass_col_src) ? rpass_col_src->
rect :
NULL;
55 if (!pix_z || !pix_col) {
57 "Warning: To render grease pencil, enable Combined and Z passes.");
64 int pix_num = rpass_z_src->
rectx * rpass_z_src->
recty;
67 for (
int i = 0; i < pix_num; i++) {
68 pix_z[i] = (-winmat[3][2] / -pix_z[i]) - winmat[2][2];
69 pix_z[i] =
clamp_f(pix_z[i] * 0.5f + 0.5f, 0.0f, 1.0f);
76 float range_inv = 1.0f /
fabsf(far - near);
77 for (
int i = 0; i < pix_num; i++) {
78 pix_z[i] = (pix_z[i] + near) * range_inv;
79 pix_z[i] =
clamp_f(pix_z[i], 0.0f, 1.0f);
85 const bool do_clear_z = !pix_z || do_region;
86 const bool do_clear_col = !pix_col || do_region;
106 GPU_framebuffer_ensure_config(&fbl->
render_fb,
108 GPU_ATTACHMENT_TEXTURE(txl->render_depth_tx),
109 GPU_ATTACHMENT_TEXTURE(txl->render_color_tx),
112 if (do_clear_z || do_clear_col) {
116 const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
117 GPU_framebuffer_clear_color(fbl->
render_fb, clear_col);
120 GPU_framebuffer_clear_depth(fbl->
render_fb, 1.0f);
154 const char *viewname,
179 for (
int i = 0; i < pix_num; i++) {
180 if (rp->
rect[i] == 1.0f) {
184 rp->
rect[i] = rp->
rect[i] * 2.0f - 1.0f;
185 rp->
rect[i] = winmat[3][2] / (rp->
rect[i] + winmat[2][2]);
193 float range =
fabsf(far - near);
195 for (
int i = 0; i < pix_num; i++) {
196 if (rp->
rect[i] == 1.0f) {
200 rp->
rect[i] = rp->
rect[i] * range - near;
208 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)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
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(const DRWView *view)
void DRW_view_set_active(const DRWView *view)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
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_GetCameraModelMatrix(const Render *re, const struct Object *camera, float r_modelmat[4][4])
struct Object * RE_GetCamera(Render *re)
void RE_GetCameraWindow(struct Render *re, const struct Object *camera, float r_winmat[4][4])
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 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