internal void Draw(Matrix4 projection, int environmentMapMatrix = -1) { if (environmentMapMatrix >= 0) { _viewMatrix = HelperSkybox._viewMatrixSkybox[environmentMapMatrix]; projection = HelperSkybox._projectionMatrixSkybox; } else { if (KWEngine.CurrentWorld.IsFirstPersonMode) { _viewMatrix = HelperCamera.GetViewMatrix(KWEngine.CurrentWorld.GetFirstPersonObject().Position); } else { _viewMatrix = KWEngine.CurrentWindow._viewMatrix; } } // Clear translation part: _viewMatrix = _viewMatrix.ClearTranslation(); _viewMatrix = KWEngine.CurrentWorld._skyboxRotation * _viewMatrix; Matrix4 MVP = _viewMatrix * projection; GL.FrontFace(FrontFaceDirection.Cw); GL.DepthFunc(DepthFunction.Lequal); GL.UseProgram(mProgramId); GL.UniformMatrix4(mUniform_MVP, false, ref MVP); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.TextureCubeMap, KWEngine.CurrentWorld._textureSkybox); GL.Uniform1(mUniform_Texture, 0); Vector4 skyColor = new Vector4(KWEngine.CurrentWorld._ambientLight.Xyz, KWEngine.CurrentWorld._ambientLight.W * KWEngine.CurrentWorld._textureBackgroundMultiplier); GL.Uniform4(mUniform_TintColor, ref skyColor); GeoMesh mesh = KWEngine.Models["KWCube"].Meshes.Values.ElementAt(0); GL.BindVertexArray(mesh.VAO); GL.BindBuffer(BufferTarget.ElementArrayBuffer, mesh.VBOIndex); GL.DrawElements(mesh.Primitive, mesh.IndexCount, DrawElementsType.UnsignedInt, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); GL.BindTexture(TextureTarget.TextureCubeMap, 0); GL.UseProgram(0); GL.DepthFunc(DepthFunction.Less); GL.FrontFace(FrontFaceDirection.Ccw); }
internal override void Draw(GameObject g, ref Matrix4 viewProjection) { if (KWEngine.CurrentWorld.IsFirstPersonMode) { _viewMatrix = HelperCamera.GetViewMatrix(KWEngine.CurrentWorld.GetFirstPersonObject().Position); } else { _viewMatrix = KWEngine.CurrentWindow._viewMatrix; } // Clear translation part: _viewMatrix = _viewMatrix.ClearTranslation(); _viewMatrix = KWEngine.CurrentWorld._skyboxRotation * _viewMatrix; Matrix4 MVP = _viewMatrix * viewProjection; GL.FrontFace(FrontFaceDirection.Cw); GL.DepthFunc(DepthFunction.Lequal); GL.UseProgram(mProgramId); GL.UniformMatrix4(mUniform_MVP, false, ref MVP); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.TextureCubeMap, KWEngine.CurrentWorld._textureSkybox); GL.Uniform1(mUniform_Texture, 0); GL.Uniform4(mUniform_TintColor, ref KWEngine.CurrentWorld._textureBackgroundTint); GeoMesh mesh = KWEngine.Models["KWCube"].Meshes.Values.ElementAt(0); GL.BindVertexArray(mesh.VAO); GL.BindBuffer(BufferTarget.ElementArrayBuffer, mesh.VBOIndex); GL.DrawElements(mesh.Primitive, mesh.IndexCount, DrawElementsType.UnsignedInt, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); GL.BindTexture(TextureTarget.TextureCubeMap, 0); GL.UseProgram(0); GL.DepthFunc(DepthFunction.Less); GL.FrontFace(FrontFaceDirection.Ccw); }