MCPcopy Create free account
hub / github.com/RenderKit/embree / sample_component2

Function sample_component2

tutorials/pathtracer/pathtracer_device.cpp:131–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131inline Vec3fa sample_component2(const Vec3fa& c0, const Sample3f& wi0, const Medium& medium0,
132 const Vec3fa& c1, const Sample3f& wi1, const Medium& medium1,
133 const Vec3fa& Lw, Sample3f& wi_o, Medium& medium_o, const float s)
134{
135 const Vec3fa m0 = Lw*c0/wi0.pdf;
136 const Vec3fa m1 = Lw*c1/wi1.pdf;
137
138 const float C0 = wi0.pdf == 0.0f ? 0.0f : max(max(m0.x,m0.y),m0.z);
139 const float C1 = wi1.pdf == 0.0f ? 0.0f : max(max(m1.x,m1.y),m1.z);
140 const float C = C0 + C1;
141
142 if (C == 0.0f) {
143 wi_o = make_Sample3f(Vec3fa(0,0,0),0);
144 return Vec3fa(0,0,0);
145 }
146
147 const float CP0 = C0/C;
148 const float CP1 = C1/C;
149 if (s < CP0) {
150 wi_o = make_Sample3f(wi0.v,wi0.pdf*CP0);
151 medium_o = medium0; return c0;
152 }
153 else {
154 wi_o = make_Sample3f(wi1.v,wi1.pdf*CP1);
155 medium_o = medium1; return c1;
156 }
157}
158
159////////////////////////////////////////////////////////////////////////////////
160// Minneart BRDF //

Callers 4

VelvetMaterial__sampleFunction · 0.85

Calls 3

make_Sample3fFunction · 0.85
maxFunction · 0.50
Vec3faClass · 0.50

Tested by

no test coverage detected