浏览代码

Merge pull request #552 from jyb125/YibingProject

fixed the black dots on screen bug
/stochastic_alpha_test
GitHub 7 年前
当前提交
5a6a0bee
共有 3 个文件被更改,包括 23 次插入22 次删除
  1. 18
      ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/Fabric.hlsl
  2. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/FabricDataInternal.hlsl
  3. 16
      ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl

18
ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/Fabric.hlsl


bsdfData.tangentWS = tangentWS;
bsdfData.bitangentWS = cross(normalWS, tangentWS);
ConvertAnisotropyToRoughness(roughness, anisotropy, bsdfData.roughnessT, bsdfData.roughnessB);
bsdfData.anisotropy = 1;
bsdfData.anisotropy = 0.75;
}
//-----------------------------------------------------------------------------

float3 F = F_Schlick(0.2, LdotH);
float Vis;
float D;
float D_Velvet;//Ready at dawn cloth
float roughnessSq = bsdfData.roughness*bsdfData.roughness;
float cnorm = 1.0 / (PI * (4.0 * roughnessSq + 1.0));
float roughnessSq = bsdfData.roughness*bsdfData.roughness;
float N = 1.0 / (PI * (4.0 * roughnessSq + 1.0));
float cot2 = NdotH2 / (1.0 - NdotH2);
float sin2 = 1.0 - NdotH2;
float sin4 = sin2 * sin2;
float amp = 4.0;
D = cnorm * (1.0 + (amp * exp(-cot2 / roughnessSq) / sin4));
float cotNdotH2 = NdotH2 / (1.000001 - NdotH2);
float sinNdotH2 = 1.0 - NdotH2;
D_Velvet = N * (1.0 + (4.0 * exp(-cotNdotH2 / roughnessSq) / max(sinNdotH2*sinNdotH2,1e-5)));
#ifdef LIT_USE_BSDF_PRE_LAMBDAV
Vis = V_SmithJointGGX(NdotL, NdotV, bsdfData.roughness, preLightData.ggxLambdaV);

float NdotLwrap = sqrt(NdotL);
specularLighting = NdotLwrap*F *(Vis * D)*_FuzzTint;
specularLighting = NdotLwrap* F *Vis * D_Velvet *_FuzzTint;
#ifdef LIT_DIFFUSE_LAMBERT_BRDF
float diffuseTerm = Lambert();

11
ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/FabricDataInternal.hlsl


#endif
surfaceData.perceptualSmoothness *= ADD_IDX(lerp(0.1,0.6,_Smoothness));
#ifdef _DETAIL_MAP_IDX
surfaceData.perceptualSmoothness *= 2.0 * saturate(detailSmoothness * ADD_IDX(_DetailSmoothnessScale));
// Use overlay blend mode for detail abledo: (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
float smoothnessOverlay = (detailSmoothness < 0.5) ?
surfaceData.perceptualSmoothness * PositivePow(2.0 * detailSmoothness, ADD_IDX(_DetailSmoothnessScale)) :
1.0 - (1.0 - surfaceData.perceptualSmoothness) * PositivePow(2.0 * (1.0 - detailSmoothness), ADD_IDX(_DetailSmoothnessScale));
surfaceData.perceptualSmoothness = saturate(smoothnessOverlay);
// MaskMap is RGBA: Metallic, Ambient Occlusion (Optional), emissive Mask (Optional), Smoothness
#ifdef _MASKMAP_IDX
surfaceData.ambientOcclusion = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_MaskMap), SAMPLER_MASKMAP_IDX, ADD_IDX(layerTexCoord.base)).g;

surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
#endif
surfaceData.anisotropy = 1.0;
surfaceData.anisotropy = 0.8;
surfaceData.specular = 0.04;
surfaceData.specular = 1;
surfaceData.subsurfaceProfile = _SubsurfaceProfile;
surfaceData.subsurfaceRadius = _SubsurfaceRadius;

16
ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl


bsdfData.normalWS = surfaceData.normalWS;
//NOTE: On Hair UI side, we use slider for roughness. So not necesarry to invert.
bsdfData.perceptualRoughness = lerp(0.4,1.5,surfaceData.perceptualSmoothness);//PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness);
bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
bsdfData.perceptualRoughness = surfaceData.ambientOcclusion;//PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness);
bsdfData.roughness = PerceptualRoughnessToRoughness(lerp(0.4,1.5,surfaceData.perceptualSmoothness));
bsdfData.fresnel0 = 0.04;

float invLenLV = rsqrt(abs(2 + 2 * LdotV)); // invLenLV = rcp(length(L + V))
float NdotH = saturate((NdotL + NdotV) * invLenLV);
float LdotH = saturate(invLenLV + invLenLV * LdotV);
float invVdotL = saturate(dot(V,-L));
//float3 F = F_Schlick(bsdfData.fresnel0, LdotH);

// For anisotropy we must not saturate these values
float3 transL=L+bsdfData.normalWS*0.3;
// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
specularLighting = 0.15*bsdfData.specularOcclusion*(hairSpec1 + hairSpec2);
specularLighting = 0.15*bsdfData.perceptualRoughness*(hairSpec1 + hairSpec2);
float scatterFresnel = 3*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*(1.0 - NdotV)*(1.0 - NdotL)+ 0.5*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV);
float transAmount = _Scatter*scatterFresnel;
float3 transColor = 2*saturate(transAmount * float3(1, 0.6, 0.26)*bsdfData.specularOcclusion*bsdfData.specularOcclusion);
float scatterFresnel = 30*pow(invVdotL,9)*(1.0 - NdotV)*(1.0 - NdotL)+ 5*pow((1-NdotV),9);
float scatterAmount = _Scatter*scatterFresnel;
float3 transColor = 2*saturate(scatterAmount * float3(1, 0.6, 0.26)*bsdfData.specularOcclusion*bsdfData.specularOcclusion);
float diffuseTerm = Lambert();
diffuseLighting = bsdfData.diffuseColor * diffuseTerm+transColor;
}

正在加载...
取消
保存