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

How to make a neon effect in a shader?

Cocos

Hello, you may want to change the uv0 settings from the shader code. So 0 means the far left side of the sprite and 1 represents the far right side of the sprite. In the example they show on the manual, they made it so that the effect changes along the x-axis from the uv0.x It is important to know that the uv0.x

Shaders 52
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

Shader array properties

Cocos

We are currently using this shader to create dynamic light effect on 2d sprites, so we are updating it very often. Also every sprite has it’s own material. First of all declare your array on the shader. stringwizard5: Glad to hear it’s working for you!

Shaders 40
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
article thumbnail

[Tutorial]Outer Stroke Effect for 2D Sprites

Cocos

Original: [link] Author: BitByBit Outer Stroke Effect for 2D Sprites Continuing from the previous article Inner Stroke Effect for 2D Sprites Introduction In the last article, we introduced the method of inner stroke and also discussed its pros and cons. The above is the part of the custom post-processing shader.

Sprite 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

Mask with sprite stencil and custom material?

Cocos

I’m attempting to make a UI mask with a sprite stencil. I have a shader that I’ve made that essentially takes the sprite and adds a glitchy effect to it… (like a static glitch on a hologram display) It works great with sprites and does exactly what I want it to do.

Sprite 40