def execute(self, instance): name = self.evaluate_index(0) uniform = self.evaluate_index(1) value = int(self.evaluate_index(2)) shaders = instance.objectPlayer.shaders[name] for item in shaders: item.bind() item.uniformi(uniform, value) Shader.unbind()
def execute(self, instance): name = self.evaluate_expression(self.get_parameter(0)) uniform = self.evaluate_expression(self.get_parameter(1)) value = int(self.evaluate_expression(self.get_parameter(2))) shaders = instance.objectPlayer.shaders[name] for item in shaders: item.bind() item.uniformi(uniform, value) Shader.unbind()
def push(self, vertex, fragment): if vertex is None: vertex = [] else: vertex = [vertex] if fragment is None: fragment = [] else: fragment = [fragment] shader = Shader(vertex, fragment) shader.initialize() self.stack.append(shader)
def load_shader(name): name = name.split('.')[0] if name in cached: return cached[name] try: vert = [open('./shaders/%s.vert' % name, 'rb').read()] except: vert = [] try: frag = [open('./shaders/%s.frag' % name, 'rb').read()] except: frag = [] if not vert and not frag: shader = None else: shader = Shader(vert, frag) shader.initialize() shader = [shader] cached[name] = shader return shader
# along with Anaconda. If not, see <http://www.gnu.org/licenses/>. from mmfparser.player.shader import Shader MONOCHROME_SHADER = [ Shader([ """ varying vec2 texture_coordinate; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_FrontColor = gl_Color; texture_coordinate = vec2(gl_MultiTexCoord0); } """ ], [ """ varying vec2 texture_coordinate; uniform sampler2D Tex0; void main() { vec4 col = texture2D(Tex0, texture_coordinate); col *= vec4(0.299,0.587,0.114,1.0); col.rgb = vec3(col.r+col.g+col.b); gl_FragColor = col * gl_Color; } """ ]) ] __all__ = ['MONOCHROME_SHADER']