Shader/Effect differences between Editor and Preview

I’m following the tutorial here: Tutorial: Cocos Shader Series - Use a Noise Map to Make a Dissolve Texture

And the effect works correctly/as expected in the editor, but when running the preview the scale of the dissolve texture is massively different.

Can anyone explain what is happening here?

I don’t know what settings could be affecting the scaling like this since it’s working in the editor so I assume the shader is working as intended? Is it something to do with the textures?

Have included the effect code here (a modified version of the builtin-sprite effect)

t// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
  - passes:
    - vert: sprite-vs:vert
      frag: sprite-fs:frag
        depthTest: false
        depthWrite: false
        - blend: true
          blendSrc: src_alpha
          blendDst: one_minus_src_alpha
          blendDstAlpha: one_minus_src_alpha
        cullMode: none
        alphaThreshold: { value: 0.5 }
        u_dissolveMap: {value: White, editor: {tooltip: 'Noise map'}}
        dissolveThreshold: { value: 0.5, editor: {range: [0, 1, 0.01], slide: true, tooltip: 'dissolve threshold'}}
        u_dissolveColor: { editor: { type: color } }
        dissolveEdgeThreshold: {value: 0.05, editor: {range: [0, 1, 0.01], slide: true}}
        uvTilingMultiplier: {value: [1, 1], editor: {type: vec2}}

CCProgram sprite-vs %{
  precision highp float;

  #include <cc-global>
    #include <cc-local>
    #include <common>
  in vec3 a_position;
  in vec2 a_texCoord;
  in vec4 a_color;

  out vec4 color;
  out vec2 uv0;

  vec4 vert () {

    vec4 pos = vec4(a_position, 1);

    #if USE_LOCAL
      pos = cc_matWorld * pos;

    uv0 = a_texCoord;

      pos = cc_matView * pos; = floor(;
      pos = cc_matProj * pos;
      pos = cc_matViewProj * pos;

    uv0 = a_texCoord;
    color = a_color;

    return pos;

CCProgram sprite-fs %{
  precision highp float;
  #include <embedded-alpha>
  #include <alpha-test>

  in vec4 color;

  uniform Disslove{
    float dissolveThreshold;
    float dissolveEdgeThreshold;

  uniform DissolveColor{
    vec4 u_dissolveColor;

  uniform TilingMultiplier{
    vec2 uvTilingMultiplier;

    in vec2 uv0;

    uniform sampler2D u_dissolveMap;
    #pragma builtin(local)
    layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;

  vec4 frag () {
    vec4 o = color;

    float value = 1.0;

    vec2 mutlipliedUVs = uv0 * uvTilingMultiplier;

      vec4 dissolveMap = texture(u_dissolveMap, mutlipliedUVs);
      value *= dissolveMap.r;

      if (value < dissolveThreshold){
    o *= texture(cc_spriteTexture, uv0);

    o *= color;
    if (value <dissolveThreshold + dissolveEdgeThreshold){
      o = u_dissolveColor;
    return o;

What version of Cocos Creator are you using? I can ask engineering to have a look.

I’m using version 3.3.1 on Mac OS Monterey

hi, I tested normal.
demo: (1.4 MB)
Maybe you didn’t uncheck packable

Or not remove the checkbox for this(CLEANUP_IMAGE_CACHE).

If you use a shader to manipulate the uv of a texture, you cannot use Dynamic Atlas.

1 Like

ticking CLEANUP_IMAGE_CACHE fixed it for me - thank you, I hadn’t seen any mention of that option before :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.