Fix cut-out transparency in Principled material
This commit is contained in:
committed by
Miroslaw Pawlowski
parent
54f060e660
commit
26de7347fa
@@ -141,9 +141,22 @@ std::vector<cpp::Material> PtPrincipledTex::buildMaterials(
|
||||
setTexture<float>(materials.back(), "backlight", texR, 2.f);
|
||||
}
|
||||
|
||||
materials.push_back(cpp::Material("principled"));
|
||||
materials.back().setParam("baseColor", vec3f(1.f, 0.8f, 0.7f));
|
||||
setTexture<vec3f>(materials.back(), "emissiveColor", texRGBA);
|
||||
{
|
||||
// emissive
|
||||
materials.push_back(cpp::Material("principled"));
|
||||
materials.back().setParam("baseColor", vec3f(1.f, 0.8f, 0.7f));
|
||||
setTexture<vec3f>(materials.back(), "emissiveColor", texRGBA);
|
||||
|
||||
// transparency
|
||||
materials.push_back(cpp::Material("principled"));
|
||||
materials.back().setParam("baseColor", vec3f(0.860f, 0.0258f, 0.0536f));
|
||||
setTexture<vec3f>(materials.back(), "baseColor", texRGBA);
|
||||
|
||||
// opacity
|
||||
materials.push_back(cpp::Material("principled"));
|
||||
materials.back().setParam("baseColor", vec3f(0.860f, 0.0258f, 0.0536f));
|
||||
setTexture<float>(materials.back(), "opacity", texR);
|
||||
}
|
||||
|
||||
return materials;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ static cpp::Texture makeCheckerboardTextureRGBA8()
|
||||
index_sequence_2D idx(vec2i(width, height));
|
||||
for (auto i : idx) {
|
||||
uint8_t v = ((i.x & 2) ^ (i.y & 2)) * 255;
|
||||
dbyte[idx.flatten(i)] = vec4uc(v, v, v, 255);
|
||||
dbyte[idx.flatten(i)] = vec4uc(v, v, v, 128 + v / 2);
|
||||
}
|
||||
|
||||
// Create texture object
|
||||
@@ -202,8 +202,10 @@ inline cpp::World PtTex::buildWorld() const
|
||||
cpp::Texture texRGBA = makeCheckerboardTextureRGBA8();
|
||||
|
||||
std::vector<cpp::Material> materials = buildMaterials(texR, texRGBA);
|
||||
const int dimCount = sqrtf(materials.size());
|
||||
const int dimSize = dimCount - 1;
|
||||
size_t dimCount = sqrtf(materials.size());
|
||||
if (dimCount * dimCount < materials.size())
|
||||
dimCount++;
|
||||
const size_t dimSize = dimCount - 1;
|
||||
|
||||
cpp::Geometry sphereGeometry = makeSphereMesh(25, 50);
|
||||
|
||||
@@ -212,10 +214,12 @@ inline cpp::World PtTex::buildWorld() const
|
||||
box3f bbox(empty);
|
||||
index_sequence_2D numSpheres(dimCount);
|
||||
for (auto i : numSpheres) {
|
||||
const auto idx = numSpheres.flatten(i);
|
||||
if (idx >= materials.size())
|
||||
break;
|
||||
// Construct GeometricModel for each instance
|
||||
cpp::GeometricModel model(sphereGeometry);
|
||||
model.setParam(
|
||||
"material", cpp::CopiedData(materials[numSpheres.flatten(i)]));
|
||||
model.setParam("material", cpp::CopiedData(materials[idx]));
|
||||
model.commit();
|
||||
|
||||
// Construct Group for each instance
|
||||
|
||||
@@ -415,7 +415,8 @@ SYCL_EXTERNAL const varying BSDF *uniform Principled_getBSDF(
|
||||
}
|
||||
|
||||
// cut-out transparency
|
||||
if (1.f - self->opacity > EPS) {
|
||||
if (1.f - self->opacity > EPS || valid(self->opacityMap)
|
||||
|| hasAlpha(self->baseColorMap)) {
|
||||
const float transparency = 1.f - opacity;
|
||||
Transmission_Constructor(
|
||||
&bsdf->transmission, frame, make_vec3f(transparency));
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
87a2eff0c9ec4aeb40263168aa2c1d81
|
||||
41ddb4e5febf2144fec35803a200103e
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
b1eae3b5638b160aa9ab8d9fc1342ea2
|
||||
c268dbb557f08c8184fdf69bfe51d4e1
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
87a2eff0c9ec4aeb40263168aa2c1d81
|
||||
41ddb4e5febf2144fec35803a200103e
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
b1eae3b5638b160aa9ab8d9fc1342ea2
|
||||
c268dbb557f08c8184fdf69bfe51d4e1
|
||||
|
||||
Reference in New Issue
Block a user