예제 #1
0
 /// <summary>
 /// Compiles and links vertex and fragment shaders from strings.
 /// </summary>
 /// <param name="shaderProgram">The empty shader to which the two shader sources are linked to.</param>
 /// <param name="sVertexShd_">The vertex shader source code string.</param>
 /// <param name="sFragmentShd_">The fragment shader source code string.</param>
 /// <returns>The shader log, Empty if no errors.</returns>
 public static string FromStrings(this IShaderProgram shaderProgram, string sVertexShd_, string sFragmentShd_)
 {
     shaderProgram.Compile(sVertexShd_, ShaderType.VertexShader);
     shaderProgram.Compile(sFragmentShd_, ShaderType.FragmentShader);
     shaderProgram.Link();
     return(shaderProgram.LastLog);
 }
예제 #2
0
        public bool LoadShaders()
        {
            List <OrthoRenderer> rendererers = new List <OrthoRenderer>();

            orthoShaderKeys = capi.Assets.TryGet("config/orthoshaderlist.json")?.ToObject <string[]>();
            if (orthoShaderKeys == null)
            {
                return(false);
            }

            for (int i = 0; i < orthoShaderKeys.Length; i++)
            {
                IShaderProgram shader  = capi.Shader.NewShaderProgram();
                int            program = capi.Shader.RegisterFileShaderProgram(orthoShaderKeys[i], shader);
                shader = capi.Render.GetShader(program);
                shader.Compile();

                OrthoRenderer renderer = new OrthoRenderer(capi, shader);

                if (orthoRenderers != null)
                {
                    orthoRenderers[i].prog = shader;
                    capi.Event.ReRegisterRenderer(orthoRenderers[i], EnumRenderStage.Ortho);
                }
                rendererers.Add(renderer);
            }
            orthoRenderers = rendererers.ToArray();

            return(true);
        }
예제 #3
0
        public bool LoadShaders()
        {
            if (renderer != null)
            {
                capi.Event.UnregisterRenderer(renderer, EnumRenderStage.Ortho);
                renderer.Dispose();
            }

            List <IShaderProgram> shaders = new List <IShaderProgram>();

            orthoShaderKeys = capi.Assets.TryGet("config/orthoshaderlist.json")?.ToObject <string[]>();
            if (orthoShaderKeys == null)
            {
                return(false);
            }

            foreach (var val in orthoShaderKeys)
            {
                IShaderProgram shader  = capi.Shader.NewShaderProgram();
                int            program = capi.Shader.RegisterFileShaderProgram(val, shader);
                shader = capi.Render.GetShader(program);
                shader.Compile();
                shaders.Add(shader);
            }
            renderer = new ScreenSpaceRenderer(capi, shaders);
            capi.Event.RegisterRenderer(renderer, EnumRenderStage.Ortho);
            return(true);
        }
예제 #4
0
        public bool LoadShader()
        {
            prog = capi.Shader.NewShaderProgram();
            prog.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            prog.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            capi.Shader.RegisterFileShaderProgram("rift", prog);

            return(prog.Compile());
        }
예제 #5
0
        private bool LoadShader()
        {
            anvilShaderProg = capi.Shader.NewShaderProgram();

            anvilShaderProg.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            anvilShaderProg.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            capi.Shader.RegisterFileShaderProgram("anvilworkitem", anvilShaderProg);

            return(anvilShaderProg.Compile());
        }
        public bool LoadShader()
        {
            prog = capi.Shader.NewShaderProgram();

            prog.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            prog.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            capi.Shader.RegisterFileShaderProgram("mechpower", prog);

            prog.PrepareUniformLocations("rgbaFogIn", "rgbaAmbientIn", "fogMinIn", "fogDensityIn", "projectionMatrix", "modelViewMatrix", "tex");
            return(prog.Compile());
        }
예제 #7
0
        public bool LoadShader()
        {
            prog = capi.Shader.NewShaderProgram();

            prog.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            prog.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            capi.Shader.RegisterFileShaderProgram("clouds", prog);

            prog.PrepareUniformLocations("zNear", "zFar", "sunPosition", "sunColor", "dayLight", "windOffset", "playerPos", "globalCloudBrightness", "rgbaFogIn", "fogMinIn", "fogDensityIn", "flatFogDensity", "flatFogStart", "projectionMatrix", "modelViewMatrix", "shadowDistanceFar", "toShadowMapSpaceMatrixFar", "shadowDistanceNear", "toShadowMapSpaceMatrixNear", "pointLights", "pointLightColors", "pointLightQuantity", "cloudTileSize", "cloudsLength");

            return(prog.Compile());
        }
        public bool LoadShader()
        {
            overlayShaderProg = capi.Shader.NewShaderProgram();
            overlayShaderProg.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            overlayShaderProg.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            overlayShaderProg.VertexShader.Code   = GetVertexShaderCode();
            overlayShaderProg.FragmentShader.Code = GetFragmentShaderCode();

            capi.Shader.RegisterMemoryShaderProgram("squintoverlay", overlayShaderProg);
            overlayShaderProg.Compile();

            return(true);
        }
예제 #9
0
        public void LoadShader()
        {
            overlayShaderProg = capi.Shader.NewShaderProgram();
            overlayShaderProg.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            overlayShaderProg.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            overlayShaderProg.VertexShader.Code   = GetVertexShaderCode();
            overlayShaderProg.FragmentShader.Code = GetFragmentShaderCode();

            capi.Shader.RegisterMemoryShaderProgram("exampleoverlay", overlayShaderProg);
            overlayShaderProg.PrepareUniformLocations("time");
            overlayShaderProg.Compile();

            if (renderer != null)
            {
                renderer.overlayShaderProg = overlayShaderProg;
            }
        }
예제 #10
0
        public bool LoadShader()
        {
            eyeShaderProg = capi.Shader.NewShaderProgram();

            eyeShaderProg.VertexShader   = capi.Shader.NewShader(EnumShaderType.VertexShader);
            eyeShaderProg.FragmentShader = capi.Shader.NewShader(EnumShaderType.FragmentShader);

            eyeShaderProg.VertexShader.Code   = VertexShaderCode;
            eyeShaderProg.FragmentShader.Code = FragmentShaderCode;

            capi.Shader.RegisterMemoryShaderProgram("sleepoverlay", eyeShaderProg);

            if (renderer != null)
            {
                renderer.eyeShaderProg = eyeShaderProg;
            }

            return(eyeShaderProg.Compile());
        }