Cleanup: line length

This commit is contained in:
Campbell Barton
2017-04-22 16:11:12 +10:00
parent 36b29c05db
commit 4ee36a2aea
10 changed files with 99 additions and 53 deletions

View File

@@ -372,7 +372,8 @@ static void CLAY_engine_init(void *vedata)
/* convert the view vectors to view space */
for (i = 0; i < 3; i++) {
mul_m4_v4(invproj, viewvecs[i]);
/* normalized trick see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
/* normalized trick see:
* http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][3]);
if (is_persp)
mul_v3_fl(viewvecs[i], 1.0f / viewvecs[i][2]);
@@ -429,9 +430,10 @@ static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, in
return grp;
}
static int search_mat_to_ubo(CLAY_Storage *storage, float matcap_rot, float matcap_hue, float matcap_sat,
float matcap_val, float ssao_distance, float ssao_factor_cavity,
float ssao_factor_edge, float ssao_attenuation, int matcap_icon)
static int search_mat_to_ubo(
CLAY_Storage *storage, float matcap_rot, float matcap_hue, float matcap_sat,
float matcap_val, float ssao_distance, float ssao_factor_cavity,
float ssao_factor_edge, float ssao_attenuation, int matcap_icon)
{
/* For now just use a linear search and test all parameters */
/* TODO make a hash table */
@@ -547,7 +549,9 @@ static void CLAY_cache_init(void *vedata)
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
psl->depth_pass_cull = DRW_pass_create(
"Depth Pass Cull",
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
}

View File

@@ -153,7 +153,9 @@ void hue_sat(float hue, float sat, float value, inout vec3 col)
#ifdef USE_AO
/* Prototype */
void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 screenco, out float cavities, out float edges);
void ssao_factors(
in float depth, in vec3 normal, in vec3 position, in vec2 screenco,
out float cavities, out float edges);
#endif
void main() {

View File

@@ -6,7 +6,9 @@
/* from The Alchemy screen-space ambient obscurance algorithm
* http://graphics.cs.williams.edu/papers/AlchemyHPG11/VV11AlchemyAO.pdf */
void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 screenco, out float cavities, out float edges)
void ssao_factors(
in float depth, in vec3 normal, in vec3 position, in vec2 screenco,
out float cavities, out float edges)
{
/* take the normalized ray direction here */
vec2 rotX = texture(ssao_jitter, screenco.xy * jitter_tilling).rg;

View File

@@ -49,7 +49,9 @@ float get_max_horizon(in vec2 co, in vec3 x, in vec3 omega_o, in float h)
return h;
}
void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 screenco, out float cavities, out float edges)
void ssao_factors(
in float depth, in vec3 normal, in vec3 position, in vec2 screenco,
out float cavities, out float edges)
{
/* Renaming */
vec3 omega_o = -normalize(position); /* viewvec */
@@ -117,4 +119,4 @@ void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 scre
cavities = 1.0 - A;
edges = 0.0;
}
}

View File

@@ -134,10 +134,11 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
lib_str = BLI_dynstr_get_cstring(ds_vert);
BLI_dynstr_free(ds_vert);
struct GPUShader *sh = DRW_shader_create_with_lib(datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, datatoc_bsdf_lut_frag_glsl, lib_str,
"#define HAMMERSLEY_SIZE 8192\n"
"#define BRDF_LUT_SIZE 64\n"
"#define NOISE_SIZE 64\n");
struct GPUShader *sh = DRW_shader_create_with_lib(
datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, datatoc_bsdf_lut_frag_glsl, lib_str,
"#define HAMMERSLEY_SIZE 8192\n"
"#define BRDF_LUT_SIZE 64\n"
"#define NOISE_SIZE 64\n");
DRWPass *pass = DRW_pass_create("Probe Filtering", DRW_STATE_WRITE_COLOR);
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
@@ -221,22 +222,25 @@ static void EEVEE_engine_init(void *ved)
lib_str = BLI_dynstr_get_cstring(ds_vert);
BLI_dynstr_free(ds_vert);
e_data.default_lit = DRW_shader_create_with_lib(datatoc_lit_surface_vert_glsl, NULL, datatoc_lit_surface_frag_glsl, lib_str,
"#define MAX_LIGHT 128\n"
"#define MAX_SHADOW_CUBE 42\n"
"#define MAX_SHADOW_MAP 64\n"
"#define MAX_SHADOW_CASCADE 8\n"
"#define MAX_CASCADE_NUM 4\n");
e_data.default_lit = DRW_shader_create_with_lib(
datatoc_lit_surface_vert_glsl, NULL, datatoc_lit_surface_frag_glsl, lib_str,
"#define MAX_LIGHT 128\n"
"#define MAX_SHADOW_CUBE 42\n"
"#define MAX_SHADOW_MAP 64\n"
"#define MAX_SHADOW_CASCADE 8\n"
"#define MAX_CASCADE_NUM 4\n");
MEM_freeN(lib_str);
}
if (!e_data.shadow_sh) {
e_data.shadow_sh = DRW_shader_create(datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, datatoc_shadow_frag_glsl, NULL);
e_data.shadow_sh = DRW_shader_create(
datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, datatoc_shadow_frag_glsl, NULL);
}
if (!e_data.probe_sh) {
e_data.probe_sh = DRW_shader_create(datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, datatoc_probe_frag_glsl, NULL);
e_data.probe_sh = DRW_shader_create(
datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, datatoc_probe_frag_glsl, NULL);
}
if (!e_data.probe_filter_sh) {
@@ -249,9 +253,10 @@ static void EEVEE_engine_init(void *ved)
shader_str = BLI_dynstr_get_cstring(ds_frag);
BLI_dynstr_free(ds_frag);
e_data.probe_filter_sh = DRW_shader_create(datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, shader_str,
"#define HAMMERSLEY_SIZE 8192\n"
"#define NOISE_SIZE 64\n");
e_data.probe_filter_sh = DRW_shader_create(
datatoc_probe_vert_glsl, datatoc_probe_geom_glsl, shader_str,
"#define HAMMERSLEY_SIZE 8192\n"
"#define NOISE_SIZE 64\n");
MEM_freeN(shader_str);
}
@@ -304,7 +309,8 @@ static DRWShadingGroup *eevee_cube_shgroup(struct GPUShader *sh, DRWPass *pass,
return grp;
}
static DRWShadingGroup *eevee_cube_shadow_shgroup(EEVEE_PassList *psl, EEVEE_StorageList *stl, struct Batch *geom, float (*obmat)[4])
static DRWShadingGroup *eevee_cube_shadow_shgroup(
EEVEE_PassList *psl, EEVEE_StorageList *stl, struct Batch *geom, float (*obmat)[4])
{
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.shadow_sh, psl->shadow_cube_pass, geom);
DRW_shgroup_uniform_block(grp, "shadow_render_block", stl->shadow_render_ubo, 0);
@@ -316,7 +322,8 @@ static DRWShadingGroup *eevee_cube_shadow_shgroup(EEVEE_PassList *psl, EEVEE_Sto
return grp;
}
static DRWShadingGroup *eevee_cascade_shadow_shgroup(EEVEE_PassList *psl, EEVEE_StorageList *stl, struct Batch *geom, float (*obmat)[4])
static DRWShadingGroup *eevee_cascade_shadow_shgroup(
EEVEE_PassList *psl, EEVEE_StorageList *stl, struct Batch *geom, float (*obmat)[4])
{
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.shadow_sh, psl->shadow_cascade_pass, geom);
DRW_shgroup_uniform_block(grp, "shadow_render_block", stl->shadow_render_ubo, 0);
@@ -395,7 +402,9 @@ static void EEVEE_cache_init(void *vedata)
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
psl->depth_pass_cull = DRW_pass_create(
"Depth Pass Cull",
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
}

View File

@@ -140,19 +140,28 @@ void EEVEE_lights_cache_finish(EEVEE_StorageList *stl, EEVEE_TextureList *txl, E
/* Initialize Textures Arrays first so DRW_framebuffer_init just bind them */
if (!txl->shadow_depth_cube_pool) {
txl->shadow_depth_cube_pool = DRW_texture_create_2D_array(512, 512, MAX2(1, linfo->num_cube * 6), DRW_TEX_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_cube_fb)
txl->shadow_depth_cube_pool = DRW_texture_create_2D_array(
512, 512, MAX2(1, linfo->num_cube * 6), DRW_TEX_DEPTH_24,
DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_cube_fb) {
DRW_framebuffer_texture_attach(fbl->shadow_cube_fb, txl->shadow_depth_cube_pool, 0, 0);
}
}
if (!txl->shadow_depth_map_pool) {
txl->shadow_depth_map_pool = DRW_texture_create_2D_array(512, 512, MAX2(1, linfo->num_map), DRW_TEX_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_map_fb)
txl->shadow_depth_map_pool = DRW_texture_create_2D_array(
512, 512, MAX2(1, linfo->num_map), DRW_TEX_DEPTH_24,
DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_map_fb) {
DRW_framebuffer_texture_attach(fbl->shadow_map_fb, txl->shadow_depth_map_pool, 0, 0);
}
}
if (!txl->shadow_depth_cascade_pool) {
txl->shadow_depth_cascade_pool = DRW_texture_create_2D_array(512, 512, MAX2(1, linfo->num_cascade * MAX_CASCADE_NUM), DRW_TEX_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_cascade_fb)
txl->shadow_depth_cascade_pool = DRW_texture_create_2D_array(
512, 512, MAX2(1, linfo->num_cascade * MAX_CASCADE_NUM), DRW_TEX_DEPTH_24,
DRW_TEX_FILTER | DRW_TEX_COMPARE, NULL);
if (fbl->shadow_cascade_fb) {
DRW_framebuffer_texture_attach(fbl->shadow_cascade_fb, txl->shadow_depth_map_pool, 0, 0);
}
}
DRWFboTexture tex_cube = {&txl->shadow_depth_cube_pool, DRW_BUF_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE};

View File

@@ -190,7 +190,9 @@ typedef struct DRWFboTexture {
DRWTextureFlag flag;
} DRWFboTexture;
void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTexture textures[MAX_FBO_TEX], int texnbr);
void DRW_framebuffer_init(
struct GPUFrameBuffer **fb, int width, int height,
DRWFboTexture textures[MAX_FBO_TEX], int textures_len);
void DRW_framebuffer_bind(struct GPUFrameBuffer *fb);
void DRW_framebuffer_clear(bool color, bool depth, bool stencil, float clear_col[4], float clear_depth);
void DRW_framebuffer_read_data(int x, int y, int w, int h, int channels, int slot, float *data);
@@ -200,8 +202,10 @@ void DRW_framebuffer_blit(struct GPUFrameBuffer *fb_read, struct GPUFrameBuffer
void DRW_framebuffer_viewport_size(struct GPUFrameBuffer *UNUSED(fb_read), int w, int h);
/* Shaders */
struct GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, const char *frag, const char *lib, const char *defines);
struct GPUShader *DRW_shader_create(
const char *vert, const char *geom, const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_with_lib(
const char *vert, const char *geom, const char *frag, const char *lib, const char *defines);
struct GPUShader *DRW_shader_create_2D(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_3D(const char *frag, const char *defines);
struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines);

View File

@@ -403,7 +403,8 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
/* this function set the object space to use
* for all subsequent DRW_shgroup_bone_*** calls */
static void DRW_shgroup_armature(
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire, DRWShadingGroup *shgrp_relationship_lines)
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire,
DRWShadingGroup *shgrp_relationship_lines)
{
current_armature = ob;
bone_octahedral_solid = NULL;
@@ -418,7 +419,8 @@ static void DRW_shgroup_armature(
}
void DRW_shgroup_armature_object(
Object *ob, SceneLayer *sl, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire, DRWShadingGroup *shgrp_relationship_lines)
Object *ob, SceneLayer *sl, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire,
DRWShadingGroup *shgrp_relationship_lines)
{
float *color;
DRW_object_wire_theme_get(ob, sl, &color);
@@ -428,15 +430,17 @@ void DRW_shgroup_armature_object(
}
void DRW_shgroup_armature_pose(
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire, DRWShadingGroup *shgrp_relationship_lines)
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire,
DRWShadingGroup *shgrp_relationship_lines)
{
DRW_shgroup_armature(ob, pass_bone_solid, pass_bone_wire, shgrp_relationship_lines);
draw_armature_pose(ob, NULL);
}
void DRW_shgroup_armature_edit(
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire, DRWShadingGroup *shgrp_relationship_lines)
Object *ob, DRWPass *pass_bone_solid, DRWPass *pass_bone_wire,
DRWShadingGroup *shgrp_relationship_lines)
{
DRW_shgroup_armature(ob, pass_bone_solid, pass_bone_wire, shgrp_relationship_lines);
draw_armature_edit(ob);
}
}

View File

@@ -299,7 +299,8 @@ GPUTexture *DRW_texture_create_2D(int w, int h, DRWTextureFormat format, DRWText
return tex;
}
GPUTexture *DRW_texture_create_2D_array(int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
GPUTexture *DRW_texture_create_2D_array(
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
{
GPUTexture *tex;
GPUTextureFormat data_type;
@@ -362,7 +363,8 @@ GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *fra
return GPU_shader_create(vert, frag, geom, NULL, defines);
}
GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, const char *frag, const char *lib, const char *defines)
GPUShader *DRW_shader_create_with_lib(
const char *vert, const char *geom, const char *frag, const char *lib, const char *defines)
{
GPUShader *sh;
char *vert_with_lib = NULL;
@@ -700,10 +702,12 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup)
for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) {
BLI_assert(attrib->size <= 4); /* matrices have no place here for now */
if (attrib->type == DRW_ATTRIB_FLOAT) {
attrib->format_id = VertexFormat_add_attrib(&interface->vbo_format, attrib->name, COMP_F32, attrib->size, KEEP_FLOAT);
attrib->format_id = VertexFormat_add_attrib(
&interface->vbo_format, attrib->name, COMP_F32, attrib->size, KEEP_FLOAT);
}
else if (attrib->type == DRW_ATTRIB_INT) {
attrib->format_id = VertexFormat_add_attrib(&interface->vbo_format, attrib->name, COMP_I8, attrib->size, KEEP_INT);
attrib->format_id = VertexFormat_add_attrib(
&interface->vbo_format, attrib->name, COMP_I8, attrib->size, KEEP_INT);
}
else {
BLI_assert(false);
@@ -1060,12 +1064,14 @@ static void draw_shgroup(DRWShadingGroup *shgroup)
switch (uni->type) {
case DRW_UNIFORM_BOOL:
case DRW_UNIFORM_INT:
GPU_shader_uniform_vector_int(shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)uni->value);
GPU_shader_uniform_vector_int(
shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)uni->value);
break;
case DRW_UNIFORM_FLOAT:
case DRW_UNIFORM_MAT3:
case DRW_UNIFORM_MAT4:
GPU_shader_uniform_vector(shgroup->shader, uni->location, uni->length, uni->arraysize, (float *)uni->value);
GPU_shader_uniform_vector(
shgroup->shader, uni->location, uni->length, uni->arraysize, (float *)uni->value);
break;
case DRW_UNIFORM_TEXTURE:
tex = (GPUTexture *)uni->value;
@@ -1250,16 +1256,17 @@ static GPUTextureFormat convert_tex_format(int fbo_format, int *channels, bool *
}
}
void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTexture textures[MAX_FBO_TEX],
int texnbr)
void DRW_framebuffer_init(
struct GPUFrameBuffer **fb, int width, int height,
DRWFboTexture textures[MAX_FBO_TEX], int textures_len)
{
BLI_assert(texnbr <= MAX_FBO_TEX);
BLI_assert(textures_len <= MAX_FBO_TEX);
if (!*fb) {
int color_attachment = -1;
*fb = GPU_framebuffer_create();
for (int i = 0; i < texnbr; ++i) {
for (int i = 0; i < textures_len; ++i) {
int channels;
bool is_depth;

View File

@@ -103,7 +103,9 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx)
return total_ct;
}
static bool drawgrid_draw(ARegion *ar, double x0, double y0, double dx, int skip_mod, unsigned pos, unsigned col, GLubyte col_value[3])
static bool drawgrid_draw(
ARegion *ar, double x0, double y0, double dx, int skip_mod,
unsigned pos, unsigned col, GLubyte col_value[3])
{
/* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw
* always skip exact x0 & y0 axes; they will be drawn later in color
@@ -297,8 +299,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **
if (grids_to_draw == 2) {
UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2);
if (drawgrid_draw(ar, x, y, dx, v3d->gridsubdiv, pos, color, col2))
if (drawgrid_draw(ar, x, y, dx, v3d->gridsubdiv, pos, color, col2)) {
drawgrid_draw(ar, x, y, dx * sublines, 0, pos, color, col);
}
}
else if (grids_to_draw == 1) {
drawgrid_draw(ar, x, y, dx, 0, pos, color, col);