Exemplo n.º 1
0
        private static int RenderHdrToCubemapSkybox(Matrix4 view, Matrix4 projection, ISceneObject skybox)
        {
            GL.CullFace(CullFaceMode.Front);
            GL.DepthFunc(DepthFunction.Lequal);
            SkyboxSceneObjectComponent skyboxComponent     = (SkyboxSceneObjectComponent)skybox.components["SkyboxSceneObjectComponent"];
            MeshSceneObjectComponent   skyboxMeshComponent = (MeshSceneObjectComponent)skybox.components["MeshSceneObjectComponent"];

            GL.UseProgram(skyboxComponent.Shader.ProgramID);
            skyboxComponent.Shader.EnableVertexAttribArrays();
            GL.UniformMatrix4(skyboxComponent.Shader.GetUniform("projection"), false, ref projection);
            Matrix4 clearTraslationViewMatrix = view.ClearTranslation();

            GL.UniformMatrix4(skyboxComponent.Shader.GetUniform("view"), false, ref clearTraslationViewMatrix);
            bool isSetted =
                new UniformHelper().
                TryAddUniformTextureCubemap(skyboxComponent.EnvironmentMap, "environmentMap", skyboxComponent.Shader, TextureUnit.Texture0);

            if (!isSetted)
            {
                Console.WriteLine("wrong uniform");
            }
            GL.DrawElements(BeginMode.Triangles, skyboxMeshComponent.ModelMesh.IndiceCount, DrawElementsType.UnsignedInt, 0 * sizeof(uint));
            GL.DepthFunc(DepthFunction.Less);
            skyboxComponent.Shader.DisableVertexAttribArrays();
            return(skyboxMeshComponent.ModelMesh.IndiceCount);
        }
Exemplo n.º 2
0
        public Skybox(string skyboxLocation = "Resources//newport_loft.hdr") : base("HdriSkybox")
        {
            SkyboxSceneObjectComponent skyboxComponent =
                new SkyboxSceneObjectComponent(skyboxLocation,
                                               SkyboxSceneObjectComponent.SkyboxType.hdr);
            MeshSceneObjectComponent meshComponent = new MeshSceneObjectComponent(
                new WavefrontModelLoader(),
                "Resources/box.obj1"
                );

            AddComponent(meshComponent);
            AddComponent(skyboxComponent);
        }
Exemplo n.º 3
0
        public Skybox(ShaderProg shader, string skyboxLocation = "Resources//Cubemaps") : base("CubemapSkybox")
        {
            SkyboxSceneObjectComponent skyboxComponent =
                new SkyboxSceneObjectComponent(skyboxLocation,
                                               shader,
                                               SkyboxSceneObjectComponent.SkyboxType.cubemap);
            MeshSceneObjectComponent meshComponent = new MeshSceneObjectComponent(
                new WavefrontModelLoader(),
                "Resources/box.obj1"
                );

            AddComponent(meshComponent);
            AddComponent(skyboxComponent);
        }
Exemplo n.º 4
0
        public void OnLoad()
        {
            //sceneObjects which required for default render pipeline camera etc.
            List <ISceneObject> specificSceneObjects = new List <ISceneObject>();

            //gather specific objects
            foreach (ISceneObject sceneObject in Objects)
            {
                //gather all light sources
                if (sceneObject.components.ContainsKey("PointLightSceneObjectComponent"))
                {
                    Lights.Add(sceneObject);
                }
                //gather cameras
                if (sceneObject.GetType().Name == "PlayerCamera")
                {
                    Cam = (Camera)sceneObject.components["Camera"];
                    specificSceneObjects.Add(sceneObject);
                }
                //gather skybox
                if (sceneObject.GetType().Name == "Skybox")
                {
                    Skybox          = sceneObject;
                    SkyboxComponent = (SkyboxSceneObjectComponent)Skybox.components["SkyboxSceneObjectComponent"];
                }
            }


            //remove specific objects from main collection of sceneObjects
            foreach (SceneObject sceneObject in specificSceneObjects)
            {
                sceneObject.OnLoad();
                Objects.Remove(sceneObject);
            }

            foreach (SceneObject sceneObject in Lights)
            {
                Objects.Remove(sceneObject);
            }
        }