mirror of
https://github.com/ZDoom/ZDRay.git
synced 2025-02-03 13:11:04 +00:00
- change the multisample option to sample in a more predictable manner
This commit is contained in:
parent
78a3da5b8c
commit
96d705fbef
2 changed files with 14 additions and 18 deletions
|
@ -417,18 +417,13 @@ void LightmapBuilder::TraceSurface(Surface *surface)
|
||||||
{
|
{
|
||||||
Vec3 c(0.0f, 0.0f, 0.0f);
|
Vec3 c(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
for (int k = 0; k < multisampleCount; k++)
|
int totalsamples = (multisampleCount * 2 + 1);
|
||||||
|
float scale = 0.5f / totalsamples;
|
||||||
|
for (int yy = -multisampleCount; yy <= multisampleCount; yy++)
|
||||||
{
|
{
|
||||||
Vec2 multisamplePos((float)j, (float)i);
|
for (int xx = -multisampleCount; xx <= multisampleCount; xx++)
|
||||||
if (k > 0)
|
|
||||||
{
|
{
|
||||||
multisamplePos.x += rand() / (float)RAND_MAX - 0.5f;
|
Vec2 multisamplePos((float)j + xx * scale, (float)i + yy * scale);
|
||||||
multisamplePos.y += rand() / (float)RAND_MAX - 0.5f;
|
|
||||||
multisamplePos.x = std::max(multisamplePos.x, 0.0f);
|
|
||||||
multisamplePos.y = std::max(multisamplePos.y, 0.0f);
|
|
||||||
multisamplePos.x = std::min(multisamplePos.x, (float)sampleWidth);
|
|
||||||
multisamplePos.y = std::min(multisamplePos.y, (float)sampleHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert the texel into world-space coordinates.
|
// convert the texel into world-space coordinates.
|
||||||
// this will be the origin in which a line will be traced from
|
// this will be the origin in which a line will be traced from
|
||||||
|
@ -436,8 +431,9 @@ void LightmapBuilder::TraceSurface(Surface *surface)
|
||||||
|
|
||||||
c += LightTexelSample(pos, surface);
|
c += LightTexelSample(pos, surface);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c /= multisampleCount;
|
c /= totalsamples * totalsamples;
|
||||||
|
|
||||||
colorSamples[i * sampleWidth + j] = c;
|
colorSamples[i * sampleWidth + j] = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,8 +449,8 @@ static void ParseArgs(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
Multisample = atoi(optarg);
|
Multisample = atoi(optarg);
|
||||||
if (Multisample <= 0) Multisample = 1;
|
if (Multisample <= 0) Multisample = 0;
|
||||||
if (Multisample > 64) Multisample = 64;
|
if (Multisample > 16) Multisample = 16;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
LightBounce = atoi(optarg);
|
LightBounce = atoi(optarg);
|
||||||
|
|
Loading…
Reference in a new issue