diff options
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 157 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_lamp.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 51 |
3 files changed, 30 insertions, 184 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 8b344716a9c..e0a71f841fd 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -31,8 +31,8 @@ * Utility functions for dealing with OpenGL texture & material context, * mipmap generation and light objects. * - * These are some obscure rendering functions shared between the - * game engine and the blender, in this module to avoid duplication + * These are some obscure rendering functions shared between the game engine (not anymore) + * and the blender, in this module to avoid duplication * and abstract them away from the rest a bit. */ @@ -70,9 +70,6 @@ #include "BKE_node.h" #include "BKE_scene.h" #include "BKE_DerivedMesh.h" -#ifdef WITH_GAMEENGINE -# include "BKE_object.h" -#endif #include "GPU_basic_shader.h" #include "GPU_buffers.h" @@ -98,131 +95,7 @@ extern Material defmaterial; /* from material.c */ -/* Text Rendering */ - -static void gpu_mcol(unsigned int ucol) -{ - /* mcol order is swapped */ - const char *cp = (char *)&ucol; - glColor3ub(cp[3], cp[2], cp[1]); -} - -void GPU_render_text( - int mode, const char *textstr, int textlen, unsigned int *col, - const float *v_quad[4], const float *uv_quad[4], - int glattrib) -{ - /* XXX, 2.8 removes texface */ -#if 0 - Image *ima = mtexpoly->tpage; -#else - Image *ima = NULL; -#endif - if ((mode & GEMAT_TEXT) && (textlen > 0) && ima) { - const float *v1 = v_quad[0]; - const float *v2 = v_quad[1]; - const float *v3 = v_quad[2]; - const float *v4 = v_quad[3]; - const size_t textlen_st = textlen; - float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; - - /* multiline */ - float line_start = 0.0f, line_height; - - if (v4) - line_height = max_ffff(v1[1], v2[1], v3[1], v4[2]) - min_ffff(v1[1], v2[1], v3[1], v4[2]); - else - line_height = max_fff(v1[1], v2[1], v3[1]) - min_fff(v1[1], v2[1], v3[1]); - line_height *= 1.2f; /* could be an option? */ - /* end multiline */ - - - /* color has been set */ - if (!col) - glColor3f(1.0f, 1.0f, 1.0f); - - gpuPushMatrix(); - - /* get the tab width */ - ImBuf *first_ibuf = BKE_image_get_first_ibuf(ima); - matrixGlyph(first_ibuf, ' ', ¢erx, ¢ery, - &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - - float advance_tab = advance * 4; /* tab width could also be an option */ - - - for (size_t index = 0; index < textlen_st; ) { - unsigned int character; - float uv[4][2]; - - /* lets calculate offset stuff */ - character = BLI_str_utf8_as_unicode_and_size_safe(textstr + index, &index); - - if (character == '\n') { - gpuTranslate2f(line_start, -line_height); - line_start = 0.0f; - continue; - } - else if (character == '\t') { - gpuTranslate2f(advance_tab, 0.0f); - line_start -= advance_tab; /* so we can go back to the start of the line */ - continue; - - } - else if (character > USHRT_MAX) { - /* not much we can do here bmfonts take ushort */ - character = '?'; - } - - /* space starts at offset 1 */ - /* character = character - ' ' + 1; */ - matrixGlyph(first_ibuf, character, & centerx, ¢ery, - &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - - uv[0][0] = (uv_quad[0][0] - centerx) * sizex + transx; - uv[0][1] = (uv_quad[0][1] - centery) * sizey + transy; - uv[1][0] = (uv_quad[1][0] - centerx) * sizex + transx; - uv[1][1] = (uv_quad[1][1] - centery) * sizey + transy; - uv[2][0] = (uv_quad[2][0] - centerx) * sizex + transx; - uv[2][1] = (uv_quad[2][1] - centery) * sizey + transy; - - glBegin(GL_POLYGON); - if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[0]); - else glTexCoord2fv(uv[0]); - if (col) gpu_mcol(col[0]); - glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]); - - if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[1]); - else glTexCoord2fv(uv[1]); - if (col) gpu_mcol(col[1]); - glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]); - - if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[2]); - else glTexCoord2fv(uv[2]); - if (col) gpu_mcol(col[2]); - glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); - - if (v4) { - uv[3][0] = (uv_quad[3][0] - centerx) * sizex + transx; - uv[3][1] = (uv_quad[3][1] - centery) * sizey + transy; - - if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[3]); - else glTexCoord2fv(uv[3]); - if (col) gpu_mcol(col[3]); - glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]); - } - glEnd(); - - gpuTranslate2f(advance, 0.0f); - line_start -= advance; /* so we can go back to the start of the line */ - } - gpuPopMatrix(); - - BKE_image_release_ibuf(ima, first_ibuf, NULL); - } -} - -/* Checking powers of two for images since OpenGL ES requires it */ +//* Checking powers of two for images since OpenGL ES requires it */ #ifdef WITH_DDS static bool is_power_of_2_resolution(int w, int h) { @@ -1553,7 +1426,7 @@ void GPU_end_dupli_object(void) } void GPU_begin_object_materials( - View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob, + View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *UNUSED(view_layer), Object *ob, bool glsl, bool *do_alpha_after) { Material *ma; @@ -1590,14 +1463,6 @@ void GPU_begin_object_materials( } #endif -#ifdef WITH_GAMEENGINE - if (rv3d->rflag & RV3D_IS_GAME_ENGINE) { - ob = BKE_object_lod_matob_get(ob, view_layer); - } -#else - UNUSED_VARS(view_layer); -#endif - /* initialize state */ /* DupliObject must be restored */ dob = GMS.dob; @@ -1843,18 +1708,10 @@ int GPU_object_material_bind(int nr, void *attribs) GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gob->col, auto_bump_scale, &partile_info, object_info); GMS.gboundmat = mat; - /* for glsl use alpha blend mode, unless it's set to solid and - * we are already drawing in an alpha pass */ - if (mat->game.alpha_blend != GPU_BLEND_SOLID) - alphablend = mat->game.alpha_blend; - if (GMS.is_alpha_pass) glDepthMask(1); if (GMS.backface_culling) { - if (mat->game.flag) - glEnable(GL_CULL_FACE); - else - glDisable(GL_CULL_FACE); + glDisable(GL_CULL_FACE); } if (GMS.use_matcaps) @@ -2120,8 +1977,8 @@ static void gpu_disable_multisample(void) /* Default OpenGL State * - * This is called on startup, for opengl offscreen render and to restore state - * for the game engine. Generally we should always return to this state when + * This is called on startup, for opengl offscreen render. + * Generally we should always return to this state when * temporarily modifying the state for drawing, though that are (undocumented) * exceptions that we should try to get rid of. */ diff --git a/source/blender/gpu/intern/gpu_lamp.c b/source/blender/gpu/intern/gpu_lamp.c index 8968521060d..f8ca11782a5 100644 --- a/source/blender/gpu/intern/gpu_lamp.c +++ b/source/blender/gpu/intern/gpu_lamp.c @@ -345,11 +345,9 @@ void GPU_lamp_free(Object *ob) BLI_freelistN(&ob->gpulamp); } -bool GPU_lamp_has_shadow_buffer(GPULamp *lamp) +bool GPU_lamp_has_shadow_buffer(GPULamp *UNUSED(lamp)) { - return (!(lamp->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && - !(lamp->scene->gm.flag & GAME_GLSL_NO_LIGHTS) && - lamp->tex && lamp->fb); + return false; } void GPU_lamp_update_buffer_mats(GPULamp *lamp) diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 98d8eea6036..53ef9835d1d 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1049,7 +1049,7 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff) Material *ma = shi->mat; GPUMaterial *mat = shi->gpumat; - if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) { + { if (ma->ramp_col) { if (ma->rampin_col == MA_RAMP_IN_RESULT) { GPUNodeLink *fac; @@ -1068,9 +1068,7 @@ static void add_to_diffuse( { GPUNodeLink *fac, *tmp, *addcol; - if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && - ma->ramp_col && (ma->mode & MA_RAMP_COL)) - { + if (ma->ramp_col && (ma->mode & MA_RAMP_COL)) { /* MA_RAMP_IN_RESULT is exceptional */ if (ma->rampin_col == MA_RAMP_IN_RESULT) { addcol = shi->rgb; @@ -1108,9 +1106,7 @@ static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec) Material *ma = shi->mat; GPUMaterial *mat = shi->gpumat; - if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && - ma->ramp_spec && ma->rampin_spec == MA_RAMP_IN_RESULT) - { + if (ma->ramp_spec && ma->rampin_spec == MA_RAMP_IN_RESULT) { GPUNodeLink *fac; GPU_link(mat, "ramp_rgbtobw", *spec, &fac); @@ -1224,7 +1220,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la is = inp; /* Lambert */ - if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) { + { if (ma->diff_shader == MA_DIFF_ORENNAYAR) GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is); @@ -1240,10 +1236,9 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) - if (ma->shade_flag & MA_CUBIC) - GPU_link(mat, "shade_cubic", is, &is); - + if (ma->shade_flag & MA_CUBIC) + GPU_link(mat, "shade_cubic", is, &is); + i = is; GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i); @@ -1260,8 +1255,8 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la /* this replaces if (i > 0.0) conditional until that is supported */ /* done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); */ - if ((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) { - if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) { + if (ma->mode & MA_SHADOW) { + { mat->dynproperty |= DYN_LAMP_PERSMAT; if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) { @@ -1300,7 +1295,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } } - else if ((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { + else if (lamp->mode & LA_ONLYSHADOW) { add_user_list(&mat->lamps, lamp); return; } @@ -1318,10 +1313,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la } } - if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS) { - /* pass */ - } - else if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && + if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && (GPU_link_changed(shi->spec) || ma->spec != 0.0f)) { if (lamp->type == LA_HEMI) { @@ -1674,7 +1666,7 @@ static void do_material_tex(GPUShadeInput *shi) texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) { + if (mtex->mapto & MAP_COLSPEC) { GPUNodeLink *colspecfac; if (mtex->colspecfac == 1.0f) colspecfac = stencil; @@ -1698,7 +1690,7 @@ static void do_material_tex(GPUShadeInput *shi) } } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { + if (mtex->mapto & MAP_NORM) { if (tex->type == TEX_IMAGE) { found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP; @@ -1905,7 +1897,7 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_rgbtoint", trgb, &tin); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { + if (mtex->mapto & MAP_REF) { GPUNodeLink *difffac; if (mtex->difffac == 1.0f) difffac = stencil; @@ -1916,7 +1908,7 @@ static void do_material_tex(GPUShadeInput *shi) mtex->blendtype, &shi->refl); GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { + if (mtex->mapto & MAP_SPEC) { GPUNodeLink *specfac; if (mtex->specfac == 1.0f) specfac = stencil; @@ -1927,7 +1919,7 @@ static void do_material_tex(GPUShadeInput *shi) mtex->blendtype, &shi->spec); GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { + if (mtex->mapto & MAP_EMIT) { GPUNodeLink *emitfac; if (mtex->emitfac == 1.0f) emitfac = stencil; @@ -1938,7 +1930,7 @@ static void do_material_tex(GPUShadeInput *shi) mtex->blendtype, &shi->emit); GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { + if (mtex->mapto & MAP_HAR) { GPUNodeLink *hardfac; if (mtex->hardfac == 1.0f) hardfac = stencil; @@ -1961,7 +1953,7 @@ static void do_material_tex(GPUShadeInput *shi) mtex->blendtype, &shi->alpha); GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha); } - if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { + if (mtex->mapto & MAP_AMB) { GPUNodeLink *ambfac; if (mtex->ambfac == 1.0f) ambfac = stencil; @@ -2056,7 +2048,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) do_material_tex(shi); - if ((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { + if (ma->mode & MA_SHLESS) { GPU_link(mat, "set_rgb", shi->rgb, &shr->diff); GPU_link(mat, "set_rgb_zero", &shr->spec); GPU_link(mat, "set_value", shi->alpha, &shr->alpha); @@ -2098,8 +2090,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) } /* environment lighting */ - if (!(mat->scene->gm.flag & GAME_GLSL_NO_ENV_LIGHTING) && - (world->mode & WO_ENV_LIGHT) && + if ((world->mode & WO_ENV_LIGHT) && (mat->scene->r.mode & R_SHADOW) && !BKE_scene_use_new_shading_nodes(mat->scene)) { @@ -2608,7 +2599,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_open else if (new_shading_nodes && ma->alpha < 1.0f) GPU_material_enable_alpha(mat); - if (!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { + if (ma->nodetree && ma->use_nodes) { /* create nodes */ if (new_shading_nodes) ntreeGPUMaterialNodes(ma->nodetree, mat, NODE_NEW_SHADING); |