Esempio n. 1
0
        public void RenderWaterRefraction(DirectionalLight Sun, BaseCamera camera, ref Matrix4 ProjectionMatrix,
                                          Vector4 clipPlane = new Vector4())
        {
            if (bPostConstructor)
            {
                return;
            }

            Matrix4 modelMatrix;

            modelMatrix = GetWorldMatrix();

            /*If clip plane is setted - enable clipping plane*/
            if (clipPlane.X == 0 && clipPlane.Y == 0 && clipPlane.Z == 0 && clipPlane.W == 0)
            {
                GL.Disable(EnableCap.ClipDistance0);
            }
            else
            {
                GL.Enable(EnableCap.ClipDistance0);
            }

            m_liteRefractionShader.startProgram();       //Бинд шейдера

            m_texture.BindTexture(TextureUnit.Texture0); // diffusemap texture
            bool bEnableNM = m_normalMap != null;
            bool bEnableSM = m_specularMap != null;

            if (bEnableNM)
            {
                m_normalMap.BindTexture(TextureUnit.Texture1);  // normalmap
            }
            if (bEnableSM)
            {
                m_specularMap.BindTexture(TextureUnit.Texture2);  //Bind specular map
            }
            m_liteReflectionShader.SetTexture(0);
            if (bEnableNM)
            {
                m_liteRefractionShader.SetNormalMap(1);
            }
            if (bEnableSM)
            {
                m_liteRefractionShader.SetSpecularMap(2);
            }
            m_liteRefractionShader.SetAlbedoTexture(0);
            m_liteRefractionShader.SetMaterial(m_material);
            m_liteRefractionShader.SetTransformationMatrices(ref modelMatrix, camera.GetViewMatrix(), ref ProjectionMatrix);
            m_liteRefractionShader.SetDirectionalLight(Sun);
            m_liteRefractionShader.SetClipPlane(ref clipPlane);

            m_skin.Buffer.RenderVAO(PrimitiveType.Triangles);
            m_liteRefractionShader.stopProgram();
        }
        public void RenderWaterRefraction(DirectionalLight Sun, BaseCamera camera, ref Matrix4 ProjectionMatrix,
                                          Vector4 clipPlane = default(Vector4))
        {
            if (bPostConstructor)
            {
                return;
            }

            Matrix4 modelMatrix;

            modelMatrix = GetWorldMatrix();

            /*If clip plane is set - enable clipping plane*/
            if (GeometryMath.CMP(clipPlane.LengthSquared, 0.0f) > 0)
            {
                GL.Disable(EnableCap.ClipDistance0);
            }
            else
            {
                GL.Enable(EnableCap.ClipDistance0);
            }

            m_liteRefractionShader.startProgram();

            m_texture.BindTexture(TextureUnit.Texture0);
            m_normalMap?.BindTexture(TextureUnit.Texture1);

            m_liteRefractionShader.SetAlbedoTexture(0);
            m_liteRefractionShader.SetNormalMap(1);
            m_liteRefractionShader.SetMaterial(m_material);
            m_liteRefractionShader.SetTransformationMatrices(ref modelMatrix, camera.GetViewMatrix(), ref ProjectionMatrix);
            m_liteRefractionShader.SetDirectionalLight(Sun);
            m_liteRefractionShader.SetClipPlane(ref clipPlane);

            m_skin.Buffer.RenderVAO(PrimitiveType.Triangles);
            m_liteRefractionShader.stopProgram();
        }