mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-13 17:09:05 -05:00
Set up for multipletextures in dataplane
This commit is contained in:
@@ -88,26 +88,28 @@ void CygnetPlane::render(const RenderData& data){
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
setUniforms();
|
||||
|
||||
setPscUniforms(*_shader.get(), data.camera, position);
|
||||
|
||||
ghoul::opengl::TextureUnit tfUnits;
|
||||
ghoul::opengl::TextureUnit tfUnits[_transferFunctions.size()];
|
||||
if(!_transferFunctions.empty()){
|
||||
if(_transferFunctions.size() == 1){
|
||||
tfUnits.activate();
|
||||
tfUnits[0].activate();
|
||||
_transferFunctions[0]->bind();
|
||||
_shader->setUniform("tf", tfUnits);
|
||||
_shader->setUniform("tf", tfUnits[0]);
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::opengl::TextureUnit txUnits;
|
||||
ghoul::opengl::TextureUnit txUnits[_textures.size()];
|
||||
if(_textures.size() == 1){
|
||||
txUnits.activate();
|
||||
txUnits[0].activate();
|
||||
_textures[0]->bind();
|
||||
_shader->setUniform("texture1", txUnits);
|
||||
}
|
||||
_shader->setUniform("texture1", txUnits[0]);
|
||||
}
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
protected:
|
||||
virtual bool loadTexture() = 0;
|
||||
virtual bool updateTexture() = 0;
|
||||
virtual void setUniforms() = 0;
|
||||
|
||||
void createPlane();
|
||||
void destroyPlane();
|
||||
|
||||
@@ -173,6 +173,11 @@ bool DataPlane::updateTexture(){
|
||||
return false;
|
||||
}
|
||||
|
||||
void DataPlane::setUniforms(){
|
||||
_shader->setUniform("numTextures", (int) _textures.size());
|
||||
_shader->setUniform("averageValues", false);
|
||||
};
|
||||
|
||||
void DataPlane::readHeader(){
|
||||
if(!_memorybuffer.empty()){
|
||||
std::stringstream memorystream(_memorybuffer);
|
||||
|
||||
@@ -46,6 +46,8 @@ class DataPlane : public CygnetPlane {
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override;
|
||||
|
||||
void readHeader();
|
||||
float* readData();
|
||||
void processData(
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override {};
|
||||
|
||||
static int id();
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
private:
|
||||
virtual bool loadTexture() override;
|
||||
virtual bool updateTexture() override;
|
||||
virtual void setUniforms() override {};
|
||||
|
||||
static int id();
|
||||
};
|
||||
|
||||
@@ -22,8 +22,14 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
uniform float time;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D textures[10];
|
||||
uniform sampler2D tf;
|
||||
uniform sampler2D tfs[10];
|
||||
|
||||
uniform int numTextures;
|
||||
uniform bool averageValues;
|
||||
|
||||
// uniform float background;
|
||||
|
||||
@@ -36,12 +42,24 @@ in vec4 vs_position;
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse;
|
||||
vec4 diffuse = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
float v;
|
||||
if(numTextures > 1){
|
||||
for(uint i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
diffuse += texture(tfs[i], vec2(v,0));
|
||||
}
|
||||
}else{
|
||||
v = texture(texture1, vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
diffuse = texture(tf, vec2(v,0));
|
||||
}
|
||||
|
||||
if(averageValues){
|
||||
diffuse /= numTextures;
|
||||
}
|
||||
|
||||
// diffuse = texture(tf, vec2(1-vs_st.s, 0));
|
||||
// diffuse = texture(tf, texture(texture1, vec2(vs_st.s,1-vs_st.t)).r);
|
||||
float v = texture(texture1, vec2(vs_st.s, 1-vs_st.t)).r;
|
||||
diffuse = texture(tf, vec2(v,0));
|
||||
|
||||
// if (diffuse.a <= 0.05)
|
||||
// discard;
|
||||
|
||||
Reference in New Issue
Block a user