libgdx/libgdx — pull request #775 by xoppa (2013-09-28 20:21:35+00:00)
Title: 3dapi: remove Lights, add Environment and others

Sorry for breaking stuff, but like we discussed, this is probably the last api change (don't pin me on it) I think needs to be added before going stable for 3d api (besides shader graph of course). The change is not fully complete (need to add light attributes), but most API changes are included and I don't want to bloat the PR.

- Separate DefaultShaderProvider and add GLES10ShaderProvider, there's no need to check if gles 20 is available on every call.
- Add DefaultShader.Config, so the DefaultShader isn't bloated with arguments anymore.
- Separate the Attribute class from the Material class
- Add Attributes class which is basically a set of Attribute instances
- Make Material extends Attributes so it only adds an ID
- Rename Lights to Environment and make it extend Attributes
- Make TextureDescriptor generic (T extends GLTexture), restrict TextureAttribute to Texture
- Add CubemapAttribute
- Various other changes

The idea behind this change is that an Attribute (e.g. ColorAttribute) can be set to either the Material and Environment (if the attribute is present in both, the Material will be used). This simplifies shaders (just a bunch of attributes to match with uniforms) and makes environment much more flexible (e.g. add ColorAttribute.Fog to add fog etc.).

There is a downside to this change, e.g. one could add ColorAttribute.Diffuse to the environment (causing all models without a diffuse color to be using that diffuse color). So there is no distinction between material attributes and environment attributes, which might be hard to understand if you're new to the concept. However, it also allows you to "bake" environment attributes onto a model, which I think is justifying this change.

Another downside might be that the number of attributes is limited to the number of bits in long. But I don't expect that's going to be a problem atm.