2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-19 12:14:58 +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
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-19 12:14:58 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation, full update, glsl support
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_view3d/drawmesh.c
|
|
|
|
|
* \ingroup spview3d
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2011-05-09 04:06:48 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BLI_edgehash.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "DNA_material_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_property_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
2010-03-11 18:27:45 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_material.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_property.h"
|
2009-07-24 10:43:58 +00:00
|
|
|
#include "BKE_tessmesh.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_scene.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
2010-07-14 10:46:12 +00:00
|
|
|
#include "GPU_buffers.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
#include "GPU_draw.h"
|
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
|
|
|
#include "GPU_material.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-30 13:16:14 +00:00
|
|
|
#include "ED_mesh.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "ED_uvedit.h"
|
2008-12-30 13:16:14 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
#include "view3d_intern.h" /* own include */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
/* user data structures for derived mesh callbacks */
|
|
|
|
|
typedef struct drawMeshFaceSelect_userData {
|
|
|
|
|
Mesh *me;
|
|
|
|
|
EdgeHash *eh;
|
|
|
|
|
} drawMeshFaceSelect_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawEMTFMapped_userData {
|
2011-12-20 10:59:56 +00:00
|
|
|
BMEditMesh *em;
|
2011-12-20 08:47:36 +00:00
|
|
|
short has_mcol;
|
|
|
|
|
short has_mtface;
|
|
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
} drawEMTFMapped_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawTFace_userData {
|
|
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
} drawTFace_userData;
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/**************************** Face Select Mode *******************************/
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Flags for marked edges */
|
2008-12-19 12:14:58 +00:00
|
|
|
enum {
|
2012-03-25 23:54:33 +00:00
|
|
|
eEdge_Visible = (1 << 0),
|
|
|
|
|
eEdge_Select = (1 << 1),
|
2008-12-19 12:14:58 +00:00
|
|
|
};
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Creates a hash of edges to flags indicating selected/visible */
|
2008-12-19 12:14:58 +00:00
|
|
|
static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flags)
|
|
|
|
|
{
|
|
|
|
|
int *flags_p;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!BLI_edgehash_haskey(eh, v0, v1))
|
2011-03-03 17:59:04 +00:00
|
|
|
BLI_edgehash_insert(eh, v0, v1, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
flags_p = (int *) BLI_edgehash_lookup_p(eh, v0, v1);
|
2008-12-19 12:14:58 +00:00
|
|
|
*flags_p |= flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
|
|
|
|
|
{
|
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp;
|
|
|
|
|
MLoop *ml;
|
|
|
|
|
MLoop *ml_next;
|
|
|
|
|
int i, j;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0; i < me->totpoly; i++) {
|
2012-02-05 03:25:13 +00:00
|
|
|
mp = &me->mpoly[i];
|
2011-01-12 03:41:12 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
if (!(mp->flag & ME_HIDE)) {
|
2011-08-12 18:13:55 +00:00
|
|
|
unsigned int flags = eEdge_Visible;
|
2012-02-05 03:25:13 +00:00
|
|
|
if (mp->flag & ME_FACE_SEL) flags |= eEdge_Select;
|
2011-08-12 18:13:55 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
ml = me->mloop + mp->loopstart;
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < mp->totloop; j++, ml++) {
|
2012-02-05 03:25:13 +00:00
|
|
|
ml_next = ME_POLY_LOOP_NEXT(me->mloop, mp, j);
|
|
|
|
|
get_marked_edge_info__orFlags(eh, ml->v, ml_next->v, flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData *data = userData;
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = data->me;
|
2009-01-31 13:30:56 +00:00
|
|
|
MEdge *med = &me->medge[index];
|
2008-12-19 12:14:58 +00:00
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEDGES) {
|
2012-03-08 06:47:05 +00:00
|
|
|
if ((me->drawflag & ME_HIDDENEDGES) || (flags & eEdge_Visible))
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flags & eEdge_Select)
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData *data = userData;
|
2008-12-19 12:14:58 +00:00
|
|
|
MEdge *med = &data->me->medge[index];
|
|
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
return (flags & eEdge_Select) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* draws unselected */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int index)
|
2010-10-19 15:35:46 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = (Mesh *)userData;
|
2010-10-19 15:35:46 +00:00
|
|
|
|
2012-04-03 23:40:24 +00:00
|
|
|
MPoly *mpoly = &me->mpoly[index];
|
|
|
|
|
if (!(mpoly->flag & ME_HIDE) && !(mpoly->flag & ME_FACE_SEL))
|
2012-03-25 23:54:33 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2010-10-19 15:35:46 +00:00
|
|
|
else
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2010-10-19 15:35:46 +00:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2012-09-15 01:52:28 +00:00
|
|
|
static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawMeshFaceSelect_userData data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
data.me = me;
|
|
|
|
|
data.eh = get_tface_mesh_marked_edge_info(me);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* Draw (Hidden) Edges */
|
|
|
|
|
setlinestyle(1);
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_EDGE_FACESEL);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
|
2010-10-19 15:35:46 +00:00
|
|
|
setlinestyle(0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Draw Selected Faces */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWFACES) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2010-10-19 15:35:46 +00:00
|
|
|
/* dull unselected faces so as not to get in the way of seeing color */
|
|
|
|
|
glColor4ub(96, 96, 96, 64);
|
2012-04-05 02:23:00 +00:00
|
|
|
dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, (void *)me, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
/* Draw Stippled Outline for selected faces */
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3ub(255, 255, 255);
|
|
|
|
|
setlinestyle(1);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 0.0); /* resets correctly now, even after calling accumulated offsets */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
BLI_edgehash_free(data.eh, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/***************************** Texture Drawing ******************************/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
static Material *give_current_material_or_def(Object *ob, int matnr)
|
|
|
|
|
{
|
2012-07-08 20:36:00 +00:00
|
|
|
extern Material defmaterial; /* render module abuse... */
|
2012-03-25 23:54:33 +00:00
|
|
|
Material *ma = give_current_material(ob, matnr);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
return ma ? ma : &defmaterial;
|
2008-12-19 12:14:58 +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
|
|
|
/* Icky globals, fix with userdata parameter */
|
|
|
|
|
|
|
|
|
|
static struct TextureDrawState {
|
|
|
|
|
Object *ob;
|
2012-05-19 13:28:19 +00:00
|
|
|
int is_lit, is_tex;
|
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 color_profile;
|
|
|
|
|
unsigned char obcol[4];
|
|
|
|
|
} Gtexdraw = {NULL, 0, 0, 0, {0, 0, 0, 0}};
|
|
|
|
|
|
|
|
|
|
static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw)
|
2008-12-19 12:14:58 +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
|
|
|
static Material *c_ma;
|
2008-12-19 12:14:58 +00:00
|
|
|
static int c_textured;
|
2012-04-10 16:28:26 +00:00
|
|
|
static MTFace c_texface;
|
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 int c_backculled;
|
2008-12-19 12:14:58 +00:00
|
|
|
static int c_badtex;
|
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 int c_lit;
|
2012-04-10 16:28:26 +00:00
|
|
|
static int c_has_texface;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
Object *litob = NULL; /* to get mode to turn off mipmap in painting mode */
|
2011-10-23 17:52:20 +00:00
|
|
|
int backculled = GEMAT_BACKCULL;
|
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 = 0;
|
|
|
|
|
int textured = 0;
|
|
|
|
|
int lit = 0;
|
2012-04-10 16:28:26 +00:00
|
|
|
int has_texface = texface != NULL;
|
|
|
|
|
int need_set_tpage = FALSE;
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
if (clearcache) {
|
2012-03-25 23:54:33 +00:00
|
|
|
c_textured = c_lit = c_backculled = -1;
|
2012-04-10 16:28:26 +00:00
|
|
|
memset(&c_texface, 0, sizeof(MTFace));
|
2012-03-25 23:54:33 +00:00
|
|
|
c_badtex = 0;
|
2012-04-10 16:28:26 +00:00
|
|
|
c_has_texface = -1;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-19 13:28:19 +00:00
|
|
|
textured = gtexdraw.is_tex;
|
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
|
|
|
litob = gtexdraw.ob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* convert number of lights into boolean */
|
2012-05-19 13:28:19 +00:00
|
|
|
if (gtexdraw.is_lit) lit = 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
|
|
|
|
|
|
|
|
if (ma) {
|
|
|
|
|
alphablend = ma->game.alpha_blend;
|
|
|
|
|
if (ma->mode & MA_SHLESS) lit = 0;
|
|
|
|
|
backculled = ma->game.flag & GEMAT_BACKCULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (texface) {
|
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
|
|
|
textured = textured && (texface->tpage);
|
|
|
|
|
|
|
|
|
|
/* no material, render alpha if texture has depth=32 */
|
|
|
|
|
if (!ma && BKE_image_has_alpha(texface->tpage))
|
|
|
|
|
alphablend = GPU_BLEND_ALPHA;
|
2008-12-19 12:14:58 +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
|
|
|
else
|
|
|
|
|
textured = 0;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (backculled != c_backculled) {
|
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
|
|
|
if (backculled) glEnable(GL_CULL_FACE);
|
|
|
|
|
else glDisable(GL_CULL_FACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
c_backculled = backculled;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-10 16:28:26 +00:00
|
|
|
/* need to re-set tpage if textured flag changed or existsment of texface changed.. */
|
|
|
|
|
need_set_tpage = textured != c_textured || has_texface != c_has_texface;
|
|
|
|
|
/* ..or if settings inside texface were changed (if texface was used) */
|
|
|
|
|
need_set_tpage |= texface && memcmp(&c_texface, texface, sizeof(c_texface));
|
|
|
|
|
|
|
|
|
|
if (need_set_tpage) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (textured) {
|
|
|
|
|
c_badtex = !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT), alphablend);
|
2012-03-24 07:52:14 +00:00
|
|
|
}
|
|
|
|
|
else {
|
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_tpage(NULL, 0, 0);
|
2012-03-25 23:54:33 +00:00
|
|
|
c_badtex = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
c_textured = textured;
|
2012-04-10 16:28:26 +00:00
|
|
|
c_has_texface = has_texface;
|
|
|
|
|
if (texface)
|
|
|
|
|
memcpy(&c_texface, texface, sizeof(c_texface));
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (c_badtex) lit = 0;
|
|
|
|
|
if (lit != c_lit || ma != c_ma) {
|
2008-12-19 12:14:58 +00:00
|
|
|
if (lit) {
|
|
|
|
|
float spec[4];
|
2012-07-08 20:36:00 +00:00
|
|
|
if (!ma) ma = give_current_material_or_def(NULL, 0); /* default material */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
spec[0] = ma->spec * ma->specr;
|
|
|
|
|
spec[1] = ma->spec * ma->specg;
|
|
|
|
|
spec[2] = ma->spec * ma->specb;
|
|
|
|
|
spec[3] = 1.0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
2011-03-25 13:37:50 +00:00
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128));
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
c_lit = lit;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c_badtex;
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
unsigned char obcol[4];
|
2012-05-19 13:28:19 +00:00
|
|
|
int is_tex, solidtex;
|
2012-08-14 18:01:58 +00:00
|
|
|
Mesh *me = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* XXX scene->obedit warning */
|
2011-10-06 05:01:24 +00:00
|
|
|
|
|
|
|
|
/* texture draw is abused for mask selection mode, do this so wire draw
|
|
|
|
|
* with face selection in weight paint is not lit. */
|
2012-04-24 23:47:10 +00:00
|
|
|
if ((v3d->drawtype <= OB_WIRE) && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))) {
|
2012-03-25 23:54:33 +00:00
|
|
|
solidtex = FALSE;
|
2012-05-19 13:28:19 +00:00
|
|
|
Gtexdraw.is_lit = 0;
|
2011-10-06 05:01:24 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (v3d->drawtype == OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype != OB_TEXTURE)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with default lights in solid draw mode and edit mode */
|
2012-03-25 23:54:33 +00:00
|
|
|
solidtex = TRUE;
|
2012-05-19 13:28:19 +00:00
|
|
|
Gtexdraw.is_lit = -1;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-02-06 19:21:24 +00:00
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with lights in the scene otherwise */
|
2012-03-25 23:54:33 +00:00
|
|
|
solidtex = FALSE;
|
2012-05-19 13:28:19 +00:00
|
|
|
Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
|
2009-02-06 19:21:24 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-01-19 10:04:51 +00:00
|
|
|
rgba_float_to_uchar(obcol, ob->col);
|
|
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
if (solidtex || v3d->drawtype == OB_TEXTURE) is_tex = 1;
|
|
|
|
|
else is_tex = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
Gtexdraw.ob = ob;
|
2012-05-19 13:28:19 +00:00
|
|
|
Gtexdraw.is_tex = is_tex;
|
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
|
|
|
|
|
|
|
|
/* OCIO_TODO: for now assume OpenGL is always doing color management and working in sRGB space
|
|
|
|
|
* supporting for real display conversion could be nice here, but it's a bit challenging
|
|
|
|
|
* since all the shaders should be aware of such a transform
|
|
|
|
|
* perhaps this flag could be completely removed before release in separated commit and
|
|
|
|
|
* be re-implemented if real display transform would be needed
|
|
|
|
|
*/
|
|
|
|
|
Gtexdraw.color_profile = TRUE;
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));
|
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
|
|
|
set_draw_settings_cached(1, NULL, NULL, Gtexdraw);
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
2012-08-14 18:01:58 +00:00
|
|
|
if (v3d->flag2 & V3D_BACKFACE_CULLING) {
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
}
|
|
|
|
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void draw_textured_end(void)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
/* switch off textures */
|
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_tpage(NULL, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
/* XXX, bad patch - GPU_default_lights() calls
|
2012-05-04 07:23:50 +00:00
|
|
|
* glLightfv(GL_POSITION, ...) which
|
2008-12-19 12:14:58 +00:00
|
|
|
* is transformed by the current matrix... we
|
|
|
|
|
* need to make sure that matrix is identity.
|
|
|
|
|
*
|
|
|
|
|
* It would be better if drawmesh.c kept track
|
|
|
|
|
* of and restored the light settings it changed.
|
|
|
|
|
* - zr
|
|
|
|
|
*/
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
GPU_default_lights();
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
|
|
|
|
|
int validtexture = 0;
|
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
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE))
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +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
|
|
|
validtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
|
|
|
|
|
|
|
|
|
|
if (tface && validtexture) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3ub(0xFF, 0x00, 0xFF);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ma && (ma->shade_flag & MA_OBCOLOR)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3ubv(Gtexdraw.obcol);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!has_mcol) {
|
2008-12-19 12:14:58 +00:00
|
|
|
if (tface) glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ma) {
|
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
|
|
|
float col[3];
|
2012-02-22 16:52:06 +00:00
|
|
|
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
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
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
}
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-10-04 11:42:44 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), int has_mcol, int UNUSED(matnr))
|
2011-06-17 18:04:56 +00:00
|
|
|
{
|
2012-03-08 06:47:05 +00:00
|
|
|
if (has_mcol)
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_NO_MCOL;
|
2011-06-17 18:04:56 +00:00
|
|
|
}
|
2011-10-04 11:42:44 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
|
2009-10-22 23:22:05 +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
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return 0;
|
|
|
|
|
|
|
|
|
|
if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-10 22:00:55 +00:00
|
|
|
else if (tface && (tface->mode & TF_OBCOL)) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!has_mcol) {
|
2012-03-08 06:47:05 +00:00
|
|
|
/* XXX: this return value looks wrong (and doesn't match comment) */
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL; /* Don't set color */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL; /* Set color from mcol */
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 16:08:22 +00:00
|
|
|
|
|
|
|
|
static void update_tface_color_layer(DerivedMesh *dm)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2012-04-10 19:27:02 +00:00
|
|
|
MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2009-10-22 23:22:05 +00:00
|
|
|
MFace *mface = dm->getTessFaceArray(dm);
|
|
|
|
|
MCol *finalCol;
|
2012-03-25 23:54:33 +00:00
|
|
|
int i, j;
|
2012-03-22 08:41:50 +00:00
|
|
|
MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!mcol)
|
2009-10-22 23:22:05 +00:00
|
|
|
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
|
|
|
|
|
|
2012-07-12 16:08:22 +00:00
|
|
|
if (CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) {
|
|
|
|
|
finalCol = CustomData_get_layer(&dm->faceData, CD_TEXTURE_MCOL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer");
|
|
|
|
|
|
|
|
|
|
CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0; i < dm->getNumTessFaces(dm); i++) {
|
|
|
|
|
Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 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
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ma && (ma->game.flag & GEMAT_INVISIBLE)) {
|
|
|
|
|
if (mcol)
|
|
|
|
|
memcpy(&finalCol[i * 4], &mcol[i * 4], sizeof(MCol) * 4);
|
2009-10-22 23:22:05 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = 255;
|
|
|
|
|
finalCol[i * 4 + j].g = 255;
|
|
|
|
|
finalCol[i * 4 + j].r = 255;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-09-15 06:29:32 +00:00
|
|
|
else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = 255;
|
|
|
|
|
finalCol[i * 4 + j].g = 0;
|
|
|
|
|
finalCol[i * 4 + j].r = 255;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-10 22:00:55 +00:00
|
|
|
else if (tface && (tface->mode & TF_OBCOL)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = FTOCHAR(Gtexdraw.obcol[0]);
|
|
|
|
|
finalCol[i * 4 + j].g = FTOCHAR(Gtexdraw.obcol[1]);
|
|
|
|
|
finalCol[i * 4 + j].r = FTOCHAR(Gtexdraw.obcol[2]);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (!mcol) {
|
2009-10-22 23:22:05 +00:00
|
|
|
if (tface) {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = 255;
|
|
|
|
|
finalCol[i * 4 + j].g = 255;
|
|
|
|
|
finalCol[i * 4 + j].r = 255;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
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
|
|
|
float col[3];
|
2012-03-25 23:54:33 +00:00
|
|
|
Material *ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1);
|
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
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ma) {
|
|
|
|
|
if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
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
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = FTOCHAR(col[0]);
|
|
|
|
|
finalCol[i * 4 + j].g = FTOCHAR(col[1]);
|
|
|
|
|
finalCol[i * 4 + j].r = FTOCHAR(col[2]);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
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
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].b = 255;
|
|
|
|
|
finalCol[i * 4 + j].g = 255;
|
|
|
|
|
finalCol[i * 4 + j].r = 255;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
finalCol[i * 4 + j].r = mcol[i * 4 + j].r;
|
|
|
|
|
finalCol[i * 4 + j].g = mcol[i * 4 + j].g;
|
|
|
|
|
finalCol[i * 4 + j].b = mcol[i * 4 + j].b;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-08 09:07:24 +00:00
|
|
|
Mesh *me = (Mesh *)userData;
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
/* array checked for NULL before calling */
|
|
|
|
|
MPoly *mpoly = &me->mpoly[index];
|
2011-11-13 15:13:59 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
BLI_assert(index >= 0 && index < me->totpoly);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
if (mpoly->flag & ME_HIDE) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
2012-02-08 09:07:24 +00:00
|
|
|
else {
|
|
|
|
|
MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[index] : NULL;
|
2012-03-25 23:54:33 +00:00
|
|
|
MTFace mtf = {{{0}}};
|
2012-02-08 09:07:24 +00:00
|
|
|
int matnr = mpoly->mat_nr;
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
if (tpoly) {
|
|
|
|
|
ME_MTEXFACE_CPY(&mtf, tpoly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawEMTFMapped_userData *data = userData;
|
2011-09-24 11:03:52 +00:00
|
|
|
BMEditMesh *em = data->em;
|
2012-03-27 04:46:52 +00:00
|
|
|
BMFace *efa = EDBM_face_at_index(em, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (efa == NULL || BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2011-09-24 11:03:52 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
MTFace mtf = {{{0}}};
|
2011-09-24 11:03:52 +00:00
|
|
|
int matnr = efa->mat_nr;
|
|
|
|
|
|
|
|
|
|
if (data->has_mtface) {
|
|
|
|
|
MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
|
2012-02-08 09:02:10 +00:00
|
|
|
ME_MTEXFACE_CPY(&mtf, tpoly);
|
2011-09-24 11:03:52 +00:00
|
|
|
}
|
2009-07-25 14:13:26 +00:00
|
|
|
|
2012-03-06 21:21:22 +00:00
|
|
|
return draw_tface__set_draw_legacy(data->has_mtface ? &mtf : NULL,
|
2012-03-25 23:54:33 +00:00
|
|
|
data->has_mcol, matnr);
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-11 07:03:47 +00:00
|
|
|
/* when face select is on, use face hidden flag */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption wpaint__setSolidDrawOptions_facemask(void *userData, int index)
|
2012-01-11 07:03:47 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = (Mesh *)userData;
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp = &me->mpoly[index];
|
2012-03-08 06:47:05 +00:00
|
|
|
if (mp->flag & ME_HIDE)
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-01-11 07:03:47 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
DerivedMesh *ddm;
|
2012-02-08 09:07:24 +00:00
|
|
|
MPoly *mp, *mface = me->mpoly;
|
|
|
|
|
MTexPoly *mtpoly = me->mtpoly;
|
|
|
|
|
MLoopUV *mloopuv = me->mloopuv;
|
|
|
|
|
MLoopUV *luv;
|
2012-03-25 23:54:33 +00:00
|
|
|
MLoopCol *mloopcol = me->mloopcol; /* why does mcol exist? */
|
2012-02-08 09:07:24 +00:00
|
|
|
MLoopCol *lcol;
|
|
|
|
|
|
2012-09-18 04:35:30 +00:00
|
|
|
bProperty *prop = BKE_bproperty_object_get(ob, "Text");
|
2008-12-19 12:14:58 +00:00
|
|
|
GPUVertexAttribs gattribs;
|
2012-02-08 09:07:24 +00:00
|
|
|
int a, totpoly = me->totpoly;
|
|
|
|
|
|
|
|
|
|
/* fake values to pass to GPU_render_text() */
|
2012-03-25 23:54:33 +00:00
|
|
|
MCol tmp_mcol[4] = {{0}};
|
2012-02-08 09:07:24 +00:00
|
|
|
MCol *tmp_mcol_pt = mloopcol ? tmp_mcol : NULL;
|
|
|
|
|
MTFace tmp_tf = {{{0}}};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* don't draw without tfaces */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!mtpoly || !mloopuv)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* don't draw when editing */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_EDIT)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ob == OBACT)
|
2012-02-22 16:52:06 +00:00
|
|
|
if (paint_facesel_test(ob) || paint_vertsel_test(ob))
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0, mp = mface; a < totpoly; a++, mtpoly++, mp++) {
|
|
|
|
|
short matnr = mp->mat_nr;
|
|
|
|
|
int mf_smooth = mp->flag & ME_SMOOTH;
|
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
|
|
|
Material *mat = me->mat[matnr];
|
2012-07-12 09:56:18 +00:00
|
|
|
int mode = mat ? mat->game.flag : GEMAT_INVISIBLE;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!(mode & GEMAT_INVISIBLE) && (mode & GEMAT_TEXT) && mp->totloop >= 3) {
|
2012-02-08 09:07:24 +00:00
|
|
|
/* get the polygon as a tri/quad */
|
|
|
|
|
int mp_vi[4];
|
2008-12-19 12:14:58 +00:00
|
|
|
float v1[3], v2[3], v3[3], v4[3];
|
|
|
|
|
char string[MAX_PROPSTRING];
|
2012-03-25 23:54:33 +00:00
|
|
|
int characters, i, glattrib = -1, badtex = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
|
|
|
|
|
/* TEXFACE */
|
|
|
|
|
ME_MTEXFACE_CPY(&tmp_tf, mtpoly);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (glsl) {
|
2012-03-25 23:54:33 +00:00
|
|
|
GPU_enable_material(matnr + 1, &gattribs);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0; i < gattribs.totlayer; i++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (gattribs.layer[i].type == CD_MTFACE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glattrib = gattribs.layer[i].glindex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-08 09:07:24 +00:00
|
|
|
badtex = set_draw_settings_cached(0, &tmp_tf, mat, Gtexdraw);
|
2008-12-19 12:14:58 +00:00
|
|
|
if (badtex) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
mp_vi[0] = me->mloop[mp->loopstart + 0].v;
|
2012-03-25 23:54:33 +00:00
|
|
|
mp_vi[1] = me->mloop[mp->loopstart + 1].v;
|
|
|
|
|
mp_vi[2] = me->mloop[mp->loopstart + 2].v;
|
|
|
|
|
mp_vi[3] = (mp->totloop >= 4) ? me->mloop[mp->loopstart + 3].v : 0;
|
2012-02-08 09:07:24 +00:00
|
|
|
|
|
|
|
|
/* UV */
|
|
|
|
|
luv = &mloopuv[mp->loopstart];
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[0], luv->uv); luv++;
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[1], luv->uv); luv++;
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[2], luv->uv); luv++;
|
|
|
|
|
if (mp->totloop >= 4) {
|
|
|
|
|
copy_v2_v2(tmp_tf.uv[3], luv->uv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* COLOR */
|
|
|
|
|
if (mloopcol) {
|
|
|
|
|
unsigned int totloop_clamp = MIN2(4, mp->totloop);
|
|
|
|
|
unsigned int j;
|
|
|
|
|
lcol = &mloopcol[mp->loopstart];
|
|
|
|
|
|
2012-09-19 02:06:27 +00:00
|
|
|
for (j = 0; j < totloop_clamp; j++, lcol++) {
|
2012-03-17 20:39:28 +00:00
|
|
|
MESH_MLOOPCOL_TO_MCOL(lcol, &tmp_mcol[j]);
|
2012-02-08 09:07:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* LOCATION */
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[0], v1);
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[1], v2);
|
2012-02-25 16:04:03 +00:00
|
|
|
ddm->getVertCo(ddm, mp_vi[2], v3);
|
2012-02-08 09:07:24 +00:00
|
|
|
if (mp->totloop >= 4) {
|
|
|
|
|
ddm->getVertCo(ddm, mp_vi[3], v4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* The BM_FONT handling is in the gpu module, shared with the
|
|
|
|
|
* game engine, was duplicated previously */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-09-18 04:35:30 +00:00
|
|
|
BKE_bproperty_set_valstr(prop, string);
|
2008-12-19 12:14:58 +00:00
|
|
|
characters = strlen(string);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!BKE_image_get_ibuf(mtpoly->tpage, NULL))
|
2008-12-19 12:14:58 +00:00
|
|
|
characters = 0;
|
|
|
|
|
|
|
|
|
|
if (!mf_smooth) {
|
|
|
|
|
float nor[3];
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
normal_tri_v3(nor, v1, v2, v3);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glNormal3fv(nor);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
GPU_render_text(&tmp_tf, mode, string, characters,
|
2012-03-25 23:54:33 +00:00
|
|
|
(unsigned int *)tmp_mcol_pt, v1, v2, v3, (mp->totloop >= 4 ? v4 : NULL), glattrib);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ddm->release(ddm);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-01 12:12:39 +00:00
|
|
|
static int compareDrawOptions(void *userData, int cur_index, int next_index)
|
|
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawTFace_userData *data = userData;
|
2011-12-01 12:12:39 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr)
|
2011-12-01 12:12:39 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage)
|
2011-12-01 12:12:39 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-01 18:26:57 +00:00
|
|
|
static int compareDrawOptionsEm(void *userData, int cur_index, int next_index)
|
|
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
drawEMTFMapped_userData *data = userData;
|
2011-12-01 18:26:57 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr)
|
2011-12-01 18:26:57 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage)
|
2011-12-01 18:26:57 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-15 01:52:28 +00:00
|
|
|
static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
|
|
|
|
Object *ob, DerivedMesh *dm, const int draw_flags)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* correct for negative scale */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
|
2008-12-19 12:14:58 +00:00
|
|
|
else glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
/* draw the textured mesh */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_textured_begin(scene, v3d, rv3d, ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
2010-11-25 21:59:12 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2011-12-20 08:47:36 +00:00
|
|
|
drawEMTFMapped_userData data;
|
2011-09-23 18:29:45 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
data.em = me->edit_btmesh;
|
|
|
|
|
data.has_mcol = CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL);
|
|
|
|
|
data.has_mtface = CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
data.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
data.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2011-09-23 18:29:45 +00:00
|
|
|
|
2011-12-01 18:26:57 +00:00
|
|
|
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (draw_flags & DRAW_FACE_SELECT) {
|
|
|
|
|
if (ob->mode & OB_MODE_WEIGHT_PAINT)
|
2012-03-07 12:48:52 +00:00
|
|
|
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me,
|
2012-03-25 23:54:33 +00:00
|
|
|
DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2011-12-02 01:01:07 +00:00
|
|
|
dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (GPU_buffer_legacy(dm)) {
|
Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview.
User side:
* Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though.
* Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one.
* Last active preview modifier in stack wins!
Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now.
Dev side:
* In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW
* Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope).
* Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data.
* Added three new modifier funcs, to handle preview modifiers in draw code / mod stack.
* For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s).
So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work.
2012-01-22 17:54:23 +00:00
|
|
|
if (draw_flags & DRAW_MODIFIERS_PREVIEW)
|
2011-12-01 12:12:39 +00:00
|
|
|
dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL);
|
2011-06-17 18:04:56 +00:00
|
|
|
else
|
2011-12-01 12:12:39 +00:00
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
else {
|
2011-12-20 08:47:36 +00:00
|
|
|
drawTFace_userData userData;
|
2011-12-09 11:46:48 +00:00
|
|
|
|
2012-07-12 16:08:22 +00:00
|
|
|
update_tface_color_layer(dm);
|
2011-08-12 18:13:55 +00:00
|
|
|
|
2011-12-10 05:38:00 +00:00
|
|
|
userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
2011-12-09 11:46:48 +00:00
|
|
|
|
|
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw game engine text hack */
|
2012-09-18 04:35:30 +00:00
|
|
|
if (BKE_bproperty_object_get(ob, "Text"))
|
2008-12-22 09:43:29 +00:00
|
|
|
draw_mesh_text(scene, ob, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
draw_textured_end();
|
|
|
|
|
|
|
|
|
|
/* draw edges and selected faces over textured mesh */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
|
2011-08-12 18:13:55 +00:00
|
|
|
draw_mesh_face_select(rv3d, me, dm);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* reset from negative scale correction */
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* in editmode, the blend mode needs to be set in case it was ADD */
|
2008-12-19 12:14:58 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/************************** NEW SHADING NODES ********************************/
|
|
|
|
|
|
|
|
|
|
typedef struct TexMatCallback {
|
|
|
|
|
Scene *scene;
|
|
|
|
|
Object *ob;
|
|
|
|
|
Mesh *me;
|
|
|
|
|
DerivedMesh *dm;
|
|
|
|
|
} TexMatCallback;
|
|
|
|
|
|
|
|
|
|
static void tex_mat_set_material_cb(void *UNUSED(userData), int mat_nr, void *attribs)
|
|
|
|
|
{
|
|
|
|
|
/* all we have to do here is simply enable the GLSL material, but note
|
2012-03-03 16:31:46 +00:00
|
|
|
* that the GLSL code will give different result depending on the drawtype,
|
|
|
|
|
* in texture draw mode it will output the active texture node, in material
|
|
|
|
|
* draw mode it will show the full material. */
|
2011-11-08 13:07:16 +00:00
|
|
|
GPU_enable_material(mat_nr, attribs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs)
|
|
|
|
|
{
|
|
|
|
|
/* texture draw mode without GLSL */
|
2012-03-25 23:54:33 +00:00
|
|
|
TexMatCallback *data = (TexMatCallback *)userData;
|
2011-11-08 13:07:16 +00:00
|
|
|
GPUVertexAttribs *gattribs = attribs;
|
|
|
|
|
Image *ima;
|
|
|
|
|
ImageUser *iuser;
|
|
|
|
|
bNode *node;
|
2012-03-25 23:54:33 +00:00
|
|
|
int texture_set = 0;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* draw image texture if we find one */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node)) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* get openl texture */
|
2012-03-25 23:54:33 +00:00
|
|
|
int mipmap = 1;
|
2012-08-30 17:42:04 +00:00
|
|
|
int bindcode = (ima) ? GPU_verify_image(ima, iuser, 0, 0, mipmap, FALSE) : 0;
|
2011-11-08 13:07:16 +00:00
|
|
|
float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bindcode) {
|
2012-03-25 23:54:33 +00:00
|
|
|
NodeTexBase *texbase = node->storage;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* disable existing material */
|
|
|
|
|
GPU_disable_material();
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
|
|
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
|
|
|
|
|
|
|
|
|
|
/* bind texture */
|
2012-04-12 15:23:34 +00:00
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
2011-11-08 13:07:16 +00:00
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadMatrixf(texbase->tex_mapping.mat);
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* use active UV texture layer */
|
|
|
|
|
memset(gattribs, 0, sizeof(*gattribs));
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
gattribs->layer[0].type = CD_MTFACE;
|
|
|
|
|
gattribs->layer[0].name[0] = '\0';
|
|
|
|
|
gattribs->layer[0].gltexco = 1;
|
|
|
|
|
gattribs->totlayer = 1;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
texture_set = 1;
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!texture_set) {
|
2011-11-08 13:07:16 +00:00
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* disable texture */
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
|
|
|
|
|
/* draw single color */
|
|
|
|
|
GPU_enable_material(mat_nr, attribs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int tex_mat_set_face_mesh_cb(void *userData, int index)
|
|
|
|
|
{
|
|
|
|
|
/* faceselect mode face hiding */
|
2012-03-25 23:54:33 +00:00
|
|
|
TexMatCallback *data = (TexMatCallback *)userData;
|
|
|
|
|
Mesh *me = (Mesh *)data->me;
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp = &me->mpoly[index];
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
return !(mp->flag & ME_HIDE);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-10 03:40:02 +00:00
|
|
|
static int tex_mat_set_face_editmesh_cb(void *userData, int index)
|
2011-11-08 13:07:16 +00:00
|
|
|
{
|
|
|
|
|
/* editmode face hiding */
|
2012-03-25 23:54:33 +00:00
|
|
|
TexMatCallback *data = (TexMatCallback *)userData;
|
|
|
|
|
Mesh *me = (Mesh *)data->me;
|
2012-03-27 04:46:52 +00:00
|
|
|
BMFace *efa = EDBM_face_at_index(me->edit_btmesh, index);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-04 01:23:50 +00:00
|
|
|
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
|
|
|
|
Object *ob, DerivedMesh *dm, const int draw_flags)
|
2011-11-08 13:07:16 +00:00
|
|
|
{
|
2012-05-05 14:33:36 +00:00
|
|
|
if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) {
|
2011-11-09 15:46:53 +00:00
|
|
|
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags);
|
2011-11-08 13:07:16 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
|
2012-05-10 06:32:24 +00:00
|
|
|
draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
|
2012-05-02 10:52:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* set opengl state for negative scale & color */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
|
2011-11-08 13:07:16 +00:00
|
|
|
else glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
|
2012-05-02 10:52:29 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
2011-11-08 13:07:16 +00:00
|
|
|
TexMatCallback data = {scene, ob, me, dm};
|
2012-03-25 23:54:33 +00:00
|
|
|
int (*set_face_cb)(void *, int);
|
2011-11-08 13:07:16 +00:00
|
|
|
int glsl;
|
|
|
|
|
|
|
|
|
|
/* face hiding callback depending on mode */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob == scene->obedit)
|
2012-03-25 23:54:33 +00:00
|
|
|
set_face_cb = tex_mat_set_face_editmesh_cb;
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (draw_flags & DRAW_FACE_SELECT)
|
2012-03-25 23:54:33 +00:00
|
|
|
set_face_cb = tex_mat_set_face_mesh_cb;
|
2011-11-08 13:07:16 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
set_face_cb = NULL;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* test if we can use glsl */
|
2012-03-25 23:54:33 +00:00
|
|
|
glsl = (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support();
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (glsl) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* draw glsl */
|
|
|
|
|
dm->drawMappedFacesMat(dm,
|
2012-03-25 23:54:33 +00:00
|
|
|
tex_mat_set_material_cb,
|
|
|
|
|
set_face_cb, &data);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
/* draw textured */
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
|
|
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
|
|
|
|
|
|
|
|
|
|
dm->drawMappedFacesMat(dm,
|
2012-03-25 23:54:33 +00:00
|
|
|
tex_mat_set_texture_cb,
|
|
|
|
|
set_face_cb, &data);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reset opengl state */
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
glMatrixMode(GL_TEXTURE);
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
|
|
/* faceselect mode drawing over textured mesh */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
|
2011-11-08 13:07:16 +00:00
|
|
|
draw_mesh_face_select(rv3d, ob->data, dm);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-02 10:52:29 +00:00
|
|
|
/* Vertex Paint and Weight Paint */
|
|
|
|
|
|
2012-09-04 01:23:50 +00:00
|
|
|
void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
|
|
|
|
|
Object *ob, DerivedMesh *dm, const int draw_flags)
|
2012-05-02 10:52:29 +00:00
|
|
|
{
|
|
|
|
|
DMSetDrawOptions facemask = NULL;
|
|
|
|
|
Mesh *me = ob->data;
|
2012-05-10 06:32:24 +00:00
|
|
|
const short do_light = (v3d->drawtype >= OB_SOLID);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
|
|
|
|
/* hide faces in face select mode */
|
|
|
|
|
if (draw_flags & DRAW_FACE_SELECT)
|
|
|
|
|
facemask = wpaint__setSolidDrawOptions_facemask;
|
|
|
|
|
|
2012-09-05 01:42:52 +00:00
|
|
|
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
|
2012-05-10 06:32:24 +00:00
|
|
|
|
|
|
|
|
if (do_light) {
|
2012-06-07 09:04:45 +00:00
|
|
|
const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
|
|
|
|
|
|
2012-05-10 06:32:24 +00:00
|
|
|
/* enforce default material settings */
|
|
|
|
|
GPU_enable_material(0, NULL);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
2012-05-10 06:32:24 +00:00
|
|
|
/* but set default spec */
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
|
2012-06-07 09:04:45 +00:00
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
2012-05-10 06:32:24 +00:00
|
|
|
/* diffuse */
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
|
|
|
|
|
dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
|
2012-05-08 15:55:29 +00:00
|
|
|
DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
2012-05-10 06:32:24 +00:00
|
|
|
if (do_light) {
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
2012-05-10 06:32:24 +00:00
|
|
|
GPU_disable_material();
|
|
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
}
|
|
|
|
|
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
|
2012-05-08 15:55:29 +00:00
|
|
|
if (me->mloopcol) {
|
2012-05-02 10:52:29 +00:00
|
|
|
dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
|
2012-05-08 15:55:29 +00:00
|
|
|
DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH);
|
|
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
else {
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me,
|
2012-05-08 15:55:29 +00:00
|
|
|
DM_DRAW_ALWAYS_SMOOTH);
|
2012-05-02 10:52:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw face selection on top */
|
2012-05-10 06:32:24 +00:00
|
|
|
if (draw_flags & DRAW_FACE_SELECT) {
|
2012-05-02 10:52:29 +00:00
|
|
|
draw_mesh_face_select(rv3d, me, dm);
|
2012-05-10 06:32:24 +00:00
|
|
|
}
|
|
|
|
|
else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) {
|
|
|
|
|
|
|
|
|
|
/* weight paint in solid mode, special case. focus on making the weights clear
|
|
|
|
|
* rather than the shading, this is also forced in wire view */
|
|
|
|
|
|
|
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
2012-05-10 06:32:24 +00:00
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glColor4ub(255, 255, 255, 96);
|
|
|
|
|
glEnable(GL_LINE_STIPPLE);
|
|
|
|
|
glLineStipple(1, 0xAAAA);
|
|
|
|
|
|
|
|
|
|
dm->drawEdges(dm, 1, 1);
|
|
|
|
|
|
|
|
|
|
bglPolygonOffset(rv3d->dist, 0.0);
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
glDisable(GL_LINE_STIPPLE);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
}
|
|
|
|
|
|