mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-14 15:40:19 -06:00
Added limit for screen size of renderablebillboards.
This commit is contained in:
@@ -9,7 +9,7 @@ return {
|
||||
Alpha = 0.4,
|
||||
Texture = "textures/DarkUniverse_mellinger_8k.jpg",
|
||||
Orientation = "Inside/Outside",
|
||||
FadeOutThreshould = 0.18
|
||||
FadeOutThreshould = 0.25
|
||||
},
|
||||
GuiPath = "/Milky Way/Milky Way"
|
||||
}
|
||||
|
||||
Submodule ext/ghoul updated: a6244a16f9...4dce717aac
@@ -650,6 +650,10 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, const g
|
||||
_program->setUniform("right", orthoRight);
|
||||
|
||||
_program->setUniform("fadeInValue", fadeInVariable);
|
||||
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
_program->setUniform("screenSize", glm::vec2(viewport[2], viewport[3]));
|
||||
|
||||
ghoul::opengl::TextureUnit spriteTextureUnit;
|
||||
if (_hasSpriteTexture) {
|
||||
|
||||
@@ -38,6 +38,7 @@ uniform dvec3 cameraPosition;
|
||||
uniform dvec3 cameraLookUp;
|
||||
uniform dvec4 centerScreenInWorldPosition;
|
||||
uniform int renderOption;
|
||||
uniform vec2 screenSize;
|
||||
|
||||
|
||||
in vec4 colorMap[];
|
||||
@@ -101,36 +102,70 @@ void main() {
|
||||
//dvec4 dpos = transformMatrix * dvec4(dvec3(pos.xyz) * unit, 1.0);
|
||||
dvec4 dpos = dvec4(dvec3(pos.xyz) * unit, 1.0);
|
||||
|
||||
texCoord = corners[0];
|
||||
// texCoord = corners[0];
|
||||
vec4 initialPosition = z_normalization(vec4(modelViewProjectionTransform *
|
||||
dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w)));
|
||||
vs_screenSpaceDepth = initialPosition.w;
|
||||
gl_Position = initialPosition;
|
||||
EmitVertex();
|
||||
// gl_Position = initialPosition;
|
||||
// EmitVertex();
|
||||
|
||||
texCoord = corners[1];
|
||||
gl_Position = z_normalization(vec4(modelViewProjectionTransform *
|
||||
// texCoord = corners[1];
|
||||
vec4 secondPosition = z_normalization(vec4(modelViewProjectionTransform *
|
||||
dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w)));
|
||||
EmitVertex();
|
||||
// gl_Position = secondPosition;
|
||||
// EmitVertex();
|
||||
|
||||
texCoord = corners[2];
|
||||
//texCoord = corners[2];
|
||||
vec4 crossCorner = z_normalization(vec4(modelViewProjectionTransform *
|
||||
dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w)));
|
||||
gl_Position = crossCorner;
|
||||
EmitVertex();
|
||||
EndPrimitive(); // First Triangle
|
||||
// gl_Position = crossCorner;
|
||||
// EmitVertex();
|
||||
// EndPrimitive(); // First Triangle
|
||||
|
||||
texCoord = corners[0];
|
||||
gl_Position = initialPosition;
|
||||
EmitVertex();
|
||||
// texCoord = corners[0];
|
||||
// gl_Position = initialPosition;
|
||||
// EmitVertex();
|
||||
|
||||
texCoord = corners[2];
|
||||
gl_Position = crossCorner;
|
||||
EmitVertex();
|
||||
// texCoord = corners[2];
|
||||
// gl_Position = crossCorner;
|
||||
// EmitVertex();
|
||||
|
||||
texCoord = corners[3];
|
||||
gl_Position = z_normalization(vec4(modelViewProjectionTransform *
|
||||
// texCoord = corners[3];
|
||||
vec4 thirdPosition = z_normalization(vec4(modelViewProjectionTransform *
|
||||
dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w)));
|
||||
EmitVertex();
|
||||
EndPrimitive(); // Second Triangle
|
||||
// gl_Position = thirdPosition;
|
||||
// EmitVertex();
|
||||
// EndPrimitive(); // Second Triangle
|
||||
|
||||
// Testing size:
|
||||
vec4 topLeft = thirdPosition/thirdPosition.w;
|
||||
topLeft = ((topLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0);
|
||||
vec4 bottomLeft = initialPosition/initialPosition.w;
|
||||
bottomLeft = ((bottomLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0);
|
||||
|
||||
if ((topLeft.y - bottomLeft.y) > (0.2 * screenSize.y)) {
|
||||
return;
|
||||
} else {
|
||||
// Build primitive
|
||||
texCoord = corners[0];
|
||||
gl_Position = initialPosition;
|
||||
EmitVertex();
|
||||
texCoord = corners[1];
|
||||
gl_Position = secondPosition;
|
||||
EmitVertex();
|
||||
texCoord = corners[2];
|
||||
gl_Position = crossCorner;
|
||||
EmitVertex();
|
||||
EndPrimitive(); // First Triangle
|
||||
texCoord = corners[0];
|
||||
gl_Position = initialPosition;
|
||||
EmitVertex();
|
||||
texCoord = corners[2];
|
||||
gl_Position = crossCorner;
|
||||
EmitVertex();
|
||||
texCoord = corners[3];
|
||||
gl_Position = thirdPosition;
|
||||
EmitVertex();
|
||||
EndPrimitive(); // Second Triangle
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user