diff --git a/cocos/asset/assets/texture-cube.ts b/cocos/asset/assets/texture-cube.ts index 3777c8b980..28f041586a 100644 --- a/cocos/asset/assets/texture-cube.ts +++ b/cocos/asset/assets/texture-cube.ts @@ -168,10 +168,11 @@ export class TextureCube extends SimpleTexture { } /** - * @en Fill mipmaps with convolutional maps. - * @zh 使用卷积图填充mipmaps。 - * @param value All mipmaps of each face of the cube map are stored in the form of atlas + * @en Fill mipmaps for cube map with atlas. + * @zh 使用 atlas 方式排布的图填充到立方体贴图的 mipmaps。 + * @param value @en All mipmaps of each face of the cube map are stored in the form of atlas * and the value contains the atlas of the 6 faces and the layout information of each mipmap layer. + * @zh 立方体贴图六个面的图,其中每张图中的全部 mip 数据都使用 atlas 方式排布 */ set mipmapAtlas (value: ITextureCubeMipmapAtlas | null) { this._mipmapAtlas = value; diff --git a/editor/assets/chunks/builtin/uniforms/cc-forward-light.chunk b/editor/assets/chunks/builtin/uniforms/cc-forward-light.chunk index bc22e41c47..40654b6fa0 100644 --- a/editor/assets/chunks/builtin/uniforms/cc-forward-light.chunk +++ b/editor/assets/chunks/builtin/uniforms/cc-forward-light.chunk @@ -9,7 +9,7 @@ #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0 #pragma builtin(local) layout(set = 2, binding = 1) uniform CCForwardLight { - highp vec4 cc_lightPos[LIGHTS_PER_PASS]; // xyz: pos, w: isSpotLight + highp vec4 cc_lightPos[LIGHTS_PER_PASS]; // xyz: pos, w: light type vec4 cc_lightColor[LIGHTS_PER_PASS]; // xyz: color, w: intensity vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS]; // x: size, y: range, z: cos(half outterAngle), w: enable shadow vec4 cc_lightDir[LIGHTS_PER_PASS]; // xyz: dir, w: valid light count diff --git a/editor/assets/chunks/common/common-define.chunk b/editor/assets/chunks/common/common-define.chunk index 589b5e2f87..4554ad0e80 100644 --- a/editor/assets/chunks/common/common-define.chunk +++ b/editor/assets/chunks/common/common-define.chunk @@ -55,8 +55,12 @@ // Light Type #define LIGHT_TYPE_DIRECTIONAL 0.0 -#define LIGHT_TYPE_SPHERE 1.0 +#define LIGHT_TYPE_POINT 1.0 #define LIGHT_TYPE_SPOT 2.0 +#define LIGHT_TYPE_SPHERE 3.0 +#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0 #define IS_DIRECTIONAL_LIGHT(light_type) equalf(light_type, LIGHT_TYPE_DIRECTIONAL) #define IS_SPHERE_LIGHT(light_type) equalf(light_type, LIGHT_TYPE_SPHERE) #define IS_SPOT_LIGHT(light_type) equalf(light_type, LIGHT_TYPE_SPOT) +#define IS_POINT_LIGHT(light_type) equalf(light_type, LIGHT_TYPE_POINT) +#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) equalf(light_type, LIGHT_TYPE_RANGED_DIRECTIONAL) diff --git a/editor/assets/chunks/common/lighting/brdf.chunk b/editor/assets/chunks/common/lighting/brdf.chunk index 93043acbaf..abd2d1a24c 100644 --- a/editor/assets/chunks/common/lighting/brdf.chunk +++ b/editor/assets/chunks/common/lighting/brdf.chunk @@ -12,7 +12,7 @@ float D_GGXMobile(float roughness, float NoH) { float OneMinusNoHSqr = 1.0 - NoH * NoH; float a = roughness * roughness; float n = NoH * a; - float p = a / (OneMinusNoHSqr + n * n); + float p = a / max(EPSILON, OneMinusNoHSqr + n * n); return p * p; } diff --git a/editor/assets/chunks/legacy/shading-standard-base.chunk b/editor/assets/chunks/legacy/shading-standard-base.chunk index 09848b152d..7595d3f308 100644 --- a/editor/assets/chunks/legacy/shading-standard-base.chunk +++ b/editor/assets/chunks/legacy/shading-standard-base.chunk @@ -27,7 +27,7 @@ float GGXMobile (float roughness, float NoH, vec3 H, vec3 N) { float OneMinusNoHSqr = dot(NxH, NxH); float a = roughness * roughness; float n = NoH * a; - float p = a / (OneMinusNoHSqr + n * n); + float p = a / max(EPSILON, OneMinusNoHSqr + n * n); return p * p; } @@ -166,7 +166,7 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) { finalColor += lightingColor * dirlightContrib; #endif - float fAmb = 0.5 - N.y * 0.5; + float fAmb = max(EPSILON, 0.5 - N.y * 0.5); vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb); vec3 env = vec3(0.0); diff --git a/editor/assets/chunks/lighting-models/model-functions/standard-common.chunk b/editor/assets/chunks/lighting-models/model-functions/standard-common.chunk index 515ff46b65..a9e92bfce5 100644 --- a/editor/assets/chunks/lighting-models/model-functions/standard-common.chunk +++ b/editor/assets/chunks/lighting-models/model-functions/standard-common.chunk @@ -84,7 +84,7 @@ vec3 SampleEnvironmentSpecular(samplerCube tex, in LightingIntermediateData ligh vec3 CalculateEnvironmentDiffuse(in LightingIntermediateData lightingData, float lightIntensity) { // Hemisphere Lighting - float fAmb = 0.5 - lightingData.N.y * 0.5; + float fAmb = max(EPSILON, 0.5 - lightingData.N.y * 0.5); vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb); // Diffuse Map diff --git a/editor/assets/effects/surfaces/terrain.effect b/editor/assets/effects/surfaces/terrain.effect index 35cc74a2ab..b17c1f4055 100644 --- a/editor/assets/effects/surfaces/terrain.effect +++ b/editor/assets/effects/surfaces/terrain.effect @@ -42,6 +42,11 @@ CCEffect %{ propertyIndex: 0 rasterizerState: cullMode: back + - &reflect-map + vert: terrain-vs + frag: reflect-map-fs + phase: reflect-map + propertyIndex: 0 }% CCProgram shared-ubos %{ @@ -56,6 +61,7 @@ CCProgram macro-remapping %{ #pragma define-meta USE_NORMALMAP #define CC_SURFACES_USE_TANGENT_SPACE USE_NORMALMAP }% + CCProgram surface-vertex %{ #define CC_SURFACES_VERTEX_MODIFY_WORLD_POS vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In) @@ -96,10 +102,13 @@ CCProgram surface-fragment %{ void SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData) { vec2 uvw = FSInput_texcoord; - vec2 uv0 = FSInput_localPos.xz * UVScale.x; - vec2 uv1 = FSInput_localPos.xz * UVScale.y; - vec2 uv2 = FSInput_localPos.xz * UVScale.z; - vec2 uv3 = FSInput_localPos.xz * UVScale.w; + vec2 uv0, uv1, uv2, uv3; + #if CC_SURFACES_TRANSFER_LOCAL_POS + uv0 = FSInput_localPos.xz * UVScale.x; + uv1 = FSInput_localPos.xz * UVScale.y; + uv2 = FSInput_localPos.xz * UVScale.z; + uv3 = FSInput_localPos.xz * UVScale.w; + #endif vec4 w = vec4(0.0); #if LAYERS > 1 w = texture(weightMap, uvw); @@ -204,10 +213,9 @@ CCProgram surface-fragment %{ CCProgram terrain-vs %{ precision highp float; - #include #include // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros - #include + #include // 2. common include with corresponding shader stage, include before surface functions #include @@ -238,9 +246,8 @@ CCProgram shadow-caster-vs %{ CCProgram terrain-fs %{ precision highp float; - #include // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros - #include + #include // 2. common include with corresponding shader stage, include before surface functions #include @@ -268,3 +275,15 @@ CCProgram shadow-caster-fs %{ #include #include }% + +CCProgram reflect-map-fs %{ + precision highp float; + #include + #include + #include + #include + #include + #include + #include + #include +}%