Ticket #955 (assigned task)
new Material system and multiple sub-classes
| Reported by: | ArcRiley | Owned by: | ArcRiley |
|---|---|---|---|
| Priority: | Medium | Milestone: | beta3 |
| Component: | soy.materials | Version: | Trunk |
| Keywords: | Cc: |
Description (last modified by ArcRiley) (diff)
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 be a plain greyish white material as the default for new faces.
Colored 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:
def virtual render (pass : int, texcoords : array of float,
tslvs : array of float) : bool
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 true, a render pass will done and this function called again. False is returned if no further rendering or cleanup is needed. 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 its textures, and setting each of its texture environment parameters.



