Skip to content

Commit 836afdb

Browse files
committed
Fixed geometries naming and formatting for consistency
1 parent af175d4 commit 836afdb

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingSakuraForestSER/D3D12RaytracingSakuraForestSER.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,11 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
10261026
ComPtr<ID3D12Resource> instanceDescsResource;
10271027
std::vector<D3D12_RAYTRACING_INSTANCE_DESC> instanceDesc;
10281028

1029-
int objectsPerRow = 20; // Object per row along Z and X axis
1029+
int cubesPerRow = 20; // Number of cubes per row along Z and X axis that make up the floor
10301030
float largerCubeSpacing = 4.0f; // Spacing between larger cubes
10311031
float randomCubeSpacing = 0.1f; // Spacing between random smaller cubes
1032+
int treesPerRow = 30; // Number of trees per row along Z and X axis
1033+
float treeSpacing = 1.9f; // Spacing between trees
10321034

10331035
// Create random number generator for random offsets
10341036
std::random_device rd;
@@ -1040,9 +1042,9 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
10401042
std::uniform_real_distribution<float> randomOffsetBush(0.7f, 0.75f);
10411043

10421044
// Larger cubes for the floor
1043-
for (int x = -objectsPerRow / 2; x <= objectsPerRow / 2; ++x)
1045+
for (int x = -cubesPerRow / 2; x <= cubesPerRow / 2; ++x)
10441046
{
1045-
for (int z = -objectsPerRow / 2; z <= objectsPerRow / 2; ++z)
1047+
for (int z = -cubesPerRow / 2; z <= cubesPerRow / 2; ++z)
10461048
{
10471049
float posX = x * largerCubeSpacing + 10.0f;
10481050
float posY = 0.0f;
@@ -1074,7 +1076,7 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
10741076
{
10751077
float randomYOffset = randomOffset(gen);
10761078

1077-
float posX = x * randomCubeSpacing;
1079+
float posX = 0.5f + x * randomCubeSpacing;
10781080
float posY = 1.7f + randomYOffset;
10791081
float posZ = z * randomCubeSpacing;
10801082

@@ -1084,9 +1086,9 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
10841086
desc.Transform[1][1] = scale;
10851087
desc.Transform[2][2] = scale;
10861088

1087-
desc.Transform[0][3] = 0.5f + posX; // X position with offset
1088-
desc.Transform[1][3] = posY; // Y position with offset
1089-
desc.Transform[2][3] = posZ; // Z position
1089+
desc.Transform[0][3] = posX;
1090+
desc.Transform[1][3] = posY;
1091+
desc.Transform[2][3] = posZ;
10901092

10911093
desc.InstanceMask = 1;
10921094
desc.AccelerationStructure = m_bottomLevelAccelerationStructureCube->GetGPUVirtualAddress();
@@ -1096,9 +1098,6 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
10961098
}
10971099
}
10981100

1099-
int treesPerRow = 30;
1100-
float spacingBetweenTrees = 1.9f;
1101-
11021101
// Trunk and leaves
11031102
// Store random positions for trunks
11041103
std::vector<std::tuple<float, float, float>> trunkPositions;
@@ -1112,9 +1111,9 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
11121111
float randomYOffset = randomOffset(gen);
11131112
float randomZOffset = randomOffset(gen);
11141113

1115-
float posX = x * spacingBetweenTrees + (randomXOffset / 6);
1114+
float posX = x * treeSpacing + (randomXOffset / 6);
11161115
float posY = 2.0f - (randomYOffset / 3);
1117-
float posZ = z * spacingBetweenTrees + (randomZOffset / 6);
1116+
float posZ = z * treeSpacing + (randomZOffset / 6);
11181117
trunkPositions.emplace_back(posX, posY, posZ);
11191118

11201119
// Trunk instance
@@ -1127,6 +1126,7 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
11271126
desc.Transform[0][3] = posX;
11281127
desc.Transform[1][3] = posY;
11291128
desc.Transform[2][3] = posZ;
1129+
11301130
desc.InstanceMask = 1;
11311131
desc.AccelerationStructure = m_bottomLevelAccelerationStructureTrunk->GetGPUVirtualAddress();
11321132
desc.InstanceID = static_cast<UINT>(instanceDesc.size());
@@ -1147,9 +1147,9 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
11471147
desc.Transform[2][2] = scale;
11481148

11491149
// Use the same position as the corresponding trunk
1150-
desc.Transform[0][3] = std::get<0>(trunkPositions[i]); // X position
1151-
desc.Transform[1][3] = std::get<1>(trunkPositions[i]); // Y position
1152-
desc.Transform[2][3] = std::get<2>(trunkPositions[i]); // Z position
1150+
desc.Transform[0][3] = std::get<0>(trunkPositions[i]);
1151+
desc.Transform[1][3] = std::get<1>(trunkPositions[i]);
1152+
desc.Transform[2][3] = std::get<2>(trunkPositions[i]);
11531153

11541154
desc.InstanceMask = 1;
11551155
desc.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE;
@@ -1179,10 +1179,9 @@ void D3D12RaytracingSakuraForestSER::BuildAccelerationStructures()
11791179
desc.Transform[1][1] = scale;
11801180
desc.Transform[2][2] = scale;
11811181

1182-
desc.Transform[0][3] = posX; // X position with offset
1183-
desc.Transform[1][3] = posY; // Y position with offset
1184-
desc.Transform[2][3] = posZ; // Z position
1185-
1182+
desc.Transform[0][3] = posX;
1183+
desc.Transform[1][3] = posY;
1184+
desc.Transform[2][3] = posZ;
11861185
desc.InstanceMask = 1;
11871186
desc.AccelerationStructure = m_bottomLevelAccelerationStructureBushes->GetGPUVirtualAddress();
11881187
desc.InstanceID = static_cast<UINT>(instanceDesc.size());

Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingSakuraForestSER/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SER is used to give hints to the GPU for grouping threads for better execution e
88
- **Sort by reflectHint**: A custom key derived from texture sampling on the floor, used to identify reflective regions such as dark crevices resembling water and cubes randomly in the space.
99
- **Sort by Both**: Combines HitObject and reflectHint .
1010

11+
**Note:** The scene applies a heavy workload to the skybox, which makes this element more expensive than in a typical game scenario. This characteristic contributes to the performance differences observed with Shader Execution Reordering in this sample.
12+
1113
The `reflectHint` is computed by sampling the floor texture at the estimated hit location. If the sampled color is sufficiently dark, the surface is treated as reflective, triggering additional shading logic such as Fresnel-based reflections. This technique mimics subtle water pooling effects in shaded areas.
1214
## Usage
1315
D3D12RaytracingBasicShaderExecutionReordering.exe

0 commit comments

Comments
 (0)