Files
cocos4/editor/assets/effects/editor/light.effect
T
Yun Hsiao Wu 4cf1350fe0 gfx: swapchain refactor (#9030)
* update effect.hideInEditor

* swapchain refactor

* webgl multi draw

* implicit depth/stencil format

* native adapt

* explicit resizable texture

* DrawInfo in InputAssembler

* device cached states

* sync defines

* gfx: empty backend

* update playground

* remove profiler camera

* update effect types

* fix pass.resetUniform
2021-08-31 19:40:50 +08:00

60 lines
1.3 KiB
Plaintext

CCEffect %{
editor:
hide: true
techniques:
- passes:
- vert: light-vs:vert
frag: light-fs:frag
rasterizerState:
cullMode: none
depthStencilState:
depthTest: true
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
}%
CCProgram light-vs %{
precision mediump float;
#include <cc-local>
#include <cc-global>
#include <common>
in vec3 a_position;
in vec2 a_texCoord;
out vec2 v_uv;
vec4 vert () {
v_uv = a_texCoord;
return cc_matViewProj * cc_matWorld * vec4(a_position, 1.0);
}
}%
CCProgram light-fs %{
precision mediump float;
#include <output>
uniform Constant {
vec4 mainColor;
vec4 intensitySize; // x: intensity, y: glow
};
in vec2 v_uv;
float sphere(vec3 d, vec3 p) {
return smoothstep(1.0 - intensitySize.y, 1.0, 1.0 / length(cross(d, p)));
}
vec4 frag () {
vec2 uv = v_uv - 0.5;
vec3 R = normalize(vec3(1.0, uv));
// if (any(greaterThan(abs(uv), vec2(0.48)))) return vec4(0.0, 0.0, 0.0, 1.0);
return CCFragOutput(vec4(mainColor.rgb, mix(sphere(R, vec3(5.0, 0.0, 0.0)), 1.0, dot(uv, uv) < 0.0625 ? 1.0 : 0.0)));
// return vec4(color, sphere(R, vec3(4.5, 0.0, 0.0)));
}
}%