Skip to content

Commit 90e96c2

Browse files
committed
path tracing crash fix when there are no instances
1 parent 8db4b09 commit 90e96c2

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

WickedEngine/shaders/raytraceCS.hlsl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,18 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
6565
ray.Direction = normalize(ray.Direction);
6666

6767
float4 additive_dist = float4(0, 0, 0, FLT_MAX);
68-
68+
6969
#ifdef RTAPI
7070
wiRayQuery q;
71+
#else
72+
RayHit hit;
73+
#endif // RTAPI
74+
75+
bool exit_sky = GetScene().instanceCount == 0;
76+
77+
if(!exit_sky)
78+
{
79+
#ifdef RTAPI
7180

7281
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES;
7382
#ifdef RAY_BACKFACE_CULLING
@@ -115,13 +124,15 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
115124
result += max(0, energy * additive_dist.xyz);
116125
}
117126

118-
if (q.CommittedStatus() != COMMITTED_TRIANGLE_HIT)
127+
exit_sky = q.CommittedStatus() != COMMITTED_TRIANGLE_HIT;
119128
#else
120-
RayHit hit = TraceRay_Closest(ray, xTraceUserData.y, rng, groupIndex);
129+
hit = TraceRay_Closest(ray, xTraceUserData.y, rng, groupIndex);
121130

122-
if (hit.distance >= FLT_MAX - 1)
131+
exit_sky = hit.distance >= FLT_MAX - 1;
123132
#endif // RTAPI
133+
}
124134

135+
if (exit_sky)
125136
{
126137
float3 envColor;
127138
[branch]

WickedEngine/wiVersion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace wi::version
99
// minor features, major updates, breaking compatibility changes
1010
const int minor = 71;
1111
// minor bug fixes, alterations, refactors, updates
12-
const int revision = 583;
12+
const int revision = 584;
1313

1414
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
1515

@@ -50,7 +50,7 @@ All contributors: https://github.com/turanszkij/WickedEngine/graphs/contributors
5050
5151
Patreon supporters
5252
---------------------------
53-
Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad, ykl, Alex Krokos, Timmy, Avaflow, mat, Hexegonel Samael Michael, Joe Spataro, soru, GeniokV, Mammoth, Ignacio, datae, Jason Rice, MarsBEKET, Tim, Twisty, Zelf ieats kiezen, Romildo Franco, zNachoh, Dmitriy, Alex Minerva, Stefan Kent, Natty, Sunny Krishna
53+
Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad, ykl, Alex Krokos, Timmy, Avaflow, mat, Hexegonel Samael Michael, Joe Spataro, soru, GeniokV, Mammoth, Ignacio, datae, Jason Rice, MarsBEKET, Tim, Twisty, Zelf ieats kiezen, Romildo Franco, zNachoh, Dmitriy, Alex Minerva, Stefan Kent, Natty, Sunny Krishna, Vilmos Malárik, Ferrata
5454
)";
5555

5656
return credits;

0 commit comments

Comments
 (0)