Last active
December 29, 2015 18:18
-
-
Save anossov/7709460 to your computer and use it in GitHub Desktop.
Panda3d: trying to use sampler2DArray in GLSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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