Skip to content

Shader demo based on the material system of Cocos Creator 2.2.

Notifications You must be signed in to change notification settings

Rodmen13/demo-shader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CreatorShaderDemo

Shader demo based on the material system of Cocos Creator.

CustomRenderComponent & CustomAssembler

CustomRenderComponent must override the two methods _resetAssembler and _activateMaterial.

    //override
    _resetAssembler () {
        this.setVertsDirty(true);
        this._assembler = new CustomAssembler();
        this._assembler.init(this);
    }

    //override
    _activateMaterial () {
        let material = this.sharedMaterials[0];
        if (!material) {
            this.disableRender();
            return;
        }
        
        material = cc.Material.getInstantiatedMaterial(material, this);
        this.setMaterial(0, material);
        this.markForRender(true);
    }

CustomAssembler must override methods init, updateRenderData and fillBuffers.

   init (comp) {
        super.init(comp);
        this._renderData = new cc.RenderData();
        this._renderData.init(this);

        this.initLocal();
        this.initData();
    }

    //override
    updateRenderData (comp) {
        if (comp._vertsDirty) {
            this.updateUVs(comp);
            this.updateVerts(comp);
            comp._vertsDirty = false;
        }
    }

Material & Effect

Transplant some 2D Shaders to learn the new material system.

天气相关:

滚动背景

预览

预览

预览

预览

图片相关:

使用RenderTexture进行屏幕后处理:

预览

GamePlay:

点光源:

预览

About

Shader demo based on the material system of Cocos Creator 2.2.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%