Esempio n. 1
0
        protected void ApplyShaderParams(RendererShader shader)
        {
            foreach (var entry in ShaderParams)
            {
                var name  = entry.Key;
                var value = entry.Value;
                if (value == null)
                {
                    continue;
                }

                var type = value.GetType();
                if (type == typeof(int))
                {
                    shader.SetInt(name, (int)value);
                }
                else if (type == typeof(Vector3))
                {
                    shader.SetVector3(name, (Vector3)value);
                }
                else
                {
                    throw new NotSupportedException(type.Name);
                }
            }
        }
Esempio n. 2
0
        private void RenderPass2(RenderContext context, Camera camera)
        {
            Pass = DeferredPass.Pass2;
            ObjectManager.PushDebugGroup("OnRender LightShader", this);

            _DefLightShader.Bind();

            GPosition.Bind(TextureUnit.Texture0);
            GNormal.Bind(TextureUnit.Texture1);
            GAlbedoSpec.Bind(TextureUnit.Texture2);
            GMaterial.Bind(TextureUnit.Texture3);

            if (Renderer.Current.UseShadows)
            {
                context.GetPipeline <DirectionalShadowRenderPipeline>().FrameBuffer.GetDestinationTexture().Bind(TextureUnit.Texture4);
                _DefLightShader.SetInt("DirectionalShadowMap", 4);
                context.GetPipeline <PointShadowRenderPipeline>().FrameBuffer.GetDestinationTexture().Bind(TextureUnit.Texture5);
                _DefLightShader.SetInt("PointShadowMap", 5);
            }

            _DefLightShader.SetVector3("ViewPos", camera.Position);
            _DefLightShader.SetFloat("FarPlane", camera.FarPlane);

            // TODO: Move to Pass1
            //_DefLightShader.SetMaterial("material", Material.Default);

            _DefLightShader.BindBlock("LightsArray", context.LightBinding);
            _DefLightShader.SetInt("LightCount", context.LightObjects.Count);

            context.GetPipeline <ForwardRenderPipeline>().FrameBuffer.Bind();
            vao.Bind();
            GL.Disable(EnableCap.DepthTest);
            vao.Draw();
            GL.Enable(EnableCap.DepthTest);

            ObjectManager.PopDebugGroup();
        }