12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd.
- // 用于BoundingBox的线的渲染,被物体挡住的包围盒的线会带透明度,没被物体挡住的线是实体的。
- %{
- "techniques": [
- {
- "stages": [
- "transparent"
- ],
- "passes": [
- {
- "vert": "line-vs",
- "frag": "line-fs:front",
- "cullMode": "none",
- "depthTest": true,
- "blend": true,
- "blendEq": "add",
- "blendSrc": "srcAlpha",
- "blendDst": "one",
- },
- {
- "vert": "line-vs",
- "frag": "line-fs:back",
- "cullMode": "none",
- "depthTest": true,
- "depthFunc": "greater",
- "blend": true,
- "blendEq": "add",
- "blendSrc": "srcAlpha",
- "blendDst": "one",
- }
- ]
- }
- ],
- "properties": {
- "diffuseColor": {
- "type": "color4",
- "value": [1, 1, 1, 1]
- }
- }
- %}
- %% line-vs {
- precision highp float;
- #include <cc-global>
- #include <cc-local>
- #include <common-attribute>
- void main () {
- gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1);
- gl_Position.z -= 0.0001;
- }
- }
- %% line-fs {
- precision highp float;
-
- #include <encodings>
- uniform vec4 diffuseColor;
- vec4 front() {
- return LINEAR_TO_OUTPUT_TEXEL(diffuseColor);
- }
- vec4 back() {
- return LINEAR_TO_OUTPUT_TEXEL(vec4(diffuseColor.rgb, diffuseColor.a * 0.2));
- }
- }
|