浏览代码

more updated - SSS

/Yibing-Project-2
Sebastien Lagarde 7 年前
当前提交
5a26f7cd
共有 4 个文件被更改,包括 13 次插入8 次删除
  1. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Character/Character.hlsl
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/Fabric.hlsl
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Character/Character.hlsl


// This function require the 3 structure surfaceData, builtinData, bsdfData because it may require both the engine side data, and data that will not be store inside the gbuffer.
float3 GetBakedDiffuseLigthing(SurfaceData surfaceData, BuiltinData builtinData, BSDFData bsdfData, PreLightData preLightData)
{
bsdfData.diffuseColor = ApplyDiffuseTexturingMode(bsdfData);
// Premultiply bake diffuse lighting information with DisneyDiffuse pre-integration
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
}

diffuseLighting = float3(0.0, 0.0, 0.0);
}
#endif // #ifdef HAS_LIGHTLOOP
#endif // #ifdef HAS_LIGHTLOOP

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/Fabric.hlsl


// This function require the 3 structure surfaceData, builtinData, bsdfData because it may require both the engine side data, and data that will not be store inside the gbuffer.
float3 GetBakedDiffuseLigthing(SurfaceData surfaceData, BuiltinData builtinData, BSDFData bsdfData, PreLightData preLightData)
{
bsdfData.diffuseColor = ApplyDiffuseTexturingMode(bsdfData);
// Premultiply bake diffuse lighting information with DisneyDiffuse pre-integration
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
}

// Maybe always using aniso maybe a win ?
float3 H = (L + V) * invLenLV;
bsdfData.roughness = 1- ClampRoughnessForAnalyticalLights(bsdfData.roughness);
float roughnessSq = bsdfData.roughness*bsdfData.roughness;
float N = 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 cotNdotH2 = NdotH2 / (1.000001 - NdotH2);
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)));

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl


// This function require the 3 structure surfaceData, builtinData, bsdfData because it may require both the engine side data, and data that will not be store inside the gbuffer.
float3 GetBakedDiffuseLigthing(SurfaceData surfaceData, BuiltinData builtinData, BSDFData bsdfData, PreLightData preLightData)
{
bsdfData.diffuseColor = ApplyDiffuseTexturingMode(bsdfData);
// Premultiply bake diffuse lighting information with DisneyDiffuse pre-integration
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
}

// We can rewrite specExp from exp2(10 * (1.0 - roughness)) in order
// to remove the need to take the square root of sinTH
float specExp = exp2(9 - 10*roughness);
return dirAttn * pow (sinTHSq, specExp) ;
return dirAttn * pow (sinTHSq, specExp) ;
}
//-----------------------------------------------------------------------------

// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
float3 hairSpec1 = 0.5*_PrimarySpecular*KajiyaKaySpecular(H, V, bsdfData.normalWS, B1, _PrimarySpecularShift, 0.5*bsdfData.roughness)*lerp(1,_SpecularTint,0.3);
float3 hairSpec2 = _SecondarySpecular*KajiyaKaySpecular(H, V, bsdfData.normalWS, B2, _SecondarySpecularShift, bsdfData.roughness)*lerp(bsdfData.diffuseColor,_SpecularTint,0.5);
float3 hairSpec2 = _SecondarySpecular*KajiyaKaySpecular(H, V, bsdfData.normalWS, B2, _SecondarySpecularShift, bsdfData.roughness)*lerp(bsdfData.diffuseColor,_SpecularTint,0.5);
specularLighting = 0.15*bsdfData.perceptualRoughness*(hairSpec1 + hairSpec2);
specularLighting *= (bsdfData.isFrontFace ? 1.0 : 0.0); //Disable backfacing specular for now. Look into having a flipped normal entirely.
float scatterFresnel;

1
ScriptableRenderPipeline/HDRenderPipeline/Material/LightEvaluationShare1.hlsl


float3 albedo = bsdfData.diffuseColor;
#ifdef WANT_SSS_CODE
if (bsdfData.materialId == MATERIALID_LIT_SSS)
{
#if defined(SHADERPASS) && (SHADERPASS == SHADERPASS_SUBSURFACE_SCATTERING)
// If the SSS pass is executed, we know we have SSS enabled.

正在加载...
取消
保存