Gameplay3D中的材质

Motivation

Gameplay3D引擎材质系统简描述,一个材质模板文件应该像这样的一个结构

MaterialTemplate
{
     Technique0
     {
          Pass0{}
          Pass1{}
     }
     Technique1
     {
          Pass0{}
          Pass1{}
     }
}

Material

  • Material类的设计目的是对外接口类,提供Material资源,Technique资源,Pass资源,RenderState资源的加载.
  • 多Technique是指一个材质中,应该包含不只一个实现方案。 这样当我们进行材质更替,或者进行高中低端机适配的时候。 就不会那么麻烦。 同时在数据管理上,也显得更为规范.
  • Material类包含本材质包含的Technique实例组,以及当前使用的curTechnique实例.
  • Technique实例组可以有共同的uniform参数.
  • 用Technique实例组index或者Technique id获取相应的Technique.
  • 一次drawscene/render,只有current Technique实例会起效.

Technique

  • 有时候,我们为了实现一个绘制效果,靠单次绘制是无法实现的。比如描边效果。 这就要求我们单个物体能够在进行绘制的时候,多次提交材质并绘制。
  • support different sets of shader + definitions that will be all loaded when a material is loaded.
  • You can then change the rendering technique at runtime without having to first load the shaders.
  • A technique has one or more passes for supporting multi pass rendering.
  • 多少个pass,意味着该Technique材质最终绘制(gldraw)几次,以实现具体材质效果
  • 高中低端机适配是一个很重要的特性,因为玩家的机型不可能是一样的。 在需要保证效率的情况下,我们很多时候需要降低物体渲染的复杂度。有两种方案。 一种是通过宏定义,一种是动态切换Technique。

Pass

  • This class encapsulates the parameters and logic required to apply a shader to an object to be rendered.
  • 继承于RenderState,即包含RenderState
  • 持有Effect实例
  • 持有VertexAttributeBinding实例

RenderState

  • Defines the rendering state of the graphics device.
  • Implementing a custom auto binding resolver
  • Defines blend constants supported by the blend function.
  • Defines the supported depth compare functions.
  • Defines culling criteria for front-facing, back-facing and both-side facets.
  • Defines the winding of vertices in faces that are considered front facing.
  • Defines the supported stencil compare functions.
  • Defines the supported stencil operations to perform.

Effect

  • An effect essentially wraps an OpenGL program object.
  • includes the vertex and fragment shader.
  • the map of Uniform name and Uniform location within an effect.
  • the map of Attribute location and Attribute Name within an effect.

VertexAttributeBinding

  • Defines a binding between the vertex layout of a Mesh and the vertex input attributes of a vertex shader (Effect).
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值