1

I'm trying to create a shader in Apple's OpenGL Shader Builder and I need a texture as input for the fragment shader.

The input is defined like:

uniform sampler2D texture;

It seems obvious I could somehow use a texture already loaded into OpenGL Shader Builder but I can't figure out how.

yns
  • 25
  • 1
  • 4

2 Answers2

2

In the main window you should see three tabs : Render, Texture and Symbols. Click the Texture tab and simply drag and drop an image file in the first available slot. Each slot represents a texture unit and will always be in the order of your uniforms.

If you don't have any texture set up, the result will be a black screen.

Grimmy
  • 3,280
  • 19
  • 23
  • You can also specify which texture unit the uniform is bound to by using layout(binding=0) sampler2D texture, where 0 is the index of aforementioned texturing unit. – fluffels May 23 '13 at 08:19
  • 1
    @fluffels [layout qualifiers](http://www.opengl.org/wiki/Layout_Qualifier_(GLSL)) seem like the answer, but are only available in OpenGL 4.2 (to date OS X only seems to support 4.1) :( – Jaysen Marais Feb 04 '14 at 00:47
1

Once you define a uniform sampler2D symbol for the texture, you can go to symbols pane, there you can set the number of texture unit for the symbol (I think the first entry field is the one, but won't hurt if you fill all three).

PetrM
  • 21
  • 1