Skip to content

Commit ffbdb30

Browse files
committed
metal: fix raytrace seed
1 parent 4f47226 commit ffbdb30

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

base/shaders/raytrace/raytrace_brute_core.metal

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,15 @@ kernel void raytracingKernel(
275275
texpaint1.g = -texpaint1.g;
276276
n = float3x3(tangent, binormal, n) * texpaint1.rgb;
277277

278-
uint bounce_seed = 0;
279-
float f = rand(tid.x, tid.y, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
280-
bounce_seed += 1;
278+
float f = rand(tid.x, tid.y, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
279+
thread_seed += 1;
281280

282281
#ifdef _TRANSLUCENCY
283282
float3 diffuse_dir = texpaint0.a < f ?
284-
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
285-
cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
283+
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
284+
cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
286285
#else
287-
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
286+
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288287
#endif
289288

290289
#ifdef _FRESNEL

base/shaders/raytrace/raytrace_brute_full.metal

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,15 @@ kernel void raytracingKernel(
277277
texpaint1.g = -texpaint1.g;
278278
n = float3x3(tangent, binormal, n) * texpaint1.rgb;
279279

280-
uint bounce_seed = 0;
281-
float f = rand(tid.x, tid.y, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
282-
bounce_seed += 1;
280+
float f = rand(tid.x, tid.y, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
281+
thread_seed += 1;
283282

284283
#ifdef _TRANSLUCENCY
285284
float3 diffuse_dir = texpaint0.a < f ?
286-
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
287-
cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
285+
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
286+
cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288287
#else
289-
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288+
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
290289
#endif
291290

292291
#ifdef _FRESNEL

base/shaders/raytrace/src/raytrace_brute_core.metal

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,15 @@ kernel void raytracingKernel(
275275
texpaint1.g = -texpaint1.g;
276276
n = float3x3(tangent, binormal, n) * texpaint1.rgb;
277277

278-
uint bounce_seed = 0;
279-
float f = rand(tid.x, tid.y, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
280-
bounce_seed += 1;
278+
float f = rand(tid.x, tid.y, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
279+
thread_seed += 1;
281280

282281
#ifdef _TRANSLUCENCY
283282
float3 diffuse_dir = texpaint0.a < f ?
284-
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
285-
cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
283+
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
284+
cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
286285
#else
287-
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
286+
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288287
#endif
289288

290289
#ifdef _FRESNEL

base/shaders/raytrace/src/raytrace_brute_full.metal

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,15 @@ kernel void raytracingKernel(
277277
texpaint1.g = -texpaint1.g;
278278
n = float3x3(tangent, binormal, n) * texpaint1.rgb;
279279

280-
uint bounce_seed = 0;
281-
float f = rand(tid.x, tid.y, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
282-
bounce_seed += 1;
280+
float f = rand(tid.x, tid.y, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
281+
thread_seed += 1;
283282

284283
#ifdef _TRANSLUCENCY
285284
float3 diffuse_dir = texpaint0.a < f ?
286-
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
287-
cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
285+
cos_weighted_hemisphere_direction(tid, ray.direction, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank) :
286+
cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288287
#else
289-
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, bounce_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
288+
float3 diffuse_dir = cos_weighted_hemisphere_direction(tid, n, payload.color.a, thread_seed, constant_buffer.eye.w, mytexture_sobol, mytexture_scramble, mytexture_rank);
290289
#endif
291290

292291
#ifdef _FRESNEL

0 commit comments

Comments
 (0)