Ticket #955 (new task)
Opened 5 months ago
new Material system and multiple sub-classes
| Reported by: | ArcRiley | Owned by: | |
|---|---|---|---|
| Priority: | Medium | Milestone: | beta3 |
| Component: | soy.materials | Version: | Trunk |
| Keywords: | Cc: |
Description
soy.materials.Material has become unwieldy and we haven't even started to add the sort of features I'd like to see.
After several attempts to improve it, and realizing that many of these prospective features conflict with each other, it's time to break it up into more refined classes, for now including Material, Textured, and Bumpmapped.
Material will have just the basic colors properties. No textures, no cell shading, no adjustable shades beyond 0 (smooth) and 1 (flat), no blurring, no refraction, no metalic effects, and only the most basic alpha translucency.
Textured will inherit Material and add support for colormap and glowmap textures.
Bumpmapped will inherit Textured and add support for bumpmap in either multipass (as we use now) or singlepass-multitexture.
Future classes may include (just ideas) Metallic and CellShaded.
To accommodate this in a sane manner, the bind/unbind API needs to be replaced with a more flexible system:
cdef int _render(self, int _pass, float* _texcoords, float* _tslvs)
_pass is the pass number, starting with zero
_texcoords are the vertices' standard texcoords strided by 48 bytes, it's up to Material._render to set the pointer for any texture that needs this
_tslvs are the Tangent-Space-Light-Vectors with a 0 stride. This is needed for bumpmaps and possibly other types of materials (ie, for a chrome effect)
If the function returns a 1, a render pass will done and this function called again. 0 is returned after a cleanup "pass" and is not followed by actual rendering. Thus:
_pass = 0
while (material._render(_pass, _texcoords, _tslvs) :
gl.glDrawElements (gl.GL_TRIANGLES,
length * 3,
gl.GL_UNSIGNED_SHORT,
offset)
_pass += 1
Each material is responsible for enabling each texture unit used, disabling those unused, setting the blend mode and function, enabling/disabling each of it's textures, and setting each of it's texture environment parameters.
