model : 3.5.2
I used ‘CCToonShading’ in my cocos impact file.
However, the results of ‘CCToonShading’ is similar as undefined.
Eventhough i multiply small worth, at all times result’s white.
I can’t perceive the results of at all times getting white.
Anybody have resolution?
That is my impact file. This impact works effective in different environments.
// Impact Syntax Information: https://docs.cocos.com/creator/guide/zh/shader/index.html
CCEffect %{
methods:
- title: opaque
passes:
- vert: general-vs:vert # builtin header
frag: unlit-fs:frag
properties: &props
mainTexture: { worth: white }
_R_Color: { worth: [1, 1, 1, 1], editor: { kind: colour } }
_G_Color: { worth: [1, 1, 1, 1], editor: { kind: colour } }
_B_Color: { worth: [1, 1, 1, 1], editor: { kind: colour } }
mainColor: { worth: [0.6, 0.6, 0.6, 1.0], goal: baseColor, linear: true, editor: { displayName: BaseColor, kind: colour } }
shadeColor1: { worth: [0.4, 0.4, 0.4, 1.0], linear: true, editor: { kind: colour } }
shadeColor2: { worth: [0.2, 0.2, 0.2, 1.0], linear: true, editor: { kind: colour } }
specular: { worth: [1.0, 1.0, 1.0, 0.3], linear: true, editor: { kind: colour } }
baseStep: { worth: 0.8, goal: shadeParams.x }
baseFeather: { worth: 0.001, goal: shadeParams.y }
shadeStep: { worth: 0.5, goal: shadeParams.z }
shadeFeather: { worth: 0.001, goal: shadeParams.w }
- title: clear
passes:
- vert: general-vs:vert # builtin header
frag: unlit-fs:frag
blendState:
targets:
- mix: true
blendSrc: one
blendDst: one
blendSrcAlpha: zero
blendDstAlpha: one
properties: *props
}%
CCProgram shared-ubos %{
uniform Constants {
vec4 baseColor;
//vec4 colorScaleAndCutoff;
vec4 shadeColor1;
vec4 shadeColor2;
vec4 specular; // xyz: specular colour, w: energy
vec4 shadeParams;
vec4 _R_Color;
vec4 _G_Color;
vec4 _B_Color;
};
}%
CCProgram unlit-vs %{
precision highp float;
#embody <input-standard>
#embody <cc-global>
#embody <decode-base>
#embody <cc-local-batch>
#embody <shared-ubos>
#embody <cc-shadow-map-vs>
out vec3 v_position;
out vec2 v_uv;
out mediump vec3 v_normal;
vec4 vert () {
StandardVertInput In;
CCVertInput(In);
mat4 matWorld, matWorldIT;
CCGetWorldMatrixFull(matWorld, matWorldIT);
vec4 pos = matWorld * In.place;
v_position = pos.xyz;
v_uv = a_texCoord ;
v_normal = (matWorldIT * vec4(In.regular, 0.0)).xyz;
CC_TRANSFER_SHADOW(pos);
return cc_matProj * (cc_matView * matWorld) * In.place;
}
}%
CCProgram unlit-fs %{
precision highp float;
#embody <cc-global>
#embody <shading-toon>
#embody <shared-ubos>
#embody <output-standard>
#embody <gamma>
in vec3 v_position;
in vec2 v_uv;
in mediump vec3 v_normal;
uniform sampler2D mainTexture;
void surf (out ToonSurface s) {
s.shade2 = shadeColor2.rgb;
s.shade1 = shadeColor1.rgb;
vec4 baseColor = baseColor;
s.baseColor = baseColor;
s.regular = v_normal;
HIGHP_VALUE_TO_STRUCT_DEFINED(v_position, s.place);
s.specular = specular;
s.baseStep = shadeParams.x;
s.baseFeather = shadeParams.y;
s.shadeStep = shadeParams.z;
s.shadeFeather = shadeParams.w;
}
vec4 frag () {
ToonSurface s; surf(s);
vec4 colour = CCToonShading(s);
vec4 alpha = vec4(0,0,0,1);
vec4 col = texture(mainTexture, v_uv);
col = col.r * _R_Color + col.g * _G_Color + col.b * _B_Color + col.a * alpha;
colour = colour * col;
return CCFragOutput(colour);
}
}%