-
Creator 版本: 3.6.2
-
目标平台: 预览
-
重现方式:场景中存在使用自定义effect的材质
-
首个报错:
[Scene] Buffer binding ‘CCForwardLight’ at set 2 binding 1 is not boundedError: [Scene] Buffer binding ‘CCForwardLight’ at set 2 binding 1 is not bounded
at error (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:147638:12)
at WebGL2CmdFuncBindStates (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:243866:11)
at WebGL2PrimaryCommandBuffer.bindStates (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:246276:11)
at WebGL2PrimaryCommandBuffer.draw (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:246163:20)
at Proxy.newFunc (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:119279:37)
at RenderQueue.recordCommandBuffer (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:146895:21)
at ForwardStage.render (C:\ProgramData\cocos\editors\Creator\3.6.2\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:260383:33)
#include <builtin/uniforms/cc-global>
#include <common/common-define>
#include <common/data/packing>
struct HalfLambertSurface {
vec4 albedo;
HIGHP_VALUE_STRUCT_DEFINE(vec3, position);
vec3 normal;
#if CC_RECEIVE_SHADOW
vec2 shadowBias;
#endif
};
// Inspired by UTS2, (C)UTJ/UCL
// #if CC_FORWARD_ADD
#include <legacy/lighting>
#include <legacy/shadow-map-fs>
vec4 CCHalfLambertShading (HalfLambertSurface s, vec4 shadowPos) {
vec3 position;
HIGHP_VALUE_FROM_STRUCT_DEFINED(position, s.position);
vec3 diffuse = s.albedo.rgb;
vec3 diffuseContrib = diffuse / PI;
vec3 N = normalize(s.normal);
vec3 V = normalize(cc_cameraPos.xyz - position);
vec3 finalColor = vec3(0.0);
int numLights = CC_PIPELINE_TYPE == CC_PIPELINE_TYPE_FORWARD ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);
for (int i = 0; i < LIGHTS_PER_PASS; i++) {
if (i >= numLights) break;
vec3 SLU = cc_lightPos[i].xyz - position;
vec3 SL = normalize(SLU);
vec3 SH = normalize(SL + V);
float SNL = max(dot(N, SL), 0.0);
float SNH = max(dot(N, SH), 0.0);
float distSqr = dot(SLU, SLU);
float litRadius = cc_lightSizeRangeAngle[i].x;
float litRadiusSqr = litRadius * litRadius;
float illum = litRadiusSqr / max(litRadiusSqr , distSqr);
float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);
attRadiusSqrInv *= attRadiusSqrInv;
float att = GetDistAtt(distSqr, attRadiusSqrInv);
if (cc_lightPos[i].w > 0.0) {
float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);
float cosOuter = cc_lightSizeRangeAngle[i].z;
float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);
float litAngleOffset = -cosOuter * litAngleScale;
att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);
}
vec3 lightColor = cc_lightColor[i].rgb;
float shadow = 1.0;
#if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {
shadow = CCSpotShadowFactorBase(shadowPos, position, s.shadowBias);
}
#endif
lightColor *= shadow;
finalColor += SNL * lightColor * cc_lightColor[i].a * illum * att * diffuseContrib;
}
return vec4(finalColor, 0.0);
}
// #endif
参考standard和toon的代码改的chunk。一直会报错,如果新建个球面光,报错就停止了。
