article thumbnail

How to create a texture?

Cocos

As from the view data amplitudes:number[] = []; create a texture for uniform sampler2D soundTex; ? I want to send the texture to the shader mat.setProperty("soundTex", soundTex);```

Texture 40
article thumbnail

How to create waves in shader?

Cocos

It looks like a wave, but it goes beyond the texture area. 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, contentSize.width, 1.0 / this.node.getComponent(UITransform).contentSize.height));

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

Does the shader have a built-in function to get the texture size?

Cocos

? ? Does the shader have a built-in function to get the texture size? I’m trying to draw a circle on a texture, the texture is in sprite. I tried it in different ways, sometimes it turns out to be a stretched circle, sometimes it’s not visible at all, sometimes only part of the circle is visible.

Texture 40
article thumbnail

Does the shader have a built-in function to get the texture size?

Cocos

Does the shader have a built-in function to get the texture size? I’m trying to draw a circle on a texture, the texture is in sprite. I tried it in different ways, sometimes it turns out to be a stretched circle, sometimes it’s not visible at all, sometimes only part of the circle is visible. float v = length(uv); v -= 0.5;

Texture 40
article thumbnail

Does the shader have a built-in function to get the texture size?

Cocos

Assuming you’re using the latest versions of GLSL, you can get texture size with the “textureSize()” Example code here… uniform sampler2D myTexture; // Uniform for the texture void main() { //Note: if you don’t specify a LOD, glsl will default to 0 automatically ivec2 texSize = textureSize(myTexture, 0); // Get size of the texture at LOD 0 int width (..)

Texture 52
article thumbnail

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

Cocos

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

Shaders 98
article thumbnail

Shader display problem

Cocos

On a smaller texture, the distortion is greater than on a larger texture. The HelloWorld texture has a size of 196 X 270. One shader is used, only the sprite texture changes. I scaled it up in the graphics editor to 400 x 554 and the distortion is barely noticeable. Do you need some tweaks or is this a bug?

Shaders 52