fix data compatible with wrong normal tangent data (#13984)

This commit is contained in:
jk20012001
2023-01-30 01:01:20 +08:00
committed by GitHub
parent 92c0220258
commit e70a9aaee2
7 changed files with 41 additions and 17 deletions
+4 -3
View File
@@ -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;
@@ -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
@@ -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)
@@ -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;
}
@@ -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);
@@ -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
+27 -8
View File
@@ -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 <surfaces/effect-macros/terrain>
#include <builtin/uniforms/cc-local>
// 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
#include <surfaces/effect-macros/common-macros>
#include <surfaces/effect-macros/terrain>
// 2. common include with corresponding shader stage, include before surface functions
#include <surfaces/includes/common-vs>
@@ -238,9 +246,8 @@ CCProgram shadow-caster-vs %{
CCProgram terrain-fs %{
precision highp float;
#include <surfaces/effect-macros/terrain>
// 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
#include <surfaces/effect-macros/common-macros>
#include <surfaces/effect-macros/terrain>
// 2. common include with corresponding shader stage, include before surface functions
#include <surfaces/includes/common-fs>
@@ -268,3 +275,15 @@ CCProgram shadow-caster-fs %{
#include <surface-fragment>
#include <shading-entries/main-functions/render-to-shadowmap/fs>
}%
CCProgram reflect-map-fs %{
precision highp float;
#include <macro-remapping>
#include <surfaces/effect-macros/terrain>
#include <surfaces/includes/common-fs>
#include <shared-ubos>
#include <surface-fragment>
#include <lighting-models/includes/standard>
#include <surfaces/includes/standard-fs>
#include <shading-entries/main-functions/render-to-reflectmap/fs>
}%