浏览代码

Disable refraction for pre-transparents

/Yibing-Project-2
Frédéric Vauchelles 7 年前
当前提交
4ea18fae
共有 7 个文件被更改,包括 12 次插入12 次删除
  1. 4
      SampleScenes/HDTest/GraphicTest/Common/Material/Mat_refraction_thicksphere_EarthMap_pretransparent.mat
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  5. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader

4
SampleScenes/HDTest/GraphicTest/Common/Material/Mat_refraction_thicksphere_EarthMap_pretransparent.mat


m_Name: Mat_refraction_thicksphere_EarthMap_pretransparent
m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}
m_ShaderKeywords: _ALPHACUTOFFENABLE_OFF _BLENDMODE_LERP _MASKMAP _NORMALMAP_TANGENT_SPACE
_REFRACTION_ON _REFRACTION_THICKSPHERE _ROUGH_REFRACTION _ROUGH_REFRACTION_ON
_REFRACTION_THICKSPHERE _ROUGH_REFRACTION _ROUGH_REFRACTION_ON
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

- _ZTestMode: 8
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor: {r: 1, g: 1, b: 1, a: 0.428}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


// Do a depth pre-pass for transparent objects that want it that will fill the depth buffer to reduce the overdraw (typical usage is hair rendering)
RenderTransparentDepthPrepass(m_CullResults, camera, renderContext, cmd);
cmd.Blit(m_CameraColorBufferRT, m_GaussianPyramidColorBuffer);
// Render pre transparent objects
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent);

cmd.ClearRenderTarget(false, true, Color.clear);
// Only transparent object can render distortion vectors
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preTransparentQueue:true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


}
var isPrePass = material.GetFloat(kTransparentPrepass) > 0.0;
SetKeyword(material, "_REFRACTION_ROUGHNESS_ON", !isPrePass); // Rough refraction is not available for pre transparent
SetKeyword(material, "_REFRACTION_ON", !isPrePass); // Refraction is not available for pre transparent (color buffer cannot be fetched)
}
static public void SetupBaseLitMaterialPass(Material material)

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


EditorGUILayout.LabelField(StylesBaseUnlit.TransparencyInputsText, EditorStyles.boldLabel);
++EditorGUI.indentLevel;
if (refractionMode != null)
var isPrePass = material.GetFloat(kTransparentPrepass) > 0.0;
if (refractionMode != null && !isPrePass)
{
m_MaterialEditor.ShaderProperty(refractionMode, Styles.refractionModeText);
var mode = (Lit.RefractionMode)refractionMode.floatValue;

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


specularLighting = float3(0.0, 0.0, 0.0);
weight = float2(0.0, 0.0);
#if !defined(_REFRACTION_ON)
return;
#endif
#if defined(_REFRACTION_THINPLANE) || defined(_REFRACTION_THICKPLANE) || defined(_REFRACTION_THICKSPHERE)
// Refraction process:
// 1. Depending on the shape model, we calculate the refracted point in world space and the optical depth

return;
}
#ifdef _REFRACTION_ROUGHNESS_ON
float mipLevel = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness, uint(_GaussianPyramidColorMipSize.z));
float mipLevel = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness);
#else
diffuseLighting = SAMPLE_TEXTURE2D_LOD(_GaussianPyramidColorTexture, s_trilinear_clamp_sampler, refractedBackPointSS.xy, 0.0).rgb;
#endif
// Beer-Lamber law for absorption
float3 transmittance = exp(-bsdfData.absorptionCoefficient * opticalDepth);

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


#pragma shader_feature _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE
#pragma shader_feature _VERTEX_WIND
#pragma shader_feature _ _REFRACTION_THINPLANE _REFRACTION_THICKPLANE _REFRACTION_THICKSPHERE
#pragma shader_feature _REFRACTION_ROUGHNESS_ON
#pragma shader_feature _REFRACTION_ON
#pragma shader_feature _ _MAPPING_PLANAR _MAPPING_TRIPLANAR
#pragma shader_feature _NORMALMAP_TANGENT_SPACE

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

正在加载...
取消
保存