internal void BindGBufferTexturesTo(Shader shader)
        {
            GL.Disable(EnableCap.DepthTest);
            GL.DepthMask(false);
            GL.CullFace(CullFaceMode.Back);

            GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, frameBufferObjectHandle);

            // draw to the one we are not reading
            if (readFirstFinalTexture)
            {
                GL.DrawBuffer(DrawBufferMode.ColorAttachment5);
            }
            else
            {
                GL.DrawBuffer(DrawBufferMode.ColorAttachment4);
            }

            shader.SetUniform("gBufferUniform.depthBuffer", depthTexture);
            shader.SetUniform("gBufferUniform.final", finalTextureToRead);

            for (int i = 0; i < textures.Length - 2; i++)
            {
                shader.SetUniform("gBufferUniform." + ((GBufferTextures)i).ToString().ToLower(), textures[i]);

                /* // !!!!! WASTED AROUND 10 HOURS, BEFOURE I FOUND THE BUG IS HERE OMFG !!!!!! old wrong code below, when used i could not make diffuse lighting in deferred lighting pass
                 * if (shader.SetParam("G" + enums[i].ToLower(), texturingUnit))
                 * {
                 *  var textureHandle = textures[i];
                 *  GL.ActiveTexture(TextureUnit.Texture0 + texturingUnit);
                 *  GL.BindTexture(TextureTarget.Texture2D, textureHandle);
                 *  texturingUnit++;
                 * }*/
            }
        }
Esempio n. 2
0
        override internal void BindUniforms(Shader shader = null)
        {
            if (shader == null)
            {
                shader = this.gBufferShader;
            }
            //shader.SetUniform("material.albedoTexture", albedoTexture);
            foreach (var p in fieldsToSend)
            {
                object val = p.GetValue(this);
                if (val != null)
                {
                    shader.SetUniform("material." + p.Name, val);
                }
            }
            shader.SetUniform("material.useNormalMapping", normalMap != null);
            shader.SetUniform("material.useParallaxMapping", depthMap != null);

            base.BindUniforms(shader);

            /*shader.SetUniform("material.albedo", albedo);
             * shader.SetUniform("material.metallic", metallic);
             * shader.SetUniform("material.smoothness", smoothness);
             * shader.SetUniform("material.emission", emission);*/
        }
Esempio n. 3
0
        internal void BindUniforms(Shader shader)
        {
            var shadowMatrix = this.shadowViewCamera.GetViewMat() * this.shadowViewCamera.GetProjectionMat();

            // projection matrix is in range -1 1, but it is rendered into rexture which is in range 0 1
            // so lets move it from -1 1 into 0 1 range, since we are reading from texture
            shadowMatrix *= Matrix4.CreateScale(new Vector3(0.5f, 0.5f, 0.5f));
            shadowMatrix *= Matrix4.CreateTranslation(new Vector3(0.5f, 0.5f, 0.5f));

            shader.SetUniform("shadowMap.level0", depthMap);
            shader.SetUniform("shadowMap.viewProjectionMatrix", shadowMatrix);
        }
 internal virtual void BindUniforms(Shader shader = null)
 {
     if (shader == null)
     {
         shader = this.gBufferShader;
     }
     foreach (var name in uniformsChanged)
     {
         shader.SetUniform(name, uniformsData[name]);
     }
     uniformsChanged.Clear();
 }