Files
cocos4/editor/assets/chunks/outline-vs.chunk
T
2020-08-06 22:09:24 +08:00

38 lines
810 B
Plaintext

precision highp float;
#include <input-standard>
#include <cc-global>
#include <cc-local-batch>
out vec2 v_uv;
uniform OutlineVert {
vec4 outlineParams; // x: line width, y: depth hack
};
vec4 vert () {
StandardVertInput In;
CCVertInput(In);
mat4 matWorld;
CCGetWorldMatrix(matWorld);
float width = outlineParams.x * 0.001;
#if USE_POSITION_SCALING
vec3 dir = normalize(In.position.xyz);
float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;
In.position.xyz += flip * dir * width * 2.0;
vec4 pos = cc_matProj * (cc_matView * matWorld) * In.position;
#else
In.position.xyz += normalize(In.normal) * width;
vec4 pos = cc_matProj * (cc_matView * matWorld) * In.position;
#endif
pos.z -= outlineParams.y * 0.002;
v_uv = a_texCoord;
return pos;
}