mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Hide the unset (black) bits.
This commit is contained in:
parent
6c15468c87
commit
c3c2265ddd
3 changed files with 20 additions and 8 deletions
|
@ -21,13 +21,13 @@ void main(void) {
|
|||
// transform and store the normal for interpolation
|
||||
normal = normalize(gl_ModelViewMatrix * vec4(0.0, 1.0, 0.0, 0.0));
|
||||
|
||||
// pass along the vertex color
|
||||
gl_FrontColor = gl_Color;
|
||||
|
||||
// pass along the texture coordinates
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
// add the height to the position
|
||||
gl_Position = gl_ModelViewProjectionMatrix * (gl_Vertex +
|
||||
vec4(0.0, texture2D(heightMap, gl_MultiTexCoord0.st).r, 0.0, 0.0));
|
||||
float height = texture2D(heightMap, gl_MultiTexCoord0.st).r;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * (gl_Vertex + vec4(0.0, height, 0.0, 0.0));
|
||||
|
||||
// the zero height should be invisible
|
||||
gl_FrontColor = vec4(1.0, 1.0, 1.0, step(height, 0.0));
|
||||
}
|
||||
|
|
|
@ -397,7 +397,11 @@ void HeightfieldBuffer::render() {
|
|||
QHash<int, HeightfieldBuffer::BufferPair> HeightfieldBuffer::_bufferPairs;
|
||||
|
||||
void HeightfieldPreview::render(const glm::vec3& translation, float scale) const {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.75f);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_EQUAL, 0.0f);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -418,6 +422,9 @@ void HeightfieldPreview::render(const glm::vec3& translation, float scale) const
|
|||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
BufferDataAttribute::BufferDataAttribute(const QString& name) :
|
||||
|
@ -695,7 +702,10 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox
|
|||
|
||||
_pointProgram.release();
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_EQUAL, 0.0f);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
_heightfieldProgram.bind();
|
||||
|
||||
|
@ -710,6 +720,7 @@ void DefaultMetavoxelRendererImplementation::render(MetavoxelData& data, Metavox
|
|||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
|
|
@ -578,7 +578,8 @@ bool HeightfieldAttribute::merge(void*& parent, void* children[], bool postRead)
|
|||
int childSizePlusOne = childSize + 1;
|
||||
for (int z = 0; z < halfSize; z++) {
|
||||
for (char* end = dest + halfSize; dest != end; src += 2) {
|
||||
*dest++ = yOffset + (qMax(qMax(src[0], src[1]), qMax(src[childSize], src[childSizePlusOne])) >> 1);
|
||||
int max = qMax(qMax(src[0], src[1]), qMax(src[childSize], src[childSizePlusOne]));
|
||||
*dest++ = (max == 0) ? 0 : (yOffset + (max >> 1));
|
||||
}
|
||||
dest += halfSize;
|
||||
src += childSize;
|
||||
|
|
Loading…
Reference in a new issue