[Bf-codereview] BGE: Material replacement for texface options (issue4289041)

dfelinto at gmail.com dfelinto at gmail.com
Fri Mar 11 19:37:09 CET 2011


Reviewers: bf-codereview_blender.org,

Description:
[patch originally submitted to:
http://projects.blender.org/tracker/?func=detail&aid=26461&group_id=9&atid=127
]

This patch follows (with small changes) the proposal presented here -
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
Not implemented: Backward Compatibility. Please refer to the
bf-committers for discussions on that.
Other technical discussions, bugs, reviews, can happen here.

Summary:
========
The idea here is to move the texface options into the material panel.
See the wip.jpg and ui.jpg images for the final UI (the one in the
proposal had to be changed).

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 - Code that needs review:
===================
2.1) set_draw_settings_cached
this function was changed considerably. I think I could pass the
material instead of flags and do the guessing game inside the function.
Thoughts?

2.2) defines, defines, defines
They are a few defines with the same value. We had more (and even some
hardcoded values :/). What I did was to avoid bringing the
DNA_material_types.h defines all the way to the Rasterizer. So
Rasterizer has its own defines. The code is commented to make it easy
for grep them.
I'm not sure, however, if this is a good idea - or if the best way to do
it is to use the GEMAT_ defines everywhere.

2.3) As a user I can't understand how ZSorting would affect Add Alpha. I
tried indeed and nothing happens. The BGE code, however, consider valid
the combination Add + Sort. Standing to the perception that Add
shouldn't have sorting, I brought the sort option as part of the
blending menu, so we have opaque, add, clip, blend alpha and blend alpha
sort. In the code I could, after setting the material to use zsort, to
convert GEMAT_ ALPHA_SORT to GEMAT_ALPHA. It works fine indeed. However
I prefered to create the GPU_BLEND_ equivalent of the GEMAT_ALPHA_SORT
and deal with that in the gpu as if it's alpha.

3 - Random Notes:
============
3.1) Now "Use Face Textures" in material Option panel will work in
Multitexture even if there is no texture channel.

3.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?

3.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.4) Attached also two of the sample files I used for tests -
shadeless.blend and everything.blend. [ actually I don't see where to
add more files here, so you can get them in the original report -
http://projects.blender.org/tracker/?func=detail&aid=26461&group_id=9&atid=127
]

3.5) I don't expect anyone to understand the whole patch. It involves a
lot of areas that I myself wasn't familiar before doing this code. But a
review in the general structure and one or other specific area would be
nice.

Thanks,
Dalai

Please review this at http://codereview.appspot.com/4289041/

Affected files:
   release/scripts/ui/properties_material.py
   source/blender/editors/mesh/editmesh_mods.c
   source/blender/editors/space_image/space_image.c
   source/blender/editors/space_view3d/drawmesh.c
   source/blender/editors/space_view3d/view3d_view.c
   source/blender/editors/uvedit/uvedit_ops.c
   source/blender/gpu/GPU_draw.h
   source/blender/gpu/GPU_material.h
   source/blender/gpu/intern/gpu_draw.c
   source/blender/makesdna/DNA_material_types.h
   source/blender/makesrna/intern/rna_actuator.c
   source/blender/makesrna/intern/rna_material.c
   source/blender/modifiers/intern/MOD_uvproject.c
   source/gameengine/Converter/BL_BlenderDataConversion.cpp
   source/gameengine/Ketsji/BL_Material.cpp
   source/gameengine/Ketsji/BL_Material.h
   source/gameengine/Ketsji/KX_BlenderMaterial.cpp
   source/gameengine/Ketsji/KX_BlenderMaterial.h
   source/gameengine/Ketsji/KX_PolygonMaterial.cpp
   source/gameengine/Ketsji/KX_PolygonMaterial.h
   source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
   source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
   source/gameengine/Rasterizer/RAS_IRasterizer.h




More information about the Bf-codereview mailing list