Skip to content

Instantly share code, notes, and snippets.

@anossov
Last active December 29, 2015 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anossov/7709460 to your computer and use it in GitHub Desktop.
Save anossov/7709460 to your computer and use it in GitHub Desktop.
Panda3d: trying to use sampler2DArray in GLSL
import direct.directbase.DirectStart
from panda3d.core import *
vertex = '''
#version 330
in vec4 p3d_Vertex;
in vec2 p3d_MultiTexCoord0;
uniform mat4 p3d_ModelViewProjectionMatrix;
out vec2 texcoord;
void main() {
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
texcoord = p3d_MultiTexCoord0;
}
'''
fragment = '''
#version 330
uniform sampler2DArray sampler;
in vec2 texcoord;
out vec4 color;
void main() {
color = texture(sampler, vec3(texcoord, 0));
}
'''
texture = TexturePool.load2dTextureArray('test0#.png')
shader = Shader.make(Shader.SLGLSL, vertex, fragment)
cm = CardMaker('test')
cm.setFrameFullscreenQuad()
cm.setHasUvs(True)
node = render2d.attachNewNode(cm.generate())
node.setShader(shader)
node.setShaderInput('sampler', texture)
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment