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"
|
2013-05-12 08:42:24 +00:00
|
|
|
#include "BLI_bitmap.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.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"
|
|
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
2012-11-26 08:00:15 +00:00
|
|
|
#include "BKE_global.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#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"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.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"
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
2014-03-21 10:11:54 +01:00
|
|
|
#include "RE_engine.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;
|
2013-07-22 23:20:48 +00:00
|
|
|
BLI_bitmap *edge_flags; /* pairs of edge options (visible, select) */
|
2011-12-20 08:47:36 +00:00
|
|
|
} drawMeshFaceSelect_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawEMTFMapped_userData {
|
2011-12-20 10:59:56 +00:00
|
|
|
BMEditMesh *em;
|
2014-02-03 18:55:59 +11:00
|
|
|
bool has_mcol;
|
|
|
|
|
bool has_mtface;
|
2011-12-20 08:47:36 +00:00
|
|
|
MFace *mf;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
} drawEMTFMapped_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawTFace_userData {
|
2013-06-26 10:14:30 +00:00
|
|
|
Mesh *me;
|
2011-12-20 08:47:36 +00:00
|
|
|
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
|
|
|
|
2013-05-12 08:42:24 +00:00
|
|
|
/* mainly to be less confusing */
|
|
|
|
|
BLI_INLINE int edge_vis_index(const int index) { return index * 2; }
|
|
|
|
|
BLI_INLINE int edge_sel_index(const int index) { return index * 2 + 1; }
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-12-02 17:56:40 +01:00
|
|
|
static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me, bool draw_select_edges)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-07-22 23:20:48 +00:00
|
|
|
BLI_bitmap *bitmap_edge_flags = BLI_BITMAP_NEW(me->totedge * 2, __func__);
|
2012-02-05 03:25:13 +00:00
|
|
|
MPoly *mp;
|
|
|
|
|
MLoop *ml;
|
|
|
|
|
int i, j;
|
2013-05-12 08:42:24 +00:00
|
|
|
bool select_set;
|
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)) {
|
2013-05-12 08:42:24 +00:00
|
|
|
select_set = (mp->flag & ME_FACE_SEL) != 0;
|
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++) {
|
2014-12-02 17:56:40 +01:00
|
|
|
if ((draw_select_edges == false) &&
|
|
|
|
|
(select_set && BLI_BITMAP_TEST(bitmap_edge_flags, edge_sel_index(ml->e))))
|
|
|
|
|
{
|
|
|
|
|
BLI_BITMAP_DISABLE(bitmap_edge_flags, edge_vis_index(ml->e));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_vis_index(ml->e));
|
|
|
|
|
if (select_set) {
|
|
|
|
|
BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_sel_index(ml->e));
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-12 08:42:24 +00:00
|
|
|
return bitmap_edge_flags;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEDGES) {
|
2014-12-02 17:56:40 +01:00
|
|
|
if ((BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))))
|
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
|
|
|
}
|
2014-12-02 17:56:40 +01:00
|
|
|
else if (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) &&
|
|
|
|
|
BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index)))
|
|
|
|
|
{
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2014-12-02 17:56:40 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2014-12-02 17:56:40 +01:00
|
|
|
}
|
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;
|
2014-12-02 17:56:40 +01:00
|
|
|
return (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) &&
|
|
|
|
|
BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))) ? 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
|
|
|
|
2014-12-02 17:56:40 +01:00
|
|
|
void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, bool draw_select_edges)
|
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;
|
2014-12-02 17:56:40 +01:00
|
|
|
data.edge_flags = get_tface_mesh_marked_edge_info(me, draw_select_edges);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 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);
|
|
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0); /* resets correctly now, even after calling accumulated offsets */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-05-12 08:42:24 +00:00
|
|
|
MEM_freeN(data.edge_flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
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;
|
2014-08-28 16:40:38 +02:00
|
|
|
Image *stencil; /* texture painting stencil */
|
|
|
|
|
Image *canvas; /* texture painting canvas, for image mode */
|
2014-03-21 10:11:54 +01:00
|
|
|
bool use_game_mat;
|
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;
|
2013-02-18 15:08:23 +00:00
|
|
|
bool use_backface_culling;
|
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
|
|
|
unsigned char obcol[4];
|
2014-07-21 12:02:05 +02:00
|
|
|
bool is_texpaint;
|
2014-08-28 16:40:38 +02:00
|
|
|
bool texpaint_material; /* use material slots for texture painting */
|
2014-09-02 15:57:22 +02:00
|
|
|
} Gtexdraw = {NULL, NULL, NULL, false, 0, 0, 0, false, {0, 0, 0, 0}, false, false};
|
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
|
|
|
|
2013-03-20 23:14:18 +00:00
|
|
|
static bool 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;
|
2013-03-20 23:14:18 +00:00
|
|
|
static bool 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
|
|
|
|
2013-05-14 10:20:58 +00:00
|
|
|
int backculled = 1;
|
2014-03-21 10:11:54 +01:00
|
|
|
int alphablend = GPU_BLEND_SOLID;
|
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 textured = 0;
|
|
|
|
|
int lit = 0;
|
2012-04-10 16:28:26 +00:00
|
|
|
int has_texface = texface != NULL;
|
2013-03-20 23:14:18 +00:00
|
|
|
bool need_set_tpage = false;
|
2014-07-21 12:02:05 +02:00
|
|
|
bool texpaint = ((gtexdraw.ob->mode & OB_MODE_TEXTURE_PAINT) != 0);
|
|
|
|
|
|
|
|
|
|
Image *ima = NULL;
|
2012-04-10 16:28:26 +00:00
|
|
|
|
2014-06-27 15:33:57 +06:00
|
|
|
if (ma != NULL) {
|
|
|
|
|
if (ma->mode & MA_TRANSP) {
|
|
|
|
|
alphablend = GPU_BLEND_ALPHA;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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));
|
2013-03-20 23:14:18 +00:00
|
|
|
c_badtex = false;
|
2012-04-10 16:28:26 +00:00
|
|
|
c_has_texface = -1;
|
2014-07-21 12:02:05 +02:00
|
|
|
c_ma = NULL;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
2014-03-31 20:05:09 +02:00
|
|
|
backculled = gtexdraw.use_backface_culling;
|
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) {
|
|
|
|
|
if (ma->mode & MA_SHLESS) lit = 0;
|
2014-03-21 10:11:54 +01:00
|
|
|
if (gtexdraw.use_game_mat) {
|
|
|
|
|
backculled = backculled || (ma->game.flag & GEMAT_BACKCULL);
|
|
|
|
|
alphablend = ma->game.alpha_blend;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (texface && !texpaint) {
|
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
|
|
|
}
|
2014-10-06 15:12:06 +02:00
|
|
|
else if (texpaint) {
|
2014-08-28 16:40:38 +02:00
|
|
|
if (gtexdraw.texpaint_material)
|
2014-10-06 15:12:06 +02:00
|
|
|
ima = ma && ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL;
|
|
|
|
|
else
|
2014-08-28 16:40:38 +02:00
|
|
|
ima = gtexdraw.canvas;
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
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) */
|
2014-07-21 12:02:05 +02:00
|
|
|
need_set_tpage |= (texpaint && c_ma != ma) || (texface && memcmp(&c_texface, texface, sizeof(c_texface)));
|
2012-04-10 16:28:26 +00:00
|
|
|
|
|
|
|
|
if (need_set_tpage) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (textured) {
|
2014-07-21 12:02:05 +02:00
|
|
|
if (texpaint) {
|
|
|
|
|
c_badtex = false;
|
|
|
|
|
if (GPU_verify_image(ima, NULL, 0, 1, 0, false)) {
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
2014-09-02 16:48:43 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);
|
2014-09-02 15:57:22 +02:00
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE1);
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
2014-10-06 15:12:06 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PREVIOUS);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
|
2014-09-02 15:57:22 +02:00
|
|
|
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
|
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-02 15:57:22 +02:00
|
|
|
glActiveTexture(GL_TEXTURE1);
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
c_badtex = true;
|
|
|
|
|
GPU_clear_tpage(true);
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
2014-09-02 15:57:22 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
c_badtex = !GPU_set_tpage(texface, !texpaint, 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);
|
2013-03-20 23:14:18 +00:00
|
|
|
c_badtex = false;
|
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;
|
2014-07-21 12:02:05 +02:00
|
|
|
c_ma = ma;
|
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];
|
2013-03-20 23:14:18 +00:00
|
|
|
bool is_tex, solidtex;
|
2012-08-14 18:01:58 +00:00
|
|
|
Mesh *me = ob->data;
|
2014-07-21 12:02:05 +02:00
|
|
|
ImagePaintSettings *imapaint = &scene->toolsettings->imapaint;
|
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))) {
|
2013-03-20 23:14:18 +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 */
|
2013-03-20 23:14:18 +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 */
|
2013-03-20 23:14:18 +00:00
|
|
|
solidtex = false;
|
2013-10-16 04:08:20 +00:00
|
|
|
if (v3d->flag2 & V3D_SHADELESS_TEX)
|
2013-10-15 15:56:00 +00:00
|
|
|
Gtexdraw.is_lit = 0;
|
|
|
|
|
else
|
|
|
|
|
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);
|
|
|
|
|
|
2013-03-20 23:14:18 +00:00
|
|
|
if (solidtex || v3d->drawtype == OB_TEXTURE) is_tex = true;
|
|
|
|
|
else is_tex = false;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
Gtexdraw.ob = ob;
|
2014-07-21 12:02:05 +02:00
|
|
|
Gtexdraw.stencil = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL) ? imapaint->stencil : NULL;
|
|
|
|
|
Gtexdraw.is_texpaint = (ob->mode == OB_MODE_TEXTURE_PAINT);
|
2014-08-28 16:40:38 +02:00
|
|
|
Gtexdraw.texpaint_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL);
|
|
|
|
|
Gtexdraw.canvas = (Gtexdraw.texpaint_material) ? NULL : imapaint->canvas;
|
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
|
|
|
|
2014-09-02 15:57:22 +02:00
|
|
|
/* naughty multitexturing hacks to quickly support stencil + shading + alpha blending
|
|
|
|
|
* in new texpaint code. The better solution here would be to support GLSL */
|
|
|
|
|
if (Gtexdraw.is_texpaint) {
|
2014-07-21 12:02:05 +02:00
|
|
|
glActiveTexture(GL_TEXTURE1);
|
2014-09-02 15:57:22 +02:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
|
2014-09-02 16:48:43 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PREVIOUS);
|
2014-09-02 15:57:22 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
2014-09-02 16:48:43 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
|
2014-09-02 15:57:22 +02:00
|
|
|
|
|
|
|
|
/* load the stencil texture here */
|
|
|
|
|
if (Gtexdraw.stencil != NULL) {
|
|
|
|
|
glActiveTexture(GL_TEXTURE2);
|
|
|
|
|
if (GPU_verify_image(Gtexdraw.stencil, NULL, false, false, false, false)) {
|
|
|
|
|
float col[4] = {imapaint->stencil_col[0], imapaint->stencil_col[1], imapaint->stencil_col[2], 1.0f};
|
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_CONSTANT);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_TEXTURE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_TEXTURE);
|
|
|
|
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, col);
|
|
|
|
|
if ((imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) == 0) {
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_ONE_MINUS_SRC_COLOR);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
|
|
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
|
|
|
|
}
|
2014-09-02 15:57:22 +02:00
|
|
|
|
2012-10-01 11:14:02 +00:00
|
|
|
Gtexdraw.color_profile = BKE_scene_check_color_management_enabled(scene);
|
2014-03-21 10:11:54 +01:00
|
|
|
Gtexdraw.use_game_mat = (RE_engines_find(scene->r.engine)->flag & RE_GAME) != 0;
|
2013-02-18 15:08:23 +00:00
|
|
|
Gtexdraw.use_backface_culling = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0;
|
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
|
|
|
|
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);
|
2013-02-18 15:08:23 +00:00
|
|
|
glCullFace(GL_BACK);
|
2012-08-14 18:01:58 +00:00
|
|
|
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
|
|
|
{
|
2014-07-21 12:02:05 +02:00
|
|
|
if (Gtexdraw.ob->mode & OB_MODE_TEXTURE_PAINT) {
|
2014-09-02 15:57:22 +02:00
|
|
|
glActiveTexture(GL_TEXTURE1);
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (Gtexdraw.stencil != NULL) {
|
2014-09-02 15:57:22 +02:00
|
|
|
glActiveTexture(GL_TEXTURE2);
|
2014-07-21 12:02:05 +02:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
|
|
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
2014-08-12 13:49:27 +02:00
|
|
|
}
|
2014-09-02 15:57:22 +02:00
|
|
|
glActiveTexture(GL_TEXTURE0);
|
2014-08-12 13:49:27 +02:00
|
|
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
2014-07-21 12:02:05 +02:00
|
|
|
/* manual reset, since we don't use tpage */
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
/* force switch off textures */
|
|
|
|
|
GPU_clear_tpage(true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* switch off textures */
|
|
|
|
|
GPU_set_tpage(NULL, 0, 0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
2013-01-05 08:24:22 +00:00
|
|
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* 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();
|
2012-10-21 05:46:41 +00:00
|
|
|
glLoadIdentity();
|
2008-12-19 12:14:58 +00:00
|
|
|
GPU_default_lights();
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool 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);
|
2013-03-20 23:14:18 +00:00
|
|
|
bool invalidtexture = false;
|
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
|
|
|
|
2012-12-18 12:42:13 +00:00
|
|
|
invalidtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
|
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-12-18 12:42:13 +00:00
|
|
|
if (tface && invalidtexture) {
|
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) {
|
2013-03-09 03:46:30 +00:00
|
|
|
if (tface) {
|
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
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
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(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;
|
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (tface || Gtexdraw.is_texpaint)
|
2013-01-15 10:47:44 +00:00
|
|
|
set_draw_settings_cached(0, tface, ma, Gtexdraw);
|
|
|
|
|
|
2012-12-18 12:42:13 +00:00
|
|
|
/* always use color from mcol, as set in update_tface_color_layer */
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2012-07-12 16:08:22 +00:00
|
|
|
|
2015-04-10 13:05:17 +02:00
|
|
|
static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
|
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;
|
2015-04-10 13:05:17 +02:00
|
|
|
MCol *mcol = NULL;
|
|
|
|
|
|
|
|
|
|
if (use_mcol) {
|
|
|
|
|
mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
|
|
|
|
|
if (!mcol)
|
|
|
|
|
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
|
|
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
|
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-12-18 12:42:13 +00:00
|
|
|
else if (ma && (ma->shade_flag & MA_OBCOLOR)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (j = 0; j < 4; j++) {
|
2012-12-18 12:42:13 +00:00
|
|
|
finalCol[i * 4 + j].b = Gtexdraw.obcol[0];
|
|
|
|
|
finalCol[i * 4 + j].g = Gtexdraw.obcol[1];
|
|
|
|
|
finalCol[i * 4 + j].r = 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-10-12 14:35:10 +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
|
|
|
|
2014-11-27 20:12:46 +01:00
|
|
|
static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, int UNUSED(mat_nr))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-26 10:14:30 +00:00
|
|
|
Mesh *me = ((drawTFace_userData *)userData)->me;
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
/* array checked for NULL before calling */
|
2014-11-27 19:12:48 +01:00
|
|
|
MPoly *mpoly = &me->mpoly[origindex];
|
2011-11-13 15:13:59 +00:00
|
|
|
|
2014-11-27 19:12:48 +01:00
|
|
|
BLI_assert(origindex >= 0 && origindex < 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 {
|
2014-11-27 19:12:48 +01:00
|
|
|
MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[origindex] : 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);
|
|
|
|
|
}
|
2014-11-27 19:12:48 +01:00
|
|
|
|
2012-02-08 09:07:24 +00:00
|
|
|
return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-27 20:12:46 +01:00
|
|
|
static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, int mat_nr)
|
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;
|
2013-07-14 23:41:33 +00:00
|
|
|
BMFace *efa;
|
|
|
|
|
|
2014-11-27 19:12:48 +01:00
|
|
|
if (UNLIKELY(origindex >= em->bm->totface))
|
2013-07-14 23:41:33 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
|
2014-11-27 19:12:48 +01:00
|
|
|
efa = BM_face_at_index(em->bm, origindex);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-06-20 07:00:57 +00:00
|
|
|
if (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}}};
|
2014-11-27 20:12:46 +01:00
|
|
|
int matnr = (mat_nr != -1) ? mat_nr : efa->mat_nr;
|
2011-09-24 11:03:52 +00:00
|
|
|
|
|
|
|
|
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-10-22 08:15:51 +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)
|
2014-02-26 16:00:54 +11:00
|
|
|
if (BKE_paint_select_elem_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;
|
2015-04-20 23:37:04 +10:00
|
|
|
const bool mf_smooth = (mp->flag & ME_SMOOTH) != 0;
|
2013-05-13 05:37:45 +00:00
|
|
|
Material *mat = (me->mat) ? me->mat[matnr] : NULL;
|
2012-07-12 09:56:18 +00:00
|
|
|
int mode = mat ? mat->game.flag : GEMAT_INVISIBLE;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-05-13 05:37:45 +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) {
|
2012-10-25 22:47:54 +00:00
|
|
|
unsigned int totloop_clamp = min_ii(4, mp->totloop);
|
2012-02-08 09:07:24 +00:00
|
|
|
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-11-15 15:59:58 +00:00
|
|
|
if (!BKE_image_has_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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 10:14:30 +00:00
|
|
|
|
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;
|
2014-07-21 12:02:05 +02:00
|
|
|
DMDrawFlag uvflag = DM_DRAW_USE_ACTIVE_UV;
|
|
|
|
|
|
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
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
|
|
|
|
uvflag = DM_DRAW_USE_TEXPAINT_UV;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data, 0);
|
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);
|
2013-06-26 10:14:30 +00:00
|
|
|
else {
|
|
|
|
|
drawTFace_userData userData;
|
|
|
|
|
|
|
|
|
|
userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
|
|
|
|
userData.me = me;
|
2014-07-21 12:02:05 +02:00
|
|
|
dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions, &userData, uvflag);
|
2013-06-26 10:14:30 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-11-28 14:38:18 +01:00
|
|
|
else {
|
|
|
|
|
drawTFace_userData userData;
|
|
|
|
|
|
2015-04-10 13:05:17 +02:00
|
|
|
update_tface_color_layer(dm, !(ob->mode & OB_MODE_TEXTURE_PAINT));
|
2014-11-28 14:38:18 +01:00
|
|
|
|
|
|
|
|
userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE);
|
|
|
|
|
userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
|
|
|
|
|
userData.me = NULL;
|
|
|
|
|
|
|
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData, uvflag);
|
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 */
|
2014-12-02 17:56:40 +01:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) {
|
|
|
|
|
bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
|
|
|
|
|
draw_mesh_face_select(rv3d, me, dm, draw_select_edges);
|
|
|
|
|
}
|
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 */
|
2014-07-23 11:33:29 -03:00
|
|
|
if (ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node, NULL)) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* get openl texture */
|
2012-03-25 23:54:33 +00:00
|
|
|
int mipmap = 1;
|
2013-03-20 23:14:18 +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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-19 10:40:52 +00:00
|
|
|
static bool tex_mat_set_face_mesh_cb(void *userData, int index)
|
2011-11-08 13:07:16 +00:00
|
|
|
{
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
|
2013-07-19 10:40:52 +00:00
|
|
|
static bool 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;
|
2013-07-14 23:41:33 +00:00
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
|
|
|
|
BMFace *efa;
|
|
|
|
|
|
|
|
|
|
if (UNLIKELY(index >= em->bm->totface))
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
efa = BM_face_at_index(em->bm, 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
|
|
|
{
|
2013-01-22 12:36:06 +00:00
|
|
|
/* if not cycles, or preview-modifiers, or drawing matcaps */
|
2014-05-29 02:32:25 +10:00
|
|
|
if ((draw_flags & DRAW_MODIFIERS_PREVIEW) ||
|
|
|
|
|
(v3d->flag2 & V3D_SHOW_SOLID_MATCAP) ||
|
2014-07-21 12:02:05 +02:00
|
|
|
(BKE_scene_use_new_shading_nodes(scene) == false) ||
|
|
|
|
|
((ob->mode & OB_MODE_TEXTURE_PAINT) && ELEM(v3d->drawtype, OB_TEXTURE, OB_SOLID)))
|
2014-05-29 02:32:25 +10:00
|
|
|
{
|
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);
|
|
|
|
|
|
2013-10-15 15:56:00 +00:00
|
|
|
if ((v3d->drawtype == OB_TEXTURE) && (v3d->flag2 & V3D_SHADELESS_TEX))
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
|
else
|
|
|
|
|
glEnable(GL_LIGHTING);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
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};
|
2013-07-19 10:40:52 +00:00
|
|
|
bool (*set_face_cb)(void *, int);
|
2015-04-20 23:37:04 +10:00
|
|
|
bool glsl, picking = (G.f & G_PICKSEL) != 0;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* 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-11-26 08:00:15 +00:00
|
|
|
glsl = (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support() && !picking;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
|
|
|
|
|
2013-10-17 14:04:10 +00:00
|
|
|
if (glsl || picking) {
|
2013-10-14 19:37:12 +00:00
|
|
|
/* draw glsl or solid */
|
2011-11-08 13:07:16 +00:00
|
|
|
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 */
|
2014-12-02 17:56:40 +01:00
|
|
|
if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) {
|
|
|
|
|
bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
|
|
|
|
|
draw_mesh_face_select(rv3d, ob->data, dm, draw_select_edges);
|
|
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 10:52:29 +00:00
|
|
|
/* Vertex Paint and Weight Paint */
|
2014-03-20 11:33:33 +11:00
|
|
|
static void draw_mesh_paint_light_begin(void)
|
|
|
|
|
{
|
|
|
|
|
const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
|
|
|
|
|
|
|
|
|
|
GPU_enable_material(0, NULL);
|
|
|
|
|
|
|
|
|
|
/* but set default spec */
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
|
|
|
|
|
|
|
|
|
|
/* diffuse */
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
static void draw_mesh_paint_light_end(void)
|
|
|
|
|
{
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
|
|
|
|
|
GPU_disable_material();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-01 01:25:21 +00:00
|
|
|
void draw_mesh_paint_weight_faces(DerivedMesh *dm, const bool use_light,
|
|
|
|
|
void *facemask_cb, void *user_data)
|
2013-07-01 00:42:44 +00:00
|
|
|
{
|
|
|
|
|
if (use_light) {
|
2014-03-20 11:33:33 +11:00
|
|
|
draw_mesh_paint_light_begin();
|
2013-07-01 00:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 01:25:21 +00:00
|
|
|
dm->drawMappedFaces(dm, (DMSetDrawOptions)facemask_cb, GPU_enable_material, NULL, user_data,
|
2014-11-20 15:26:58 +01:00
|
|
|
DM_DRAW_USE_COLORS);
|
2013-07-01 00:42:44 +00:00
|
|
|
|
|
|
|
|
if (use_light) {
|
2014-03-20 11:33:33 +11:00
|
|
|
draw_mesh_paint_light_end();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-07-01 00:42:44 +00:00
|
|
|
|
2014-03-20 11:33:33 +11:00
|
|
|
void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light,
|
|
|
|
|
void *facemask_cb, void *user_data,
|
|
|
|
|
const Mesh *me)
|
|
|
|
|
{
|
|
|
|
|
if (use_light) {
|
|
|
|
|
draw_mesh_paint_light_begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (me->mloopcol) {
|
|
|
|
|
dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data,
|
2014-11-20 15:26:58 +01:00
|
|
|
DM_DRAW_USE_COLORS);
|
2014-03-20 11:33:33 +11:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
2014-11-20 15:26:58 +01:00
|
|
|
dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data, 0);
|
2014-03-20 11:33:33 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (use_light) {
|
|
|
|
|
draw_mesh_paint_light_end();
|
2013-07-01 00:42:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 11:44:48 +11:00
|
|
|
void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
|
|
|
|
|
const bool use_depth, const bool use_alpha,
|
2013-07-01 01:25:21 +00:00
|
|
|
void *edgemask_cb, void *user_data)
|
2013-07-01 00:42:44 +00:00
|
|
|
{
|
|
|
|
|
/* weight paint in solid mode, special case. focus on making the weights clear
|
|
|
|
|
* rather than the shading, this is also forced in wire view */
|
|
|
|
|
|
|
|
|
|
if (use_depth) {
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2013-07-01 00:42:44 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 11:44:48 +11:00
|
|
|
if (use_alpha) {
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-01 00:42:44 +00:00
|
|
|
glColor4ub(255, 255, 255, 96);
|
|
|
|
|
glEnable(GL_LINE_STIPPLE);
|
|
|
|
|
glLineStipple(1, 0xAAAA);
|
|
|
|
|
|
2013-07-01 01:25:21 +00:00
|
|
|
dm->drawMappedEdges(dm, (DMSetDrawOptions)edgemask_cb, user_data);
|
2013-07-01 00:42:44 +00:00
|
|
|
|
|
|
|
|
if (use_depth) {
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2013-07-01 00:42:44 +00:00
|
|
|
glDepthMask(1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDisable(GL_LINE_STIPPLE);
|
2014-03-20 11:44:48 +11:00
|
|
|
|
|
|
|
|
if (use_alpha) {
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
2013-07-01 00:42:44 +00:00
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
|
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;
|
2013-07-01 00:42:44 +00:00
|
|
|
const bool use_light = (v3d->drawtype >= OB_SOLID);
|
2012-05-02 10:52:29 +00:00
|
|
|
|
|
|
|
|
/* hide faces in face select mode */
|
2012-12-23 08:20:44 +00:00
|
|
|
if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL))
|
2012-05-02 10:52:29 +00:00
|
|
|
facemask = wpaint__setSolidDrawOptions_facemask;
|
|
|
|
|
|
2012-09-05 01:42:52 +00:00
|
|
|
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
|
2013-07-01 01:25:21 +00:00
|
|
|
draw_mesh_paint_weight_faces(dm, use_light, facemask, me);
|
2012-05-02 10:52:29 +00:00
|
|
|
}
|
|
|
|
|
else if (ob->mode & OB_MODE_VERTEX_PAINT) {
|
2014-03-20 11:33:33 +11:00
|
|
|
draw_mesh_paint_vcolor_faces(dm, use_light, facemask, me, me);
|
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) {
|
2014-12-02 17:56:40 +01:00
|
|
|
bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0;
|
|
|
|
|
draw_mesh_face_select(rv3d, me, dm, draw_select_edges);
|
2012-05-10 06:32:24 +00:00
|
|
|
}
|
2013-07-01 00:42:44 +00:00
|
|
|
else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) {
|
|
|
|
|
const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT);
|
2014-03-20 11:44:48 +11:00
|
|
|
const bool use_alpha = (ob->mode & OB_MODE_VERTEX_PAINT) == 0;
|
|
|
|
|
|
|
|
|
|
if (use_alpha == false) {
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draw_mesh_paint_weight_edges(rv3d, dm, use_depth, use_alpha, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (use_alpha == false) {
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
2012-05-10 06:32:24 +00:00
|
|
|
}
|
2012-05-02 10:52:29 +00:00
|
|
|
}
|
|
|
|
|
|