2017-02-07 11:20:15 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2016, Blender Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Institute
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2017-11-20 14:11:45 +11:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
#include "BLI_dynstr.h"
|
|
|
|
|
#include "BLI_rand.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
#include "DNA_particle_types.h"
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "BKE_icons.h"
|
2017-03-30 17:01:23 +02:00
|
|
|
#include "BKE_idprop.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "BKE_main.h"
|
2017-05-09 16:23:47 +02:00
|
|
|
#include "BKE_particle.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-19 17:13:48 +02:00
|
|
|
#include "GPU_shader.h"
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
|
|
2017-11-20 14:11:45 +11:00
|
|
|
#include "DRW_render.h"
|
|
|
|
|
|
2017-04-26 17:42:39 +10:00
|
|
|
#include "clay_engine.h"
|
2017-06-04 23:11:48 +02:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
#ifdef WITH_CLAY_ENGINE
|
2017-07-19 18:17:45 +02:00
|
|
|
#include "../eevee/eevee_lut.h" /* TODO find somewhere to share blue noise Table */
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Shaders */
|
|
|
|
|
|
2017-02-07 16:54:09 +01:00
|
|
|
#define CLAY_ENGINE "BLENDER_CLAY"
|
|
|
|
|
|
2017-05-18 11:20:54 +10:00
|
|
|
#define MAX_CLAY_MAT 512 /* 512 = 9 bit material id */
|
|
|
|
|
|
|
|
|
|
#define SHADER_DEFINES \
|
|
|
|
|
"#define MAX_MATERIAL " STRINGIFY(MAX_CLAY_MAT) "\n" \
|
|
|
|
|
"#define USE_ROTATION\n" \
|
|
|
|
|
"#define USE_AO\n" \
|
|
|
|
|
"#define USE_HSV\n"
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
extern char datatoc_clay_frag_glsl[];
|
|
|
|
|
extern char datatoc_clay_vert_glsl[];
|
2017-05-23 14:13:25 +02:00
|
|
|
extern char datatoc_clay_particle_vert_glsl[];
|
|
|
|
|
extern char datatoc_clay_particle_strand_frag_glsl[];
|
2017-02-07 11:20:15 +01:00
|
|
|
extern char datatoc_ssao_alchemy_glsl[];
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
/* *********** LISTS *********** */
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
/**
|
|
|
|
|
* UBOs data needs to be 16 byte aligned (size of vec4)
|
|
|
|
|
*
|
|
|
|
|
* Reminder: float, int, bool are 4 bytes
|
|
|
|
|
*
|
|
|
|
|
* \note struct is expected to be initialized with all pad-bits zero'd
|
|
|
|
|
* so we can use 'memcmp' to check for duplicates. Possibly hash data later.
|
|
|
|
|
*/
|
2017-02-07 11:20:15 +01:00
|
|
|
typedef struct CLAY_UBO_Material {
|
|
|
|
|
float ssao_params_var[4];
|
|
|
|
|
/* - 16 -*/
|
|
|
|
|
float matcap_hsv[3];
|
|
|
|
|
float matcap_id; /* even float encoding have enough precision */
|
|
|
|
|
/* - 16 -*/
|
|
|
|
|
float matcap_rot[2];
|
|
|
|
|
float pad[2]; /* ensure 16 bytes alignement */
|
|
|
|
|
} CLAY_UBO_Material; /* 48 bytes */
|
2017-05-16 16:43:24 +02:00
|
|
|
BLI_STATIC_ASSERT_ALIGN(CLAY_UBO_Material, 16)
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
typedef struct CLAY_HAIR_UBO_Material {
|
2017-05-15 17:18:13 +02:00
|
|
|
float hair_randomness;
|
2017-05-15 16:25:52 +02:00
|
|
|
float matcap_id;
|
|
|
|
|
float matcap_rot[2];
|
|
|
|
|
float matcap_hsv[3];
|
|
|
|
|
float pad;
|
2017-05-16 16:43:24 +02:00
|
|
|
} CLAY_HAIR_UBO_Material; /* 32 bytes */
|
2017-05-22 16:34:10 +02:00
|
|
|
BLI_STATIC_ASSERT_ALIGN(CLAY_HAIR_UBO_Material, 16)
|
2017-05-09 16:23:47 +02:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
typedef struct CLAY_UBO_Storage {
|
2017-02-08 21:44:13 +01:00
|
|
|
CLAY_UBO_Material materials[MAX_CLAY_MAT];
|
2017-02-07 11:20:15 +01:00
|
|
|
} CLAY_UBO_Storage;
|
|
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
typedef struct CLAY_HAIR_UBO_Storage {
|
|
|
|
|
CLAY_HAIR_UBO_Material materials[MAX_CLAY_MAT];
|
|
|
|
|
} CLAY_HAIR_UBO_Storage;
|
|
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
/* GPUViewport.storage
|
|
|
|
|
* Is freed everytime the viewport engine changes */
|
|
|
|
|
typedef struct CLAY_Storage {
|
|
|
|
|
/* Materials Parameter UBO */
|
|
|
|
|
CLAY_UBO_Storage mat_storage;
|
2017-05-09 16:23:47 +02:00
|
|
|
CLAY_HAIR_UBO_Storage hair_mat_storage;
|
2017-02-08 21:44:13 +01:00
|
|
|
int ubo_current_id;
|
2017-05-09 16:23:47 +02:00
|
|
|
int hair_ubo_current_id;
|
2017-02-08 21:44:13 +01:00
|
|
|
DRWShadingGroup *shgrps[MAX_CLAY_MAT];
|
2017-05-18 20:43:53 +10:00
|
|
|
DRWShadingGroup *shgrps_flat[MAX_CLAY_MAT];
|
2017-05-09 16:23:47 +02:00
|
|
|
DRWShadingGroup *hair_shgrps[MAX_CLAY_MAT];
|
2017-02-08 21:44:13 +01:00
|
|
|
} CLAY_Storage;
|
|
|
|
|
|
|
|
|
|
typedef struct CLAY_StorageList {
|
|
|
|
|
struct CLAY_Storage *storage;
|
|
|
|
|
struct GPUUniformBuffer *mat_ubo;
|
2017-05-09 16:23:47 +02:00
|
|
|
struct GPUUniformBuffer *hair_mat_ubo;
|
2017-04-29 16:52:12 +10:00
|
|
|
struct CLAY_PrivateData *g_data;
|
2017-02-08 21:44:13 +01:00
|
|
|
} CLAY_StorageList;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-22 18:52:07 +01:00
|
|
|
typedef struct CLAY_FramebufferList {
|
2017-02-07 11:20:15 +01:00
|
|
|
/* default */
|
|
|
|
|
struct GPUFrameBuffer *default_fb;
|
|
|
|
|
/* engine specific */
|
2017-02-15 15:15:42 +01:00
|
|
|
struct GPUFrameBuffer *dupli_depth;
|
2017-02-07 11:20:15 +01:00
|
|
|
} CLAY_FramebufferList;
|
|
|
|
|
|
2017-02-22 18:52:07 +01:00
|
|
|
typedef struct CLAY_PassList {
|
2017-02-07 11:20:15 +01:00
|
|
|
struct DRWPass *depth_pass;
|
2017-02-16 12:59:06 +01:00
|
|
|
struct DRWPass *depth_pass_cull;
|
2017-02-07 11:20:15 +01:00
|
|
|
struct DRWPass *clay_pass;
|
2017-05-18 20:43:53 +10:00
|
|
|
struct DRWPass *clay_pass_flat;
|
2017-05-09 16:23:47 +02:00
|
|
|
struct DRWPass *hair_pass;
|
2017-02-07 11:20:15 +01:00
|
|
|
} CLAY_PassList;
|
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
typedef struct CLAY_Data {
|
2017-04-03 19:32:05 +02:00
|
|
|
void *engine_type;
|
2017-03-08 20:00:09 +01:00
|
|
|
CLAY_FramebufferList *fbl;
|
2017-05-16 03:03:58 +02:00
|
|
|
DRWViewportEmptyList *txl;
|
2017-03-08 20:00:09 +01:00
|
|
|
CLAY_PassList *psl;
|
|
|
|
|
CLAY_StorageList *stl;
|
|
|
|
|
} CLAY_Data;
|
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
typedef struct CLAY_ViewLayerData {
|
2017-06-04 23:11:48 +02:00
|
|
|
struct GPUTexture *jitter_tx;
|
|
|
|
|
struct GPUUniformBuffer *sampling_ubo;
|
|
|
|
|
int cached_sample_num;
|
2017-11-22 10:52:39 -02:00
|
|
|
} CLAY_ViewLayerData;
|
2017-06-04 23:11:48 +02:00
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
/* *********** STATIC *********** */
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
|
/* Depth Pre Pass */
|
|
|
|
|
struct GPUShader *depth_sh;
|
|
|
|
|
/* Shading Pass */
|
|
|
|
|
struct GPUShader *clay_sh;
|
2017-05-18 20:43:53 +10:00
|
|
|
struct GPUShader *clay_flat_sh;
|
2017-05-09 16:23:47 +02:00
|
|
|
struct GPUShader *hair_sh;
|
2017-03-18 22:14:53 +01:00
|
|
|
|
|
|
|
|
/* Matcap textures */
|
|
|
|
|
struct GPUTexture *matcap_array;
|
|
|
|
|
float matcap_colors[24][3];
|
|
|
|
|
|
|
|
|
|
/* Ssao */
|
|
|
|
|
float winmat[4][4];
|
|
|
|
|
float viewvecs[3][4];
|
|
|
|
|
float ssao_params[4];
|
|
|
|
|
|
|
|
|
|
/* Just a serie of int from 0 to MAX_CLAY_MAT-1 */
|
|
|
|
|
int ubo_mat_idxs[MAX_CLAY_MAT];
|
2017-05-16 03:03:58 +02:00
|
|
|
|
|
|
|
|
/* engine specific */
|
|
|
|
|
struct GPUTexture *depth_dup;
|
2017-03-18 22:14:53 +01:00
|
|
|
} e_data = {NULL}; /* Engine data */
|
|
|
|
|
|
2017-04-29 16:52:12 +10:00
|
|
|
typedef struct CLAY_PrivateData {
|
2017-03-18 22:14:53 +01:00
|
|
|
DRWShadingGroup *depth_shgrp;
|
|
|
|
|
DRWShadingGroup *depth_shgrp_select;
|
|
|
|
|
DRWShadingGroup *depth_shgrp_active;
|
|
|
|
|
DRWShadingGroup *depth_shgrp_cull;
|
|
|
|
|
DRWShadingGroup *depth_shgrp_cull_select;
|
|
|
|
|
DRWShadingGroup *depth_shgrp_cull_active;
|
2017-04-29 16:52:12 +10:00
|
|
|
} CLAY_PrivateData; /* Transient data */
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Functions */
|
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
static void clay_view_layer_data_free(void *storage)
|
2017-06-04 23:11:48 +02:00
|
|
|
{
|
2017-11-22 10:52:39 -02:00
|
|
|
CLAY_ViewLayerData *sldata = (CLAY_ViewLayerData *)storage;
|
2017-06-04 23:11:48 +02:00
|
|
|
|
|
|
|
|
DRW_UBO_FREE_SAFE(sldata->sampling_ubo);
|
|
|
|
|
DRW_TEXTURE_FREE_SAFE(sldata->jitter_tx);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
static CLAY_ViewLayerData *CLAY_view_layer_data_get(void)
|
2017-06-04 23:11:48 +02:00
|
|
|
{
|
2017-11-22 10:52:39 -02:00
|
|
|
CLAY_ViewLayerData **sldata = (CLAY_ViewLayerData **)DRW_view_layer_engine_data_get(&draw_engine_clay_type, &clay_view_layer_data_free);
|
2017-06-04 23:11:48 +02:00
|
|
|
|
|
|
|
|
if (*sldata == NULL) {
|
2017-11-22 10:52:39 -02:00
|
|
|
*sldata = MEM_callocN(sizeof(**sldata), "CLAY_ViewLayerData");
|
2017-06-04 23:11:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *sldata;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
static void add_icon_to_rect(PreviewImage *prv, float *final_rect, int layer)
|
|
|
|
|
{
|
|
|
|
|
int image_size = prv->w[0] * prv->h[0];
|
|
|
|
|
float *new_rect = &final_rect[image_size * 4 * layer];
|
|
|
|
|
|
|
|
|
|
IMB_buffer_float_from_byte(new_rect, (unsigned char *)prv->rect[0], IB_PROFILE_SRGB, IB_PROFILE_SRGB,
|
|
|
|
|
false, prv->w[0], prv->h[0], prv->w[0], prv->w[0]);
|
|
|
|
|
|
|
|
|
|
/* Find overall color */
|
|
|
|
|
for (int y = 0; y < 4; ++y) {
|
|
|
|
|
for (int x = 0; x < 4; ++x) {
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.matcap_colors[layer][0] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 0];
|
|
|
|
|
e_data.matcap_colors[layer][1] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 1];
|
|
|
|
|
e_data.matcap_colors[layer][2] += new_rect[y * 512 * 128 * 4 + x * 128 * 4 + 2];
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.matcap_colors[layer][0] /= 16.0f * 2.0f; /* the * 2 is to darken for shadows */
|
|
|
|
|
e_data.matcap_colors[layer][1] /= 16.0f * 2.0f;
|
|
|
|
|
e_data.matcap_colors[layer][2] /= 16.0f * 2.0f;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct GPUTexture *load_matcaps(PreviewImage *prv[24], int nbr)
|
|
|
|
|
{
|
|
|
|
|
struct GPUTexture *tex;
|
|
|
|
|
int w = prv[0]->w[0];
|
|
|
|
|
int h = prv[0]->h[0];
|
|
|
|
|
float *final_rect = MEM_callocN(sizeof(float) * 4 * w * h * nbr, "Clay Matcap array rect");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < nbr; ++i) {
|
|
|
|
|
add_icon_to_rect(prv[i], final_rect, i);
|
|
|
|
|
BKE_previewimg_free(&prv[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tex = DRW_texture_create_2D_array(w, h, nbr, DRW_TEX_RGBA_8, DRW_TEX_FILTER, final_rect);
|
|
|
|
|
MEM_freeN(final_rect);
|
|
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int matcap_to_index(int matcap)
|
|
|
|
|
{
|
2017-05-12 15:47:08 +02:00
|
|
|
switch (matcap) {
|
|
|
|
|
case ICON_MATCAP_01: return 0;
|
|
|
|
|
case ICON_MATCAP_02: return 1;
|
|
|
|
|
case ICON_MATCAP_03: return 2;
|
|
|
|
|
case ICON_MATCAP_04: return 3;
|
|
|
|
|
case ICON_MATCAP_05: return 4;
|
|
|
|
|
case ICON_MATCAP_06: return 5;
|
|
|
|
|
case ICON_MATCAP_07: return 6;
|
|
|
|
|
case ICON_MATCAP_08: return 7;
|
|
|
|
|
case ICON_MATCAP_09: return 8;
|
|
|
|
|
case ICON_MATCAP_10: return 9;
|
|
|
|
|
case ICON_MATCAP_11: return 10;
|
|
|
|
|
case ICON_MATCAP_12: return 11;
|
|
|
|
|
case ICON_MATCAP_13: return 12;
|
|
|
|
|
case ICON_MATCAP_14: return 13;
|
|
|
|
|
case ICON_MATCAP_15: return 14;
|
|
|
|
|
case ICON_MATCAP_16: return 15;
|
|
|
|
|
case ICON_MATCAP_17: return 16;
|
|
|
|
|
case ICON_MATCAP_18: return 17;
|
|
|
|
|
case ICON_MATCAP_19: return 18;
|
|
|
|
|
case ICON_MATCAP_20: return 19;
|
|
|
|
|
case ICON_MATCAP_21: return 20;
|
|
|
|
|
case ICON_MATCAP_22: return 21;
|
|
|
|
|
case ICON_MATCAP_23: return 22;
|
|
|
|
|
case ICON_MATCAP_24: return 23;
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(!"Should not happen");
|
2017-02-07 11:20:15 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
/* Using Hammersley distribution */
|
|
|
|
|
static float *create_disk_samples(int num_samples)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-06-04 23:11:48 +02:00
|
|
|
/* vec4 to ensure memory alignment. */
|
|
|
|
|
float (*texels)[4] = MEM_mallocN(sizeof(float[4]) * num_samples, "concentric_tex");
|
|
|
|
|
const float num_samples_inv = 1.0f / num_samples;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < num_samples; i++) {
|
|
|
|
|
float r = (i + 0.5f) * num_samples_inv;
|
2017-09-26 21:38:23 +02:00
|
|
|
double dphi;
|
|
|
|
|
BLI_hammersley_1D(i, &dphi);
|
|
|
|
|
|
|
|
|
|
float phi = (float)dphi * 2.0f * M_PI;
|
2017-06-04 23:11:48 +02:00
|
|
|
texels[i][0] = cosf(phi);
|
|
|
|
|
texels[i][1] = sinf(phi);
|
|
|
|
|
/* This deliberatly distribute more samples
|
|
|
|
|
* at the center of the disk (and thus the shadow). */
|
|
|
|
|
texels[i][2] = r;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
return (float *)texels;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
static struct GPUTexture *create_jitter_texture(int num_samples)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-06-04 23:11:48 +02:00
|
|
|
float jitter[64 * 64][3];
|
|
|
|
|
const float num_samples_inv = 1.0f / num_samples;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 64 * 64; i++) {
|
|
|
|
|
float phi = blue_noise[i][0] * 2.0f * M_PI;
|
|
|
|
|
/* This rotate the sample per pixels */
|
|
|
|
|
jitter[i][0] = cosf(phi);
|
|
|
|
|
jitter[i][1] = sinf(phi);
|
|
|
|
|
/* This offset the sample along it's direction axis (reduce banding) */
|
|
|
|
|
float bn = blue_noise[i][1] - 0.5f;
|
|
|
|
|
CLAMP(bn, -0.499f, 0.499f); /* fix fireflies */
|
|
|
|
|
jitter[i][2] = bn * num_samples_inv;
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-08-04 18:43:02 +02:00
|
|
|
UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx);
|
2017-06-04 23:11:48 +02:00
|
|
|
|
|
|
|
|
return DRW_texture_create_2D(64, 64, DRW_TEX_RGB_16, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void CLAY_engine_init(void *vedata)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
|
|
|
|
|
CLAY_FramebufferList *fbl = ((CLAY_Data *)vedata)->fbl;
|
2017-11-22 10:52:39 -02:00
|
|
|
CLAY_ViewLayerData *sldata = CLAY_view_layer_data_get();
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Create Texture Array */
|
2017-03-18 22:14:53 +01:00
|
|
|
if (!e_data.matcap_array) {
|
2017-02-07 11:20:15 +01:00
|
|
|
PreviewImage *prv[24]; /* For now use all of the 24 internal matcaps */
|
|
|
|
|
|
|
|
|
|
/* TODO only load used matcaps */
|
|
|
|
|
prv[0] = UI_icon_to_preview(ICON_MATCAP_01);
|
|
|
|
|
prv[1] = UI_icon_to_preview(ICON_MATCAP_02);
|
|
|
|
|
prv[2] = UI_icon_to_preview(ICON_MATCAP_03);
|
|
|
|
|
prv[3] = UI_icon_to_preview(ICON_MATCAP_04);
|
|
|
|
|
prv[4] = UI_icon_to_preview(ICON_MATCAP_05);
|
|
|
|
|
prv[5] = UI_icon_to_preview(ICON_MATCAP_06);
|
|
|
|
|
prv[6] = UI_icon_to_preview(ICON_MATCAP_07);
|
|
|
|
|
prv[7] = UI_icon_to_preview(ICON_MATCAP_08);
|
|
|
|
|
prv[8] = UI_icon_to_preview(ICON_MATCAP_09);
|
|
|
|
|
prv[9] = UI_icon_to_preview(ICON_MATCAP_10);
|
|
|
|
|
prv[10] = UI_icon_to_preview(ICON_MATCAP_11);
|
|
|
|
|
prv[11] = UI_icon_to_preview(ICON_MATCAP_12);
|
|
|
|
|
prv[12] = UI_icon_to_preview(ICON_MATCAP_13);
|
|
|
|
|
prv[13] = UI_icon_to_preview(ICON_MATCAP_14);
|
|
|
|
|
prv[14] = UI_icon_to_preview(ICON_MATCAP_15);
|
|
|
|
|
prv[15] = UI_icon_to_preview(ICON_MATCAP_16);
|
|
|
|
|
prv[16] = UI_icon_to_preview(ICON_MATCAP_17);
|
|
|
|
|
prv[17] = UI_icon_to_preview(ICON_MATCAP_18);
|
|
|
|
|
prv[18] = UI_icon_to_preview(ICON_MATCAP_19);
|
|
|
|
|
prv[19] = UI_icon_to_preview(ICON_MATCAP_20);
|
|
|
|
|
prv[20] = UI_icon_to_preview(ICON_MATCAP_21);
|
|
|
|
|
prv[21] = UI_icon_to_preview(ICON_MATCAP_22);
|
|
|
|
|
prv[22] = UI_icon_to_preview(ICON_MATCAP_23);
|
|
|
|
|
prv[23] = UI_icon_to_preview(ICON_MATCAP_24);
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.matcap_array = load_matcaps(prv, 24);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Depth prepass */
|
2017-03-18 22:14:53 +01:00
|
|
|
if (!e_data.depth_sh) {
|
|
|
|
|
e_data.depth_sh = DRW_shader_create_3D_depth_only();
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Shading pass */
|
2017-03-18 22:14:53 +01:00
|
|
|
if (!e_data.clay_sh) {
|
2017-02-07 11:20:15 +01:00
|
|
|
DynStr *ds = BLI_dynstr_new();
|
|
|
|
|
char *matcap_with_ao;
|
|
|
|
|
|
|
|
|
|
BLI_dynstr_append(ds, datatoc_clay_frag_glsl);
|
|
|
|
|
BLI_dynstr_append(ds, datatoc_ssao_alchemy_glsl);
|
|
|
|
|
|
|
|
|
|
matcap_with_ao = BLI_dynstr_get_cstring(ds);
|
|
|
|
|
|
2017-05-18 20:43:53 +10:00
|
|
|
e_data.clay_sh = DRW_shader_create(
|
|
|
|
|
datatoc_clay_vert_glsl, NULL, matcap_with_ao,
|
|
|
|
|
SHADER_DEFINES);
|
|
|
|
|
e_data.clay_flat_sh = DRW_shader_create(
|
|
|
|
|
datatoc_clay_vert_glsl, NULL, matcap_with_ao,
|
|
|
|
|
SHADER_DEFINES
|
|
|
|
|
"#define USE_FLAT_NORMAL\n");
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
|
BLI_dynstr_free(ds);
|
|
|
|
|
MEM_freeN(matcap_with_ao);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
if (!e_data.hair_sh) {
|
2017-05-22 16:23:25 +10:00
|
|
|
e_data.hair_sh = DRW_shader_create(
|
2017-05-23 14:13:25 +02:00
|
|
|
datatoc_clay_particle_vert_glsl, NULL, datatoc_clay_particle_strand_frag_glsl,
|
2017-05-22 16:23:25 +10:00
|
|
|
"#define MAX_MATERIAL 512\n");
|
2017-05-09 16:23:47 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
if (!stl->storage) {
|
|
|
|
|
stl->storage = MEM_callocN(sizeof(CLAY_Storage), "CLAY_Storage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stl->mat_ubo) {
|
|
|
|
|
stl->mat_ubo = DRW_uniformbuffer_create(sizeof(CLAY_UBO_Storage), NULL);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
if (!stl->hair_mat_ubo) {
|
|
|
|
|
stl->hair_mat_ubo = DRW_uniformbuffer_create(sizeof(CLAY_HAIR_UBO_Storage), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
if (e_data.ubo_mat_idxs[1] == 0) {
|
2017-02-08 21:44:13 +01:00
|
|
|
/* Just int to have pointers to them */
|
|
|
|
|
for (int i = 0; i < MAX_CLAY_MAT; ++i) {
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.ubo_mat_idxs[i] = i;
|
2017-02-08 21:44:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-02-15 15:15:42 +01:00
|
|
|
|
2017-04-27 02:04:56 +10:00
|
|
|
if (DRW_state_is_fbo()) {
|
2017-04-12 12:10:01 +10:00
|
|
|
const float *viewport_size = DRW_viewport_size_get();
|
2017-11-14 20:49:13 +01:00
|
|
|
DRWFboTexture tex = {&e_data.depth_dup, DRW_TEX_DEPTH_24_STENCIL_8, DRW_TEX_TEMP};
|
2017-05-16 03:03:58 +02:00
|
|
|
DRW_framebuffer_init(&fbl->dupli_depth, &draw_engine_clay_type,
|
2017-02-15 15:15:42 +01:00
|
|
|
(int)viewport_size[0], (int)viewport_size[1],
|
|
|
|
|
&tex, 1);
|
|
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-17 17:29:43 +01:00
|
|
|
/* SSAO setup */
|
|
|
|
|
{
|
2017-05-05 16:27:31 +02:00
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer = draw_ctx->view_layer;
|
|
|
|
|
IDProperty *props = BKE_view_layer_engine_evaluated_get(
|
|
|
|
|
view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY);
|
2017-05-05 16:27:31 +02:00
|
|
|
int ssao_samples = BKE_collection_engine_property_value_get_int(props, "ssao_samples");
|
|
|
|
|
|
2017-02-17 17:29:43 +01:00
|
|
|
float invproj[4][4];
|
|
|
|
|
float dfdyfacs[2];
|
2017-04-21 18:43:54 +10:00
|
|
|
const bool is_persp = DRW_viewport_is_persp_get();
|
2017-05-22 16:23:25 +10:00
|
|
|
/* view vectors for the corners of the view frustum.
|
|
|
|
|
* Can be used to recreate the world space position easily */
|
2017-02-17 17:29:43 +01:00
|
|
|
float viewvecs[3][4] = {
|
|
|
|
|
{-1.0f, -1.0f, -1.0f, 1.0f},
|
|
|
|
|
{1.0f, -1.0f, -1.0f, 1.0f},
|
|
|
|
|
{-1.0f, 1.0f, -1.0f, 1.0f}
|
|
|
|
|
};
|
|
|
|
|
int i;
|
2017-04-12 12:10:01 +10:00
|
|
|
const float *size = DRW_viewport_size_get();
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-04-27 02:04:56 +10:00
|
|
|
DRW_state_dfdy_factors_get(dfdyfacs);
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-30 17:01:23 +02:00
|
|
|
e_data.ssao_params[0] = ssao_samples;
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.ssao_params[1] = size[0] / 64.0;
|
|
|
|
|
e_data.ssao_params[2] = size[1] / 64.0;
|
|
|
|
|
e_data.ssao_params[3] = dfdyfacs[1]; /* dfdy sign for offscreen */
|
2017-02-17 17:29:43 +01:00
|
|
|
|
|
|
|
|
/* invert the view matrix */
|
2017-03-18 22:14:53 +01:00
|
|
|
DRW_viewport_matrix_get(e_data.winmat, DRW_MAT_WIN);
|
|
|
|
|
invert_m4_m4(invproj, e_data.winmat);
|
2017-02-17 17:29:43 +01:00
|
|
|
|
|
|
|
|
/* convert the view vectors to view space */
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
|
mul_m4_v4(invproj, viewvecs[i]);
|
2017-04-22 16:11:12 +10:00
|
|
|
/* normalized trick see:
|
|
|
|
|
* http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
|
2017-02-17 17:29:43 +01:00
|
|
|
mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][3]);
|
|
|
|
|
if (is_persp)
|
|
|
|
|
mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]);
|
|
|
|
|
viewvecs[i][3] = 1.0;
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
copy_v4_v4(e_data.viewvecs[i], viewvecs[i]);
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-17 17:29:43 +01:00
|
|
|
/* we need to store the differences */
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.viewvecs[1][0] -= e_data.viewvecs[0][0];
|
|
|
|
|
e_data.viewvecs[1][1] = e_data.viewvecs[2][1] - e_data.viewvecs[0][1];
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-17 17:29:43 +01:00
|
|
|
/* calculate a depth offset as well */
|
|
|
|
|
if (!is_persp) {
|
|
|
|
|
float vec_far[] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
|
|
|
|
mul_m4_v4(invproj, vec_far);
|
|
|
|
|
mul_v3_fl(vec_far, 1.0f / vec_far[3]);
|
2017-03-18 22:14:53 +01:00
|
|
|
e_data.viewvecs[1][2] = vec_far[2] - e_data.viewvecs[0][2];
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
2017-03-24 14:49:33 +01:00
|
|
|
|
|
|
|
|
/* AO Samples Tex */
|
2017-06-04 23:11:48 +02:00
|
|
|
if (sldata->sampling_ubo && (sldata->cached_sample_num != ssao_samples)) {
|
|
|
|
|
DRW_UBO_FREE_SAFE(sldata->sampling_ubo);
|
|
|
|
|
DRW_TEXTURE_FREE_SAFE(sldata->jitter_tx);
|
2017-03-24 14:49:33 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
if (sldata->sampling_ubo == NULL) {
|
|
|
|
|
float *samples = create_disk_samples(ssao_samples);
|
|
|
|
|
sldata->jitter_tx = create_jitter_texture(ssao_samples);
|
|
|
|
|
sldata->sampling_ubo = DRW_uniformbuffer_create(sizeof(float[4]) * ssao_samples, samples);
|
|
|
|
|
sldata->cached_sample_num = ssao_samples;
|
|
|
|
|
MEM_freeN(samples);
|
2017-03-24 14:49:33 +01:00
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 23:15:29 +02:00
|
|
|
static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id, bool use_flat)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-09-11 23:15:29 +02:00
|
|
|
CLAY_StorageList *stl = vedata->stl;
|
2017-11-22 10:52:39 -02:00
|
|
|
CLAY_ViewLayerData *sldata = CLAY_view_layer_data_get();
|
2017-05-18 20:43:53 +10:00
|
|
|
DRWShadingGroup *grp = DRW_shgroup_create(use_flat ? e_data.clay_flat_sh : e_data.clay_sh, pass);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
|
DRW_shgroup_uniform_vec2(grp, "screenres", DRW_viewport_size_get(), 1);
|
2017-05-16 03:03:58 +02:00
|
|
|
DRW_shgroup_uniform_buffer(grp, "depthtex", &e_data.depth_dup);
|
2017-05-09 22:08:25 +02:00
|
|
|
DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array);
|
2017-03-18 22:14:53 +01:00
|
|
|
DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)e_data.winmat);
|
2017-04-18 19:12:28 +02:00
|
|
|
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)e_data.viewvecs, 3);
|
2017-03-18 22:14:53 +01:00
|
|
|
DRW_shgroup_uniform_vec4(grp, "ssao_params", e_data.ssao_params, 1);
|
2017-04-18 19:12:28 +02:00
|
|
|
DRW_shgroup_uniform_vec3(grp, "matcaps_color[0]", (float *)e_data.matcap_colors, 24);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
DRW_shgroup_uniform_texture(grp, "ssao_jitter", sldata->jitter_tx);
|
|
|
|
|
DRW_shgroup_uniform_block(grp, "samples_block", sldata->sampling_ubo);
|
2017-09-11 23:15:29 +02:00
|
|
|
DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
|
return grp;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 23:15:29 +02:00
|
|
|
static DRWShadingGroup *CLAY_hair_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
2017-09-11 23:15:29 +02:00
|
|
|
CLAY_StorageList *stl = vedata->stl;
|
2017-05-09 16:23:47 +02:00
|
|
|
DRWShadingGroup *grp = DRW_shgroup_create(e_data.hair_sh, pass);
|
|
|
|
|
|
2017-05-15 16:25:52 +02:00
|
|
|
DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array);
|
2017-05-09 16:23:47 +02:00
|
|
|
DRW_shgroup_uniform_int(grp, "mat_id", material_id, 1);
|
2017-09-11 23:15:29 +02:00
|
|
|
DRW_shgroup_uniform_block(grp, "material_block", stl->mat_ubo);
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
|
return grp;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int search_mat_to_ubo(CLAY_Storage *storage, const CLAY_UBO_Material *mat_ubo_test)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-02-08 21:44:13 +01:00
|
|
|
/* For now just use a linear search and test all parameters */
|
|
|
|
|
/* TODO make a hash table */
|
2017-02-22 18:52:07 +01:00
|
|
|
for (int i = 0; i < storage->ubo_current_id; ++i) {
|
2017-02-08 21:44:13 +01:00
|
|
|
CLAY_UBO_Material *ubo = &storage->mat_storage.materials[i];
|
2017-05-18 13:06:51 +10:00
|
|
|
if (memcmp(ubo, mat_ubo_test, sizeof(*mat_ubo_test)) == 0) {
|
2017-02-08 21:44:13 +01:00
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int search_hair_mat_to_ubo(CLAY_Storage *storage, const CLAY_HAIR_UBO_Material *hair_mat_ubo_test)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
|
|
|
|
/* For now just use a linear search and test all parameters */
|
|
|
|
|
/* TODO make a hash table */
|
|
|
|
|
for (int i = 0; i < storage->hair_ubo_current_id; ++i) {
|
|
|
|
|
CLAY_HAIR_UBO_Material *ubo = &storage->hair_mat_storage.materials[i];
|
2017-05-18 13:06:51 +10:00
|
|
|
if (memcmp(ubo, hair_mat_ubo_test, sizeof(*hair_mat_ubo_test)) == 0) {
|
2017-05-09 16:23:47 +02:00
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int push_mat_to_ubo(CLAY_Storage *storage, const CLAY_UBO_Material *mat_ubo_test)
|
2017-02-08 21:44:13 +01:00
|
|
|
{
|
|
|
|
|
int id = storage->ubo_current_id;
|
|
|
|
|
CLAY_UBO_Material *ubo = &storage->mat_storage.materials[id];
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
*ubo = *mat_ubo_test;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
storage->ubo_current_id++;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
return id;
|
|
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int push_hair_mat_to_ubo(CLAY_Storage *storage, const CLAY_HAIR_UBO_Material *hair_mat_ubo_test)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
|
|
|
|
int id = storage->hair_ubo_current_id;
|
|
|
|
|
CLAY_HAIR_UBO_Material *ubo = &storage->hair_mat_storage.materials[id];
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
*ubo = *hair_mat_ubo_test;
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
|
storage->hair_ubo_current_id++;
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int mat_in_ubo(CLAY_Storage *storage, const CLAY_UBO_Material *mat_ubo_test)
|
2017-02-08 21:44:13 +01:00
|
|
|
{
|
|
|
|
|
/* Search material in UBO */
|
2017-05-18 13:06:51 +10:00
|
|
|
int id = search_mat_to_ubo(storage, mat_ubo_test);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
/* if not found create it */
|
|
|
|
|
if (id == -1) {
|
2017-05-18 13:06:51 +10:00
|
|
|
id = push_mat_to_ubo(storage, mat_ubo_test);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-08 21:44:13 +01:00
|
|
|
return id;
|
|
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static int hair_mat_in_ubo(CLAY_Storage *storage, const CLAY_HAIR_UBO_Material *hair_mat_ubo_test)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
|
|
|
|
/* Search material in UBO */
|
2017-05-18 13:06:51 +10:00
|
|
|
int id = search_hair_mat_to_ubo(storage, hair_mat_ubo_test);
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
|
/* if not found create it */
|
|
|
|
|
if (id == -1) {
|
2017-05-18 13:06:51 +10:00
|
|
|
id = push_hair_mat_to_ubo(storage, hair_mat_ubo_test);
|
2017-05-09 16:23:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
static void ubo_mat_from_object(Object *ob, CLAY_UBO_Material *r_ubo)
|
2017-02-08 21:44:13 +01:00
|
|
|
{
|
2017-05-05 16:27:31 +02:00
|
|
|
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY);
|
2017-02-08 21:44:13 +01:00
|
|
|
|
|
|
|
|
/* Default Settings */
|
2017-03-30 17:01:23 +02:00
|
|
|
float matcap_rot = BKE_collection_engine_property_value_get_float(props, "matcap_rotation");
|
|
|
|
|
float matcap_hue = BKE_collection_engine_property_value_get_float(props, "matcap_hue");
|
|
|
|
|
float matcap_sat = BKE_collection_engine_property_value_get_float(props, "matcap_saturation");
|
|
|
|
|
float matcap_val = BKE_collection_engine_property_value_get_float(props, "matcap_value");
|
|
|
|
|
float ssao_distance = BKE_collection_engine_property_value_get_float(props, "ssao_distance");
|
|
|
|
|
float ssao_factor_cavity = BKE_collection_engine_property_value_get_float(props, "ssao_factor_cavity");
|
|
|
|
|
float ssao_factor_edge = BKE_collection_engine_property_value_get_float(props, "ssao_factor_edge");
|
|
|
|
|
float ssao_attenuation = BKE_collection_engine_property_value_get_float(props, "ssao_attenuation");
|
|
|
|
|
int matcap_icon = BKE_collection_engine_property_value_get_int(props, "matcap_icon");
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
memset(r_ubo, 0x0, sizeof(*r_ubo));
|
|
|
|
|
|
|
|
|
|
r_ubo->matcap_rot[0] = cosf(matcap_rot * 3.14159f * 2.0f);
|
|
|
|
|
r_ubo->matcap_rot[1] = sinf(matcap_rot * 3.14159f * 2.0f);
|
|
|
|
|
|
|
|
|
|
r_ubo->matcap_hsv[0] = matcap_hue + 0.5f;
|
|
|
|
|
r_ubo->matcap_hsv[1] = matcap_sat * 2.0f;
|
|
|
|
|
r_ubo->matcap_hsv[2] = matcap_val * 2.0f;
|
|
|
|
|
|
|
|
|
|
r_ubo->ssao_params_var[0] = ssao_distance;
|
|
|
|
|
r_ubo->ssao_params_var[1] = ssao_factor_cavity;
|
|
|
|
|
r_ubo->ssao_params_var[2] = ssao_factor_edge;
|
|
|
|
|
r_ubo->ssao_params_var[3] = ssao_attenuation;
|
|
|
|
|
r_ubo->matcap_id = matcap_to_index(matcap_icon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void hair_ubo_mat_from_object(Object *ob, CLAY_HAIR_UBO_Material *r_ubo)
|
|
|
|
|
{
|
|
|
|
|
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_CLAY);
|
|
|
|
|
|
|
|
|
|
/* Default Settings */
|
|
|
|
|
float matcap_rot = BKE_collection_engine_property_value_get_float(props, "matcap_rotation");
|
|
|
|
|
float matcap_hue = BKE_collection_engine_property_value_get_float(props, "matcap_hue");
|
|
|
|
|
float matcap_sat = BKE_collection_engine_property_value_get_float(props, "matcap_saturation");
|
|
|
|
|
float matcap_val = BKE_collection_engine_property_value_get_float(props, "matcap_value");
|
|
|
|
|
float hair_randomness = BKE_collection_engine_property_value_get_float(props, "hair_brightness_randomness");
|
|
|
|
|
int matcap_icon = BKE_collection_engine_property_value_get_int(props, "matcap_icon");
|
|
|
|
|
|
|
|
|
|
memset(r_ubo, 0x0, sizeof(*r_ubo));
|
|
|
|
|
|
|
|
|
|
r_ubo->matcap_rot[0] = cosf(matcap_rot * 3.14159f * 2.0f);
|
|
|
|
|
r_ubo->matcap_rot[1] = sinf(matcap_rot * 3.14159f * 2.0f);
|
|
|
|
|
r_ubo->matcap_hsv[0] = matcap_hue + 0.5f;
|
|
|
|
|
r_ubo->matcap_hsv[1] = matcap_sat * 2.0f;
|
|
|
|
|
r_ubo->matcap_hsv[2] = matcap_val * 2.0f;
|
|
|
|
|
r_ubo->hair_randomness = hair_randomness;
|
|
|
|
|
r_ubo->matcap_id = matcap_to_index(matcap_icon);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 20:43:53 +10:00
|
|
|
static DRWShadingGroup *CLAY_object_shgrp_get(
|
|
|
|
|
CLAY_Data *vedata, Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl, bool use_flat)
|
2017-05-18 13:06:51 +10:00
|
|
|
{
|
2017-05-18 20:43:53 +10:00
|
|
|
DRWShadingGroup **shgrps = use_flat ? stl->storage->shgrps_flat : stl->storage->shgrps;
|
2017-05-18 13:06:51 +10:00
|
|
|
CLAY_UBO_Material mat_ubo_test;
|
|
|
|
|
|
|
|
|
|
ubo_mat_from_object(ob, &mat_ubo_test);
|
|
|
|
|
|
|
|
|
|
int id = mat_in_ubo(stl->storage, &mat_ubo_test);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-16 12:59:06 +01:00
|
|
|
if (shgrps[id] == NULL) {
|
2017-05-18 20:43:53 +10:00
|
|
|
shgrps[id] = CLAY_shgroup_create(
|
|
|
|
|
vedata, use_flat ? psl->clay_pass_flat : psl->clay_pass, &e_data.ubo_mat_idxs[id], use_flat);
|
2017-02-16 12:59:06 +01:00
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-16 12:59:06 +01:00
|
|
|
return shgrps[id];
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-11 23:15:29 +02:00
|
|
|
static DRWShadingGroup *CLAY_hair_shgrp_get(CLAY_Data *vedata, Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
|
|
|
|
DRWShadingGroup **hair_shgrps = stl->storage->hair_shgrps;
|
|
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
CLAY_HAIR_UBO_Material hair_mat_ubo_test;
|
|
|
|
|
hair_ubo_mat_from_object(ob, &hair_mat_ubo_test);
|
2017-05-09 16:23:47 +02:00
|
|
|
|
2017-05-18 13:06:51 +10:00
|
|
|
int hair_id = hair_mat_in_ubo(stl->storage, &hair_mat_ubo_test);
|
2017-05-09 16:23:47 +02:00
|
|
|
|
|
|
|
|
if (hair_shgrps[hair_id] == NULL) {
|
2017-09-11 23:15:29 +02:00
|
|
|
hair_shgrps[hair_id] = CLAY_hair_shgroup_create(vedata, psl->hair_pass, &e_data.ubo_mat_idxs[hair_id]);
|
2017-05-09 16:23:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hair_shgrps[hair_id];
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 20:43:53 +10:00
|
|
|
static DRWShadingGroup *CLAY_object_shgrp_default_mode_get(
|
|
|
|
|
CLAY_Data *vedata, Object *ob, CLAY_StorageList *stl, CLAY_PassList *psl)
|
|
|
|
|
{
|
|
|
|
|
bool use_flat = DRW_object_is_flat_normal(ob);
|
|
|
|
|
return CLAY_object_shgrp_get(vedata, ob, stl, psl, use_flat);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void CLAY_cache_init(void *vedata)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
CLAY_PassList *psl = ((CLAY_Data *)vedata)->psl;
|
|
|
|
|
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-03-26 20:13:34 +02:00
|
|
|
if (!stl->g_data) {
|
|
|
|
|
/* Alloc transient pointers */
|
2017-04-29 16:52:12 +10:00
|
|
|
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
|
2017-03-26 20:13:34 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Depth Pass */
|
|
|
|
|
{
|
2017-02-17 17:29:43 +01:00
|
|
|
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
2017-03-26 20:13:34 +02:00
|
|
|
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
2017-03-18 01:55:41 +01:00
|
|
|
|
2017-04-22 16:11:12 +10:00
|
|
|
psl->depth_pass_cull = DRW_pass_create(
|
|
|
|
|
"Depth Pass Cull",
|
|
|
|
|
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
|
2017-03-26 20:13:34 +02:00
|
|
|
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clay Pass */
|
|
|
|
|
{
|
2017-02-17 17:29:43 +01:00
|
|
|
psl->clay_pass = DRW_pass_create("Clay Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
|
2017-02-08 21:44:13 +01:00
|
|
|
stl->storage->ubo_current_id = 0;
|
2017-02-16 12:59:06 +01:00
|
|
|
memset(stl->storage->shgrps, 0, sizeof(DRWShadingGroup *) * MAX_CLAY_MAT);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
2017-05-09 16:23:47 +02:00
|
|
|
|
2017-05-18 20:43:53 +10:00
|
|
|
/* Clay Pass (Flat) */
|
|
|
|
|
{
|
|
|
|
|
psl->clay_pass_flat = DRW_pass_create("Clay Pass Flat", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
|
|
|
|
|
memset(stl->storage->shgrps_flat, 0, sizeof(DRWShadingGroup *) * MAX_CLAY_MAT);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
/* Hair Pass */
|
|
|
|
|
{
|
2017-05-16 14:52:49 +02:00
|
|
|
psl->hair_pass = DRW_pass_create(
|
|
|
|
|
"Hair Pass",
|
|
|
|
|
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WIRE);
|
2017-05-09 16:23:47 +02:00
|
|
|
stl->storage->hair_ubo_current_id = 0;
|
|
|
|
|
memset(stl->storage->hair_shgrps, 0, sizeof(DRWShadingGroup *) * MAX_CLAY_MAT);
|
|
|
|
|
}
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void CLAY_cache_populate(void *vedata, Object *ob)
|
2017-02-17 17:29:43 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
CLAY_PassList *psl = ((CLAY_Data *)vedata)->psl;
|
|
|
|
|
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
DRWShadingGroup *clay_shgrp, *hair_shgrp;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-08 11:15:28 +10:00
|
|
|
if (!DRW_object_is_renderable(ob))
|
2017-02-17 17:29:43 +01:00
|
|
|
return;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-17 17:06:55 +10:00
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const bool is_active = (ob == draw_ctx->obact);
|
|
|
|
|
if (is_active) {
|
2017-07-13 00:27:06 +10:00
|
|
|
if (DRW_object_is_mode_shade(ob) == true) {
|
2017-05-17 17:06:55 +10:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-12 17:54:14 +02:00
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
|
2017-04-21 02:18:14 +10:00
|
|
|
if (geom) {
|
2017-05-05 16:27:31 +02:00
|
|
|
IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
|
2017-05-17 17:06:55 +10:00
|
|
|
const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
|
|
|
|
|
const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
|
2017-05-18 20:43:53 +10:00
|
|
|
const bool is_default_mode_shader = is_sculpt_mode;
|
2017-04-21 04:29:33 +10:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
/* Depth Prepass */
|
2017-05-17 17:06:55 +10:00
|
|
|
{
|
|
|
|
|
DRWShadingGroup *depth_shgrp = do_cull ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp;
|
|
|
|
|
if (is_sculpt_mode) {
|
|
|
|
|
DRW_shgroup_call_sculpt_add(depth_shgrp, ob, ob->obmat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2017-06-09 15:19:48 +02:00
|
|
|
DRW_shgroup_call_object_add(depth_shgrp, geom, ob);
|
2017-05-17 17:06:55 +10:00
|
|
|
}
|
2017-05-12 17:54:14 +02:00
|
|
|
}
|
2017-03-08 20:00:09 +01:00
|
|
|
|
|
|
|
|
/* Shading */
|
2017-05-18 20:43:53 +10:00
|
|
|
if (is_default_mode_shader) {
|
|
|
|
|
clay_shgrp = CLAY_object_shgrp_default_mode_get(vedata, ob, stl, psl);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
clay_shgrp = CLAY_object_shgrp_get(vedata, ob, stl, psl, false);
|
|
|
|
|
}
|
2017-05-12 17:54:14 +02:00
|
|
|
|
2017-05-17 17:06:55 +10:00
|
|
|
if (is_sculpt_mode) {
|
2017-05-12 17:54:14 +02:00
|
|
|
DRW_shgroup_call_sculpt_add(clay_shgrp, ob, ob->obmat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DRW_shgroup_call_add(clay_shgrp, geom, ob->obmat);
|
|
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
2017-05-09 16:23:47 +02:00
|
|
|
|
2017-05-24 16:47:00 +02:00
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
|
Scene *scene = draw_ctx->scene;
|
|
|
|
|
Object *obedit = scene->obedit;
|
|
|
|
|
|
|
|
|
|
if (ob != obedit) {
|
|
|
|
|
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
|
|
|
|
if (psys_check_enabled(ob, psys, false)) {
|
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
|
|
|
|
|
|
|
|
|
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
|
|
|
|
|
draw_as = PART_DRAW_DOT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float mat[4][4];
|
|
|
|
|
unit_m4(mat);
|
|
|
|
|
|
|
|
|
|
if (draw_as == PART_DRAW_PATH) {
|
2017-06-22 19:19:55 +02:00
|
|
|
geom = DRW_cache_particles_get_hair(psys, NULL);
|
2017-09-11 23:15:29 +02:00
|
|
|
hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl);
|
2017-05-24 16:47:00 +02:00
|
|
|
DRW_shgroup_call_add(hair_shgrp, geom, mat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void CLAY_cache_finish(void *vedata)
|
2017-02-17 17:29:43 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
|
2017-02-08 21:44:13 +01:00
|
|
|
|
|
|
|
|
DRW_uniformbuffer_update(stl->mat_ubo, &stl->storage->mat_storage);
|
2017-05-09 16:23:47 +02:00
|
|
|
DRW_uniformbuffer_update(stl->hair_mat_ubo, &stl->storage->hair_mat_storage);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void CLAY_draw_scene(void *vedata)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
|
|
|
|
|
CLAY_PassList *psl = ((CLAY_Data *)vedata)->psl;
|
|
|
|
|
CLAY_FramebufferList *fbl = ((CLAY_Data *)vedata)->fbl;
|
2017-03-08 20:00:09 +01:00
|
|
|
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
2017-03-05 18:09:43 +01:00
|
|
|
|
2017-02-07 11:20:15 +01:00
|
|
|
/* Pass 1 : Depth pre-pass */
|
2017-02-17 17:29:43 +01:00
|
|
|
DRW_draw_pass(psl->depth_pass);
|
|
|
|
|
DRW_draw_pass(psl->depth_pass_cull);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-02-15 15:15:42 +01:00
|
|
|
/* Pass 2 : Duplicate depth */
|
|
|
|
|
/* Unless we go for deferred shading we need this to avoid manual depth test and artifacts */
|
2017-04-27 02:04:56 +10:00
|
|
|
if (DRW_state_is_fbo()) {
|
2017-05-16 03:03:58 +02:00
|
|
|
/* attach temp textures */
|
|
|
|
|
DRW_framebuffer_texture_attach(fbl->dupli_depth, e_data.depth_dup, 0, 0);
|
|
|
|
|
|
2017-11-10 23:36:05 +01:00
|
|
|
DRW_framebuffer_blit(dfbl->default_fb, fbl->dupli_depth, true, false);
|
2017-05-16 03:03:58 +02:00
|
|
|
|
|
|
|
|
/* detach temp textures */
|
|
|
|
|
DRW_framebuffer_texture_detach(e_data.depth_dup);
|
|
|
|
|
|
|
|
|
|
/* restore default fb */
|
|
|
|
|
DRW_framebuffer_bind(dfbl->default_fb);
|
2017-04-26 04:39:25 +10:00
|
|
|
}
|
2017-02-07 11:20:15 +01:00
|
|
|
|
|
|
|
|
/* Pass 3 : Shading */
|
2017-02-17 17:29:43 +01:00
|
|
|
DRW_draw_pass(psl->clay_pass);
|
2017-05-18 20:43:53 +10:00
|
|
|
DRW_draw_pass(psl->clay_pass_flat);
|
2017-05-09 16:23:47 +02:00
|
|
|
DRW_draw_pass(psl->hair_pass);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-05 16:27:31 +02:00
|
|
|
static void CLAY_layer_collection_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-03-30 17:01:23 +02:00
|
|
|
BLI_assert(props &&
|
|
|
|
|
props->type == IDP_GROUP &&
|
|
|
|
|
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
|
|
|
|
|
|
|
|
|
|
BKE_collection_engine_property_add_int(props, "matcap_icon", ICON_MATCAP_01);
|
|
|
|
|
BKE_collection_engine_property_add_int(props, "type", CLAY_MATCAP_NONE);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "matcap_rotation", 0.0f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "matcap_hue", 0.5f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "matcap_saturation", 0.5f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "matcap_value", 0.5f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "ssao_distance", 0.2f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "ssao_attenuation", 1.0f);
|
|
|
|
|
BKE_collection_engine_property_add_float(props, "ssao_factor_cavity", 1.0f);
|
2017-05-19 15:49:21 +02:00
|
|
|
BKE_collection_engine_property_add_float(props, "ssao_factor_edge", 1.0f);
|
2017-05-15 17:18:13 +02:00
|
|
|
BKE_collection_engine_property_add_float(props, "hair_brightness_randomness", 0.0f);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
static void CLAY_view_layer_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
|
2017-05-05 16:27:31 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(props &&
|
|
|
|
|
props->type == IDP_GROUP &&
|
|
|
|
|
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
|
|
|
|
|
|
2017-06-04 23:11:48 +02:00
|
|
|
BKE_collection_engine_property_add_int(props, "ssao_samples", 16);
|
2017-05-05 16:27:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
static void CLAY_engine_free(void)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2017-04-13 13:30:53 +10:00
|
|
|
DRW_SHADER_FREE_SAFE(e_data.clay_sh);
|
2017-05-18 20:43:53 +10:00
|
|
|
DRW_SHADER_FREE_SAFE(e_data.clay_flat_sh);
|
2017-05-09 16:23:47 +02:00
|
|
|
DRW_SHADER_FREE_SAFE(e_data.hair_sh);
|
2017-04-13 13:30:53 +10:00
|
|
|
DRW_TEXTURE_FREE_SAFE(e_data.matcap_array);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-04-12 19:49:19 +10:00
|
|
|
static const DrawEngineDataSize CLAY_data_size = DRW_VIEWPORT_DATA_SIZE(CLAY_Data);
|
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
DrawEngineType draw_engine_clay_type = {
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
N_("Clay"),
|
2017-04-12 19:49:19 +10:00
|
|
|
&CLAY_data_size,
|
2017-03-08 20:00:09 +01:00
|
|
|
&CLAY_engine_init,
|
|
|
|
|
&CLAY_engine_free,
|
|
|
|
|
&CLAY_cache_init,
|
|
|
|
|
&CLAY_cache_populate,
|
|
|
|
|
&CLAY_cache_finish,
|
|
|
|
|
NULL,
|
2017-09-25 20:07:02 +02:00
|
|
|
&CLAY_draw_scene,
|
|
|
|
|
NULL,
|
2017-03-08 20:00:09 +01:00
|
|
|
};
|
|
|
|
|
|
2017-04-26 17:42:39 +10:00
|
|
|
RenderEngineType DRW_engine_viewport_clay_type = {
|
2017-02-07 11:20:15 +01:00
|
|
|
NULL, NULL,
|
2017-05-01 14:55:59 +02:00
|
|
|
CLAY_ENGINE, N_("Clay"), RE_INTERNAL,
|
2017-05-05 16:27:31 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
2017-06-06 17:01:20 +02:00
|
|
|
&CLAY_layer_collection_settings_create,
|
2017-11-22 10:52:39 -02:00
|
|
|
&CLAY_view_layer_settings_create,
|
2017-03-08 20:00:09 +01:00
|
|
|
&draw_engine_clay_type,
|
2017-02-07 11:20:15 +01:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
|
};
|
2017-02-07 16:54:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef CLAY_ENGINE
|
|
|
|
|
|
|
|
|
|
#endif
|