浏览代码

HDRenderPipeline: Fix compil + fix double sided in regular case

/Branch_Batching2
Sebastien Lagarde 8 年前
当前提交
7e59ca9a
共有 1 个文件被更改,包括 9 次插入9 次删除
  1. 18
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl

18
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


void ApplyDoubleSidedFlip(inout FragInputs input)
{
#ifdef _DOUBLESIDED_ON
// _DoubleSidedMode is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : _DoubleSidedMode.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : _DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
input.tangentToWorld[0] = flipSign * input.tangentToWorld[0];
input.tangentToWorld[1] = flipSign * input.tangentToWorld[1];
input.tangentToWorld[1] = flipSign * input.tangentToWorld[1]; // bitangent
input.tangentToWorld[2] = flipSign * input.tangentToWorld[2]; // normal
#endif
#endif
}

void ApplyDoubleSidedMirror(inout float3 normalTS)
void ApplyDoubleSidedMirror(FragInputs input, inout float3 normalTS)
// _DoubleSidedMode is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : -_DoubleSidedMode.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
// _DoubleSidedConstants is float3(-1, -1, -1) in flip mode and float3(1, 1, -1) in mirror mode
float flipSign = input.isFrontFace ? 1.0 : -_DoubleSidedConstants.x; // TOCHECK : GetOddNegativeScale() is not necessary here as it is apply for tangent space creation.
#ifdef SURFACE_GRADIENT
normalTS = flipSign * normalTS;
#else

// so it allow us to correctly deal with detail normal map and optimize the code for the layered shaders
float3 normalTS;
float alpha = GetSurfaceData(input, layerTexCoord, surfaceData, normalTS);
ApplyDoubleSidedMirror(normalTS); // Apply double sided mirror on the final normalTS
ApplyDoubleSidedMirror(input, normalTS); // Apply double sided mirror on the final normalTS
GetNormalAndTangentWS(input, V, normalTS, surfaceData.normalWS, surfaceData.tangentWS);
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion *= GetHorizonOcclusion(V, surfaceData.normalWS, input.tangentToWorld[2].xyz, _HorizonFade);

surfaceData.coatPerceptualSmoothness = 1.0;
surfaceData.specularColor = float3(0.0, 0.0, 0.0);
ApplyDoubleSidedMirror(normalTS); // Apply double sided mirror on the final normalTS
ApplyDoubleSidedMirror(input, normalTS); // Apply double sided mirror on the final normalTS
GetNormalAndTangentWS(input, V, normalTS, surfaceData.normalWS, surfaceData.tangentWS);
// Done one time for all layered - cumulate with spec occ alpha for now
surfaceData.specularOcclusion = SURFACEDATA_BLEND_SCALAR(surfaceData, specularOcclusion, weights);

正在加载...
取消
保存