ShaderHelper2 components upgraded to support automatic enumeration parameters!

ShaderHelper2 components of the new experience of video presentation:
https://www.bilibili.com/video/av69314195/

ShaderHelper2 we have introduced two components, the partners do not understand can look at the following two articles:

  1. The new ShaderHelper, finally support the Creator 2.1.2!
  2. ShaderHelper2 official return, and full use of TypeScript language!

This paper describes the improvement.

Although ShaderHelper2 support the Cocos Creator 2.1.2 above the engine version, user experience has been improved, but the idea of ​​the components of the preparation Shawn is hoping the ability to produce content for the planning of art and non-programmers, in ease of use in on further improved features points are as follows:

Auto Hide props property

When a Shader Effect does not contain adjustable parameters, ShaderHelper Properties props component will not be displayed on the panel properties, look:

file

You can see the image above, Dissolve effects of component properties is very simple, just a Program attribute, we can still use ShaderTime components to adjust dynamic time parameters.

Automatically enumerate the props attribute parameters

If a parameter containing Shader Effect, when the switching properties will automatically refresh props Program attributes enumerated Shader controllable parameters, and the Key value of the parameter is read, the error will not be modified because of misuse, see figure :

file

Attribute parameter value props also supports dynamic adjustment, in real time to see the effect of the modified scene editor.

Optimization Tips warning

Previous version, a warning when switching different effects when Effect not defined USE_TEXTURE, look:

file

By EffectAsstes property inspection, a warning screen off this, in order to avoid generating annoying tips during use, check code is as follows:

 //在材质对象上开启USE_TEXTURE定义
let defineUserTexture = !!effectAsset.shaders.find(shader => shader.defines.find(def => def.name === 'USE_TEXTURE'));
if (defineUserTexture) {
    material.define('USE_TEXTURE', true); 
}

Similarly, if you select a non-dynamic Shader, while the node adds ShaderTime components, similar to the above warning will also appear, to get the same fix:

protected update(dt) {
    this._material = this.getComponent(cc.Sprite).sharedMaterials[0];
    if (this.node.active && this._material && this._material.effect._properties.time) {
        this._setShaderTime(dt);
    }
}

Code Github Address:
https://github.com/ShawnZhang2015/ShaderHelper2

Guess you like

Origin www.cnblogs.com/creator-star/p/11606310.html