浏览代码

Refactored refraction mask as opacity mask

/Add-support-for-light-specular-color-tint
Frédéric Vauchelles 7 年前
当前提交
30bcae4e
共有 8 个文件被更改,包括 721 次插入314 次删除
  1. 986
      SampleScenes/HDTest/GraphicTest/Common/Textures/EarthColorandMask.png
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs
  4. 21
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  7. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

986
SampleScenes/HDTest/GraphicTest/Common/Textures/EarthColorandMask.png
文件差异内容过多而无法显示
查看文件

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


public static string InputsText = "Inputs";
public static GUIContent baseColorText = new GUIContent("Base Color + Opacity", "Albedo (RGB) and Opacity (A)");
public static GUIContent baseColorRefractionMaskText = new GUIContent("Base Color + RefractionMask", "Albedo (RGB) and Refraction mask (A)");
public static GUIContent baseColorOpacityMaskText = new GUIContent("Base Color + Opacity Mask", "Albedo (RGB) and Opacity mask (A)");
public static GUIContent smoothnessMapChannelText = new GUIContent("Smoothness Source", "Smoothness texture and channel");
public static GUIContent metallicText = new GUIContent("Metallic", "Metallic scale factor");

bool refractionEnable = (material.HasProperty(kRefractionMode) && refractionMode.floatValue > 0.0f) && (material.HasProperty(kPreRefractionPass) && preRefractionPass.floatValue == 0.0f);
m_MaterialEditor.TexturePropertySingleLine(refractionEnable ? Styles.baseColorRefractionMaskText : Styles.baseColorText, baseColorMap[layerIndex], baseColor[layerIndex]);
m_MaterialEditor.TexturePropertySingleLine(refractionEnable ? Styles.baseColorOpacityMaskText : Styles.baseColorText, baseColorMap[layerIndex], baseColor[layerIndex]);
if ((Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitStandard || (Lit.MaterialId)materialID.floatValue == Lit.MaterialId.LitAniso)
{

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


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

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

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


// UnityEngine.Experimental.Rendering.HDPipeline.Lit+RefractionMode: static fields
//
#define REFRACTIONMODE_NONE (0)
#define REFRACTIONMODE_THICK_PLANE (1)
#define REFRACTIONMODE_THICK_SPHERE (2)
#define REFRACTIONMODE_THIN_PLANE (3)
#define REFRACTIONMODE_PLANE (1)
#define REFRACTIONMODE_SPHERE (2)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData: static fields

#define DEBUGVIEW_LIT_SURFACEDATA_IOR (1016)
#define DEBUGVIEW_LIT_SURFACEDATA_TRANSMITTANCE_COLOR (1017)
#define DEBUGVIEW_LIT_SURFACEDATA_AT_DISTANCE (1018)
#define DEBUGVIEW_LIT_SURFACEDATA_REFRACTION_MASK (1019)
#define DEBUGVIEW_LIT_SURFACEDATA_OPACITY_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_REFRACTION_MASK (1053)
#define DEBUGVIEW_LIT_BSDFDATA_OPACITY_MASK (1053)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields

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

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

case DEBUGVIEW_LIT_SURFACEDATA_AT_DISTANCE:
result = surfacedata.atDistance.xxx;
break;
case DEBUGVIEW_LIT_SURFACEDATA_REFRACTION_MASK:
result = surfacedata.refractionMask.xxx;
case DEBUGVIEW_LIT_SURFACEDATA_OPACITY_MASK:
result = surfacedata.opacityMask.xxx;
break;
}
}

case DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT:
result = bsdfdata.absorptionCoefficient;
break;
case DEBUGVIEW_LIT_BSDFDATA_REFRACTION_MASK:
result = bsdfdata.refractionMask.xxx;
case DEBUGVIEW_LIT_BSDFDATA_OPACITY_MASK:
result = bsdfdata.opacityMask.xxx;
break;
}
}

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


bsdfData.coatCoverage = coatCoverage;
}
void FillMaterialIdTransparencyData(float ior, float3 transmittanceColor, float atDistance, float thickness, float refractionMask, inout BSDFData bsdfData)
void FillMaterialIdTransparencyData(float ior, float3 transmittanceColor, float atDistance, float thickness, float opacityMask, inout BSDFData bsdfData)
bsdfData.refractionMask = refractionMask;
bsdfData.opacityMask = opacityMask;
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.refractionMask,
surfaceData.ior, surfaceData.transmittanceColor, surfaceData.atDistance, surfaceData.thickness, surfaceData.opacityMask,
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.refractionMask;
weight.x = bsdfData.opacityMask;
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.refractionMask = 0.0;
surfaceData.opacityMask = 1.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 refraction mask.
surfaceData.refractionMask = alpha;
// Rough refraction don't use opacity. Instead we use opacity as a opacity mask.
surfaceData.opacityMask = 1.0 - alpha;
surfaceData.refractionMask = 1.0;
surfaceData.opacityMask = 1.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.refractionMask = 0.0;
surfaceData.opacityMask = 1.0;
#endif // #if !defined(LAYERED_LIT_SHADER)

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存