0

完成 PBR 实施后,我注意到当我靠近反射表面时,会出现我认为是浮点错误的伪影。我真的不希望使用双打,因为我的 GPU 倾向于以性能沉重的方式处理双打 远的

更接近

真的很近

这是我的 PBR IBL 代码(所有环境贴图以及延迟缓冲区都是正确的):

// Deferred rendering
vec2 texcoord = gl_FragCoord.xy / textureSize(R_GBP, 0);
vec3  P = texture2D(R_GBP, texcoord).xyz;
vec4  A = texture2D(R_GBA, texcoord).rgba;
vec3  N = texture2D(R_GBN, texcoord).xyz;
float M = texture2D(R_GBM, texcoord).r;
float R = texture2D(R_GBR, texcoord).r;

vec3 V = normalize(R_CameraPos - P);
vec3 T = reflect(-V, N);
vec3 F0 = mix(vec3(0.04), A.rgb, M);

float NDV = max(dot(N, V), 0);
vec3 kS = FresnelSchlickRoughness(NDV, F0, R); 
vec3 kD = (1 - kS) * (1 - M);
vec3 irr = textureCube(R_EnvironmentIrradiance, N).rgb;
vec3 dfs = irr * A.rgb;

const float MaxReflectionLod = 4;
vec3 preF_col = textureLod(R_EnvironmentPreFilter, T, R * MaxReflectionLod).rgb;   
vec2 brdf = texture2D(R_EnvironmentBRDF, vec2(NDV, R)).rg;
vec3 specular = preF_col * (kS * brdf.x + brdf.y);

vec3 ambient = kD * dfs + specular;
4

0 回答 0