Skip to content

Commit aa0cf9b

Browse files
committed
UPBGE: Remove glslmat option in material.
1 parent 452ad50 commit aa0cf9b

File tree

4 files changed

+16
-125
lines changed

4 files changed

+16
-125
lines changed

source/gameengine/Converter/BL_BlenderDataConversion.cpp

Lines changed: 13 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -410,75 +410,27 @@ static void SetDefaultLightMode(Scene* scene)
410410
}
411411
}
412412

413-
414-
static bool GetMaterialUseVColor(Material *ma, const bool glslmat)
415-
{
416-
if (ma) {
417-
/* glsl uses vertex colors, otherwise use material setting
418-
* defmaterial doesn't have VERTEXCOLP as default [#34505] */
419-
return (glslmat || ma == &defmaterial || (ma->mode & MA_VERTEXCOLP) != 0);
420-
}
421-
else {
422-
/* no material, use vertex colors */
423-
return true;
424-
}
425-
}
426-
427-
// --
428413
static void GetRGB(
429-
const bool use_vcol,
430414
MFace* mface,
431415
MCol* mmcol,
432416
Material *mat,
433417
unsigned int c[4])
434418
{
435419
unsigned int color = 0xFFFFFFFFL;
436-
if (use_vcol == true) {
437-
if (mmcol) {
438-
c[0] = KX_Mcol2uint_new(mmcol[0]);
439-
c[1] = KX_Mcol2uint_new(mmcol[1]);
440-
c[2] = KX_Mcol2uint_new(mmcol[2]);
441-
if (mface->v4)
442-
c[3] = KX_Mcol2uint_new(mmcol[3]);
443-
}
444-
else { // backup white
445-
c[0] = KX_rgbaint2uint_new(color);
446-
c[1] = KX_rgbaint2uint_new(color);
447-
c[2] = KX_rgbaint2uint_new(color);
448-
if (mface->v4)
449-
c[3] = KX_rgbaint2uint_new( color );
450-
}
451-
}
452-
else {
453-
/* material rgba */
454-
if (mat) {
455-
union {
456-
unsigned char cp[4];
457-
unsigned int integer;
458-
} col_converter;
459-
col_converter.cp[3] = (unsigned char) (mat->r * 255.0f);
460-
col_converter.cp[2] = (unsigned char) (mat->g * 255.0f);
461-
col_converter.cp[1] = (unsigned char) (mat->b * 255.0f);
462-
col_converter.cp[0] = (unsigned char) (mat->alpha * 255.0f);
463-
color = col_converter.integer;
464-
}
465-
c[0] = KX_rgbaint2uint_new(color);
466-
c[1] = KX_rgbaint2uint_new(color);
467-
c[2] = KX_rgbaint2uint_new(color);
468-
if (mface->v4) {
469-
c[3] = KX_rgbaint2uint_new(color);
470-
}
420+
if (mmcol) {
421+
c[0] = KX_Mcol2uint_new(mmcol[0]);
422+
c[1] = KX_Mcol2uint_new(mmcol[1]);
423+
c[2] = KX_Mcol2uint_new(mmcol[2]);
424+
if (mface->v4)
425+
c[3] = KX_Mcol2uint_new(mmcol[3]);
471426
}
472-
473-
#if 0 /* white, unused */
474-
{
427+
else { // backup white
475428
c[0] = KX_rgbaint2uint_new(color);
476429
c[1] = KX_rgbaint2uint_new(color);
477430
c[2] = KX_rgbaint2uint_new(color);
478431
if (mface->v4)
479-
c[3] = KX_rgbaint2uint_new(color);
432+
c[3] = KX_rgbaint2uint_new( color );
480433
}
481-
#endif
482434
}
483435

484436
typedef struct MTF_localLayer {
@@ -529,15 +481,12 @@ static bool ConvertMaterial(
529481
MCol *mmcol,
530482
MTF_localLayer *layers)
531483
{
532-
bool glslmat = true;
533484
material->Initialize();
534485
int texalpha = 0;
535486
const bool validmat = (mat != NULL);
536487
const bool validface = (tface != NULL);
537-
const bool use_vcol = GetMaterialUseVColor(mat, glslmat);
538-
488+
539489
material->IdMode = DEFAULT_BLENDER;
540-
material->glslmat = (validmat) ? glslmat: false;
541490
material->materialindex = mface ? mface->mat_nr : 0;
542491

543492
// --------------------------------
@@ -556,49 +505,11 @@ static bool ConvertMaterial(
556505
MTex *mttmp = NULL;
557506
int valid_index = 0;
558507

559-
/* In Multitexture use the face texture if and only if
560-
* it is set in the buttons
561-
* In GLSL is not working yet :/ 3.2011 */
562-
bool facetex = false;
563-
if (validface && mat->mode & MA_FACETEXTURE && !glslmat) {
564-
facetex = true;
565-
}
566-
567508
// foreach MTex
568509
for (int i = 0; i < MAXTEX; i++) {
569510
// Store the uv name for later find the UV layer cooresponding to the attrib name. See BL_BlenderShader::ParseAttribs.
570511
material->uvsName[i] = layers[i].name;
571512

572-
// use face tex
573-
if (i == 0 && facetex ) {
574-
facetex = false;
575-
Image *tmp = (Image *)(tface->tpage);
576-
577-
if (tmp) {
578-
material->img[i] = tmp;
579-
material->texname[i] = material->img[i]->id.name;
580-
material->flag[i] |= MIPMAP;
581-
582-
material->flag[i] |= (mat->game.alpha_blend & GEMAT_ALPHA_SORT) ? USEALPHA : 0;
583-
material->flag[i] |= (mat->game.alpha_blend & GEMAT_ALPHA) ? USEALPHA : 0;
584-
material->flag[i] |= (mat->game.alpha_blend & GEMAT_ADD) ? CALCALPHA : 0;
585-
586-
if (material->img[i]->flag & IMA_REFLECT) {
587-
material->mapping[i].mapping |= USEREFL;
588-
}
589-
else {
590-
material->mapping[i].mapping |= USEUV;
591-
}
592-
593-
valid_index++;
594-
}
595-
else {
596-
material->img[i] = 0;
597-
material->texname[i] = "";
598-
}
599-
continue;
600-
}
601-
602513
mttmp = getMTexFromMaterial(mat, i);
603514
if (mttmp) {
604515
if (mttmp->tex) {
@@ -622,10 +533,6 @@ static bool ConvertMaterial(
622533
material->color_blend[i] = mttmp->colfac;
623534
material->flag[i] |= (mttmp->mapto & MAP_ALPHA) ? TEXALPHA : 0;
624535
material->flag[i] |= (mttmp->texflag & MTEX_NEGATIVE) ? TEXNEG : 0;
625-
626-
if (!glslmat && (material->flag[i] & TEXALPHA)) {
627-
texalpha = 1;
628-
}
629536
}
630537
}
631538
else if (mttmp->tex->type == TEX_ENVMAP) {
@@ -823,15 +730,7 @@ static bool ConvertMaterial(
823730
// but fonts now make use of them too, so we leave them in for now.
824731
unsigned int rgb[4];
825732
if (mface) {
826-
GetRGB(use_vcol, mface, mmcol, mat, rgb);
827-
}
828-
829-
// swap the material color, so MCol on bitmap font works
830-
if (validmat && (use_vcol == false) && (mat->game.flag & GEMAT_TEXT)) {
831-
material->rgb[0] = KX_rgbaint2uint_new(rgb[0]);
832-
material->rgb[1] = KX_rgbaint2uint_new(rgb[1]);
833-
material->rgb[2] = KX_rgbaint2uint_new(rgb[2]);
834-
material->rgb[3] = KX_rgbaint2uint_new(rgb[3]);
733+
GetRGB(mface, mmcol, mat, rgb);
835734
}
836735

837736
if (validmat) {
@@ -861,13 +760,11 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
861760

862761
ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol, layers);
863762

864-
if (ma && ((ma->mode & MA_FACETEXTURE) == 0 || bl_mat->glslmat))
865-
converter->CacheBlenderMaterial(scene, ma, bl_mat);
763+
converter->CacheBlenderMaterial(scene, ma, bl_mat);
866764
}
867765

868766
if (mface) {
869-
const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat);
870-
GetRGB(use_vcol, mface, mcol, ma, rgb);
767+
GetRGB(mface, mcol, ma, rgb);
871768

872769
GetUVs(bl_mat, layers, mface, tface, uvs);
873770
}
@@ -879,8 +776,7 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
879776

880777
kx_blmat->Initialize(scene, bl_mat, (ma?&ma->game:NULL), lightlayer);
881778
polymat = static_cast<RAS_IPolyMaterial*>(kx_blmat);
882-
if (ma && ((ma->mode & MA_FACETEXTURE) == 0 || bl_mat->glslmat))
883-
converter->CachePolyMaterial(scene, ma, polymat);
779+
converter->CachePolyMaterial(scene, ma, polymat);
884780
}
885781

886782
// see if a bucket was reused or a new one was created
@@ -1345,8 +1241,6 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l
13451241

13461242
lightobj->m_nodiffuse = (la->mode & LA_NO_DIFF) != 0;
13471243
lightobj->m_nospecular = (la->mode & LA_NO_SPEC) != 0;
1348-
1349-
bool glslmat = true;
13501244

13511245
if (la->type==LA_SUN) {
13521246
lightobj->m_type = RAS_ILightObject::LIGHT_SUN;

source/gameengine/Ketsji/BL_Material.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void BL_Material::Initialize()
5353
rgb[3] = 0xFFFFFFFFL;
5454
IdMode = 0;
5555
ras_mode = 0;
56-
glslmat = 0;
5756
tile = 0;
5857
matname = "NoMaterial";
5958
matcolor[0] = 0.5f;

source/gameengine/Ketsji/BL_Material.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class BL_Material
5757

5858
int IdMode;
5959
unsigned int ras_mode;
60-
bool glslmat;
6160

6261
STR_String texname[MAXTEX];
6362
unsigned int flag[MAXTEX];

source/gameengine/Ketsji/KX_BlenderMaterial.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void KX_BlenderMaterial::Initialize(
118118
m_flag |= RAS_BLENDERMAT;
119119
m_flag |= (m_material->IdMode >= ONETEX) ? RAS_MULTITEX : 0;
120120
m_flag |= ((m_material->ras_mode & USE_LIGHT) != 0) ? RAS_MULTILIGHT : 0;
121-
m_flag |= (m_material->glslmat) ? RAS_BLENDERGLSL : 0;
121+
m_flag |= RAS_BLENDERGLSL;
122122
m_flag |= ((m_material->ras_mode & CAST_SHADOW) != 0) ? RAS_CASTSHADOW : 0;
123123
m_flag |= ((m_material->ras_mode & ONLY_SHADOW) != 0) ? RAS_ONLYSHADOW : 0;
124124
m_flag |= ((ma->shade_flag & MA_OBCOLOR) != 0) ? RAS_OBJECTCOLOR : 0;
@@ -208,7 +208,7 @@ void KX_BlenderMaterial::InitTextures()
208208
}
209209
/* If we're using glsl materials, the textures are handled by bf_gpu, so don't load them twice!
210210
* However, if we're using a custom shader, then we still need to load the textures ourselves. */
211-
else if (!m_material->glslmat || m_shader) {
211+
else if (m_shader) {
212212
if (m_material->img[i]) {
213213
if (!m_textures[i].InitFromImage(i, m_material->img[i], (m_material->flag[i] & MIPMAP) != 0))
214214
spit("unable to initialize image(" << i << ") in " <<
@@ -225,8 +225,7 @@ void KX_BlenderMaterial::OnConstruction()
225225
return;
226226
}
227227

228-
if (m_material->glslmat)
229-
SetBlenderGLSLShader();
228+
SetBlenderGLSLShader();
230229

231230
InitTextures();
232231

0 commit comments

Comments
 (0)