def _build_fragment_shader(cls, texture, view_width, view_height):
        """ Internal method to build a fragment shader displaying the texture """

        sampling_code, sampler_type = cls._generate_sampling_code(texture, view_width, view_height)

        # Build actual shader
        built = """
            #version 400
            #extension GL_ARB_shading_language_420pack : enable
            #pragma include "render_pipeline_base.inc.glsl"
            in vec2 texcoord;
            out vec3 result;
            uniform int mipmap;
            uniform int slice;
            uniform float brightness;
            uniform bool tonemap;
            uniform """ + sampler_type + """ p3d_Texture0;
            void main() {
                int view_width = """ + str(view_width) + """;
                int view_height = """ + str(
            view_height
        ) + """;
                ivec2 display_coord = ivec2(texcoord * vec2(view_width, view_height));
                int int_index = display_coord.x + display_coord.y * view_width;
                """ + sampling_code + """
                result *= brightness;
                if (tonemap)
                    result = result / (1 + result);
            }
        """

        # Strip trailing spaces
        built = '\n'.join([i.strip() for i in built.split("\n")])

        return built
 Internal method to build a fragment shader displaying the texture 
metadrive/render_pipeline/rpcore/util/display_shader_builder.py