2011-02-23 10:52:22 +00:00
|
|
|
/*
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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
|
2011-11-29 10:54:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): Brecht Van Lommel.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:25:53 +00:00
|
|
|
/** \file blender/gpu/intern/gpu_draw.c
|
|
|
|
* \ingroup gpu
|
2014-01-19 23:14:24 +11:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* and abstract them away from the rest a bit.
|
2011-02-27 20:25:53 +00:00
|
|
|
*/
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-06-15 14:01:16 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2018-02-14 14:32:38 +01:00
|
|
|
#include "BLI_hash.h"
|
2013-06-15 14:01:16 +00:00
|
|
|
#include "BLI_linklist.h"
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
#include "BLI_math.h"
|
2013-06-15 14:01:16 +00:00
|
|
|
#include "BLI_threads.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
2015-11-27 21:28:36 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2009-08-20 00:33:59 +00:00
|
|
|
#include "DNA_modifier_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2009-08-20 00:33:59 +00:00
|
|
|
#include "DNA_smoke_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2016-12-28 17:30:58 +01:00
|
|
|
#include "DNA_particle_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
#include "BKE_bmfont.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_node.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-12-09 23:26:06 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
2016-06-09 09:52:41 +02:00
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
# include "BKE_object.h"
|
|
|
|
#endif
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_basic_shader.h"
|
2010-07-14 10:46:12 +00:00
|
|
|
#include "GPU_buffers.h"
|
|
|
|
#include "GPU_draw.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
#include "GPU_material.h"
|
2017-03-21 02:51:02 -04:00
|
|
|
#include "GPU_matrix.h"
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_shader.h"
|
|
|
|
#include "GPU_texture.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-05-22 11:58:07 +10:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2016-06-09 05:37:46 +10:00
|
|
|
#ifdef WITH_SMOKE
|
|
|
|
# include "smoke_API.h"
|
|
|
|
#endif
|
2009-09-09 18:39:40 +00:00
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifdef WITH_OPENSUBDIV
|
2016-06-09 05:37:46 +10:00
|
|
|
# include "BKE_subsurf.h"
|
2015-07-20 16:08:06 +02:00
|
|
|
# include "BKE_editmesh.h"
|
|
|
|
|
|
|
|
# include "gpu_codegen.h"
|
|
|
|
#endif
|
|
|
|
|
2011-05-10 14:48:06 +00:00
|
|
|
extern Material defmaterial; /* from material.c */
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* Text Rendering */
|
|
|
|
|
|
|
|
static void gpu_mcol(unsigned int ucol)
|
|
|
|
{
|
|
|
|
/* mcol order is swapped */
|
2015-03-23 15:29:42 -04:00
|
|
|
const char *cp = (char *)&ucol;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
}
|
|
|
|
|
2015-07-14 22:27:25 +10:00
|
|
|
void GPU_render_text(
|
2017-05-25 00:34:14 +10:00
|
|
|
int mode, const char *textstr, int textlen, unsigned int *col,
|
2015-07-14 22:27:25 +10:00
|
|
|
const float *v_quad[4], const float *uv_quad[4],
|
|
|
|
int glattrib)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2017-05-24 23:14:32 +10:00
|
|
|
/* XXX, 2.8 removes texface */
|
|
|
|
#if 0
|
|
|
|
Image *ima = mtexpoly->tpage;
|
|
|
|
#else
|
|
|
|
Image *ima = NULL;
|
|
|
|
#endif
|
|
|
|
if ((mode & GEMAT_TEXT) && (textlen > 0) && ima) {
|
2015-07-14 22:27:25 +10:00
|
|
|
const float *v1 = v_quad[0];
|
|
|
|
const float *v2 = v_quad[1];
|
|
|
|
const float *v3 = v_quad[2];
|
|
|
|
const float *v4 = v_quad[3];
|
2014-01-23 13:29:49 +11:00
|
|
|
const size_t textlen_st = textlen;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
/* multiline */
|
2015-03-23 15:29:42 -04:00
|
|
|
float line_start = 0.0f, line_height;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if (v4)
|
2012-12-21 05:07:26 +00:00
|
|
|
line_height = max_ffff(v1[1], v2[1], v3[1], v4[2]) - min_ffff(v1[1], v2[1], v3[1], v4[2]);
|
2009-04-20 15:06:46 +00:00
|
|
|
else
|
2012-12-21 05:07:26 +00:00
|
|
|
line_height = max_fff(v1[1], v2[1], v3[1]) - min_fff(v1[1], v2[1], v3[1]);
|
2011-04-03 10:04:16 +00:00
|
|
|
line_height *= 1.2f; /* could be an option? */
|
2009-04-20 15:06:46 +00:00
|
|
|
/* end multiline */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
/* color has been set */
|
2017-05-25 00:34:14 +10:00
|
|
|
if (!col)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
2017-03-21 16:08:14 -04:00
|
|
|
gpuPushMatrix();
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
/* get the tab width */
|
2016-01-07 13:05:53 -05:00
|
|
|
ImBuf *first_ibuf = BKE_image_get_first_ibuf(ima);
|
2013-12-13 16:22:08 +06:00
|
|
|
matrixGlyph(first_ibuf, ' ', ¢erx, ¢ery,
|
2017-04-04 20:33:23 +02:00
|
|
|
&sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
float advance_tab = advance * 4; /* tab width could also be an option */
|
2017-04-04 20:33:23 +02:00
|
|
|
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
for (size_t index = 0; index < textlen_st; ) {
|
2014-01-23 13:37:09 +11:00
|
|
|
unsigned int character;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
float uv[4][2];
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* lets calculate offset stuff */
|
2014-01-23 13:29:49 +11:00
|
|
|
character = BLI_str_utf8_as_unicode_and_size_safe(textstr + index, &index);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (character == '\n') {
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuTranslate2f(line_start, -line_height);
|
2009-04-20 15:06:46 +00:00
|
|
|
line_start = 0.0f;
|
|
|
|
continue;
|
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (character == '\t') {
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuTranslate2f(advance_tab, 0.0f);
|
2009-04-20 15:06:46 +00:00
|
|
|
line_start -= advance_tab; /* so we can go back to the start of the line */
|
|
|
|
continue;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
2014-01-23 13:37:09 +11:00
|
|
|
else if (character > USHRT_MAX) {
|
|
|
|
/* not much we can do here bmfonts take ushort */
|
|
|
|
character = '?';
|
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* space starts at offset 1 */
|
|
|
|
/* character = character - ' ' + 1; */
|
2013-12-13 16:22:08 +06:00
|
|
|
matrixGlyph(first_ibuf, character, & centerx, ¢ery,
|
2017-04-04 20:33:23 +02:00
|
|
|
&sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-07-14 22:27:25 +10:00
|
|
|
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;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glBegin(GL_POLYGON);
|
2015-11-24 02:20:38 -05:00
|
|
|
if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[0]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else glTexCoord2fv(uv[0]);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (col) gpu_mcol(col[0]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[1]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else glTexCoord2fv(uv[1]);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (col) gpu_mcol(col[1]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
|
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[2]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else glTexCoord2fv(uv[2]);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (col) gpu_mcol(col[2]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v4) {
|
2015-07-14 22:27:25 +10:00
|
|
|
uv[3][0] = (uv_quad[3][0] - centerx) * sizex + transx;
|
|
|
|
uv[3][1] = (uv_quad[3][1] - centery) * sizey + transy;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (glattrib >= 0) glVertexAttrib2fv(glattrib, uv[3]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else glTexCoord2fv(uv[3]);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (col) gpu_mcol(col[3]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuTranslate2f(advance, 0.0f);
|
2009-04-20 15:06:46 +00:00
|
|
|
line_start -= advance; /* so we can go back to the start of the line */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuPopMatrix();
|
2013-12-13 16:22:08 +06:00
|
|
|
|
2014-01-03 23:00:53 +06:00
|
|
|
BKE_image_release_ibuf(ima, first_ibuf, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-07 10:40:13 -05:00
|
|
|
/* Checking powers of two for images since OpenGL ES requires it */
|
2017-03-02 00:36:33 +11:00
|
|
|
#ifdef WITH_DDS
|
2017-02-23 11:03:56 +01:00
|
|
|
static bool is_power_of_2_resolution(int w, int h)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2013-03-15 16:16:11 +00:00
|
|
|
return is_power_of_2_i(w) && is_power_of_2_i(h);
|
|
|
|
}
|
2017-03-02 00:36:33 +11:00
|
|
|
#endif
|
2009-08-16 01:25:53 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
static bool is_over_resolution_limit(GLenum textarget, int w, int h)
|
2013-03-15 16:16:11 +00:00
|
|
|
{
|
2016-01-28 17:23:12 +11:00
|
|
|
int size = (textarget == GL_TEXTURE_2D) ?
|
|
|
|
GPU_max_texture_size() : GPU_max_cube_map_size();
|
2016-01-10 07:12:10 +11:00
|
|
|
int reslimit = (U.glreslimit != 0) ?
|
2017-04-04 20:33:23 +02:00
|
|
|
min_ii(U.glreslimit, size) : size;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2013-04-12 17:56:07 +00:00
|
|
|
return (w > reslimit || h > reslimit);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:16:11 +00:00
|
|
|
static int smaller_power_of_2_limit(int num)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-01-10 07:12:10 +11:00
|
|
|
int reslimit = (U.glreslimit != 0) ?
|
2016-01-28 17:23:12 +11:00
|
|
|
min_ii(U.glreslimit, GPU_max_texture_size()) :
|
|
|
|
GPU_max_texture_size();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* take texture clamping into account */
|
2013-04-12 17:56:07 +00:00
|
|
|
if (num > reslimit)
|
|
|
|
return reslimit;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2011-12-16 09:25:07 +00:00
|
|
|
return power_of_2_min_i(num);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Current OpenGL state caching for GPU_set_tpage */
|
|
|
|
|
|
|
|
static struct GPUTextureState {
|
|
|
|
int curtile, tile;
|
|
|
|
int curtilemode, tilemode;
|
|
|
|
int curtileXRep, tileXRep;
|
|
|
|
int curtileYRep, tileYRep;
|
|
|
|
Image *ima, *curima;
|
|
|
|
|
2015-04-28 01:14:48 +10:00
|
|
|
/* also controls min/mag filtering */
|
|
|
|
bool domipmap;
|
|
|
|
/* only use when 'domipmap' is set */
|
|
|
|
bool linearmipmap;
|
|
|
|
/* store this so that new images created while texture painting won't be set to mipmapped */
|
|
|
|
bool texpaint;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
int alphablend;
|
2011-06-15 18:59:22 +00:00
|
|
|
float anisotropic;
|
2012-06-11 16:23:10 +00:00
|
|
|
int gpu_mipmap;
|
2017-05-25 00:34:14 +10:00
|
|
|
} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.0f, 0};
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* Mipmap settings */
|
|
|
|
|
2012-12-05 11:46:13 +00:00
|
|
|
void GPU_set_gpu_mipmapping(int gpu_mipmap)
|
2012-06-20 16:43:48 +00:00
|
|
|
{
|
2012-12-05 11:46:13 +00:00
|
|
|
int old_value = GTS.gpu_mipmap;
|
|
|
|
|
|
|
|
/* only actually enable if it's supported */
|
2016-08-04 21:11:45 -04:00
|
|
|
GTS.gpu_mipmap = gpu_mipmap;
|
2012-12-05 11:46:13 +00:00
|
|
|
|
|
|
|
if (old_value != GTS.gpu_mipmap) {
|
|
|
|
GPU_free_images();
|
|
|
|
}
|
2012-06-11 16:23:10 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 01:03:28 +10:00
|
|
|
void GPU_set_mipmap(bool mipmap)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2015-04-28 01:03:28 +10:00
|
|
|
if (GTS.domipmap != mipmap) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_free_images();
|
2015-04-28 01:03:28 +10:00
|
|
|
GTS.domipmap = mipmap;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-28 01:03:28 +10:00
|
|
|
void GPU_set_linear_mipmap(bool linear)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2015-04-28 01:03:28 +10:00
|
|
|
if (GTS.linearmipmap != linear) {
|
|
|
|
GTS.linearmipmap = linear;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-28 01:03:28 +10:00
|
|
|
bool GPU_get_mipmap(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
Index: source/blender/gpu/intern/gpu_draw.c
===================================================================
--- source/blender/gpu/intern/gpu_draw.c (revision 47568)
+++ source/blender/gpu/intern/gpu_draw.c (working copy)
@@ -230,11 +230,12 @@
Image *ima, *curima;
int domipmap, linearmipmap;
+ int texpaint; /* store this so that new images created while texture painting won't be set to mipmapped */
int alphablend;
float anisotropic;
MTFace *lasttface;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL};
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, NULL};
/* Mipmap settings */
@@ -256,7 +257,7 @@
static int gpu_get_mipmap(void)
{
- return GTS.domipmap;
+ return GTS.domipmap && !GTS.texpaint;
}
static GLenum gpu_get_mipmap_filter(int mag)
@@ -730,6 +731,8 @@
if (!GTS.domipmap)
return;
+ GTS.texpaint = !mipmap;
+
if (mipmap) {
for (ima=G.main->image.first; ima; ima=ima->id.next) {
if (ima->bindcode) {
2012-06-08 13:06:06 +00:00
|
|
|
return GTS.domipmap && !GTS.texpaint;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 01:03:28 +10:00
|
|
|
bool GPU_get_linear_mipmap(void)
|
2013-04-14 00:40:24 +00:00
|
|
|
{
|
|
|
|
return GTS.linearmipmap;
|
|
|
|
}
|
|
|
|
|
2015-04-28 01:03:28 +10:00
|
|
|
static GLenum gpu_get_mipmap_filter(bool mag)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2008-10-12 00:41:28 +00:00
|
|
|
/* linearmipmap is off by default *when mipmapping is off,
|
|
|
|
* use unfiltered display */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mag) {
|
2015-04-28 01:14:48 +10:00
|
|
|
if (GTS.domipmap)
|
2008-10-12 00:41:28 +00:00
|
|
|
return GL_LINEAR;
|
|
|
|
else
|
|
|
|
return GL_NEAREST;
|
|
|
|
}
|
|
|
|
else {
|
2015-04-28 01:14:48 +10:00
|
|
|
if (GTS.domipmap) {
|
|
|
|
if (GTS.linearmipmap) {
|
|
|
|
return GL_LINEAR_MIPMAP_LINEAR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return GL_LINEAR_MIPMAP_NEAREST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-10-12 00:41:28 +00:00
|
|
|
return GL_NEAREST;
|
2015-04-28 01:14:48 +10:00
|
|
|
}
|
2008-10-12 00:41:28 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 18:59:22 +00:00
|
|
|
/* Anisotropic filtering settings */
|
|
|
|
void GPU_set_anisotropic(float value)
|
|
|
|
{
|
2012-03-06 18:40:15 +00:00
|
|
|
if (GTS.anisotropic != value) {
|
2011-06-15 18:59:22 +00:00
|
|
|
GPU_free_images();
|
|
|
|
|
|
|
|
/* Clamp value to the maximum value the graphics card supports */
|
2016-01-07 11:21:08 -05:00
|
|
|
const float max = GPU_max_texture_anisotropy();
|
|
|
|
if (value > max)
|
|
|
|
value = max;
|
2011-06-15 18:59:22 +00:00
|
|
|
|
|
|
|
GTS.anisotropic = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-28 05:06:30 +00:00
|
|
|
float GPU_get_anisotropic(void)
|
2011-06-15 18:59:22 +00:00
|
|
|
{
|
|
|
|
return GTS.anisotropic;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* Set OpenGL state for an MTFace */
|
|
|
|
|
|
|
|
static void gpu_make_repbind(Image *ima)
|
|
|
|
{
|
2016-01-07 13:05:53 -05:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ibuf == NULL)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->repbind) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
|
|
|
|
MEM_freeN(ima->repbind);
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->repbind = NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
ima->totbind = ima->xrep * ima->yrep;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
if (ima->totbind > 1) {
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->repbind = MEM_callocN(sizeof(int) * ima->totbind, "repbind");
|
2016-01-10 07:12:10 +11:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
static unsigned int *gpu_get_image_bindcode(Image *ima, GLenum textarget)
|
|
|
|
{
|
|
|
|
unsigned int *bind = 0;
|
|
|
|
|
|
|
|
if (textarget == GL_TEXTURE_2D)
|
|
|
|
bind = &ima->bindcode[TEXTARGET_TEXTURE_2D];
|
|
|
|
else if (textarget == GL_TEXTURE_CUBE_MAP)
|
|
|
|
bind = &ima->bindcode[TEXTARGET_TEXTURE_CUBE_MAP];
|
|
|
|
|
|
|
|
return bind;
|
|
|
|
}
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
static void gpu_set_alpha_blend(GPUBlendMode alphablend)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (alphablend == GPU_BLEND_SOLID) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDisable(GL_BLEND);
|
2015-07-03 19:03:29 +02:00
|
|
|
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
2018-02-14 01:01:29 +01:00
|
|
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (alphablend == GPU_BLEND_ADD) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
2015-07-03 19:03:29 +02:00
|
|
|
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glEnable(GL_BLEND);
|
2015-07-03 19:03:29 +02:00
|
|
|
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
2013-02-18 17:39:44 +00:00
|
|
|
|
|
|
|
/* for OpenGL render we use the alpha channel, this makes alpha blend correct */
|
2015-11-24 02:34:54 -05:00
|
|
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* if U.glalphaclip == 1.0, some cards go bonkers...
|
|
|
|
* turn off alpha test in this case */
|
|
|
|
|
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
else if (alphablend == GPU_BLEND_CLIP) {
|
2015-07-03 19:03:29 +02:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2015-07-03 19:03:29 +02:00
|
|
|
else if (alphablend == GPU_BLEND_ALPHA_TO_COVERAGE) {
|
|
|
|
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-05 11:25:31 +02:00
|
|
|
typedef struct VerifyThreadData {
|
|
|
|
ImBuf *ibuf;
|
|
|
|
float *srgb_frect;
|
|
|
|
} VerifyThreadData;
|
|
|
|
|
|
|
|
static void gpu_verify_high_bit_srgb_buffer_slice(float *srgb_frect,
|
|
|
|
ImBuf *ibuf,
|
|
|
|
const int start_line,
|
|
|
|
const int height)
|
|
|
|
{
|
|
|
|
size_t offset = ibuf->channels * start_line * ibuf->x;
|
|
|
|
float *current_srgb_frect = srgb_frect + offset;
|
|
|
|
float *current_rect_float = ibuf->rect_float + offset;
|
|
|
|
IMB_buffer_float_from_float(current_srgb_frect,
|
|
|
|
current_rect_float,
|
|
|
|
ibuf->channels,
|
|
|
|
IB_PROFILE_SRGB,
|
|
|
|
IB_PROFILE_LINEAR_RGB, true,
|
|
|
|
ibuf->x, height,
|
|
|
|
ibuf->x, ibuf->x);
|
|
|
|
IMB_buffer_float_unpremultiply(current_srgb_frect, ibuf->x, height);
|
|
|
|
}
|
|
|
|
|
2016-05-05 13:15:51 +02:00
|
|
|
static void verify_thread_do(void *data_v,
|
|
|
|
int start_scanline,
|
|
|
|
int num_scanlines)
|
2016-05-05 11:25:31 +02:00
|
|
|
{
|
|
|
|
VerifyThreadData *data = (VerifyThreadData *)data_v;
|
|
|
|
gpu_verify_high_bit_srgb_buffer_slice(data->srgb_frect,
|
|
|
|
data->ibuf,
|
2016-05-05 13:15:51 +02:00
|
|
|
start_scanline,
|
|
|
|
num_scanlines);
|
2016-05-05 11:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect,
|
|
|
|
ImBuf *ibuf)
|
|
|
|
{
|
|
|
|
if (ibuf->y < 64) {
|
|
|
|
gpu_verify_high_bit_srgb_buffer_slice(srgb_frect,
|
|
|
|
ibuf,
|
|
|
|
0, ibuf->y);
|
|
|
|
}
|
|
|
|
else {
|
2016-05-05 13:15:51 +02:00
|
|
|
VerifyThreadData data;
|
|
|
|
data.ibuf = ibuf;
|
|
|
|
data.srgb_frect = srgb_frect;
|
|
|
|
IMB_processor_apply_threaded_scanlines(ibuf->y, verify_thread_do, &data);
|
2016-05-05 11:25:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-09 05:44:25 +10:00
|
|
|
int GPU_verify_image(
|
|
|
|
Image *ima, ImageUser *iuser,
|
|
|
|
int textarget, int tftile, bool compare, bool mipmap, bool is_data)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
unsigned int *bind = NULL;
|
2016-01-07 13:05:53 -05:00
|
|
|
int tpx = 0, tpy = 0;
|
|
|
|
unsigned int *rect = NULL;
|
|
|
|
float *frect = NULL;
|
2012-01-17 16:31:13 +00:00
|
|
|
float *srgb_frect = NULL;
|
2016-01-07 13:05:53 -05:00
|
|
|
/* flag to determine whether deep format is used */
|
2014-04-01 11:34:00 +11:00
|
|
|
bool use_high_bit_depth = false, do_color_management = false;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* initialize tile mode and number of repeats */
|
|
|
|
GTS.ima = ima;
|
2016-01-10 07:12:10 +11:00
|
|
|
GTS.tilemode = (ima && (ima->tpageflag & (IMA_TILES | IMA_TWINANIM)));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GTS.tileXRep = 0;
|
|
|
|
GTS.tileYRep = 0;
|
|
|
|
|
|
|
|
/* setting current tile according to frame */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima && (ima->tpageflag & IMA_TWINANIM))
|
2015-03-23 15:29:42 -04:00
|
|
|
GTS.tile = ima->lastframe;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
2015-03-23 15:29:42 -04:00
|
|
|
GTS.tile = tftile;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-10-11 22:16:39 +00:00
|
|
|
GTS.tile = MAX2(0, GTS.tile);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GTS.tileXRep = ima->xrep;
|
|
|
|
GTS.tileYRep = ima->yrep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if same image & tile, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (compare && ima == GTS.curima && GTS.curtile == GTS.tile &&
|
2012-04-28 06:31:57 +00:00
|
|
|
GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep &&
|
|
|
|
GTS.curtileYRep == GTS.tileYRep)
|
|
|
|
{
|
2011-03-03 17:58:06 +00:00
|
|
|
return (ima != NULL);
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* check if we have a valid image */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima == NULL || ima->ok == 0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* check if we have a valid image buffer */
|
2016-01-07 13:05:53 -05:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ibuf == NULL)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf->rect_float) {
|
|
|
|
if (U.use_16bit_textures) {
|
2012-01-17 16:31:13 +00:00
|
|
|
/* use high precision textures. This is relatively harmless because OpenGL gives us
|
2012-03-09 18:28:30 +00:00
|
|
|
* a high precision format only if it is available */
|
2014-04-01 11:34:00 +11:00
|
|
|
use_high_bit_depth = true;
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
2016-05-05 11:25:31 +02:00
|
|
|
else if (ibuf->rect == NULL) {
|
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
}
|
2014-08-12 12:03:15 +02:00
|
|
|
/* we may skip this in high precision, but if not, we need to have a valid buffer here */
|
|
|
|
else if (ibuf->userflags & IB_RECT_INVALID) {
|
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
|
|
|
|
/* TODO unneeded when float images are correctly treated as linear always */
|
2016-05-05 11:25:31 +02:00
|
|
|
if (!is_data) {
|
2014-04-01 11:34:00 +11:00
|
|
|
do_color_management = true;
|
2016-05-05 11:25:31 +02:00
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2010-02-13 13:09:30 +00:00
|
|
|
/* currently, tpage refresh is used by ima sequences */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->tpageflag & IMA_TPAGE_REFRESH) {
|
2010-02-13 13:09:30 +00:00
|
|
|
GPU_free_image(ima);
|
|
|
|
ima->tpageflag &= ~IMA_TPAGE_REFRESH;
|
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GTS.tilemode) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* tiled mode */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima->repbind == NULL) gpu_make_repbind(ima);
|
|
|
|
if (GTS.tile >= ima->totbind) GTS.tile = 0;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* this happens when you change repeat buttons */
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (ima->repbind && textarget == GL_TEXTURE_2D) bind = &ima->repbind[GTS.tile];
|
|
|
|
else bind = gpu_get_image_bindcode(ima, textarget);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (*bind == 0) {
|
2016-01-07 13:05:53 -05:00
|
|
|
short texwindx = ibuf->x / ima->xrep;
|
|
|
|
short texwindy = ibuf->y / ima->yrep;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (GTS.tile >= ima->xrep * ima->yrep)
|
|
|
|
GTS.tile = ima->xrep * ima->yrep - 1;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
short texwinsy = GTS.tile / ima->xrep;
|
|
|
|
short texwinsx = GTS.tile - texwinsy * ima->xrep;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
texwinsx *= texwindx;
|
|
|
|
texwinsy *= texwindy;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
tpx = texwindx;
|
|
|
|
tpy = texwindy;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (use_high_bit_depth) {
|
|
|
|
if (do_color_management) {
|
2015-03-23 15:29:42 -04:00
|
|
|
srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "floar_buf_col_cor");
|
2016-05-05 11:25:31 +02:00
|
|
|
gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
|
2017-09-06 16:08:01 +10:00
|
|
|
frect = srgb_frect + (4 * (texwinsy * ibuf->x + texwinsx));
|
2016-01-10 07:12:10 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-09-06 16:08:01 +10:00
|
|
|
frect = ibuf->rect_float + (ibuf->channels * (texwinsy * ibuf->x + texwinsx));
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-10 07:12:10 +11:00
|
|
|
else {
|
|
|
|
rect = ibuf->rect + texwinsy * ibuf->x + texwinsx;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* regular image mode */
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
bind = gpu_get_image_bindcode(ima, textarget);
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (*bind == 0) {
|
|
|
|
tpx = ibuf->x;
|
|
|
|
tpy = ibuf->y;
|
|
|
|
rect = ibuf->rect;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (use_high_bit_depth) {
|
|
|
|
if (do_color_management) {
|
2015-03-23 15:29:42 -04:00
|
|
|
frect = srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(*srgb_frect) * 4, "floar_buf_col_cor");
|
2016-05-05 11:25:31 +02:00
|
|
|
gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
|
|
|
else
|
2015-03-23 15:29:42 -04:00
|
|
|
frect = ibuf->rect_float;
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (*bind != 0) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* enable opengl drawing with textures */
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(textarget, *bind);
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return *bind;
|
|
|
|
}
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
const int rectw = tpx;
|
|
|
|
const int recth = tpy;
|
|
|
|
|
|
|
|
unsigned *tilerect = NULL;
|
|
|
|
float *ftilerect = NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* for tiles, copy only part of image into buffer */
|
|
|
|
if (GTS.tilemode) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (use_high_bit_depth) {
|
2016-01-10 07:12:10 +11:00
|
|
|
ftilerect = MEM_mallocN(rectw * recth * sizeof(*ftilerect), "tilerect");
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
for (int y = 0; y < recth; y++) {
|
|
|
|
const float *frectrow = &frect[y * ibuf->x];
|
|
|
|
float *ftilerectrow = &ftilerect[y * rectw];
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
memcpy(ftilerectrow, frectrow, tpx * sizeof(*frectrow));
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
frect = ftilerect;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
else {
|
2016-01-10 07:12:10 +11:00
|
|
|
tilerect = MEM_mallocN(rectw * recth * sizeof(*tilerect), "tilerect");
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
for (int y = 0; y < recth; y++) {
|
|
|
|
const unsigned *rectrow = &rect[y * ibuf->x];
|
|
|
|
unsigned *tilerectrow = &tilerect[y * rectw];
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
memcpy(tilerectrow, rectrow, tpx * sizeof(*rectrow));
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
rect = tilerect;
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-10-25 15:25:28 +00:00
|
|
|
|
2012-06-30 04:34:34 +00:00
|
|
|
#ifdef WITH_DDS
|
2015-07-13 13:58:17 +02:00
|
|
|
if (ibuf->ftype == IMB_FTYPE_DDS)
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
GPU_create_gl_tex_compressed(bind, rect, rectw, recth, textarget, mipmap, ima, ibuf);
|
2012-06-30 04:34:34 +00:00
|
|
|
else
|
|
|
|
#endif
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
GPU_create_gl_tex(bind, rect, frect, rectw, recth, textarget, mipmap, use_high_bit_depth, ima);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2012-10-25 15:25:28 +00:00
|
|
|
/* mark as non-color data texture */
|
2012-10-30 12:18:45 +00:00
|
|
|
if (*bind) {
|
2012-10-25 15:25:28 +00:00
|
|
|
if (is_data)
|
2017-04-04 20:33:23 +02:00
|
|
|
ima->tpageflag |= IMA_GLBIND_IS_DATA;
|
2012-10-25 15:25:28 +00:00
|
|
|
else
|
2017-04-04 20:33:23 +02:00
|
|
|
ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
|
2012-10-25 15:25:28 +00:00
|
|
|
}
|
2012-06-30 04:34:34 +00:00
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
if (tilerect)
|
|
|
|
MEM_freeN(tilerect);
|
|
|
|
if (ftilerect)
|
|
|
|
MEM_freeN(ftilerect);
|
|
|
|
if (srgb_frect)
|
|
|
|
MEM_freeN(srgb_frect);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
|
2012-06-30 04:34:34 +00:00
|
|
|
return *bind;
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
static void **gpu_gen_cube_map(unsigned int *rect, float *frect, int rectw, int recth, bool use_high_bit_depth)
|
|
|
|
{
|
|
|
|
size_t block_size = use_high_bit_depth ? sizeof(float) * 4 : sizeof(unsigned char) * 4;
|
|
|
|
void **sides = NULL;
|
|
|
|
int h = recth / 2;
|
|
|
|
int w = rectw / 3;
|
|
|
|
|
|
|
|
if ((use_high_bit_depth && frect == NULL) || (!use_high_bit_depth && rect == NULL) || w != h)
|
|
|
|
return sides;
|
|
|
|
|
|
|
|
/* PosX, NegX, PosY, NegY, PosZ, NegZ */
|
2016-01-28 17:23:12 +11:00
|
|
|
sides = MEM_mallocN(sizeof(void *) * 6, "");
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
sides[i] = MEM_mallocN(block_size * w * h, "");
|
|
|
|
|
|
|
|
/* divide image into six parts */
|
|
|
|
/* ______________________
|
|
|
|
* | | | |
|
|
|
|
* | NegX | NegY | PosX |
|
|
|
|
* |______|______|______|
|
|
|
|
* | | | |
|
|
|
|
* | NegZ | PosZ | PosY |
|
|
|
|
* |______|______|______|
|
2016-07-15 02:36:21 +10:00
|
|
|
*/
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (use_high_bit_depth) {
|
|
|
|
float (*frectb)[4] = (float(*)[4])frect;
|
|
|
|
float (**fsides)[4] = (float(**)[4])sides;
|
|
|
|
|
|
|
|
for (int y = 0; y < h; y++) {
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
memcpy(&fsides[0][x * h + y], &frectb[(recth - y - 1) * rectw + 2 * w + x], block_size);
|
|
|
|
memcpy(&fsides[1][x * h + y], &frectb[(y + h) * rectw + w - 1 - x], block_size);
|
|
|
|
memcpy(&fsides[3][y * w + x], &frectb[(recth - y - 1) * rectw + 2 * w - 1 - x], block_size);
|
|
|
|
memcpy(&fsides[5][y * w + x], &frectb[(h - y - 1) * rectw + w - 1 - x], block_size);
|
|
|
|
}
|
|
|
|
memcpy(&fsides[2][y * w], frectb[y * rectw + 2 * w], block_size * w);
|
|
|
|
memcpy(&fsides[4][y * w], frectb[y * rectw + w], block_size * w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
unsigned int **isides = (unsigned int **)sides;
|
|
|
|
|
|
|
|
for (int y = 0; y < h; y++) {
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
isides[0][x * h + y] = rect[(recth - y - 1) * rectw + 2 * w + x];
|
|
|
|
isides[1][x * h + y] = rect[(y + h) * rectw + w - 1 - x];
|
|
|
|
isides[3][y * w + x] = rect[(recth - y - 1) * rectw + 2 * w - 1 - x];
|
|
|
|
isides[5][y * w + x] = rect[(h - y - 1) * rectw + w - 1 - x];
|
|
|
|
}
|
|
|
|
memcpy(&isides[2][y * w], &rect[y * rectw + 2 * w], block_size * w);
|
|
|
|
memcpy(&isides[4][y * w], &rect[y * rectw + w], block_size * w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sides;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_del_cube_map(void **cube_map)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (cube_map == NULL)
|
|
|
|
return;
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
MEM_freeN(cube_map[i]);
|
|
|
|
MEM_freeN(cube_map);
|
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* Image *ima can be NULL */
|
2016-06-09 05:44:25 +10:00
|
|
|
void GPU_create_gl_tex(
|
|
|
|
unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
|
|
|
|
int textarget, bool mipmap, bool use_high_bit_depth, Image *ima)
|
2012-06-30 04:34:34 +00:00
|
|
|
{
|
2015-02-23 16:33:18 +01:00
|
|
|
ImBuf *ibuf = NULL;
|
2012-06-30 16:56:23 +00:00
|
|
|
|
|
|
|
int tpx = rectw;
|
|
|
|
int tpy = recth;
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* create image */
|
|
|
|
glGenTextures(1, (GLuint *)bind);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(textarget, *bind);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (textarget == GL_TEXTURE_2D) {
|
|
|
|
if (use_high_bit_depth) {
|
|
|
|
if (GLEW_ARB_texture_float)
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
|
|
|
|
else
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect);
|
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
else
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
|
2015-03-16 15:45:34 +01:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
2012-06-11 16:23:10 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (GPU_get_mipmap() && mipmap) {
|
|
|
|
if (GTS.gpu_mipmap) {
|
2017-04-27 11:24:35 -04:00
|
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
if (!ibuf) {
|
|
|
|
if (use_high_bit_depth) {
|
|
|
|
ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
|
|
|
|
}
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
IMB_makemipmap(ibuf, true);
|
|
|
|
|
|
|
|
for (i = 1; i < ibuf->miptot; i++) {
|
|
|
|
ImBuf *mip = ibuf->mipmap[i - 1];
|
|
|
|
if (use_high_bit_depth) {
|
|
|
|
if (GLEW_ARB_texture_float)
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F_ARB, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
|
|
|
|
else
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA8, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
|
|
|
|
}
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
|
|
|
if (ima)
|
|
|
|
ima->tpageflag |= IMA_MIPMAP_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (textarget == GL_TEXTURE_CUBE_MAP) {
|
|
|
|
int w = rectw / 3, h = recth / 2;
|
|
|
|
|
|
|
|
if (h == w && is_power_of_2_i(h) && !is_over_resolution_limit(textarget, h, w)) {
|
|
|
|
void **cube_map = gpu_gen_cube_map(rect, frect, rectw, recth, use_high_bit_depth);
|
|
|
|
GLenum informat = use_high_bit_depth ? (GLEW_ARB_texture_float ? GL_RGBA16F_ARB : GL_RGBA16) : GL_RGBA8;
|
|
|
|
GLenum type = use_high_bit_depth ? GL_FLOAT : GL_UNSIGNED_BYTE;
|
2015-03-16 15:45:34 +01:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (cube_map)
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, informat, w, h, 0, GL_RGBA, type, cube_map[i]);
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
|
|
|
|
if (GPU_get_mipmap() && mipmap) {
|
|
|
|
if (GTS.gpu_mipmap) {
|
2017-04-27 11:24:35 -04:00
|
|
|
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
|
|
|
else {
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (!ibuf) {
|
|
|
|
if (use_high_bit_depth) {
|
|
|
|
ibuf = IMB_allocFromBuffer(NULL, frect, tpx, tpy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ibuf = IMB_allocFromBuffer(rect, NULL, tpx, tpy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IMB_makemipmap(ibuf, true);
|
|
|
|
|
|
|
|
for (int i = 1; i < ibuf->miptot; i++) {
|
|
|
|
ImBuf *mip = ibuf->mipmap[i - 1];
|
2016-01-28 17:23:12 +11:00
|
|
|
void **mip_cube_map = gpu_gen_cube_map(
|
|
|
|
mip->rect, mip->rect_float,
|
|
|
|
mip->x, mip->y, use_high_bit_depth);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
int mipw = mip->x / 3, miph = mip->y / 2;
|
|
|
|
|
|
|
|
if (mip_cube_map) {
|
|
|
|
for (int j = 0; j < 6; j++) {
|
|
|
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, i,
|
2017-04-04 20:33:23 +02:00
|
|
|
informat, mipw, miph, 0, GL_RGBA, type, mip_cube_map[j]);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gpu_del_cube_map(mip_cube_map);
|
|
|
|
}
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
|
|
|
|
|
|
|
if (ima)
|
|
|
|
ima->tpageflag |= IMA_MIPMAP_COMPLETE;
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
else {
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
}
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
gpu_del_cube_map(cube_map);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Incorrect envmap size\n");
|
|
|
|
}
|
2015-03-16 15:45:34 +01:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2011-06-15 18:59:22 +00:00
|
|
|
if (GLEW_EXT_texture_filter_anisotropic)
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glTexParameterf(textarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
|
2012-06-30 04:34:34 +00:00
|
|
|
|
2015-02-23 16:33:18 +01:00
|
|
|
if (ibuf)
|
|
|
|
IMB_freeImBuf(ibuf);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2012-06-30 04:34:34 +00:00
|
|
|
/**
|
|
|
|
* GPU_upload_dxt_texture() assumes that the texture is already bound and ready to go.
|
|
|
|
* This is so the viewport and the BGE can share some code.
|
2014-04-01 11:34:00 +11:00
|
|
|
* Returns false if the provided ImBuf doesn't have a supported DXT compression format
|
2012-06-30 04:34:34 +00:00
|
|
|
*/
|
2014-04-01 11:34:00 +11:00
|
|
|
bool GPU_upload_dxt_texture(ImBuf *ibuf)
|
2012-06-30 04:34:34 +00:00
|
|
|
{
|
2012-09-16 23:24:26 +00:00
|
|
|
#ifdef WITH_DDS
|
2012-07-01 02:47:34 +00:00
|
|
|
GLint format = 0;
|
2012-06-30 04:34:34 +00:00
|
|
|
int blocksize, height, width, i, size, offset = 0;
|
|
|
|
|
2012-12-02 08:25:53 +00:00
|
|
|
width = ibuf->x;
|
|
|
|
height = ibuf->y;
|
2012-07-01 02:47:34 +00:00
|
|
|
|
|
|
|
if (GLEW_EXT_texture_compression_s3tc) {
|
|
|
|
if (ibuf->dds_data.fourcc == FOURCC_DXT1)
|
|
|
|
format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
|
|
else if (ibuf->dds_data.fourcc == FOURCC_DXT3)
|
|
|
|
format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
|
else if (ibuf->dds_data.fourcc == FOURCC_DXT5)
|
|
|
|
format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == 0) {
|
2015-02-16 21:19:12 +01:00
|
|
|
fprintf(stderr, "Unable to find a suitable DXT compression, falling back to uncompressed\n");
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-06-30 04:34:34 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 16:16:11 +00:00
|
|
|
if (!is_power_of_2_resolution(width, height)) {
|
2015-02-16 21:19:12 +01:00
|
|
|
fprintf(stderr, "Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n");
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-10-25 12:54:16 +00:00
|
|
|
}
|
|
|
|
|
2012-12-20 15:49:59 +00:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
2012-08-18 03:32:28 +00:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
|
2012-12-21 02:49:15 +00:00
|
|
|
if (GLEW_EXT_texture_filter_anisotropic)
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
|
|
|
|
|
2012-10-25 12:54:16 +00:00
|
|
|
blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
|
2016-01-10 07:12:10 +11:00
|
|
|
for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); ++i) {
|
2012-06-30 04:34:34 +00:00
|
|
|
if (width == 0)
|
|
|
|
width = 1;
|
|
|
|
if (height == 0)
|
|
|
|
height = 1;
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize;
|
2012-06-30 04:34:34 +00:00
|
|
|
|
|
|
|
glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height,
|
2017-04-04 20:33:23 +02:00
|
|
|
0, size, ibuf->dds_data.data + offset);
|
2012-06-30 04:34:34 +00:00
|
|
|
|
|
|
|
offset += size;
|
|
|
|
width >>= 1;
|
|
|
|
height >>= 1;
|
|
|
|
}
|
|
|
|
|
2013-04-08 15:39:38 +00:00
|
|
|
/* set number of mipmap levels we have, needed in case they don't go down to 1x1 */
|
2015-03-23 15:29:42 -04:00
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i - 1);
|
2013-04-08 15:39:38 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2012-06-30 10:31:25 +00:00
|
|
|
#else
|
2012-06-30 16:56:23 +00:00
|
|
|
(void)ibuf;
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-06-30 10:31:25 +00:00
|
|
|
#endif
|
2012-06-30 04:34:34 +00:00
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
void GPU_create_gl_tex_compressed(
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
unsigned int *bind, unsigned int *pix, int x, int y,
|
|
|
|
int textarget, int mipmap, Image *ima, ImBuf *ibuf)
|
2012-06-30 04:34:34 +00:00
|
|
|
{
|
|
|
|
#ifndef WITH_DDS
|
2012-06-30 16:56:23 +00:00
|
|
|
(void)ibuf;
|
|
|
|
/* Fall back to uncompressed if DDS isn't enabled */
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
GPU_create_gl_tex(bind, pix, NULL, x, y, textarget, mipmap, 0, ima);
|
2012-06-30 04:34:34 +00:00
|
|
|
#else
|
|
|
|
glGenTextures(1, (GLuint *)bind);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(textarget, *bind);
|
2012-06-30 04:34:34 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (textarget == GL_TEXTURE_2D && GPU_upload_dxt_texture(ibuf) == 0) {
|
2012-12-28 14:19:05 +00:00
|
|
|
glDeleteTextures(1, (GLuint *)bind);
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
GPU_create_gl_tex(bind, pix, NULL, x, y, textarget, mipmap, 0, ima);
|
2012-06-30 04:34:34 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* these two functions are called on entering and exiting texture paint mode,
|
2012-03-09 18:28:30 +00:00
|
|
|
* temporary disabling/enabling mipmapping on all images for quick texture
|
|
|
|
* updates with glTexSubImage2D. images that didn't change don't have to be
|
|
|
|
* re-uploaded to OpenGL */
|
2015-04-28 01:03:28 +10:00
|
|
|
void GPU_paint_set_mipmap(bool mipmap)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!GTS.domipmap)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return;
|
|
|
|
|
Index: source/blender/gpu/intern/gpu_draw.c
===================================================================
--- source/blender/gpu/intern/gpu_draw.c (revision 47568)
+++ source/blender/gpu/intern/gpu_draw.c (working copy)
@@ -230,11 +230,12 @@
Image *ima, *curima;
int domipmap, linearmipmap;
+ int texpaint; /* store this so that new images created while texture painting won't be set to mipmapped */
int alphablend;
float anisotropic;
MTFace *lasttface;
-} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL};
+} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.f, NULL};
/* Mipmap settings */
@@ -256,7 +257,7 @@
static int gpu_get_mipmap(void)
{
- return GTS.domipmap;
+ return GTS.domipmap && !GTS.texpaint;
}
static GLenum gpu_get_mipmap_filter(int mag)
@@ -730,6 +731,8 @@
if (!GTS.domipmap)
return;
+ GTS.texpaint = !mipmap;
+
if (mipmap) {
for (ima=G.main->image.first; ima; ima=ima->id.next) {
if (ima->bindcode) {
2012-06-08 13:06:06 +00:00
|
|
|
GTS.texpaint = !mipmap;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mipmap) {
|
2016-01-07 13:05:53 -05:00
|
|
|
for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (BKE_image_has_bindcode(ima)) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->tpageflag & IMA_MIPMAP_COMPLETE) {
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
}
|
|
|
|
if (ima->bindcode[TEXTARGET_TEXTURE_CUBE_MAP]) {
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, ima->bindcode[TEXTARGET_TEXTURE_CUBE_MAP]);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
GPU_free_image(ima);
|
|
|
|
}
|
2012-02-13 21:12:14 +00:00
|
|
|
else
|
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
2016-01-07 13:05:53 -05:00
|
|
|
for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (BKE_image_has_bindcode(ima)) {
|
|
|
|
if (ima->bindcode[TEXTARGET_TEXTURE_2D]) {
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
}
|
|
|
|
if (ima->bindcode[TEXTARGET_TEXTURE_CUBE_MAP]) {
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, ima->bindcode[TEXTARGET_TEXTURE_CUBE_MAP]);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-02-13 21:12:14 +00:00
|
|
|
else
|
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 13:27:43 +00:00
|
|
|
|
|
|
|
/* check if image has been downscaled and do scaled partial update */
|
2017-04-12 20:18:44 +10:00
|
|
|
static bool gpu_check_scaled_image(ImBuf *ibuf, Image *ima, float *frect, int x, int y, int w, int h)
|
2013-06-25 13:27:43 +00:00
|
|
|
{
|
2017-01-31 02:52:43 -05:00
|
|
|
if (is_over_resolution_limit(GL_TEXTURE_2D, ibuf->x, ibuf->y)) {
|
2013-06-25 13:27:43 +00:00
|
|
|
int x_limit = smaller_power_of_2_limit(ibuf->x);
|
|
|
|
int y_limit = smaller_power_of_2_limit(ibuf->y);
|
|
|
|
|
2013-06-25 20:52:33 +00:00
|
|
|
float xratio = x_limit / (float)ibuf->x;
|
|
|
|
float yratio = y_limit / (float)ibuf->y;
|
2013-06-25 13:27:43 +00:00
|
|
|
|
|
|
|
/* find new width, height and x,y gpu texture coordinates */
|
|
|
|
|
|
|
|
/* take ceiling because we will be losing 1 pixel due to rounding errors in x,y... */
|
|
|
|
int rectw = (int)ceil(xratio * w);
|
|
|
|
int recth = (int)ceil(yratio * h);
|
|
|
|
|
|
|
|
x *= xratio;
|
|
|
|
y *= yratio;
|
|
|
|
|
|
|
|
/* ...but take back if we are over the limit! */
|
|
|
|
if (rectw + x > x_limit) rectw--;
|
|
|
|
if (recth + y > y_limit) recth--;
|
|
|
|
|
2015-02-27 14:47:39 +01:00
|
|
|
/* float rectangles are already continuous in memory so we can use IMB_scaleImBuf */
|
2013-06-25 13:27:43 +00:00
|
|
|
if (frect) {
|
2015-11-23 11:45:54 +11:00
|
|
|
ImBuf *ibuf_scale = IMB_allocFromBuffer(NULL, frect, w, h);
|
|
|
|
IMB_scaleImBuf(ibuf_scale, rectw, recth);
|
2013-06-25 13:27:43 +00:00
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
2013-06-25 13:27:43 +00:00
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
|
2015-11-23 11:45:54 +11:00
|
|
|
GL_FLOAT, ibuf_scale->rect_float);
|
2013-06-25 13:27:43 +00:00
|
|
|
|
2015-11-23 11:45:54 +11:00
|
|
|
IMB_freeImBuf(ibuf_scale);
|
2013-06-25 13:27:43 +00:00
|
|
|
}
|
|
|
|
/* byte images are not continuous in memory so do manual interpolation */
|
|
|
|
else {
|
2013-06-25 20:52:33 +00:00
|
|
|
unsigned char *scalerect = MEM_mallocN(rectw * recth * sizeof(*scalerect) * 4, "scalerect");
|
2013-06-25 13:27:43 +00:00
|
|
|
unsigned int *p = (unsigned int *)scalerect;
|
|
|
|
int i, j;
|
2013-06-25 20:52:33 +00:00
|
|
|
float inv_xratio = 1.0f / xratio;
|
|
|
|
float inv_yratio = 1.0f / yratio;
|
2013-06-25 13:27:43 +00:00
|
|
|
for (i = 0; i < rectw; i++) {
|
2013-06-25 20:52:33 +00:00
|
|
|
float u = (x + i) * inv_xratio;
|
2013-06-25 13:27:43 +00:00
|
|
|
for (j = 0; j < recth; j++) {
|
2013-06-25 20:52:33 +00:00
|
|
|
float v = (y + j) * inv_yratio;
|
2013-06-25 13:27:43 +00:00
|
|
|
bilinear_interpolation_color_wrap(ibuf, (unsigned char *)(p + i + j * (rectw)), NULL, u, v);
|
|
|
|
}
|
|
|
|
}
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
2013-06-25 13:27:43 +00:00
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, rectw, recth, GL_RGBA,
|
2013-06-25 20:52:33 +00:00
|
|
|
GL_UNSIGNED_BYTE, scalerect);
|
2013-06-25 13:27:43 +00:00
|
|
|
|
|
|
|
MEM_freeN(scalerect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GPU_get_mipmap()) {
|
2017-04-27 11:24:35 -04:00
|
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
2013-06-25 13:27:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2016-01-07 13:05:53 -05:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
2016-03-02 06:57:26 +11:00
|
|
|
|
|
|
|
if (ima->repbind ||
|
|
|
|
(!GTS.gpu_mipmap && GPU_get_mipmap()) ||
|
|
|
|
(ima->bindcode[TEXTARGET_TEXTURE_2D] == 0) ||
|
|
|
|
(ibuf == NULL) ||
|
2016-01-10 07:12:10 +11:00
|
|
|
(w == 0) || (h == 0))
|
2012-05-24 16:35:45 +00:00
|
|
|
{
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* these cases require full reload still */
|
|
|
|
GPU_free_image(ima);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* for the special case, we can do a partial update
|
|
|
|
* which is much quicker for painting */
|
|
|
|
GLint row_length, skip_pixels, skip_rows;
|
|
|
|
|
2012-01-17 16:31:13 +00:00
|
|
|
/* if color correction is needed, we must update the part that needs updating. */
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
if (ibuf->rect_float) {
|
2014-08-12 13:49:27 +02:00
|
|
|
float *buffer = MEM_mallocN(w * h * sizeof(float) * 4, "temp_texpaint_float_buf");
|
2014-04-11 11:25:41 +10:00
|
|
|
bool is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA) != 0;
|
2012-10-25 15:25:28 +00:00
|
|
|
IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
if (gpu_check_scaled_image(ibuf, ima, buffer, x, y, w, h)) {
|
2013-06-25 13:27:43 +00:00
|
|
|
MEM_freeN(buffer);
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
2015-03-23 15:29:42 -04:00
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_FLOAT, buffer);
|
2012-01-17 16:31:13 +00:00
|
|
|
|
|
|
|
MEM_freeN(buffer);
|
|
|
|
|
2012-09-18 15:58:07 +00:00
|
|
|
/* we have already accounted for the case where GTS.gpu_mipmap is false
|
|
|
|
* so we will be using GPU mipmap generation here */
|
|
|
|
if (GPU_get_mipmap()) {
|
2017-04-27 11:24:35 -04:00
|
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
2012-09-20 12:29:28 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-01-17 16:31:13 +00:00
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
2012-09-18 15:58:07 +00:00
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
2012-01-17 16:31:13 +00:00
|
|
|
return;
|
2011-06-06 22:10:05 +00:00
|
|
|
}
|
2013-06-25 13:27:43 +00:00
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
if (gpu_check_scaled_image(ibuf, ima, NULL, x, y, w, h)) {
|
2013-06-25 13:27:43 +00:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-08-12 13:49:27 +02:00
|
|
|
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length);
|
|
|
|
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels);
|
|
|
|
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows);
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, ibuf->x);
|
|
|
|
glPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
|
|
|
|
glPixelStorei(GL_UNPACK_SKIP_ROWS, y);
|
|
|
|
|
2012-10-25 15:25:28 +00:00
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA,
|
2017-04-04 20:33:23 +02:00
|
|
|
GL_UNSIGNED_BYTE, ibuf->rect);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
|
|
|
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
|
|
|
|
glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
|
|
|
|
|
2012-09-18 15:58:07 +00:00
|
|
|
/* see comment above as to why we are using gpu mipmap generation here */
|
|
|
|
if (GPU_get_mipmap()) {
|
2017-04-27 11:24:35 -04:00
|
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
2012-09-20 12:29:28 +00:00
|
|
|
}
|
|
|
|
else {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
2012-09-18 15:58:07 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_update_images_framechange(void)
|
|
|
|
{
|
2016-01-07 13:05:53 -05:00
|
|
|
for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->tpageflag & IMA_TWINANIM) {
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima->twend >= ima->xrep * ima->yrep)
|
|
|
|
ima->twend = ima->xrep * ima->yrep - 1;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* check: is bindcode not in the array? free. (to do) */
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ima->lastframe++;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->lastframe > ima->twend)
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->lastframe = ima->twsta;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int GPU_update_image_time(Image *ima, double time)
|
|
|
|
{
|
|
|
|
if (!ima)
|
|
|
|
return 0;
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima->lastupdate < 0)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
ima->lastupdate = 0;
|
|
|
|
|
2011-11-11 12:00:08 +00:00
|
|
|
if (ima->lastupdate > (float)time)
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->lastupdate = (float)time;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
int inc = 0;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->tpageflag & IMA_TWINANIM) {
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima->twend >= ima->xrep * ima->yrep) ima->twend = ima->xrep * ima->yrep - 1;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* check: is the bindcode not in the array? Then free. (still to do) */
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
float diff = (float)((float)time - ima->lastupdate);
|
2015-03-23 15:29:42 -04:00
|
|
|
inc = (int)(diff * (float)ima->animspeed);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->lastupdate += ((float)inc / (float)ima->animspeed);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
int newframe = ima->lastframe + inc;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (newframe > (int)ima->twend) {
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ima->twend - ima->twsta != 0)
|
|
|
|
newframe = (int)ima->twsta - 1 + (newframe - ima->twend) % (ima->twend - ima->twsta);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
else
|
|
|
|
newframe = ima->twsta;
|
|
|
|
}
|
|
|
|
|
|
|
|
ima->lastframe = newframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
return inc;
|
|
|
|
}
|
|
|
|
|
2009-08-20 00:33:59 +00:00
|
|
|
|
|
|
|
void GPU_free_smoke(SmokeModifierData *smd)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
|
|
|
|
if (smd->domain->tex)
|
2011-11-11 13:09:14 +00:00
|
|
|
GPU_texture_free(smd->domain->tex);
|
2009-08-20 00:33:59 +00:00
|
|
|
smd->domain->tex = NULL;
|
2009-09-09 18:39:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (smd->domain->tex_shadow)
|
2011-11-11 13:09:14 +00:00
|
|
|
GPU_texture_free(smd->domain->tex_shadow);
|
2009-09-09 18:39:40 +00:00
|
|
|
smd->domain->tex_shadow = NULL;
|
2012-10-10 13:18:07 +00:00
|
|
|
|
|
|
|
if (smd->domain->tex_flame)
|
|
|
|
GPU_texture_free(smd->domain->tex_flame);
|
|
|
|
smd->domain->tex_flame = NULL;
|
2009-08-20 00:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-09 18:39:40 +00:00
|
|
|
void GPU_create_smoke(SmokeModifierData *smd, int highres)
|
2009-08-20 00:33:59 +00:00
|
|
|
{
|
2011-07-13 18:40:21 +00:00
|
|
|
#ifdef WITH_SMOKE
|
2012-10-10 13:18:07 +00:00
|
|
|
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
|
|
|
SmokeDomainSettings *sds = smd->domain;
|
|
|
|
if (!sds->tex && !highres) {
|
|
|
|
/* rgba texture for color + density */
|
|
|
|
if (smoke_has_colors(sds->fluid)) {
|
2015-03-23 15:29:42 -04:00
|
|
|
float *data = MEM_callocN(sizeof(float) * sds->total_cells * 4, "smokeColorTexture");
|
2012-10-10 13:18:07 +00:00
|
|
|
smoke_get_rgba(sds->fluid, data, 0);
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], data, NULL);
|
2012-10-10 13:18:07 +00:00
|
|
|
MEM_freeN(data);
|
|
|
|
}
|
|
|
|
/* density only */
|
|
|
|
else {
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex = GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
|
|
|
GPU_R8, smoke_get_density(sds->fluid), NULL);
|
2017-10-27 22:35:48 +02:00
|
|
|
|
|
|
|
/* Swizzle the RGBA components to read the Red channel so
|
|
|
|
* that the shader stay the same for colored and non color
|
|
|
|
* density textures. */
|
|
|
|
GPU_texture_bind(sds->tex, 0);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_R, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_G, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
|
|
|
|
GPU_texture_unbind(sds->tex);
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex_flame = (smoke_has_fuel(sds->fluid)) ?
|
|
|
|
GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
|
|
|
GPU_R8, smoke_get_flame(sds->fluid), NULL) :
|
|
|
|
NULL;
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
|
|
|
else if (!sds->tex && highres) {
|
|
|
|
/* rgba texture for color + density */
|
|
|
|
if (smoke_turbulence_has_colors(sds->wt)) {
|
2015-03-23 15:29:42 -04:00
|
|
|
float *data = MEM_callocN(sizeof(float) * smoke_turbulence_get_cells(sds->wt) * 4, "smokeColorTexture");
|
2012-10-10 13:18:07 +00:00
|
|
|
smoke_turbulence_get_rgba(sds->wt, data, 0);
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], data, NULL);
|
2012-10-10 13:18:07 +00:00
|
|
|
MEM_freeN(data);
|
|
|
|
}
|
|
|
|
/* density only */
|
|
|
|
else {
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex = GPU_texture_create_3D_custom(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1,
|
|
|
|
GPU_R8, smoke_turbulence_get_density(sds->wt), NULL);
|
2017-10-27 22:35:48 +02:00
|
|
|
|
|
|
|
/* Swizzle the RGBA components to read the Red channel so
|
|
|
|
* that the shader stay the same for colored and non color
|
|
|
|
* density textures. */
|
|
|
|
GPU_texture_bind(sds->tex, 0);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_R, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_G, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
|
|
|
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
|
|
|
|
GPU_texture_unbind(sds->tex);
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ?
|
|
|
|
GPU_texture_create_3D_custom(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1,
|
2017-10-07 15:57:14 +11:00
|
|
|
GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
|
2017-02-03 16:01:32 +01:00
|
|
|
NULL;
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
2009-09-09 18:39:40 +00:00
|
|
|
|
2017-02-03 16:01:32 +01:00
|
|
|
sds->tex_shadow = GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
|
|
|
GPU_R8, sds->shadow, NULL);
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
2011-07-13 18:40:21 +00:00
|
|
|
#else // WITH_SMOKE
|
|
|
|
(void)highres;
|
2015-03-23 15:29:42 -04:00
|
|
|
smd->domain->tex = NULL;
|
|
|
|
smd->domain->tex_flame = NULL;
|
|
|
|
smd->domain->tex_shadow = NULL;
|
2011-07-13 18:40:21 +00:00
|
|
|
#endif // WITH_SMOKE
|
2009-08-20 00:33:59 +00:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:01:16 +00:00
|
|
|
static LinkNode *image_free_queue = NULL;
|
2010-04-13 20:34:40 +00:00
|
|
|
|
2010-04-25 10:49:13 +00:00
|
|
|
static void gpu_queue_image_for_free(Image *ima)
|
2010-04-13 12:51:03 +00:00
|
|
|
{
|
2010-04-25 10:49:13 +00:00
|
|
|
BLI_lock_thread(LOCK_OPENGL);
|
2013-08-16 13:06:40 +00:00
|
|
|
BLI_linklist_prepend(&image_free_queue, ima);
|
2010-04-25 10:49:13 +00:00
|
|
|
BLI_unlock_thread(LOCK_OPENGL);
|
2010-04-13 12:51:03 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 10:49:13 +00:00
|
|
|
void GPU_free_unused_buffers(void)
|
2010-04-13 12:51:03 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!BLI_thread_is_main())
|
2010-05-05 17:14:43 +00:00
|
|
|
return;
|
|
|
|
|
2010-04-25 10:49:13 +00:00
|
|
|
BLI_lock_thread(LOCK_OPENGL);
|
|
|
|
|
2010-07-13 13:31:43 +00:00
|
|
|
/* images */
|
2016-01-07 13:05:53 -05:00
|
|
|
for (LinkNode *node = image_free_queue; node; node = node->next) {
|
|
|
|
Image *ima = node->link;
|
2013-06-15 14:01:16 +00:00
|
|
|
|
|
|
|
/* check in case it was freed in the meantime */
|
2013-06-23 13:58:59 +00:00
|
|
|
if (G.main && BLI_findindex(&G.main->image, ima) != -1)
|
2013-06-15 14:01:16 +00:00
|
|
|
GPU_free_image(ima);
|
|
|
|
}
|
2010-04-25 10:49:13 +00:00
|
|
|
|
2013-06-15 14:01:16 +00:00
|
|
|
BLI_linklist_free(image_free_queue, NULL);
|
|
|
|
image_free_queue = NULL;
|
2010-04-25 10:49:13 +00:00
|
|
|
|
2010-07-13 13:31:43 +00:00
|
|
|
/* vbo buffers */
|
2013-08-09 19:55:43 +00:00
|
|
|
GPU_global_buffer_pool_free_unused();
|
2010-07-13 13:31:43 +00:00
|
|
|
|
2010-04-25 10:49:13 +00:00
|
|
|
BLI_unlock_thread(LOCK_OPENGL);
|
2010-04-13 12:51:03 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void GPU_free_image(Image *ima)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!BLI_thread_is_main()) {
|
2010-04-25 10:49:13 +00:00
|
|
|
gpu_queue_image_for_free(ima);
|
2010-04-13 12:51:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
|
|
|
/* free regular image binding */
|
|
|
|
if (ima->bindcode[i]) {
|
|
|
|
glDeleteTextures(1, (GLuint *)&ima->bindcode[i]);
|
|
|
|
ima->bindcode[i] = 0;
|
|
|
|
}
|
|
|
|
/* free glsl image binding */
|
|
|
|
if (ima->gputexture[i]) {
|
|
|
|
GPU_texture_free(ima->gputexture[i]);
|
|
|
|
ima->gputexture[i] = NULL;
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free repeated image binding */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima->repbind) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
MEM_freeN(ima->repbind);
|
2015-03-23 15:29:42 -04:00
|
|
|
ima->repbind = NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2012-02-13 21:12:14 +00:00
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_free_images(void)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (G.main)
|
2016-01-07 13:05:53 -05:00
|
|
|
for (Image *ima = G.main->image.first; ima; ima = ima->id.next)
|
2008-09-12 16:06:17 +00:00
|
|
|
GPU_free_image(ima);
|
2010-05-20 16:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* same as above but only free animated images */
|
|
|
|
void GPU_free_images_anim(void)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (G.main)
|
2016-01-07 13:05:53 -05:00
|
|
|
for (Image *ima = G.main->image.first; ima; ima = ima->id.next)
|
2014-01-14 04:59:58 +11:00
|
|
|
if (BKE_image_is_animated(ima))
|
2010-05-20 16:08:06 +00:00
|
|
|
GPU_free_image(ima);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2014-05-22 11:58:07 +10:00
|
|
|
|
|
|
|
void GPU_free_images_old(void)
|
|
|
|
{
|
|
|
|
static int lasttime = 0;
|
2015-07-20 16:08:06 +02:00
|
|
|
int ctime = (int)PIL_check_seconds_timer();
|
2014-05-22 11:58:07 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Run garbage collector once for every collecting period of time
|
|
|
|
* if textimeout is 0, that's the option to NOT run the collector
|
|
|
|
*/
|
|
|
|
if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* of course not! */
|
|
|
|
if (G.is_rendering)
|
|
|
|
return;
|
|
|
|
|
|
|
|
lasttime = ctime;
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
Image *ima = G.main->image.first;
|
2014-05-22 11:58:07 +10:00
|
|
|
while (ima) {
|
|
|
|
if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
|
|
|
|
/* If it's in GL memory, deallocate and set time tag to current time
|
|
|
|
* This gives textures a "second chance" to be used before dying. */
|
World textures displaying for viewport in BI.
This patch supports "Image or Movie" and "Environment map" types of world texture for the viewport.
It supports:
- "View", "AngMap" and "Equirectangular" types of mapping.
- Different types of texture blending (according to BI world render).
- Same color blending as when it lacked textures (but render via glsl).
{F207734}
{F207735}
Example: {F275180}
Original author: @valentin_b4w
Regards,
Alexander (Blend4Web Team).
Reviewers: sergey, valentin_b4w, brecht, merwin
Reviewed By: merwin
Subscribers: campbellbarton, merwin, blueprintrandom, youle, a.romanov, yurikovelenov, AlexKowel, Evgeny_Rodygin
Projects: #rendering, #opengl_gfx, #bf_blender:_next
Differential Revision: https://developer.blender.org/D1414
2016-01-27 12:06:57 +03:00
|
|
|
if (BKE_image_has_bindcode(ima) || ima->repbind) {
|
2014-05-22 11:58:07 +10:00
|
|
|
GPU_free_image(ima);
|
|
|
|
ima->lastused = ctime;
|
|
|
|
}
|
|
|
|
/* Otherwise, just kill the buffers */
|
|
|
|
else {
|
2014-05-22 17:40:35 +10:00
|
|
|
BKE_image_free_buffers(ima);
|
2014-05-22 11:58:07 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ima = ima->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* OpenGL Materials */
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
#define FIXEDMAT 8
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
/* OpenGL state caching for materials */
|
|
|
|
|
2010-09-27 06:49:27 +00:00
|
|
|
typedef struct GPUMaterialFixed {
|
2015-11-27 21:32:14 +01:00
|
|
|
float diff[3];
|
|
|
|
float spec[3];
|
2010-09-27 07:01:08 +00:00
|
|
|
int hard;
|
2015-11-27 21:32:14 +01:00
|
|
|
float alpha;
|
2017-04-04 20:33:23 +02:00
|
|
|
} GPUMaterialFixed;
|
2010-09-27 06:49:27 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
static struct GPUMaterialState {
|
2010-09-27 06:49:27 +00:00
|
|
|
GPUMaterialFixed (*matbuf);
|
|
|
|
GPUMaterialFixed matbuf_fixed[FIXEDMAT];
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
int totmat;
|
2015-07-18 05:39:01 +10:00
|
|
|
|
|
|
|
/* set when called inside GPU_begin_object_materials / GPU_end_object_materials
|
2015-11-23 21:42:17 +01:00
|
|
|
* otherwise calling GPU_object_material_bind returns zero */
|
2015-07-18 05:29:34 +10:00
|
|
|
bool is_enabled;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2009-07-13 00:40:20 +00:00
|
|
|
Material **gmatbuf;
|
|
|
|
Material *gmatbuf_fixed[FIXEDMAT];
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
Material *gboundmat;
|
|
|
|
Object *gob;
|
2018-02-06 23:27:49 +11:00
|
|
|
eObjectMode gob_object_mode;
|
2015-07-14 18:48:54 +02:00
|
|
|
DupliObject *dob;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
Scene *gscene;
|
2008-12-19 19:11:02 +00:00
|
|
|
int glay;
|
|
|
|
float (*gviewmat)[4];
|
|
|
|
float (*gviewinv)[4];
|
2015-02-02 14:25:44 +01:00
|
|
|
float (*gviewcamtexcofac);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool backface_culling;
|
2015-11-27 21:28:36 +01:00
|
|
|
bool two_sided_lighting;
|
2012-05-25 09:26:47 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPUBlendMode *alphablend;
|
|
|
|
GPUBlendMode alphablend_fixed[FIXEDMAT];
|
2014-02-03 18:55:59 +11:00
|
|
|
bool use_alpha_pass, is_alpha_pass;
|
2014-04-02 17:33:47 +03:00
|
|
|
bool use_matcaps;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
int lastmatnr, lastretval;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPUBlendMode lastalphablend;
|
2015-07-20 16:08:06 +02:00
|
|
|
bool is_opensubdiv;
|
2009-07-21 18:29:37 +00:00
|
|
|
} GMS = {NULL};
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2010-09-27 06:49:27 +00:00
|
|
|
/* fixed function material, alpha handed by caller */
|
2016-01-10 07:12:10 +11:00
|
|
|
static void gpu_material_to_fixed(
|
|
|
|
GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob,
|
|
|
|
const int new_shading_nodes, const bool dimdown)
|
2010-09-27 06:49:27 +00:00
|
|
|
{
|
2014-11-21 14:07:25 +01:00
|
|
|
if (bmat->mode & MA_SHLESS) {
|
2010-10-02 06:34:04 +00:00
|
|
|
copy_v3_v3(smat->diff, &bmat->r);
|
2010-09-27 06:49:27 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (gamma)
|
2010-09-27 06:49:27 +00:00
|
|
|
linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
zero_v3(smat->spec);
|
|
|
|
smat->alpha = 1.0f;
|
2015-03-23 15:29:42 -04:00
|
|
|
smat->hard = 0;
|
2010-09-27 06:49:27 +00:00
|
|
|
}
|
2014-11-21 14:07:25 +01:00
|
|
|
else if (new_shading_nodes) {
|
|
|
|
copy_v3_v3(smat->diff, &bmat->r);
|
|
|
|
copy_v3_v3(smat->spec, &bmat->specr);
|
2015-11-27 21:32:14 +01:00
|
|
|
smat->alpha = 1.0f;
|
2015-03-23 15:29:42 -04:00
|
|
|
smat->hard = CLAMPIS(bmat->har, 0, 128);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2014-12-01 16:20:48 +01:00
|
|
|
if (dimdown) {
|
|
|
|
mul_v3_fl(smat->diff, 0.8f);
|
|
|
|
mul_v3_fl(smat->spec, 0.5f);
|
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2014-11-21 14:07:25 +01:00
|
|
|
if (gamma) {
|
|
|
|
linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
|
|
|
|
linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
|
2014-12-01 16:20:48 +01:00
|
|
|
}
|
2014-11-21 14:07:25 +01:00
|
|
|
}
|
2010-09-27 06:49:27 +00:00
|
|
|
else {
|
2010-10-05 11:16:07 +00:00
|
|
|
mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit);
|
2010-09-27 06:49:27 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (bmat->shade_flag & MA_OBCOLOR)
|
2011-01-05 15:10:35 +00:00
|
|
|
mul_v3_v3(smat->diff, ob->col);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2010-10-05 11:16:07 +00:00
|
|
|
mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec);
|
2015-11-27 21:32:14 +01:00
|
|
|
smat->hard = CLAMPIS(bmat->har, 1, 128);
|
|
|
|
smat->alpha = 1.0f;
|
2010-09-27 07:01:08 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (gamma) {
|
2010-09-27 06:49:27 +00:00
|
|
|
linearrgb_to_srgb_v3_v3(smat->diff, smat->diff);
|
|
|
|
linearrgb_to_srgb_v3_v3(smat->spec, smat->spec);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2010-09-27 06:49:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static Material *gpu_active_node_material(Material *ma)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma && ma->use_nodes && ma->nodetree) {
|
2013-03-18 18:25:05 +00:00
|
|
|
bNode *node = nodeGetActiveID(ma->nodetree, ID_MA);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return (Material *)node->id;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ma;
|
|
|
|
}
|
|
|
|
|
2015-07-14 18:48:54 +02:00
|
|
|
void GPU_begin_dupli_object(DupliObject *dob)
|
|
|
|
{
|
|
|
|
GMS.dob = dob;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_end_dupli_object(void)
|
|
|
|
{
|
|
|
|
GMS.dob = NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
void GPU_begin_object_materials(
|
2017-11-22 10:52:39 -02:00
|
|
|
View3D *v3d, RegionView3D *rv3d, Scene *scene, ViewLayer *view_layer, Object *ob,
|
2018-02-06 23:27:49 +11:00
|
|
|
bool glsl, const eObjectMode object_mode, bool *do_alpha_after)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
Material *ma;
|
|
|
|
GPUMaterial *gpumat;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPUBlendMode alphablend;
|
2015-07-14 18:48:54 +02:00
|
|
|
DupliObject *dob;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
int a;
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool gamma = BKE_scene_check_color_management_enabled(scene);
|
|
|
|
const bool new_shading_nodes = BKE_scene_use_new_shading_nodes(scene);
|
|
|
|
const bool use_matcap = (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) != 0; /* assumes v3d->defmaterial->preview is set */
|
2015-07-20 16:08:06 +02:00
|
|
|
bool use_opensubdiv = false;
|
|
|
|
|
|
|
|
#ifdef WITH_OPENSUBDIV
|
|
|
|
{
|
|
|
|
DerivedMesh *derivedFinal = NULL;
|
2015-08-03 14:33:03 +02:00
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
|
|
|
if (em != NULL) {
|
|
|
|
derivedFinal = em->derivedFinal;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
derivedFinal = ob->derivedFinal;
|
|
|
|
}
|
2015-07-20 16:08:06 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
derivedFinal = ob->derivedFinal;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (derivedFinal != NULL && derivedFinal->type == DM_TYPE_CCGDM) {
|
|
|
|
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) derivedFinal;
|
|
|
|
use_opensubdiv = ccgdm->useGpuBackend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2013-12-17 14:42:47 -08:00
|
|
|
|
2014-04-09 11:48:04 +10:00
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
|
2018-02-06 17:06:20 +11:00
|
|
|
ob = BKE_object_lod_matob_get(ob, view_layer, object_mode);
|
2014-04-09 11:48:04 +10:00
|
|
|
}
|
2017-03-09 12:08:44 +01:00
|
|
|
#else
|
2017-11-22 10:52:39 -02:00
|
|
|
UNUSED_VARS(view_layer);
|
2014-04-09 11:48:04 +10:00
|
|
|
#endif
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* initialize state */
|
2015-07-14 18:48:54 +02:00
|
|
|
/* DupliObject must be restored */
|
|
|
|
dob = GMS.dob;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
memset(&GMS, 0, sizeof(GMS));
|
2015-07-18 05:29:34 +10:00
|
|
|
GMS.is_enabled = true;
|
2015-07-14 18:48:54 +02:00
|
|
|
GMS.dob = dob;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GMS.lastmatnr = -1;
|
|
|
|
GMS.lastretval = -1;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GMS.lastalphablend = GPU_BLEND_SOLID;
|
2014-04-02 17:33:47 +03:00
|
|
|
GMS.use_matcaps = use_matcap;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
GMS.backface_culling = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0;
|
2012-05-25 09:26:47 +00:00
|
|
|
|
2015-11-27 21:28:36 +01:00
|
|
|
GMS.two_sided_lighting = false;
|
|
|
|
if (ob && ob->type == OB_MESH)
|
2016-01-10 07:12:10 +11:00
|
|
|
GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0;
|
2015-11-27 21:28:36 +01:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GMS.gob = ob;
|
2018-02-06 17:06:20 +11:00
|
|
|
GMS.gob_object_mode = object_mode;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GMS.gscene = scene;
|
2015-07-20 16:08:06 +02:00
|
|
|
GMS.is_opensubdiv = use_opensubdiv;
|
2013-03-31 03:28:46 +00:00
|
|
|
GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */
|
2016-01-10 07:12:10 +11:00
|
|
|
GMS.glay = (v3d->localvd) ? v3d->localvd->lay : v3d->lay; /* keep lamps visible in local view */
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gviewmat = rv3d->viewmat;
|
|
|
|
GMS.gviewinv = rv3d->viewinv;
|
2015-02-02 14:25:44 +01:00
|
|
|
GMS.gviewcamtexcofac = rv3d->viewcamtexcofac;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2011-12-07 22:03:49 +00:00
|
|
|
/* alpha pass setup. there's various cases to handle here:
|
2012-03-09 18:28:30 +00:00
|
|
|
* - object transparency on: only solid materials draw in the first pass,
|
|
|
|
* and only transparent in the second 'alpha' pass.
|
|
|
|
* - object transparency off: for glsl we draw both in a single pass, and
|
|
|
|
* for solid we don't use transparency at all. */
|
2014-02-24 19:05:07 +01:00
|
|
|
GMS.use_alpha_pass = (do_alpha_after != NULL);
|
2014-04-01 11:34:00 +11:00
|
|
|
GMS.is_alpha_pass = (v3d->transp != false);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.use_alpha_pass)
|
2013-03-20 23:14:18 +00:00
|
|
|
*do_alpha_after = false;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.totmat > FIXEDMAT) {
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.matbuf = MEM_callocN(sizeof(GPUMaterialFixed) * GMS.totmat, "GMS.matbuf");
|
|
|
|
GMS.gmatbuf = MEM_callocN(sizeof(*GMS.gmatbuf) * GMS.totmat, "GMS.matbuf");
|
|
|
|
GMS.alphablend = MEM_callocN(sizeof(*GMS.alphablend) * GMS.totmat, "GMS.matbuf");
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.matbuf = GMS.matbuf_fixed;
|
|
|
|
GMS.gmatbuf = GMS.gmatbuf_fixed;
|
|
|
|
GMS.alphablend = GMS.alphablend_fixed;
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* viewport material, setup in space_view3d, defaults to matcap using ma->preview now */
|
|
|
|
if (use_matcap) {
|
|
|
|
GMS.gmatbuf[0] = v3d->defmaterial;
|
2015-07-20 16:08:06 +02:00
|
|
|
GPU_material_matcap(scene, v3d->defmaterial, use_opensubdiv);
|
2014-04-02 17:33:47 +03:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* do material 1 too, for displists! */
|
2010-09-27 06:49:27 +00:00
|
|
|
memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.alphablend[0] = GPU_BLEND_SOLID;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2013-01-22 11:18:41 +00:00
|
|
|
else {
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* no materials assigned? */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (ob->totcol == 0) {
|
2014-12-01 16:20:48 +01:00
|
|
|
gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, new_shading_nodes, true);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/* do material 1 too, for displists! */
|
|
|
|
memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
if (glsl) {
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gmatbuf[0] = &defmaterial;
|
2015-07-20 16:08:06 +02:00
|
|
|
GPU_material_from_blender(GMS.gscene, &defmaterial, GMS.is_opensubdiv);
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.alphablend[0] = GPU_BLEND_SOLID;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
/* setup materials */
|
2015-03-23 15:29:42 -04:00
|
|
|
for (a = 1; a <= ob->totcol; a++) {
|
2013-01-22 11:18:41 +00:00
|
|
|
/* find a suitable material */
|
2015-03-23 15:29:42 -04:00
|
|
|
ma = give_current_material(ob, a);
|
|
|
|
if (!glsl && !new_shading_nodes) ma = gpu_active_node_material(ma);
|
|
|
|
if (ma == NULL) ma = &defmaterial;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/* create glsl material if requested */
|
2016-01-10 07:12:10 +11:00
|
|
|
gpumat = glsl ? GPU_material_from_blender(GMS.gscene, ma, GMS.is_opensubdiv) : NULL;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
if (gpumat) {
|
|
|
|
/* do glsl only if creating it succeed, else fallback */
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gmatbuf[a] = ma;
|
2013-01-22 11:18:41 +00:00
|
|
|
alphablend = GPU_material_alpha_blend(gpumat, ob->col);
|
2011-12-07 22:03:49 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-01-22 11:18:41 +00:00
|
|
|
/* fixed function opengl materials */
|
2014-12-01 16:20:48 +01:00
|
|
|
gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes, false);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2014-02-24 19:05:07 +01:00
|
|
|
if (GMS.use_alpha_pass && ((ma->mode & MA_TRANSP) || (new_shading_nodes && ma->alpha != 1.0f))) {
|
2015-11-27 21:32:14 +01:00
|
|
|
GMS.matbuf[a].alpha = ma->alpha;
|
2016-01-10 07:12:10 +11:00
|
|
|
alphablend = (ma->alpha == 1.0f) ? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-11-27 21:32:14 +01:00
|
|
|
GMS.matbuf[a].alpha = 1.0f;
|
2013-01-22 11:18:41 +00:00
|
|
|
alphablend = GPU_BLEND_SOLID;
|
|
|
|
}
|
2011-12-07 22:03:49 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
/* setting 'do_alpha_after = true' indicates this object needs to be
|
2013-01-22 11:18:41 +00:00
|
|
|
* drawn in a second alpha pass for improved blending */
|
|
|
|
if (do_alpha_after && !GMS.is_alpha_pass)
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT))
|
2013-03-20 23:14:18 +00:00
|
|
|
*do_alpha_after = true;
|
2011-12-07 22:03:49 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.alphablend[a] = alphablend;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2015-03-23 15:29:42 -04:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* let's start with a clean state */
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_unbind();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
static int gpu_get_particle_info(GPUParticleInfo *pi)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
|
|
|
DupliObject *dob = GMS.dob;
|
|
|
|
if (dob->particle_system) {
|
|
|
|
int ind;
|
|
|
|
if (dob->persistent_id[0] < dob->particle_system->totpart)
|
|
|
|
ind = dob->persistent_id[0];
|
|
|
|
else {
|
|
|
|
ind = dob->particle_system->child[dob->persistent_id[0] - dob->particle_system->totpart].parent;
|
|
|
|
}
|
|
|
|
if (ind >= 0) {
|
|
|
|
ParticleData *p = &dob->particle_system->particles[ind];
|
|
|
|
|
2018-02-14 14:32:38 +01:00
|
|
|
pi->scalprops[0] = BLI_hash_int_01(ind);
|
2016-12-28 17:30:58 +01:00
|
|
|
pi->scalprops[1] = GMS.gscene->r.cfra - p->time;
|
|
|
|
pi->scalprops[2] = p->lifetime;
|
|
|
|
pi->scalprops[3] = p->size;
|
|
|
|
|
|
|
|
copy_v3_v3(pi->location, p->state.co);
|
|
|
|
copy_v3_v3(pi->velocity, p->state.vel);
|
|
|
|
copy_v3_v3(pi->angular_velocity, p->state.ave);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-14 18:13:44 +03:00
|
|
|
static void GPU_get_object_info(float oi[3], Material *mat)
|
|
|
|
{
|
|
|
|
Object *ob = GMS.gob;
|
|
|
|
oi[0] = ob->index;
|
|
|
|
oi[1] = mat->index;
|
|
|
|
unsigned int random;
|
|
|
|
if (GMS.dob) {
|
|
|
|
random = GMS.dob->random_id;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
random = BLI_hash_int_2d(BLI_hash_string(GMS.gob->id.name + 2), 0);
|
|
|
|
}
|
2017-04-24 21:58:28 +10:00
|
|
|
oi[2] = random * (1.0f / (float)0xFFFFFFFF);
|
2017-04-14 18:13:44 +03:00
|
|
|
}
|
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
int GPU_object_material_bind(int nr, void *attribs)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
GPUVertexAttribs *gattribs = attribs;
|
|
|
|
|
2009-07-21 18:29:37 +00:00
|
|
|
/* no GPU_begin_object_materials, use default material */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!GMS.matbuf) {
|
2009-07-21 18:29:37 +00:00
|
|
|
memset(&GMS, 0, sizeof(GMS));
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
float diffuse[3], specular[3];
|
|
|
|
mul_v3_v3fl(diffuse, &defmaterial.r, defmaterial.ref + defmaterial.emit);
|
|
|
|
mul_v3_v3fl(specular, &defmaterial.specr, defmaterial.spec);
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_colors(diffuse, specular, 35, 1.0f);
|
2009-07-21 18:29:37 +00:00
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
if (GMS.two_sided_lighting)
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_TWO_SIDED);
|
2015-11-27 21:32:14 +01:00
|
|
|
else
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING);
|
2009-07-21 18:29:37 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* prevent index to use un-initialized array items */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (nr >= GMS.totmat)
|
|
|
|
nr = 0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (gattribs)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
memset(gattribs, 0, sizeof(*gattribs));
|
|
|
|
|
|
|
|
/* keep current material */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (nr == GMS.lastmatnr)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return GMS.lastretval;
|
|
|
|
|
|
|
|
/* unbind glsl material */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.gboundmat) {
|
|
|
|
if (GMS.is_alpha_pass) glDepthMask(0);
|
2015-07-20 16:08:06 +02:00
|
|
|
GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat, GMS.is_opensubdiv));
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gboundmat = NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* draw materials with alpha in alpha pass */
|
|
|
|
GMS.lastmatnr = nr;
|
2011-12-07 22:03:49 +00:00
|
|
|
GMS.lastretval = 1;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.use_alpha_pass) {
|
2011-12-07 22:03:49 +00:00
|
|
|
GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.is_alpha_pass)
|
2011-12-07 22:03:49 +00:00
|
|
|
GMS.lastretval = !GMS.lastretval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GMS.lastretval = !GMS.is_alpha_pass;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.lastretval) {
|
2011-10-05 15:28:02 +00:00
|
|
|
/* for alpha pass, use alpha blend */
|
2016-01-07 13:05:53 -05:00
|
|
|
GPUBlendMode alphablend = GMS.alphablend[nr];
|
2011-10-05 15:28:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (gattribs && GMS.gmatbuf[nr]) {
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* bind glsl material and get attributes */
|
|
|
|
Material *mat = GMS.gmatbuf[nr];
|
2016-12-28 17:30:58 +01:00
|
|
|
GPUParticleInfo partile_info;
|
2017-04-14 18:13:44 +03:00
|
|
|
float object_info[3] = {0};
|
2015-07-14 18:48:54 +02:00
|
|
|
|
2011-12-10 01:00:12 +00:00
|
|
|
float auto_bump_scale;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
GPUMaterial *gpumat = GPU_material_from_blender(GMS.gscene, mat, GMS.is_opensubdiv);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
GPU_material_vertex_attributes(gpumat, gattribs);
|
2015-07-14 18:48:54 +02:00
|
|
|
|
2017-04-12 20:18:44 +10:00
|
|
|
if (GMS.dob) {
|
|
|
|
gpu_get_particle_info(&partile_info);
|
|
|
|
}
|
2017-04-14 18:13:44 +03:00
|
|
|
|
2017-04-18 16:30:13 +02:00
|
|
|
if ((GPU_get_material_builtins(gpumat) & GPU_OBJECT_INFO) != 0) {
|
2017-04-14 18:13:44 +03:00
|
|
|
GPU_get_object_info(object_info, mat);
|
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
|
2016-01-10 07:12:10 +11:00
|
|
|
GPU_material_bind(
|
2018-02-06 17:06:20 +11:00
|
|
|
gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob_object_mode & OB_MODE_TEXTURE_PAINT),
|
2017-11-15 15:01:57 -02:00
|
|
|
GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac);
|
2011-12-10 01:00:12 +00:00
|
|
|
|
2011-12-10 03:24:19 +00:00
|
|
|
auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
|
2017-04-14 18:13:44 +03:00
|
|
|
GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gob->col, auto_bump_scale, &partile_info, object_info);
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gboundmat = mat;
|
2011-10-05 15:28:02 +00:00
|
|
|
|
|
|
|
/* for glsl use alpha blend mode, unless it's set to solid and
|
2012-03-09 18:28:30 +00:00
|
|
|
* we are already drawing in an alpha pass */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mat->game.alpha_blend != GPU_BLEND_SOLID)
|
2016-01-10 07:12:10 +11:00
|
|
|
alphablend = mat->game.alpha_blend;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.is_alpha_pass) glDepthMask(1);
|
2012-05-25 09:26:47 +00:00
|
|
|
|
|
|
|
if (GMS.backface_culling) {
|
2012-05-25 09:51:53 +00:00
|
|
|
if (mat->game.flag)
|
2012-05-25 09:26:47 +00:00
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
else
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
}
|
2014-04-08 01:24:45 +03:00
|
|
|
|
|
|
|
if (GMS.use_matcaps)
|
2015-03-23 15:29:42 -04:00
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* or do fixed function opengl material */
|
2016-05-16 11:13:21 +03:00
|
|
|
GPU_basic_shader_colors(
|
|
|
|
GMS.matbuf[nr].diff,
|
|
|
|
GMS.matbuf[nr].spec, GMS.matbuf[nr].hard, GMS.matbuf[nr].alpha);
|
2015-11-27 21:32:14 +01:00
|
|
|
|
|
|
|
if (GMS.two_sided_lighting)
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_TWO_SIDED);
|
2015-11-27 21:32:14 +01:00
|
|
|
else
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set (alpha) blending mode */
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPU_set_material_alpha_blend(alphablend);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return GMS.lastretval;
|
|
|
|
}
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
int GPU_object_material_visible(int nr, void *attribs)
|
|
|
|
{
|
|
|
|
GPUVertexAttribs *gattribs = attribs;
|
|
|
|
int visible;
|
|
|
|
|
|
|
|
if (!GMS.matbuf)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (gattribs)
|
|
|
|
memset(gattribs, 0, sizeof(*gattribs));
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
if (nr >= GMS.totmat)
|
2015-11-27 21:32:14 +01:00
|
|
|
nr = 0;
|
|
|
|
|
|
|
|
if (GMS.use_alpha_pass) {
|
|
|
|
visible = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP);
|
|
|
|
if (GMS.is_alpha_pass)
|
|
|
|
visible = !visible;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
visible = !GMS.is_alpha_pass;
|
|
|
|
|
|
|
|
return visible;
|
|
|
|
}
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
void GPU_set_material_alpha_blend(int alphablend)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.lastalphablend == alphablend)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
return;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
gpu_set_alpha_blend(alphablend);
|
|
|
|
GMS.lastalphablend = alphablend;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
int GPU_get_material_alpha_blend(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
return GMS.lastalphablend;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
void GPU_object_material_unbind(void)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.lastmatnr = -1;
|
|
|
|
GMS.lastretval = 1;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.gboundmat) {
|
2012-05-25 09:26:47 +00:00
|
|
|
if (GMS.backface_culling)
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.is_alpha_pass) glDepthMask(0);
|
2015-07-20 16:08:06 +02:00
|
|
|
GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat, GMS.is_opensubdiv));
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.gboundmat = NULL;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2015-11-27 21:32:14 +01:00
|
|
|
else
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
GPU_set_material_alpha_blend(GPU_BLEND_SOLID);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:33:53 +00:00
|
|
|
void GPU_material_diffuse_get(int nr, float diff[4])
|
|
|
|
{
|
|
|
|
/* prevent index to use un-initialized array items */
|
|
|
|
if (nr >= GMS.totmat)
|
|
|
|
nr = 0;
|
|
|
|
|
|
|
|
/* no GPU_begin_object_materials, use default material */
|
|
|
|
if (!GMS.matbuf) {
|
|
|
|
mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.emit);
|
|
|
|
}
|
|
|
|
else {
|
2015-11-27 21:32:14 +01:00
|
|
|
copy_v3_v3(diff, GMS.matbuf[nr].diff);
|
|
|
|
diff[3] = GMS.matbuf[nr].alpha;
|
2012-10-22 17:33:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 17:33:47 +03:00
|
|
|
bool GPU_material_use_matcaps_get(void)
|
|
|
|
{
|
|
|
|
return GMS.use_matcaps;
|
|
|
|
}
|
|
|
|
|
2015-07-18 05:29:34 +10:00
|
|
|
bool GPU_object_materials_check(void)
|
|
|
|
{
|
|
|
|
return GMS.is_enabled;
|
|
|
|
}
|
2014-04-02 17:33:47 +03:00
|
|
|
|
2009-07-13 00:40:20 +00:00
|
|
|
void GPU_end_object_materials(void)
|
|
|
|
{
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_unbind();
|
2009-07-13 00:40:20 +00:00
|
|
|
|
2015-07-18 05:29:34 +10:00
|
|
|
GMS.is_enabled = false;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) {
|
2009-07-13 00:40:20 +00:00
|
|
|
MEM_freeN(GMS.matbuf);
|
|
|
|
MEM_freeN(GMS.gmatbuf);
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
MEM_freeN(GMS.alphablend);
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
2009-07-21 18:29:37 +00:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
GMS.matbuf = NULL;
|
|
|
|
GMS.gmatbuf = NULL;
|
|
|
|
GMS.alphablend = NULL;
|
2015-11-27 21:28:36 +01:00
|
|
|
GMS.two_sided_lighting = false;
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* Lights */
|
|
|
|
|
|
|
|
int GPU_default_lights(void)
|
|
|
|
{
|
|
|
|
/* initialize */
|
2015-03-23 15:29:42 -04:00
|
|
|
if (U.light[0].flag == 0 && U.light[1].flag == 0 && U.light[2].flag == 0) {
|
|
|
|
U.light[0].flag = 1;
|
|
|
|
U.light[0].vec[0] = -0.3; U.light[0].vec[1] = 0.3; U.light[0].vec[2] = 0.9;
|
|
|
|
U.light[0].col[0] = 0.8; U.light[0].col[1] = 0.8; U.light[0].col[2] = 0.8;
|
|
|
|
U.light[0].spec[0] = 0.5; U.light[0].spec[1] = 0.5; U.light[0].spec[2] = 0.5;
|
|
|
|
U.light[0].spec[3] = 1.0;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
U.light[1].flag = 0;
|
|
|
|
U.light[1].vec[0] = 0.5; U.light[1].vec[1] = 0.5; U.light[1].vec[2] = 0.1;
|
|
|
|
U.light[1].col[0] = 0.4; U.light[1].col[1] = 0.4; U.light[1].col[2] = 0.8;
|
|
|
|
U.light[1].spec[0] = 0.3; U.light[1].spec[1] = 0.3; U.light[1].spec[2] = 0.5;
|
|
|
|
U.light[1].spec[3] = 1.0;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
U.light[2].flag = 0;
|
|
|
|
U.light[2].vec[0] = 0.3; U.light[2].vec[1] = -0.3; U.light[2].vec[2] = -0.2;
|
|
|
|
U.light[2].col[0] = 0.8; U.light[2].col[1] = 0.5; U.light[2].col[2] = 0.4;
|
|
|
|
U.light[2].spec[0] = 0.5; U.light[2].spec[1] = 0.4; U.light[2].spec[2] = 0.3;
|
|
|
|
U.light[2].spec[3] = 1.0;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set_viewer(false);
|
2009-02-06 19:21:24 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for (int a = 0; a < 8; a++) {
|
2015-11-27 21:08:48 +01:00
|
|
|
if (a < 3 && U.light[a].flag) {
|
|
|
|
GPULightData light = {0};
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
light.type = GPU_LIGHT_SUN;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
normalize_v3_v3(light.direction, U.light[a].vec);
|
|
|
|
copy_v3_v3(light.diffuse, U.light[a].col);
|
|
|
|
copy_v3_v3(light.specular, U.light[a].spec);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set(a, &light);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
count++;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set(a, NULL);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
int GPU_scene_object_lights(ViewLayer *view_layer, float viewmat[4][4], int ortho)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
{
|
|
|
|
/* disable all lights */
|
2016-01-07 13:05:53 -05:00
|
|
|
for (int count = 0; count < 8; count++)
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set(count, NULL);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
/* view direction for specular is not computed correct by default in
|
2017-11-05 14:33:18 +11:00
|
|
|
* opengl, so we set the settings ourselves */
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set_viewer(!ortho);
|
2009-02-06 19:21:24 +00:00
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
int count = 0;
|
2015-03-23 15:29:42 -04:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
|
2015-03-23 15:29:42 -04:00
|
|
|
if (base->object->type != OB_LAMP)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
continue;
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
Lamp *la = base->object->data;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
/* setup lamp transform */
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuPushMatrix();
|
2017-04-15 01:29:25 -04:00
|
|
|
gpuLoadMatrix(viewmat);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
/* setup light */
|
|
|
|
GPULightData light = {0};
|
|
|
|
|
|
|
|
mul_v3_v3fl(light.diffuse, &la->r, la->energy);
|
|
|
|
mul_v3_v3fl(light.specular, &la->r, la->energy);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
if (la->type == LA_SUN) {
|
|
|
|
/* directional sun light */
|
|
|
|
light.type = GPU_LIGHT_SUN;
|
|
|
|
normalize_v3_v3(light.direction, base->object->obmat[2]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-11-27 21:08:48 +01:00
|
|
|
/* other lamps with position attenuation */
|
|
|
|
copy_v3_v3(light.position, base->object->obmat[3]);
|
|
|
|
|
|
|
|
light.constant_attenuation = 1.0f;
|
|
|
|
light.linear_attenuation = la->att1 / la->dist;
|
|
|
|
light.quadratic_attenuation = la->att2 / (la->dist * la->dist);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-03-23 15:29:42 -04:00
|
|
|
if (la->type == LA_SPOT) {
|
2015-11-27 21:08:48 +01:00
|
|
|
light.type = GPU_LIGHT_SPOT;
|
|
|
|
negate_v3_v3(light.direction, base->object->obmat[2]);
|
|
|
|
normalize_v3(light.direction);
|
|
|
|
light.spot_cutoff = RAD2DEGF(la->spotsize * 0.5f);
|
|
|
|
light.spot_exponent = 128.0f * la->spotblend;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
else
|
2015-11-27 21:08:48 +01:00
|
|
|
light.type = GPU_LIGHT_POINT;
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_light_set(count, &light);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
2017-03-21 02:51:02 -04:00
|
|
|
gpuPopMatrix();
|
2017-04-04 20:33:23 +02:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
count++;
|
2015-03-23 15:29:42 -04:00
|
|
|
if (count == 8)
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-02-13 19:15:34 +01:00
|
|
|
static void gpu_disable_multisample()
|
2014-10-07 15:46:19 -05:00
|
|
|
{
|
|
|
|
#ifdef __linux__
|
2015-11-24 02:20:38 -05:00
|
|
|
/* changing multisample from the default (enabled) causes problems on some
|
|
|
|
* systems (NVIDIA/Linux) when the pixel format doesn't have a multisample buffer */
|
|
|
|
bool toggle_ok = true;
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_UNIX, GPU_DRIVER_ANY)) {
|
|
|
|
int samples = 0;
|
|
|
|
glGetIntegerv(GL_SAMPLES, &samples);
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (samples == 0)
|
|
|
|
toggle_ok = false;
|
|
|
|
}
|
2014-10-07 15:46:19 -05:00
|
|
|
|
2015-11-24 02:20:38 -05:00
|
|
|
if (toggle_ok) {
|
2018-02-13 19:15:34 +01:00
|
|
|
glDisable(GL_MULTISAMPLE);
|
2014-10-07 15:46:19 -05:00
|
|
|
}
|
2015-11-24 02:20:38 -05:00
|
|
|
#else
|
2018-02-13 19:15:34 +01:00
|
|
|
glDisable(GL_MULTISAMPLE);
|
2015-11-24 02:20:38 -05:00
|
|
|
#endif
|
2014-10-07 15:46:19 -05:00
|
|
|
}
|
|
|
|
|
2015-11-28 01:09:13 +01:00
|
|
|
/* 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
|
|
|
|
* temporarily modifying the state for drawing, though that are (undocumented)
|
|
|
|
* exceptions that we should try to get rid of. */
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
|
|
|
void GPU_state_init(void)
|
|
|
|
{
|
|
|
|
GPU_default_lights();
|
2016-09-30 19:51:04 -04:00
|
|
|
|
|
|
|
GPU_disable_program_point_size();
|
2016-10-01 17:34:41 -04:00
|
|
|
|
2017-04-18 12:50:09 +02:00
|
|
|
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
2016-09-30 19:51:04 -04:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDepthFunc(GL_LEQUAL);
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
2017-04-27 14:18:33 -04:00
|
|
|
glDisable(GL_COLOR_LOGIC_OP);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDisable(GL_STENCIL_TEST);
|
2017-04-27 14:32:47 -04:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
glDepthRange(0.0, 1.0);
|
|
|
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
glDisable(GL_CULL_FACE);
|
2010-01-08 09:30:36 +00:00
|
|
|
|
2018-02-13 19:15:34 +01:00
|
|
|
gpu_disable_multisample();
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2017-02-09 02:28:55 +11:00
|
|
|
void GPU_enable_program_point_size(void)
|
2016-09-30 19:51:04 -04:00
|
|
|
{
|
|
|
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
|
|
|
}
|
|
|
|
|
2017-02-09 02:28:55 +11:00
|
|
|
void GPU_disable_program_point_size(void)
|
2016-09-30 19:51:04 -04:00
|
|
|
{
|
|
|
|
glDisable(GL_PROGRAM_POINT_SIZE);
|
|
|
|
}
|
|
|
|
|
2015-07-20 16:08:06 +02:00
|
|
|
#ifdef WITH_OPENSUBDIV
|
|
|
|
/* Update face-varying variables offset which might be
|
|
|
|
* different from mesh to mesh sharing the same material.
|
|
|
|
*/
|
|
|
|
void GPU_draw_update_fvar_offset(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
/* Sanity check to be sure we only do this for OpenSubdiv draw. */
|
|
|
|
BLI_assert(dm->type == DM_TYPE_CCGDM);
|
|
|
|
BLI_assert(GMS.is_opensubdiv);
|
|
|
|
|
2016-01-07 13:05:53 -05:00
|
|
|
for (int i = 0; i < GMS.totmat; ++i) {
|
2015-07-20 16:08:06 +02:00
|
|
|
Material *material = GMS.gmatbuf[i];
|
|
|
|
GPUMaterial *gpu_material;
|
|
|
|
|
|
|
|
if (material == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
gpu_material = GPU_material_from_blender(GMS.gscene,
|
|
|
|
material,
|
|
|
|
GMS.is_opensubdiv);
|
|
|
|
|
|
|
|
GPU_material_update_fvar_offset(gpu_material, dm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-06-25 20:16:33 +10:00
|
|
|
|
|
|
|
|
|
|
|
/** \name Framebuffer color depth, for selection codes
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
|
|
|
/* apple seems to round colors to below and up on some configs */
|
|
|
|
|
|
|
|
static unsigned int index_to_framebuffer(int index)
|
|
|
|
{
|
|
|
|
unsigned int i = index;
|
|
|
|
|
|
|
|
switch (GPU_color_depth()) {
|
|
|
|
case 12:
|
|
|
|
i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
|
|
|
|
/* sometimes dithering subtracts! */
|
|
|
|
i |= 0x070707;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
|
|
|
|
i |= 0x030303;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
break;
|
|
|
|
default: /* 18 bits... */
|
|
|
|
i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
|
|
|
|
i |= 0x010101;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* this is the old method as being in use for ages.... seems to work? colors are rounded to lower values */
|
|
|
|
|
|
|
|
static unsigned int index_to_framebuffer(int index)
|
|
|
|
{
|
|
|
|
unsigned int i = index;
|
|
|
|
|
|
|
|
switch (GPU_color_depth()) {
|
|
|
|
case 8:
|
|
|
|
i = ((i & 48) << 18) + ((i & 12) << 12) + ((i & 3) << 6);
|
|
|
|
i |= 0x3F3F3F;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
i = ((i & 0xF00) << 12) + ((i & 0xF0) << 8) + ((i & 0xF) << 4);
|
|
|
|
/* sometimes dithering subtracts! */
|
|
|
|
i |= 0x0F0F0F;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
i = ((i & 0x7C00) << 9) + ((i & 0x3E0) << 6) + ((i & 0x1F) << 3);
|
|
|
|
i |= 0x070707;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
break;
|
|
|
|
default: /* 18 bits... */
|
|
|
|
i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2);
|
|
|
|
i |= 0x030303;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void GPU_select_index_set(int index)
|
|
|
|
{
|
|
|
|
const int col = index_to_framebuffer(index);
|
|
|
|
glColor3ub(( (col) & 0xFF),
|
|
|
|
(((col) >> 8) & 0xFF),
|
|
|
|
(((col) >> 16) & 0xFF));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_select_index_get(int index, int *r_col)
|
|
|
|
{
|
|
|
|
const int col = index_to_framebuffer(index);
|
|
|
|
char *c_col = (char *)r_col;
|
|
|
|
c_col[0] = (col & 0xFF); /* red */
|
|
|
|
c_col[1] = ((col >> 8) & 0xFF); /* green */
|
|
|
|
c_col[2] = ((col >> 16) & 0xFF); /* blue */
|
|
|
|
c_col[3] = 0xFF; /* alpha */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define INDEX_FROM_BUF_8(col) ((((col) & 0xC00000) >> 18) + (((col) & 0xC000) >> 12) + (((col) & 0xC0) >> 6))
|
|
|
|
#define INDEX_FROM_BUF_12(col) ((((col) & 0xF00000) >> 12) + (((col) & 0xF000) >> 8) + (((col) & 0xF0) >> 4))
|
|
|
|
#define INDEX_FROM_BUF_15_16(col) ((((col) & 0xF80000) >> 9) + (((col) & 0xF800) >> 6) + (((col) & 0xF8) >> 3))
|
|
|
|
#define INDEX_FROM_BUF_18(col) ((((col) & 0xFC0000) >> 6) + (((col) & 0xFC00) >> 4) + (((col) & 0xFC) >> 2))
|
|
|
|
#define INDEX_FROM_BUF_24(col) ((col) & 0xFFFFFF)
|
|
|
|
|
|
|
|
int GPU_select_to_index(unsigned int col)
|
|
|
|
{
|
|
|
|
if (col == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (GPU_color_depth()) {
|
|
|
|
case 8: return INDEX_FROM_BUF_8(col);
|
|
|
|
case 12: return INDEX_FROM_BUF_12(col);
|
|
|
|
case 15:
|
|
|
|
case 16: return INDEX_FROM_BUF_15_16(col);
|
|
|
|
case 24: return INDEX_FROM_BUF_24(col);
|
|
|
|
default: return INDEX_FROM_BUF_18(col);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_select_to_index_array(unsigned int *col, const unsigned int size)
|
|
|
|
{
|
|
|
|
#define INDEX_BUF_ARRAY(INDEX_FROM_BUF_BITS) \
|
|
|
|
for (i = size; i--; col++) { \
|
2017-04-04 20:33:23 +02:00
|
|
|
if ((c = *col)) { \
|
|
|
|
*col = INDEX_FROM_BUF_BITS(c); \
|
|
|
|
} \
|
|
|
|
} ((void)0)
|
2016-06-25 20:16:33 +10:00
|
|
|
|
|
|
|
if (size > 0) {
|
|
|
|
unsigned int i, c;
|
|
|
|
|
|
|
|
switch (GPU_color_depth()) {
|
|
|
|
case 8:
|
|
|
|
INDEX_BUF_ARRAY(INDEX_FROM_BUF_8);
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
INDEX_BUF_ARRAY(INDEX_FROM_BUF_12);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
case 16:
|
|
|
|
INDEX_BUF_ARRAY(INDEX_FROM_BUF_15_16);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
INDEX_BUF_ARRAY(INDEX_FROM_BUF_24);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
INDEX_BUF_ARRAY(INDEX_FROM_BUF_18);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef INDEX_BUF_ARRAY
|
|
|
|
}
|
|
|
|
|
2017-05-09 15:09:39 +02:00
|
|
|
#define STATE_STACK_DEPTH 16
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
eGPUAttribMask mask;
|
|
|
|
|
|
|
|
/* GL_ENABLE_BIT */
|
|
|
|
unsigned int is_blend : 1;
|
|
|
|
unsigned int is_cull_face : 1;
|
|
|
|
unsigned int is_depth_test : 1;
|
|
|
|
unsigned int is_dither : 1;
|
|
|
|
unsigned int is_lighting : 1;
|
|
|
|
unsigned int is_line_smooth : 1;
|
|
|
|
unsigned int is_color_logic_op : 1;
|
|
|
|
unsigned int is_multisample : 1;
|
|
|
|
unsigned int is_polygon_offset_line : 1;
|
|
|
|
unsigned int is_polygon_offset_fill : 1;
|
|
|
|
unsigned int is_polygon_smooth : 1;
|
|
|
|
unsigned int is_sample_alpha_to_coverage : 1;
|
|
|
|
unsigned int is_scissor_test : 1;
|
|
|
|
unsigned int is_stencil_test : 1;
|
|
|
|
|
|
|
|
bool is_clip_plane[6];
|
|
|
|
|
|
|
|
/* GL_DEPTH_BUFFER_BIT */
|
|
|
|
/* unsigned int is_depth_test : 1; */
|
|
|
|
int depth_func;
|
|
|
|
double depth_clear_value;
|
|
|
|
bool depth_write_mask;
|
|
|
|
|
|
|
|
/* GL_SCISSOR_BIT */
|
|
|
|
int scissor_box[4];
|
|
|
|
/* unsigned int is_scissor_test : 1; */
|
|
|
|
|
|
|
|
/* GL_VIEWPORT_BIT */
|
|
|
|
int viewport[4];
|
|
|
|
double near_far[2];
|
|
|
|
} GPUAttribValues;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GPUAttribValues attrib_stack[STATE_STACK_DEPTH];
|
|
|
|
unsigned int top;
|
|
|
|
} GPUAttribStack;
|
|
|
|
|
|
|
|
static GPUAttribStack state = {
|
|
|
|
.top = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
#define AttribStack state
|
2017-06-19 20:18:04 +10:00
|
|
|
#define Gwn_VertAttr state.attrib_stack[state.top]
|
2017-05-09 15:09:39 +02:00
|
|
|
|
2017-04-04 20:33:23 +02:00
|
|
|
/**
|
|
|
|
* Replacement for glPush/PopAttributes
|
|
|
|
*
|
|
|
|
* We don't need to cover all the options of legacy OpenGL
|
|
|
|
* but simply the ones used by Blender.
|
|
|
|
*/
|
2017-05-09 15:09:39 +02:00
|
|
|
void gpuPushAttrib(eGPUAttribMask mask)
|
2017-04-04 20:33:23 +02:00
|
|
|
{
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.mask = mask;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
|
|
|
if ((mask & GPU_DEPTH_BUFFER_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
|
|
|
glGetIntegerv(GL_DEPTH_FUNC, &Gwn_VertAttr.depth_func);
|
|
|
|
glGetDoublev(GL_DEPTH_CLEAR_VALUE, &Gwn_VertAttr.depth_clear_value);
|
|
|
|
glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&Gwn_VertAttr.depth_write_mask);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_ENABLE_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_blend = glIsEnabled(GL_BLEND);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) {
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_clip_plane[i] = glIsEnabled(GL_CLIP_PLANE0 + i);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_cull_face = glIsEnabled(GL_CULL_FACE);
|
|
|
|
Gwn_VertAttr.is_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
|
|
|
Gwn_VertAttr.is_dither = glIsEnabled(GL_DITHER);
|
|
|
|
Gwn_VertAttr.is_line_smooth = glIsEnabled(GL_LINE_SMOOTH);
|
|
|
|
Gwn_VertAttr.is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
|
|
|
|
Gwn_VertAttr.is_multisample = glIsEnabled(GL_MULTISAMPLE);
|
|
|
|
Gwn_VertAttr.is_polygon_offset_line = glIsEnabled(GL_POLYGON_OFFSET_LINE);
|
|
|
|
Gwn_VertAttr.is_polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
|
|
|
|
Gwn_VertAttr.is_polygon_smooth = glIsEnabled(GL_POLYGON_SMOOTH);
|
|
|
|
Gwn_VertAttr.is_sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
|
|
|
Gwn_VertAttr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
|
|
|
Gwn_VertAttr.is_stencil_test = glIsEnabled(GL_STENCIL_TEST);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_SCISSOR_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
|
|
|
glGetIntegerv(GL_SCISSOR_BOX, (GLint *)&Gwn_VertAttr.scissor_box);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_VIEWPORT_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
glGetDoublev(GL_DEPTH_RANGE, (GLdouble *)&Gwn_VertAttr.near_far);
|
|
|
|
glGetIntegerv(GL_VIEWPORT, (GLint *)&Gwn_VertAttr.viewport);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_BLEND_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
Gwn_VertAttr.is_blend = glIsEnabled(GL_BLEND);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
2017-05-09 15:09:39 +02:00
|
|
|
|
|
|
|
BLI_assert(AttribStack.top < STATE_STACK_DEPTH);
|
|
|
|
AttribStack.top++;
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
2017-10-07 15:57:14 +11:00
|
|
|
static void restore_mask(GLenum cap, const bool value)
|
|
|
|
{
|
2017-04-04 20:33:23 +02:00
|
|
|
if (value) {
|
|
|
|
glEnable(cap);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glDisable(cap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-21 09:39:31 +10:00
|
|
|
void gpuPopAttrib(void)
|
2017-04-04 20:33:23 +02:00
|
|
|
{
|
2017-05-09 15:09:39 +02:00
|
|
|
BLI_assert(AttribStack.top > 0);
|
|
|
|
AttribStack.top--;
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
GLint mask = Gwn_VertAttr.mask;
|
2017-04-04 20:33:23 +02:00
|
|
|
|
|
|
|
if ((mask & GPU_DEPTH_BUFFER_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_DEPTH_TEST, Gwn_VertAttr.is_depth_test);
|
|
|
|
glDepthFunc(Gwn_VertAttr.depth_func);
|
|
|
|
glClearDepth(Gwn_VertAttr.depth_clear_value);
|
|
|
|
glDepthMask(Gwn_VertAttr.depth_write_mask);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_ENABLE_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_BLEND, Gwn_VertAttr.is_blend);
|
2017-04-04 20:33:23 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) {
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_CLIP_PLANE0 + i, Gwn_VertAttr.is_clip_plane[i]);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_CULL_FACE, Gwn_VertAttr.is_cull_face);
|
|
|
|
restore_mask(GL_DEPTH_TEST, Gwn_VertAttr.is_depth_test);
|
|
|
|
restore_mask(GL_DITHER, Gwn_VertAttr.is_dither);
|
|
|
|
restore_mask(GL_LINE_SMOOTH, Gwn_VertAttr.is_line_smooth);
|
|
|
|
restore_mask(GL_COLOR_LOGIC_OP, Gwn_VertAttr.is_color_logic_op);
|
|
|
|
restore_mask(GL_MULTISAMPLE, Gwn_VertAttr.is_multisample);
|
|
|
|
restore_mask(GL_POLYGON_OFFSET_LINE, Gwn_VertAttr.is_polygon_offset_line);
|
|
|
|
restore_mask(GL_POLYGON_OFFSET_FILL, Gwn_VertAttr.is_polygon_offset_fill);
|
|
|
|
restore_mask(GL_POLYGON_SMOOTH, Gwn_VertAttr.is_polygon_smooth);
|
|
|
|
restore_mask(GL_SAMPLE_ALPHA_TO_COVERAGE, Gwn_VertAttr.is_sample_alpha_to_coverage);
|
|
|
|
restore_mask(GL_SCISSOR_TEST, Gwn_VertAttr.is_scissor_test);
|
|
|
|
restore_mask(GL_STENCIL_TEST, Gwn_VertAttr.is_stencil_test);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_VIEWPORT_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
glViewport(Gwn_VertAttr.viewport[0], Gwn_VertAttr.viewport[1], Gwn_VertAttr.viewport[2], Gwn_VertAttr.viewport[3]);
|
|
|
|
glDepthRange(Gwn_VertAttr.near_far[0], Gwn_VertAttr.near_far[1]);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_SCISSOR_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_SCISSOR_TEST, Gwn_VertAttr.is_scissor_test);
|
|
|
|
glScissor(Gwn_VertAttr.scissor_box[0], Gwn_VertAttr.scissor_box[1], Gwn_VertAttr.scissor_box[2], Gwn_VertAttr.scissor_box[3]);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((mask & GPU_BLEND_BIT) != 0) {
|
2017-06-19 20:18:04 +10:00
|
|
|
restore_mask(GL_BLEND, Gwn_VertAttr.is_blend);
|
2017-04-04 20:33:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-19 20:18:04 +10:00
|
|
|
#undef Gwn_VertAttr
|
2017-05-09 15:09:39 +02:00
|
|
|
#undef AttribStack
|
|
|
|
|
2016-06-25 20:16:33 +10:00
|
|
|
/** \} */
|