mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Fixed color issue of in texture in frag
Co-Authored-By: Emil Wallberg <49481622+EmilWallberg@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <modules/base/basemodule.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
@@ -98,6 +99,8 @@ namespace openspace {
|
||||
_warpTableTex = nullptr;
|
||||
_environmentTexture = nullptr;
|
||||
_viewport.viewGrid = nullptr;
|
||||
BaseModule::ProgramObjectManager.release(_program);
|
||||
_program = nullptr;
|
||||
glDeleteBuffers(1, &_quadVbo);
|
||||
glDeleteVertexArrays(1, &_quadVao);
|
||||
}
|
||||
@@ -230,10 +233,16 @@ namespace openspace {
|
||||
}
|
||||
|
||||
void RenderableBlackHole::setupShaders() {
|
||||
_program = ghoul::opengl::ProgramObject::Build(
|
||||
|
||||
_program = BaseModule::ProgramObjectManager.request(
|
||||
"BlackHoleProgram",
|
||||
absPath("${MODULE_BLACKHOLE}/shaders/blackhole_vs.glsl"),
|
||||
absPath("${MODULE_BLACKHOLE}/shaders/blackhole_fs.glsl")
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return global::renderEngine->buildRenderProgram(
|
||||
"BlackHoleProgram",
|
||||
absPath("${MODULE_BLACKHOLE}/shaders/blackhole_vs.glsl"),
|
||||
absPath("${MODULE_BLACKHOLE}/shaders/blackhole_fs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache);
|
||||
@@ -301,7 +310,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
void RenderableBlackHole::bindSSBOData(
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject>& program,
|
||||
ghoul::opengl::ProgramObject* program,
|
||||
const std::string& ssboName,
|
||||
std::unique_ptr<ghoul::opengl::BufferBinding<ghoul::opengl::bufferbinding::Buffer::ShaderStorage>>& ssboBinding,
|
||||
GLuint& ssboID
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace openspace {
|
||||
private:
|
||||
void SendSchwarzschildTableToShader();
|
||||
void SendStarKDTreeToShader();
|
||||
void bindSSBOData(std::unique_ptr<ghoul::opengl::ProgramObject>& program,
|
||||
void bindSSBOData(ghoul::opengl::ProgramObject* program,
|
||||
const std::string& ssboName,
|
||||
std::unique_ptr<ghoul::opengl::BufferBinding<ghoul::opengl::bufferbinding::Buffer::ShaderStorage>>& ssboBinding,
|
||||
GLuint& ssboID); void bindFramebuffer();
|
||||
@@ -42,7 +42,7 @@ namespace openspace {
|
||||
void setupQuad();
|
||||
void loadEnvironmentTexture();
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program = nullptr;
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _cullProgram = nullptr;
|
||||
glm::dvec3 _chachedTranslation{};
|
||||
size_t _rayCount = 500;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
//#include "fragment.glsl"
|
||||
|
||||
#version __CONTEXT__
|
||||
#include "fragment.glsl"
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
|
||||
#define SHOW_BLACK_HOLE 1
|
||||
|
||||
#define hash
|
||||
@@ -16,8 +13,6 @@ uniform mat4 cameraRotationMatrix;
|
||||
uniform mat4 worldRotationMatrix;
|
||||
uniform float r_0;
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
|
||||
layout (std430) buffer ssbo_warp_table {
|
||||
float schwarzschildWarpTable[];
|
||||
};
|
||||
@@ -339,7 +334,8 @@ vec4 searchNearestStar(vec3 sphericalCoords, int layer) {
|
||||
Fragment shader
|
||||
***********************************************************/
|
||||
|
||||
void main() {
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
vec4 viewCoords = normalize(vec4(texture(viewGrid, TexCoord).xy, VIEWGRIDZ, 0.0f));
|
||||
|
||||
@@ -359,8 +355,8 @@ void main() {
|
||||
|
||||
if (isnan(envMapSphericalCoords.x)) {
|
||||
// If inside the event horizon
|
||||
finalColor = vec4(0.0f);
|
||||
return;
|
||||
frag.color = vec4(0.0f);
|
||||
return frag;
|
||||
}
|
||||
|
||||
vec4 envMapCoords = vec4(sphericalToCartesian(envMapSphericalCoords.x, envMapSphericalCoords.y), 0.0f);
|
||||
@@ -383,6 +379,7 @@ void main() {
|
||||
vec2 uv = sphericalToUV(sphericalCoords);
|
||||
vec4 texColor = texture(environmentTexture, uv);
|
||||
|
||||
finalColor.rgb = accumulatedColor.rgb * accumulatedWeight + texColor.rgb * (1.0 - accumulatedWeight);
|
||||
finalColor.a = 1.0;
|
||||
frag.color.rgb = accumulatedColor.rgb * accumulatedWeight + texColor.rgb * (1.0 - accumulatedWeight);
|
||||
frag.color.a = 1.0;
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#version __CONTEXT__
|
||||
#version 130
|
||||
|
||||
in vec2 aPos;
|
||||
in vec2 aTexCoord;
|
||||
|
||||
Reference in New Issue
Block a user