<commit_before>from demosys.effects import effect
from demosys.opengl import geometry
from pyrr import Vector3
from OpenGL import GL
import math


class SimpleRaymarchEffect(effect.Effect):
    """Generated raymarching effect"""
    def __init__(self):
        self.shader = self.get_shader("raymarching_simple.glsl")
        # create plane to fit whole screen
        self.plane = geometry.plane.plane_xz(size=(self.window_width, self.window_height), resolution=(10, 10))

    @effect.bind_target
    def draw(self, time, frametime, target):
        GL.glEnable(GL.GL_DEPTH_TEST)

        # Rotate plane 90 degrees, and move plane back so it will fit correctly on to screen
        backoff = math.tan(math.radians(self.sys_camera.projection.fov / 2)) * (self.window_width / 2)
        m_mv = self.create_transformation(rotation=(math.radians(90), 0.0, 0.0), translation=(0.0, 0.0, -backoff))

        # Uniforms
        fov = 0.60
        alpha = 1.0
        modifier = -0.6
        cPosition = Vector3([(math.sin(time / 6.0) * 16.0),
                             (math.sin(time / 12.0) * 16.0),
                             (math.cos(time / 3.0) * 16.0)])
        cLookAt = Vector3([0.0, 0.0, 0.0])
        lPosition = Vector3([0.0, 17.0, 0.0])
        lItensity = 2.6
        color = Vector3([0.66, 0.96, 0.26])

        # Draw the plane
        with self.plane.bind(self.shader) as shader:
            # For vertex shader
            shader.uniform_mat4("m_proj", self.sys_camera.projection.matrix)
            shader.uniform_mat4("m_mv", m_mv)

            # For fragment shader
            shader.uniform_1f("fov", fov)
            shader.uniform_1f("alpha", alpha)
            shader.uniform_1f("modifier", modifier)

            shader.uniform_3f("cPosition", cPosition.x, cPosition.y, cPosition.z)
            shader.uniform_3f("cLookAt", cLookAt.x, cLookAt.y, cLookAt.z)
            shader.uniform_3f("lPosition", lPosition.x, lPosition.y, lPosition.z)
            shader.uniform_1f("lIntensity", lItensity)
            shader.uniform_3f("color", color.x, color.y, color.z)

            shader.uniform_2f("resolution", self.window_width, self.window_height)
        self.plane.draw()<commit_msg>Update raymaching template to demosys 1.0<commit_after>from demosys.effects import effect
from demosys import geometry
from pyrr import Vector3
from OpenGL import GL
import math


class SimpleRaymarchEffect(effect.Effect):
    """Generated raymarching effect"""
    def __init__(self):
        self.shader = self.get_shader("raymarching_simple.glsl", local=True)

        # create plane to fit whole screen
        self.plane = geometry.plane.plane_xz(size=(self.window_width, self.window_height), resolution=(10, 10))

    @effect.bind_target
    def draw(self, time, frametime, target):
        GL.glEnable(GL.GL_DEPTH_TEST)

        # Rotate plane 90 degrees, and move plane back so it will fit correctly on to screen
        backoff = math.tan(math.radians(self.sys_camera.projection.fov / 2)) * (self.window_width / 2)
        m_mv = self.create_transformation(rotation=(math.radians(90), 0.0, 0.0), translation=(0.0, 0.0, -backoff))

        # Uniforms
        fov = 0.60
        alpha = 1.0
        modifier = -0.6
        cPosition = Vector3([(math.sin(time / 6.0) * 16.0),
                             (math.sin(time / 12.0) * 16.0),
                             (math.cos(time / 3.0) * 16.0)])
        cLookAt = Vector3([0.0, 0.0, 0.0])
        lPosition = Vector3([0.0, 17.0, 0.0])
        lItensity = 2.6
        color = Vector3([0.66, 0.96, 0.26])

        # Draw the plane

        # For vertex shader
        self.shader.uniform("m_proj", self.sys_camera.projection.tobytes())
        self.shader.uniform("m_mv", m_mv.astype('f4').tobytes())

        # For fragment shader
        self.shader.uniform("fov", fov)
        self.shader.uniform("alpha", alpha)
        self.shader.uniform("modifier", modifier)

        self.shader.uniform("cPosition", cPosition.astype('f4').tobytes())
        self.shader.uniform("cLookAt", cLookAt.astype('f4').tobytes())
        self.shader.uniform("lPosition", lPosition.astype('f4').tobytes())
        self.shader.uniform("lIntensity", lItensity)
        self.shader.uniform("color", color.astype('f4').tobytes())

        self.shader.uniform("resolution", (self.window_width, self.window_height))

        self.plane.draw(self.shader)
{'fraction_non_alphanumeric': 0.13302961275626424, 'fraction_numerical': 0.03599088838268793, 'mean_word_length': 2.50438946528332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5558762', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1445, 'n_words': 291}