浏览代码

Merge pull request #1859 from Unity-Technologies/Fixing-winding-and-VFACE-order-issue

Fixing winding and vface order issue
/main
GitHub 6 年前
当前提交
ea9baba9
共有 7 个文件被更改,包括 451 次插入579 次删除
  1. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
  2. 15
      TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset
  3. 8
      com.unity.render-pipelines.high-definition/HDRP/Camera/HDCamera.cs
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/SharedCode.template.hlsl
  5. 1
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
  6. 3
      com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VaryingMesh.hlsl
  7. 1
      com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2207_ReflectionProbeVFace.png
文件差异内容过多而无法显示
查看文件

15
TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset


path: Assets/GraphicTests/Scenes/2x_Lighting/2202_ReflectionProbes_Volume.unity
guid: 9b3132db666b3ae48aa17349ab100118
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2203_PlanarProbes.unity
guid: b8fa5b1235e91884799163adaf34e5d6
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2204_ReflectionProbes_Lights.unity
guid: 21d198bbbf9143d40b227ad2fe71706f
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2206_PlanarReflectionVFace.unity
guid: d4d352e2cbfbfac4686e77b69fe84ec0
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2207_ReflectionProbeVFace.unity
guid: 4814073d6e6ec404bba1f26bec73307a
- enabled: 1
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2401_Light_on_Tesselation.unity
guid: 3f6529c22f7d2ca46814b2e7afd04ef9
- enabled: 1
path: Assets/GraphicTests/Scenes/2x_Lighting/2501_Instancing_Lighting.unity
guid: d841ad64fdc2ae14ba996e30fe86b901

8
com.unity.render-pipelines.high-definition/HDRP/Camera/HDCamera.cs


public Matrix4x4 projMatrix;
public Matrix4x4 nonJitteredProjMatrix;
public Vector4 worldSpaceCameraPos;
public float detViewMatrix;
public Vector4 screenSize;
public Frustum frustum;
public Vector4[] frustumPlaneEquations;

projMatrix = gpuProj;
nonJitteredProjMatrix = gpuNonJitteredProj;
cameraPos = pos;
detViewMatrix = viewMatrix.determinant;
if (ShaderConfig.s_CameraRelativeRendering != 0)
{

// What constants in UnityPerPass need updating for stereo considerations?
// _ViewProjMatrix - It is used directly for generating tesselation factors. This should be the same
// across both eyes for consistency, and to keep shadow-generation eye-independent
// _DetViewMatrix - Used for isFrontFace determination, should be the same for both eyes. There is the scenario
// where there might be multi-eye sets that are divergent enough where this assumption is not valid,
// but that's a future problem
// _InvProjParam - Intention was for generating linear depths, but not currently used. Will need to be stereo-ized if
// actually needed.
// _FrustumPlanes - Also used for generating tesselation factors. Should be fine to use the combined stereo VP

viewMatrix = stereoCombinedViewMatrix;
var stereoCombinedProjMatrix = cullingParams.cullStereoProj;
projMatrix = GL.GetGPUProjectionMatrix(stereoCombinedProjMatrix, true);
detViewMatrix = viewMatrix.determinant;
frustum = Frustum.Create(viewProjMatrix, true, true);

cmd.SetGlobalMatrix(HDShaderIDs._NonJitteredViewProjMatrix, nonJitteredViewProjMatrix);
cmd.SetGlobalMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix);
cmd.SetGlobalVector(HDShaderIDs._WorldSpaceCameraPos, worldSpaceCameraPos);
cmd.SetGlobalFloat(HDShaderIDs._DetViewMatrix, detViewMatrix);
cmd.SetGlobalVector(HDShaderIDs._ScreenSize, screenSize);
cmd.SetGlobalVector(HDShaderIDs._ScreenToTargetScale, doubleBufferedViewportScale);
cmd.SetGlobalVector(HDShaderIDs._ZBufferParams, zBufferParams);

3
com.unity.render-pipelines.high-definition/HDRP/Editor/ShaderGraph/SharedCode.template.hlsl


$FragInputs.color: output.color = input.color;
#if SHADER_STAGE_FRAGMENT
$FragInputs.isFrontFace: output.isFrontFace = IS_FRONT_VFACE(input.cullFace, true, false); // TODO: SHADER_STAGE_FRAGMENT only
$FragInputs.isFrontFace: // Handle handness of the view matrix (In Unity view matrix default to a determinant of -1)
$FragInputs.isFrontFace: // when we render a cubemap the view matrix handness is flipped (due to convention used for cubemap) we have a determinant of +1
$FragInputs.isFrontFace: output.isFrontFace = _DetViewMatrix < 0.0 ? output.isFrontFace : !output.isFrontFace;
#endif // SHADER_STAGE_FRAGMENT
return output;

1
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs


public static readonly int _NonJitteredViewProjMatrix = Shader.PropertyToID("_NonJitteredViewProjMatrix");
public static readonly int _ViewProjMatrix = Shader.PropertyToID("_ViewProjMatrix");
public static readonly int _InvViewProjMatrix = Shader.PropertyToID("_InvViewProjMatrix");
public static readonly int _DetViewMatrix = Shader.PropertyToID("_DetViewMatrix");
public static readonly int _ZBufferParams = Shader.PropertyToID("_ZBufferParams");
public static readonly int _ProjectionParams = Shader.PropertyToID("_ProjectionParams");
public static readonly int unity_OrthoParams = Shader.PropertyToID("unity_OrthoParams");

3
com.unity.render-pipelines.high-definition/HDRP/ShaderPass/VaryingMesh.hlsl


#if defined(VARYINGS_NEED_CULLFACE) && SHADER_STAGE_FRAGMENT
output.isFrontFace = IS_FRONT_VFACE(input.cullFace, true, false);
// Handle handness of the view matrix (In Unity view matrix default to a determinant of -1)
// when we render a cubemap the view matrix handness is flipped (due to convention used for cubemap) we have a determinant of +1
output.isFrontFace = _DetViewMatrix < 0.0 ? output.isFrontFace : !output.isFrontFace;
#endif
return output;

1
com.unity.render-pipelines.high-definition/HDRP/ShaderVariables.hlsl


#else
float3 _WorldSpaceCameraPos;
#endif
float _DetViewMatrix; // determinant(_ViewMatrix)
float4 _ScreenSize; // { w, h, 1 / w, 1 / h }
float4 _ScreenToTargetScale; // { w / RTHandle.maxWidth, h / RTHandle.maxHeight } : xy = currFrame, zw = prevFrame

正在加载...
取消
保存