GLKBaseEffect 一种简单的光照/着色系统,用于基于着色器OpenGL渲染
@interface GLKBaseEffect : NSObject <GLKNamedEffect>
{
@protected
// Switches to turn effect features on and off
GLboolean _colorMaterialEnabled;
GLboolean _fogEnabled;
// Modelview, projection, texture and derived matrices for transformation
GLKEffectPropertyTransform *_transform;
// Lights
GLKLightingType _lightingType;
GLKEffectPropertyLight *_light0, *_light1, *_light2;
// Material for lighting
GLKEffectPropertyMaterial *_material;
// GL Texture Names
GLKEffectPropertyTexture *_texture2d0, *_texture2d1;
// Texture ordering array
NSArray *_textureOrder;
// Constant color (fixed color value to supplant the use of the "color" named vertex attrib array)
GLKVector4 _constantColor;
// Fog
GLKEffectPropertyFog *_fog;
// Label for effect
NSString *_label;
}
1:_label: 给Effect(效果)命名
2: _transform:配置模型视图转换,绑定效果时应用于顶点数据的模型视图,投影和纹理变换。
3: _lightingType:用于极端每个片段的光照策略
4: GLKLightingType:GLKLightingTypePerVertex表示在三角形中每个顶点执行光照计算,然后在三角形进行插值。
GLKLightingTypePerPixel表示光照计算的输入在三角形内插入,并且在每个片段之行光照计算。
配置光照
@property (nonatomic, assign) GLboolean lightModelTwoSided; // GL_FALSE
1)lightModelTwoSided 布尔值,表示为基元的两侧计算光照
2)material:计算渲染图元光照使用的材质属性。GLKEffectPropertyMaterial
@interface GLKEffectPropertyMaterial : GLKEffectProperty
3)lightModelAmbientColor:环境颜色,应用效果渲染的所有图元。{ 0.2, 0.2, 0.2, 1.0 }
4)light0,light1,light2场景中的三个光照属性。
配置纹理
@property (nonatomic, readonly) GLKEffectPropertyTexture *texture2d0, *texture2d1; // Disabled
texture2d0, texture2d1 两个纹理属性。
@property (nullable, nonatomic, copy) NSArray<GLKEffectPropertyTexture*> *textureOrder; // texture2d0, texture2d1
纹理应用于渲染图元的顺序。
雾化
fog应用于场景的雾属性
配置颜色信息
@property (nonatomic, assign) GLboolean colorMaterialEnabled; // GL_FALSE
布尔值,表示计算光照于材质交互时是否使用颜色顶点属性。
@property (nonatomic, assign) GLboolean useConstantColor; // GL_TRUE
布尔值,指示是否使用常量颜色
@property (nonatomic, assign) GLKVector4 constantColor; // { 1.0, 1.0, 1.0, 1.0 }
不提供每个顶点颜色数据时使用常量颜色。
准备渲染
prepareToDraw
网友评论