Hi,
I’ve recently noticed some unknown behaviour on an AMD Card. Previously I’ve been using nvidia cards & everythings worked absolutely fine, but having swapped to an AMD Radeon R9 270x (latest catalyst drivers), I’ve been having nothing but trouble.
The current thing that’s proving difficult is binding multiple textures to a shader. On nvidia this has been working perfectly for me in an app, but now I can’t seem to get it to respect the binds. I’ve distilled it to a super basic working app case, and still no luck;
Cinder Test App:
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class MultiBindApp : public App {
public:
void setup() override;
void update() override;
void draw() override;
void LoadShaders();
gl::GlslProgRef Multibind;
gl::Texture2dRef TexA;
gl::Texture2dRef TexB;
};
void MultiBindApp::LoadShaders() {
Multibind = gl::GlslProg::create(loadAsset("mbind.vert"), loadAsset("mBind.frag"));
}
void MultiBindApp::setup()
{
TexA = gl::Texture2d::create(loadImage(getAssetPath("ImageA.png")));
TexB = gl::Texture2d::create(loadImage(getAssetPath("ImageB.png")));
LoadShaders();
}
void MultiBindApp::update()
{
LoadShaders();
}
void MultiBindApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
Multibind->bind();
TexA->bind(3);
Multibind->uniform("TextureA", 3 );
TexB->bind(4);
Multibind->uniform("TextureB", 4);
gl::drawSolidRect(Rectf(0.0, 0.0, 128.0, 128.0));
TexA->unbind();
TexB->unbind();
}
void prepareSettings(App::Settings *settings) {
settings->setConsoleWindowEnabled(true);
}
CINDER_APP( MultiBindApp, RendererGl, prepareSettings)
Fragment shader:
#version 150
uniform sampler2D TextureA;
uniform sampler2D TextureB;
in vec2 TexCoord;
out vec4 oColor;
void main( void )
{
oColor.xyz = texture( TextureA,TexCoord).xyz;
}
No matter what I do, the best I get shown is the last bound texture. So if I bind TexA & then TexB, my shader will only ever show TexB (no matter if I put texture(TextureA…); etc.)
I’ve experimented with different bind methods too - using bind() & then sending TexA->getId() as the uniform index instead, which returns blank.
I’m not really sure what else to try - I was hoping a test case app would highlight where I was going wrong, but instead it’s confused me further. I’m hoping there’s a standard path to this that I’m missing.
I get similar issues in the _opengl samples too - the normal mapping adv. sample seems affected.
Any help is greatly appreciated, I’m completely stuck!