提交 e1db1cbe 编写于 作者: M Matt Pharr

Material improvements.

Allow multiply-nested MixMaterials in the GPU path.
Switch to Repeat texture mode for bump maps (Amazon bistro expects this).
上级 21dce278
......@@ -189,9 +189,10 @@ static __forceinline__ __device__ void ProcessClosestIntersection(
MaterialHandle material = intr.material;
const MixMaterial *mix = material.CastOrNullptr<MixMaterial>();
if (mix) {
MaterialEvalContext ctx(intr);
material = mix->ChooseMaterial(BasicTextureEvaluator(), ctx);
while (mix) {
MaterialEvalContext ctx(intr);
material = mix->ChooseMaterial(BasicTextureEvaluator(), ctx);
mix = material.CastOrNullptr<MixMaterial>();
}
if (!material) {
......
......@@ -108,12 +108,7 @@ MixMaterial *MixMaterial::Create(MaterialHandle materials[2],
// Check for this stuff here, where we can include the FileLoc in
// the error message. Note that both of these limitations could be
// relaxed if they were problematic; the issue is that we currently
// resolve MixMaterials in the closest hit shader, where we'd like
// to, for example, not introduce the complexity of potentially
// recursively evaluating textures, etc.
if (materials[0].Is<MixMaterial>() || materials[1].Is<MixMaterial>())
ErrorExit(loc, "The GPU renderer doesn't currently support using "
"\"mix\" materials as parameters to the \"mix\" material.");
// resolve MixMaterials in the closest hit shader...
if (!BasicTextureEvaluator().CanEvaluate({amount}, {}))
ErrorExit(loc, "The GPU renderer currently only supports basic textures "
"for its \"amount\" parameter.");
......
......@@ -117,10 +117,11 @@ PBRT_CPU_GPU void Bump(TextureEvaluator texEval, FloatTextureHandle displacement
} else {
// Sample normal map to compute shading normal
WrapMode2D wrap(WrapMode::Repeat);
Point2f uv(ctx.uv[0], 1 - ctx.uv[1]);
Vector3f ns(2 * normalMap->BilerpChannel(uv, 0) - 1,
2 * normalMap->BilerpChannel(uv, 1) - 1,
2 * normalMap->BilerpChannel(uv, 2) - 1);
Vector3f ns(2 * normalMap->BilerpChannel(uv, 0, wrap) - 1,
2 * normalMap->BilerpChannel(uv, 1, wrap) - 1,
2 * normalMap->BilerpChannel(uv, 2, wrap) - 1);
ns = Normalize(ns);
Frame frame = Frame::FromZ(ctx.shading.n);
ns = frame.FromLocal(ns);
......@@ -345,7 +346,7 @@ class MixMaterial {
if (amt >= 1)
return materials[1];
Float u = uint32_t(Hash(ctx.p, ctx.wo)) * 0x1p-32;
Float u = uint32_t(Hash(ctx.p, ctx.wo, materials[0], materials[1])) * 0x1p-32;
return (amt < u) ? materials[0] : materials[1];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册