浏览代码

Merge pull request #520 from Unity-Technologies/feature/refractionMask

Renamed opacity mask to transmittance mask
/Add-support-for-light-specular-color-tint
GitHub 7 年前
当前提交
1ceed0fe
共有 5 个文件被更改,包括 20 次插入20 次删除
  1. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  2. 16
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs


public Vector3 transmittanceColor;
[SurfaceDataAttributes("Transmittance Absorption Distance")]
public float atDistance;
[SurfaceDataAttributes("Opacity mask")]
public float opacityMask;
[SurfaceDataAttributes("Transmittance mask")]
public float transmittanceMask;
};
//-----------------------------------------------------------------------------

public float ior;
// Reuse thickness from SSS
public Vector3 absorptionCoefficient;
public float opacityMask;
public float transmittanceMask;
};
//-----------------------------------------------------------------------------

16
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl


#define DEBUGVIEW_LIT_SURFACEDATA_IOR (1016)
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_COLOR (1017)
#define DEBUGVIEW_LIT_SURFACEDATA_AT_DISTANCE (1018)
#define DEBUGVIEW_LIT_SURFACEDATA_OPACITY_MASK (1019)
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_MASK (1019)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData: static fields

#define DEBUGVIEW_LIT_BSDFDATA_COAT_IOR (1050)
#define DEBUGVIEW_LIT_BSDFDATA_IOR (1051)
#define DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT (1052)
#define DEBUGVIEW_LIT_BSDFDATA_OPACITY_MASK (1053)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK (1053)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields

float ior;
float3 transmittanceColor;
float atDistance;
float opacityMask;
float transmittanceMask;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData

float coatIOR;
float ior;
float3 absorptionCoefficient;
float opacityMask;
float transmittanceMask;
};
//

case DEBUGVIEW_LIT_SURFACEDATA_AT_DISTANCE:
result = surfacedata.atDistance.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_OPACITY_MASK:
result = surfacedata.opacityMask.xxx;
case DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_MASK:
result = surfacedata.transmittanceMask.xxx;
break;
}
}

case DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT:
result = bsdfdata.absorptionCoefficient;
break;
case DEBUGVIEW_LIT_BSDFDATA_OPACITY_MASK:
result = bsdfdata.opacityMask.xxx;
case DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK:
result = bsdfdata.transmittanceMask.xxx;
break;
}
}

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


bsdfData.coatCoverage = coatCoverage;
}
void FillMaterialIdTransparencyData(float ior, float3 transmittanceColor, float atDistance, float thickness, float opacityMask, inout BSDFData bsdfData)
void FillMaterialIdTransparencyData(float ior, float3 transmittanceColor, float atDistance, float thickness, float transmittanceMask, inout BSDFData bsdfData)
bsdfData.opacityMask = opacityMask;
bsdfData.transmittanceMask = transmittanceMask;
bsdfData.thickness = max(thickness, 0.0001);
}

#if HAS_REFRACTION
// Note: Will override thickness of SSS's property set
FillMaterialIdTransparencyData(
surfaceData.ior, surfaceData.transmittanceColor, surfaceData.atDistance, surfaceData.thickness, surfaceData.opacityMask,
surfaceData.ior, surfaceData.transmittanceColor, surfaceData.atDistance, surfaceData.thickness, surfaceData.transmittanceMask,
bsdfData);
#endif

// a. Get the corresponding color depending on the roughness from the gaussian pyramid of the color buffer
// b. Multiply by the transmittance for absorption (depends on the optical depth)
weight.x = bsdfData.opacityMask;
weight.x = bsdfData.transmittanceMask;
float3 refractedBackPointWS = float3(0.0, 0.0, 0.0);
float opticalDepth = 0.0;

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
surfaceData.atDistance = 1000000.0;
surfaceData.opacityMask = 1.0;
surfaceData.transmittanceMask = 0.0;
GetNormalWS(input, V, normalTS, surfaceData.normalWS);
// Use bent normal to sample GI if available

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


surfaceData.atDistance = _ATDistance;
// Thickness already defined with SSS (from both thickness and thicknessMap)
surfaceData.thickness *= _ThicknessMultiplier;
// Rough refraction don't use opacity. Instead we use opacity as a opacity mask.
surfaceData.opacityMask = 1.0 - alpha;
// Rough refraction don't use opacity. Instead we use opacity as a transmittance mask.
surfaceData.transmittanceMask = 1.0 - alpha;
surfaceData.opacityMask = 1.0;
surfaceData.transmittanceMask = 0.0;
#endif
surfaceData.coatNormalWS = input.worldToTangent[2].xyz; // Assign vertex normal

surfaceData.ior = 1.0;
surfaceData.transmittanceColor = float3(1.0, 1.0, 1.0);
surfaceData.atDistance = 1000000.0;
surfaceData.opacityMask = 1.0;
surfaceData.transmittanceMask = 0.0;
#endif // #if !defined(LAYERED_LIT_SHADER)
正在加载...
取消
保存