...
This should result in a scene similar to:
...
PBR Materials Without Textures
It’s also possible to specify PBR materials without using textures or maps.
Code Block |
---|
void TestSimplePBR()
{
typedef struct { float r, g, b, a; } RGBA;
float sphereRadius = 0.8;
float sphereOffset = 2.0;
float factorOffset = 0.2;
int factorCount = 7;
float normalFactor = 0.0;
float metalFactor = 0.0;
float roughFactor = 0.0;
float occlusionFactor = 0.0;
float alphaFactor = 0.0;
HPoint position;
char segmentName[64];
RGBA cyan;
cyan.r = 0;
cyan.g = 1;
cyan.b = 1;
cyan.a = 1;
HC_Open_Segment("test"); {
sprintf(segmentName, "sphere baseline");
position.Set(0, 0, 0);
HC_Open_Segment(segmentName); {
HC_Insert_Sphere(&position, sphereRadius, nullptr, nullptr);
HC_Set_Color("faces = (r=0.0 g=1 b=1)");
} HC_Close_Segment();
HC_Open_Segment("spheres"); {
for (int i = 0; i < factorCount; ++i)
{
for (int j = 0; j < factorCount; ++j)
{
sprintf(segmentName, "sphere %d %d", i, j);
position.x += sphereOffset;
metalFactor = i * factorOffset;
roughFactor = j * factorOffset;
HC_Open_Segment(segmentName); {
HC_Insert_Sphere(&position, sphereRadius, nullptr, nullptr);
HC_Set_PBR_Material(nullptr, nullptr, nullptr, nullptr, 0, nullptr, 0, nullptr, 0, &cyan, normalFactor, metalFactor, roughFactor, occlusionFactor, alphaFactor, nullptr);
} HC_Close_Segment();
}
position.x = 0;
position.y += sphereOffset;
}
} HC_Close_Segment();
} HC_Close_Segment();
} |
This code produces a scene as follows where the rough factor changes from 0.0 to 1.0 moving from left to right and the metal factor change from 0.0 to 1.0 moving from the bottom to the top;
...
The bottom left sphere is a baseline using regular color for comparison.
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...