mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
test clouds
This commit is contained in:
parent
cf69d3e8f4
commit
e24a5db97a
7 changed files with 409 additions and 69 deletions
|
|
@ -130,21 +130,22 @@ void Shadows::refresh(
|
|||
const std::function<void(Camera&)>& renderShadowPass
|
||||
) {
|
||||
static int frameid = 0;
|
||||
if (shadows) {
|
||||
if (frameid % 2 == 0) {
|
||||
generateShadowsMap(
|
||||
camera, pctx, *shadowMap, shadowCamera, 1.0f, renderShadowPass
|
||||
);
|
||||
} else {
|
||||
generateShadowsMap(
|
||||
camera,
|
||||
pctx,
|
||||
*wideShadowMap,
|
||||
wideShadowCamera,
|
||||
3.0f,
|
||||
renderShadowPass
|
||||
);
|
||||
}
|
||||
if (!shadows) {
|
||||
return;
|
||||
}
|
||||
if (frameid % 2 == 0) {
|
||||
generateShadowsMap(
|
||||
camera, pctx, *shadowMap, shadowCamera, 1.0f, renderShadowPass
|
||||
);
|
||||
} else {
|
||||
generateShadowsMap(
|
||||
camera,
|
||||
pctx,
|
||||
*wideShadowMap,
|
||||
wideShadowCamera,
|
||||
3.0f,
|
||||
renderShadowPass
|
||||
);
|
||||
}
|
||||
frameid++;
|
||||
}
|
||||
|
|
@ -176,10 +177,7 @@ void Shadows::generateShadowsMap(
|
|||
shadowCamera.setAspectRatio(1.0f);
|
||||
|
||||
float t = worldInfo.daytime - 0.25f;
|
||||
if (t < 0.0f) {
|
||||
t += 1.0f;
|
||||
}
|
||||
t = fmod(t, 0.5f);
|
||||
t = glm::mod(t < 0.0f ? t + 1.0f : t, 0.5f);
|
||||
|
||||
float sunCycleStep = 1.0f / 500.0f;
|
||||
float sunAngle = glm::radians(
|
||||
|
|
@ -206,15 +204,13 @@ void Shadows::generateShadowsMap(
|
|||
|
||||
shadowCamera.setProjection(glm::ortho(min.x, max.x, min.y, max.y, 0.1f, 1000.0f));
|
||||
|
||||
{
|
||||
auto sctx = pctx.sub();
|
||||
sctx.setDepthTest(true);
|
||||
sctx.setCullFace(true);
|
||||
sctx.setViewport({resolution, resolution});
|
||||
shadowMap.bind();
|
||||
if (renderShadowPass) {
|
||||
renderShadowPass(shadowCamera);
|
||||
}
|
||||
shadowMap.unbind();
|
||||
auto sctx = pctx.sub();
|
||||
sctx.setDepthTest(true);
|
||||
sctx.setCullFace(true);
|
||||
sctx.setViewport({resolution, resolution});
|
||||
shadowMap.bind();
|
||||
if (renderShadowPass) {
|
||||
renderShadowPass(shadowCamera);
|
||||
}
|
||||
shadowMap.unbind();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue