Added view distance blending in opengl renderer
This commit is contained in:
parent
74e707a989
commit
3d54ce974a
4 changed files with 13 additions and 2 deletions
|
@ -15,6 +15,8 @@ OpenGLRenderer::OpenGLRenderer(Scenery* scenery):
|
|||
functions = new OpenGLFunctions();
|
||||
shared_state = new OpenGLSharedState();
|
||||
|
||||
shared_state->set("viewDistance", 20.0);
|
||||
|
||||
skybox = new OpenGLSkybox(this);
|
||||
water = new OpenGLWater(this);
|
||||
terrain = new OpenGLTerrain(this);
|
||||
|
@ -84,6 +86,9 @@ void OpenGLRenderer::paint()
|
|||
functions->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
functions->glEnable(GL_BLEND);
|
||||
functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
skybox->render();
|
||||
terrain->render();
|
||||
water->render();
|
||||
|
|
|
@ -57,8 +57,8 @@ void OpenGLTerrain::initialize()
|
|||
program->addFragmentSource("terrain");
|
||||
|
||||
// Add terrain chunks
|
||||
int chunks = 20;
|
||||
double size = 400.0;
|
||||
int chunks = 25;
|
||||
double size = 800.0;
|
||||
double chunksize = size / (double) chunks;
|
||||
double start = -size / 2.0;
|
||||
double water_height = renderer->getWaterRenderer()->getHeightInfo().base_height;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
uniform sampler2D groundTexture;
|
||||
varying vec2 texcoord;
|
||||
uniform float viewDistance;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
@ -27,4 +28,6 @@ void main(void)
|
|||
gl_FragColor = gl_FragColor * vec4(attenuation, 0.0) + vec4(inscattering, 0.0);
|
||||
|
||||
gl_FragColor = _toneMappingUncharted(gl_FragColor, 2.0);
|
||||
|
||||
gl_FragColor.a = mix(1.0, 0.0, clamp((t - viewDistance * 0.8) / (viewDistance * 0.2), 0.0, 1.0));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
uniform vec4 waterColor;
|
||||
uniform float viewDistance;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
@ -26,4 +27,6 @@ void main(void)
|
|||
gl_FragColor = gl_FragColor * vec4(attenuation, 0.0) + vec4(inscattering, 0.0);
|
||||
|
||||
gl_FragColor = _toneMappingUncharted(gl_FragColor, 2.0);
|
||||
|
||||
gl_FragColor.a = mix(1.0, 0.0, clamp((t - viewDistance * 0.8) / (viewDistance * 0.2), 0.0, 1.0));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue