article thumbnail

Sprite Shader Render out of bounds

Cocos

Good evening, I just finished writing my own custom shader to create 2D shadows on sprites, but I can’t find a way to increase the render area of ​​the sprite. The sprite size is 450x450, I created an atlas and used the trim option, this reduced the frame to 156x393. Is there a way to increase the render bounds?

Sprite 52
article thumbnail

Tutorial: Cocos Shader Series - Use a Noise Map to Make a Dissolve Texture

Cocos

Blockquote const sprite = this.getComponent(Sprite); const mat = sprite.customMaterial; mat.setProperty(‘dissolveThreshold’, 0.5); Version 3.6.x, x, I using this code but it not bring Property affect to shader Ok, this work if turn of Packable in main Sprite inspector

Shaders 98
Insiders

Sign Up for our Newsletter

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Trending Sources

article thumbnail

How to create waves in shader?

Cocos

I have a sprite (a regular line) and I wanted to apply a wave effect to it. I tried to normalize by passing the dimensions of the sprite (line) to the shader like this mat.setProperty("iRsolutetion", new Vec2(1.0 / this.node.getComponent(UITransform).contentSize.width, this task tormented me. it doesn’t work properly.

Shaders 52
article thumbnail

Shader doesn't work on brower, or run it in the editor

Cocos

Thank you so much for telling me how to find that component, but it’s too bad it’s not related to the original problem, which is the shader. ;-( It’s simply an error log caused by a missing asset in some component. Is there a difference between applying the material to the sprite and the label?

Shaders 52
article thumbnail

Cocos Shader Tutorial 1.0 - about UV

Cocos

The vertical axes of textures and picture pixels is shown above, when sampling textures in shaders, that is from top to bottom, which is top-right corner. Use UV in Shader Both 2D and 3D shaders in Cocos are obtained in the vertex shader (VS) and passed to the pixel shader (FS). x,waveFactor.y-uv0.y); x,waveFactor.y-uv0.y);

Shaders 98
article thumbnail

Stacking Shaders: Problem with 'new EffectAsset' in code

Cocos

I am trying to create a 'CustomMaterial' to stack 2 shader effects. Maybe someone has a better way/idea to solve the problem of only having one CCEffect on one Node/Sprite/etc…? When I do effectAsset: new EffectAsset I get an error, because of the type mismatch. Thanks, tL.

Shaders 52
article thumbnail

Stacking Shaders: Problem with 'new EffectAsset' in code

Cocos

I am trying to create a 'CustomMaterial' to stack 2 shader effects. Maybe someone has a better way/idea to solve the problem of only having one CCEffect on one Node/Sprite/etc…? When I do effectAsset: new EffectAsset I get an error, because of the type mismatch. Thanks, tL.

Shaders 52