-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,084 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
float4 AdjustLodLandscapeVertexPositionMS(float4 positionMS, row_major float4x4 world, float4 cellParams) | ||
{ | ||
float4 positionWS = mul(world, positionMS); | ||
float worldXShift = positionWS.x - cellParams.x; | ||
float worldYShift = positionWS.y - cellParams.y; | ||
if ((abs(worldXShift) < cellParams.z) && (abs(worldYShift) < cellParams.w)) { | ||
positionMS.z -= (230 + positionWS.z / 1e9); | ||
} | ||
return positionMS; | ||
} | ||
|
||
float4 AdjustLodLandscapeVertexPositionCS(float4 positionCS) | ||
{ | ||
positionCS.z += min(1, 1e-4 * max(0, positionCS.z - 70000)) * 0.5; | ||
return positionCS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cbuffer PreviousBonesBuffer : register(b9) | ||
{ | ||
float4 PreviousBones[240] : packoffset(c0); | ||
} | ||
|
||
cbuffer BonesBuffer : register(b10) | ||
{ | ||
float4 Bones[240] : packoffset(c0); | ||
} | ||
|
||
float3x4 GetBoneTransformMatrix(float4 bonePositions[240], int4 boneIndices, float3 pivot, float4 boneWeights) | ||
{ | ||
float3x4 pivotMatrix = transpose(float4x3(0.0.xxx, 0.0.xxx, 0.0.xxx, pivot)); | ||
|
||
float3x4 boneMatrix1 = | ||
float3x4(bonePositions[boneIndices.x], bonePositions[boneIndices.x + 1], bonePositions[boneIndices.x + 2]); | ||
float3x4 boneMatrix2 = | ||
float3x4(bonePositions[boneIndices.y], bonePositions[boneIndices.y + 1], bonePositions[boneIndices.y + 2]); | ||
float3x4 boneMatrix3 = | ||
float3x4(bonePositions[boneIndices.z], bonePositions[boneIndices.z + 1], bonePositions[boneIndices.z + 2]); | ||
float3x4 boneMatrix4 = | ||
float3x4(bonePositions[boneIndices.w], bonePositions[boneIndices.w + 1], bonePositions[boneIndices.w + 2]); | ||
|
||
float3x4 unitMatrix = float3x4(1.0.xxxx, 1.0.xxxx, 1.0.xxxx); | ||
float3x4 weightMatrix1 = unitMatrix * boneWeights.x; | ||
float3x4 weightMatrix2 = unitMatrix * boneWeights.y; | ||
float3x4 weightMatrix3 = unitMatrix * boneWeights.z; | ||
float3x4 weightMatrix4 = unitMatrix * boneWeights.w; | ||
|
||
return (boneMatrix1 - pivotMatrix) * weightMatrix1 + | ||
(boneMatrix2 - pivotMatrix) * weightMatrix2 + | ||
(boneMatrix3 - pivotMatrix) * weightMatrix3 + | ||
(boneMatrix4 - pivotMatrix) * weightMatrix4; | ||
} | ||
|
||
float3x3 GetBoneRSMatrix(float4 bonePositions[240], int4 boneIndices, float4 boneWeights) | ||
{ | ||
float3x3 result; | ||
for (int rowIndex = 0; rowIndex < 3; ++rowIndex) { | ||
result[rowIndex] = boneWeights.xxx * bonePositions[boneIndices.x + rowIndex].xyz + | ||
boneWeights.yyy * bonePositions[boneIndices.y + rowIndex].xyz + | ||
boneWeights.zzz * bonePositions[boneIndices.z + rowIndex].xyz + | ||
boneWeights.www * bonePositions[boneIndices.w + rowIndex].xyz; | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.