Skip to content

Project skybox without perspective for ortho cameras #2955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
259c344
[HDRP] Fix coat normal space (#2888)
alelievr Dec 15, 2020
e5e7c25
Merge branch 'master' into hd/bugfix
sebastienlagarde Dec 15, 2020
b68ce13
Avoid issues causing faulty transitions in shadows (resulting in no s…
FrancescoC-unity Dec 15, 2020
9cf8ac1
Merge branch 'master' into hd/bugfix
sebastienlagarde Dec 15, 2020
53096ec
Fixed invalid loop length for probe baking (case 1289680) (#2830)
fredericv-unity3d Dec 15, 2020
7339d48
Fix volumetric fog with XR single-pass (#2823)
fabien-unity Dec 15, 2020
85f8877
[HDRP] Fix rendering issues for the first frame (#2836)
pmavridis Dec 15, 2020
2653b9c
Update 5001_Fog_FogFallback.png
sebastienlagarde Dec 15, 2020
95eb52e
Revert "Update 5001_Fog_FogFallback.png"
sebastienlagarde Dec 15, 2020
33e6948
Update 5001_Fog_FogFallback.unity
sebastienlagarde Dec 15, 2020
fcd7472
Fix AOV API for render graph (#2909)
pmavridis Dec 16, 2020
94f3898
Fix a small discrepancy in the marker placement in light intensity sl…
pmavridis Dec 17, 2020
7767a31
Merge branch 'master' into hd/bugfix
sebastienlagarde Dec 17, 2020
fb1ec50
Update CHANGELOG.md
sebastienlagarde Dec 17, 2020
abb5bb5
Fix issue with VT spewing errors when transparent and opaque are disa…
FrancescoC-unity Dec 17, 2020
6a47be7
Fixed a bug in the sphere-aabb light cluster (case 1294767). (#2920)
anisunity Dec 17, 2020
4b1ac9c
Move EndCameraRendering callback out of the profiling scope (#2917)
adrien-de-tocqueville Dec 17, 2020
980307b
Fixed baked light being included into the ray tracing light cluster (…
anisunity Dec 17, 2020
f738893
Handle all enums the same way for UI (#2913)
adrien-de-tocqueville Dec 17, 2020
a20e885
Changed the message when the graphics device doesn't support ray trac…
anisunity Dec 17, 2020
2784ac6
[HDRP] Fix default blocks for Hair and Eye shader graphs (#2919)
alelievr Dec 17, 2020
b42cae6
Init scene camera debug framesettings (#2931)
adrien-de-tocqueville Dec 17, 2020
2064794
Fixed using the wrong method to define if a light should be included …
anisunity Dec 17, 2020
2fccfa9
[HDRP] Change the behavior of custom passes when the volume is disabl…
alelievr Dec 17, 2020
4befd38
Fixed display of LOD Bias and maximum level in frame settings when us…
JulienIgnace-Unity Dec 17, 2020
1d8d6c5
Fixed an issue when trying to open a look dev env library when Look D…
JulienIgnace-Unity Dec 17, 2020
f0ae90b
Enable Reflector for Spotlight by default
sebastienlagarde Dec 17, 2020
c4ea601
- Fixed shader graph not supporting indirectdxr multibounce (case 129…
anisunity Dec 17, 2020
7276431
Fixed the planar depth texture not being properly created and rendere…
anisunity Dec 18, 2020
4bfd01d
Fixed C# 8 compilation issue with turning on nullable checks (case 13…
sebastienlagarde Dec 18, 2020
0881491
Fixed C# 8 compilation issue with turning on nullable checks - bis (#…
sebastienlagarde Dec 18, 2020
4e4bbcc
Fix scripting light test with enableReflector true by default
sebastienlagarde Dec 18, 2020
4b97a5f
Project skybox without perspective for ortho cameras
adrien-de-tocqueville Dec 18, 2020
cc29495
Merge branch 'hd/bugfix' into hd/fix-ortho-skybox
adrien-de-tocqueville Jan 14, 2021
12fc7ba
Merge branch 'hd/bugfix' into hd/fix-ortho-skybox
adrien-de-tocqueville Feb 2, 2021
87c3038
Explicit orthographic argument
adrien-de-tocqueville Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Removed the material pass probe volumes evaluation mode.
- Updated the tooltip for the Decal Angle Fade property (requires to enable Decal Layers in both HDRP asset and Frame settings) (case 1308048).
- Fixed skybox for ortho cameras.

## [11.0.0] - 2020-10-21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(ViewConstants viewCon
}
Vector2 lensShift = camera.GetGateFittedLensShift();

return HDUtils.ComputePixelCoordToWorldSpaceViewDirectionMatrix(verticalFoV, lensShift, resolution, viewConstants.viewMatrix, false, aspect);
return HDUtils.ComputePixelCoordToWorldSpaceViewDirectionMatrix(verticalFoV, lensShift, resolution, viewConstants.viewMatrix, false, aspect, camera.orthographic);
}

void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,49 @@ internal static int GetRuntimeDebugPanelWidth(HDCamera hdCamera)
internal static float ProjectionMatrixAspect(in Matrix4x4 matrix)
=> - matrix.m11 / matrix.m00;

internal static Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(float verticalFoV, Vector2 lensShift, Vector4 screenSize, Matrix4x4 worldToViewMatrix, bool renderToCubemap, float aspectRatio = -1)
internal static Matrix4x4 ComputePixelCoordToWorldSpaceViewDirectionMatrix(float verticalFoV, Vector2 lensShift, Vector4 screenSize, Matrix4x4 worldToViewMatrix, bool renderToCubemap, float aspectRatio = -1, bool isOrthographic = false)
{
aspectRatio = aspectRatio < 0 ? screenSize.x * screenSize.w : aspectRatio;
Matrix4x4 viewSpaceRasterTransform;

// Compose the view space version first.
// V = -(X, Y, Z), s.t. Z = 1,
// X = (2x / resX - 1) * tan(vFoV / 2) * ar = x * [(2 / resX) * tan(vFoV / 2) * ar] + [-tan(vFoV / 2) * ar] = x * [-m00] + [-m20]
// Y = (2y / resY - 1) * tan(vFoV / 2) = y * [(2 / resY) * tan(vFoV / 2)] + [-tan(vFoV / 2)] = y * [-m11] + [-m21]
if (isOrthographic)
{
// For ortho cameras, project the skybox with no perspective
// the same way as builtin does (case 1264647)
viewSpaceRasterTransform = new Matrix4x4(
new Vector4(-2.0f * screenSize.z, 0.0f, 0.0f, 0.0f),
new Vector4(0.0f, -2.0f * screenSize.w, 0.0f, 0.0f),
new Vector4(1.0f, 1.0f, -1.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
}
else
{
// Compose the view space version first.
// V = -(X, Y, Z), s.t. Z = 1,
// X = (2x / resX - 1) * tan(vFoV / 2) * ar = x * [(2 / resX) * tan(vFoV / 2) * ar] + [-tan(vFoV / 2) * ar] = x * [-m00] + [-m20]
// Y = (2y / resY - 1) * tan(vFoV / 2) = y * [(2 / resY) * tan(vFoV / 2)] + [-tan(vFoV / 2)] = y * [-m11] + [-m21]

float tanHalfVertFoV = Mathf.Tan(0.5f * verticalFoV);
aspectRatio = aspectRatio < 0 ? screenSize.x * screenSize.w : aspectRatio;
float tanHalfVertFoV = Mathf.Tan(0.5f * verticalFoV);

// Compose the matrix.
float m21 = (1.0f - 2.0f * lensShift.y) * tanHalfVertFoV;
float m11 = -2.0f * screenSize.w * tanHalfVertFoV;
// Compose the matrix.
float m21 = (1.0f - 2.0f * lensShift.y) * tanHalfVertFoV;
float m11 = -2.0f * screenSize.w * tanHalfVertFoV;

float m20 = (1.0f - 2.0f * lensShift.x) * tanHalfVertFoV * aspectRatio;
float m00 = -2.0f * screenSize.z * tanHalfVertFoV * aspectRatio;
float m20 = (1.0f - 2.0f * lensShift.x) * tanHalfVertFoV * aspectRatio;
float m00 = -2.0f * screenSize.z * tanHalfVertFoV * aspectRatio;

if (renderToCubemap)
{
// Flip Y.
m11 = -m11;
m21 = -m21;
}
if (renderToCubemap)
{
// Flip Y.
m11 = -m11;
m21 = -m21;
}

var viewSpaceRasterTransform = new Matrix4x4(new Vector4(m00, 0.0f, 0.0f, 0.0f),
new Vector4(0.0f, m11, 0.0f, 0.0f),
new Vector4(m20, m21, -1.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
viewSpaceRasterTransform = new Matrix4x4(new Vector4(m00, 0.0f, 0.0f, 0.0f),
new Vector4(0.0f, m11, 0.0f, 0.0f),
new Vector4(m20, m21, -1.0f, 0.0f),
new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
}

// Remove the translation component.
var homogeneousZero = new Vector4(0, 0, 0, 1);
Expand Down