Skip to content

Commit 736b457

Browse files
committed
Add Medium testrender reference images.
1 parent 422b3fe commit 736b457

11 files changed

Lines changed: 103 additions & 70 deletions

File tree

src/testrender/shading.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,22 +1553,21 @@ struct HenyeyGreenstein final : public BSDF {
15531553
Vec3 wi = frame.toworld(local_wi);
15541554
float pdf_val = PhaseHG(cos_theta, g);
15551555

1556-
Color3 weight = Color3(1.0f);
1557-
return { wi, weight, pdf_val, 0.0f };
1556+
return { wi, Color3(1.0f), pdf_val, 0.0f };
15581557
}
15591558

15601559
};
15611560

1562-
struct HomogeneousVolume final : public Medium {
1561+
struct HomogeneousMedium final : public Medium {
15631562
MediumParams params;
15641563

1565-
OSL_HOSTDEVICE HomogeneousVolume(const MediumParams& params)
1564+
OSL_HOSTDEVICE HomogeneousMedium(const MediumParams& params)
15661565
: Medium(this), params(params)
15671566
{
15681567
}
15691568

1570-
OSL_HOSTDEVICE static HomogeneousVolume* create(void* storage, const MediumParams& params) {
1571-
HomogeneousVolume* volume = new (storage) HomogeneousVolume(params);
1569+
OSL_HOSTDEVICE static HomogeneousMedium* create(void* storage, const MediumParams& params) {
1570+
HomogeneousMedium* volume = new (storage) HomogeneousMedium(params);
15721571
volume->phase_func = new HenyeyGreenstein(params.medium_g);
15731572
return volume;
15741573
}
@@ -1578,12 +1577,11 @@ struct HomogeneousVolume final : public Medium {
15781577
Vec3 rand_vol = sampler.get();
15791578

15801579
float t_volume = -logf(1.0f - rand_vol.x) / params.avg_sigma_t();
1581-
bool volume_scatter = (t_volume < hit.t);
15821580

15831581
Color3 weight;
15841582
Color3 tr;
15851583

1586-
if (volume_scatter) {
1584+
if (t_volume < hit.t) {
15871585
r.origin = r.point(t_volume);
15881586
tr = transmittance(t_volume);
15891587

@@ -1599,7 +1597,7 @@ struct HomogeneousVolume final : public Medium {
15991597
);
16001598
}
16011599

1602-
return Medium::Sample { volume_scatter, t_volume, tr, weight };
1600+
return Medium::Sample { t_volume, tr, weight };
16031601
}
16041602

16051603
OSL_HOSTDEVICE const MediumParams* get_params() const {
@@ -1614,22 +1612,22 @@ struct HomogeneousVolume final : public Medium {
16141612
}
16151613
};
16161614

1617-
struct EmptyVolume final : public Medium {
1615+
struct EmptyMedium final : public Medium {
16181616
MediumParams params;
16191617

1620-
OSL_HOSTDEVICE EmptyVolume(const MediumParams& params)
1618+
OSL_HOSTDEVICE EmptyMedium(const MediumParams& params)
16211619
: Medium(this), params(params)
16221620
{
16231621
}
16241622

1625-
OSL_HOSTDEVICE static EmptyVolume* create(void* storage, const MediumParams& params) {
1626-
EmptyVolume* volume = new (storage) EmptyVolume(params);
1623+
OSL_HOSTDEVICE static EmptyMedium* create(void* storage, const MediumParams& params) {
1624+
EmptyMedium* volume = new (storage) EmptyMedium(params);
16271625
return volume;
16281626
}
16291627

16301628
OSL_HOSTDEVICE Medium::Sample sample(Ray& ray, Sampler &sampler, Intersection& hit) const
16311629
{
1632-
return { false, 0.0f, Color3(1.0f), Color3(1.0f) };
1630+
return { 0.0f, Color3(1.0f), Color3(1.0f) };
16331631
}
16341632

16351633
OSL_HOSTDEVICE const MediumParams* get_params() const {
@@ -1781,9 +1779,9 @@ process_medium_closure(const ShaderGlobalsType& sg, float path_roughness,
17811779

17821780
if (!sg.backfacing) { // if entering
17831781
if (result.medium_data.is_vaccum()) {
1784-
medium_stack.add_medium<EmptyVolume>(result.medium_data);
1782+
medium_stack.add_medium<EmptyMedium>(result.medium_data);
17851783
} else {
1786-
medium_stack.add_medium<HomogeneousVolume>(result.medium_data);
1784+
medium_stack.add_medium<HomogeneousMedium>(result.medium_data);
17871785
}
17881786
}
17891787

@@ -1810,9 +1808,9 @@ process_medium_closure(const ShaderGlobalsType& sg, float path_roughness,
18101808

18111809
if (!sg.backfacing) { // if entering
18121810
if (result.medium_data.is_vaccum()) {
1813-
medium_stack.add_medium<EmptyVolume>(result.medium_data);
1811+
medium_stack.add_medium<EmptyMedium>(result.medium_data);
18141812
} else {
1815-
medium_stack.add_medium<HomogeneousVolume>(result.medium_data);
1813+
medium_stack.add_medium<HomogeneousMedium>(result.medium_data);
18161814
}
18171815
}
18181816

src/testrender/shading.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ struct CharlieSheen;
298298
struct SpiThinLayer;
299299
struct HenyeyGreenstein;
300300

301-
struct HomogeneousVolume;
302-
struct EmptyVolume;
301+
struct HomogeneousMedium;
302+
struct EmptyMedium;
303303

304304
// StaticVirtual generates a switch/case dispatch method for us given
305305
// a list of possible subtypes. We just need to forward declare them.
@@ -312,7 +312,7 @@ using AbstractBSDF = bsdl::StaticVirtual<
312312
MxGeneralizedSchlickOpaque, MxGeneralizedSchlick, SpiThinLayer,
313313
HenyeyGreenstein>;
314314

315-
using AbstractMedium = bsdl::StaticVirtual<HomogeneousVolume, EmptyVolume>;
315+
using AbstractMedium = bsdl::StaticVirtual<HomogeneousMedium, EmptyMedium>;
316316

317317
// Then we just need to inherit from AbstractBSDF or AbstractMedium
318318

@@ -382,18 +382,17 @@ struct has_equal<T, std::void_t<decltype(std::declval<const T&>() == std::declva
382382
struct Medium : public AbstractMedium {
383383
struct Sample {
384384
OSL_HOSTDEVICE Sample() :
385-
scatter(false), t(0.0f), transmittance(0.0f), weight(0.0f)
385+
t(0.0f), transmittance(0.0f), weight(0.0f)
386386
{
387387
}
388388
OSL_HOSTDEVICE Sample(const Sample& o) :
389-
scatter(o.scatter), t(o.t), transmittance(o.transmittance), weight(o.weight)
389+
t(o.t), transmittance(o.transmittance), weight(o.weight)
390390
{
391391
}
392-
OSL_HOSTDEVICE Sample(bool scatter, float t, Color3 transmittance, Color3 weight) :
393-
scatter(scatter), t(t), transmittance(transmittance), weight(weight)
392+
OSL_HOSTDEVICE Sample(float t, Color3 transmittance, Color3 weight) :
393+
t(t), transmittance(transmittance), weight(weight)
394394
{
395395
}
396-
bool scatter;
397396
float t;
398397
Color3 transmittance;
399398
Color3 weight;
@@ -571,21 +570,22 @@ struct MediumStack {
571570

572571
OSL_HOSTDEVICE int size() const { return depth; }
573572

574-
OSL_HOSTDEVICE bool integrate(Ray& r, Sampler& sampler, Intersection& hit, Color3& path_weight, Color3& path_radiance, float& bsdf_pdf) const
573+
OSL_HOSTDEVICE bool integrate(Ray& r, Sampler& sampler, Intersection& hit, Color3& path_weight, Color3& path_radiance, float& bsdf_pdf) const
575574
{
576575
if (depth <= 0) {
577576
return false;
578577
}
579578

580-
Medium::Sample combined_sample{ false, 1.0f, Color3(1.0f), Color3(1.0f) };
579+
Medium::Sample combined_sample{ 1.0f, Color3(1.0f), Color3(1.0f) };
580+
bool scatter = false;
581581

582582
for (int i = 0; i < depth; ++i) {
583583
Medium::Sample s = mediums[i]->sample_vrtl(r, sampler, hit);
584584

585585
combined_sample.transmittance *= s.transmittance;
586586
combined_sample.weight *= s.weight;
587587

588-
combined_sample.scatter = s.scatter || combined_sample.scatter;
588+
scatter = s.t < hit.t || scatter;
589589
combined_sample.t = s.t < combined_sample.t ? s.t : combined_sample.t;
590590
}
591591

@@ -596,8 +596,8 @@ struct MediumStack {
596596
path_weight *= combined_sample.transmittance;
597597

598598
Vec3 rand_phase = sampler.get();
599-
if (combined_sample.scatter) {
600-
if (!mediums[0]->phase_func) {
599+
if (scatter) {
600+
if (!mediums[0]->phase_func) { // EmptyMedium won't have one
601601
return false;
602602
}
603603
BSDF::Sample phase_sample = mediums[0]->phase_func->sample_vrtl(-r.direction,
171 KB
Binary file not shown.

testsuite/render-mx-anisotropic-vdf/scene.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<ShaderGroup>
2525
param color albedo 0.75 0.75 0.75;
26-
param float extinction 0.005;
26+
param float extinction 0.001;
2727
param float anisotropy 0.9;
2828

2929
shader anisotropic layer1;

testsuite/render-mx-medium-vdf-glass/glossy.osl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ glossy
3737
float alpha_x = alpha * (1.0 - anisotropy);
3838
float alpha_y = alpha;
3939
vector U = normalize(cross(N, dPdv));
40-
Ci = dielectric_bsdf(N, U, Cr, Ct, alpha_x, alpha_y, ior, "ggx") + medium_vdf(color(0.5), transmission_depth, Cr, 0.0, ior, priority);
40+
Ci = dielectric_bsdf(N, U, Cr, Ct, alpha_x, alpha_y, ior, "ggx") + medium_vdf(color(0.5), transmission_depth, color(0.5), 0.0, ior, priority);
4141
}
241 KB
Binary file not shown.

testsuite/render-mx-medium-vdf-glass/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
failthresh = 0.01
88
failpercent = 1
99
outputs = [ "out.exr" ]
10-
command = testrender("-r 196 196 -aa 16 scene.xml out.exr")
10+
command = testrender("-r 240 240 -aa 24 scene.xml out.exr")

testsuite/render-mx-medium-vdf-glass/scene.xml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,70 @@
1717

1818

1919

20-
<!-- Spheres testing priority -->
20+
<!-- Spheres testing special priority -->
2121
<ShaderGroup>
22-
color Cr 0.0 0.0 1.0;
22+
color Cr 1.0 1.0 1.0;
2323
float roughness 0.1;
2424
float anisotropy 0.0;
25-
float ior 1.2;
26-
int priority 1;
25+
float ior 1.1;
26+
int priority 0;
2727
float transmission_depth 100.0;
2828
float medium_anisotropy -1.0;
29-
int priority 1;
29+
int priority 0;
3030
shader glossy layer1;
3131
</ShaderGroup>
32-
<Sphere center="30,30,50" radius="20" />
32+
<Sphere center="40,70,70" radius="15" />
3333

3434
<ShaderGroup>
3535
color Cr 1.0 1.0 1.0;
36+
float roughness 0.1;
37+
float anisotropy 0.0;
38+
float ior 1.1;
39+
int priority 0;
40+
float transmission_depth 100.0;
41+
float medium_anisotropy -1.0;
42+
int priority 0;
43+
shader glossy layer1;
44+
</ShaderGroup>
45+
<Sphere center="60,70,70" radius="15" />
46+
47+
<!-- Spheres testing priority -->
48+
<ShaderGroup>
49+
color Cr 0.0 0.0 1.0;
50+
float roughness 0.1;
51+
float anisotropy 0.0;
52+
float ior 1.2;
53+
int priority 0;
54+
float transmission_depth 500.0;
55+
float medium_anisotropy 0.0;
56+
int priority 0;
57+
shader glossy layer1;
58+
</ShaderGroup>
59+
<Sphere center="30,30,70" radius="20" />
60+
61+
<ShaderGroup>
62+
color Cr 0.0 1.0 0.0;
3663
float roughness 0.2;
3764
float anisotropy 0.0;
38-
float ior 1.4;
39-
float transmission_depth 20.0;
65+
float ior 1.1;
66+
float transmission_depth 500.0;
4067
float medium_anisotropy 0.0;
41-
int priority 2;
68+
int priority 1;
4269
shader glossy layer1;
4370
</ShaderGroup>
44-
<Sphere center="50,50,50" radius="30" />
71+
<Sphere center="50,30,70" radius="20" />
4572

4673
<ShaderGroup>
4774
color Cr 1.0 0.0 0.0;
4875
float roughness 0.3;
4976
float anisotropy 0.0;
50-
float ior 1.8;
51-
float transmission_depth 50.0;
52-
float medium_anisotropy 1.0;
53-
int priority 3;
77+
float ior 1.1;
78+
float transmission_depth 500.0;
79+
float medium_anisotropy 0.0;
80+
int priority 2;
5481
shader glossy layer1;
5582
</ShaderGroup>
56-
<Sphere center="70,30,50" radius="20" />
83+
<Sphere center="70,30,70" radius="20" />
5784

5885

5986
</World>
138 KB
Binary file not shown.

testsuite/render-mx-medium-vdf/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
failthresh = 0.01
88
failpercent = 1
99
outputs = [ "out.exr" ]
10-
command = testrender("-v -r 160 240 -aa 64 scene.xml out.exr")
10+
command = testrender("-v -r 196 196 -aa 96 scene.xml out.exr")

0 commit comments

Comments
 (0)