Beispiel #1
0
        public void CreateSkyBox(RShader skyBoxShader, RTexture3D skyBoxTexture)
        {
            sky = RScene.Instance.CreateMeshBuilder("skybox");
            sky.CreateBox(Vector3.Zero, Vector3.One, true);
            sky.Matrix     = Matrix.Identity;
            sky.DepthWrite = false;
            RMaterial skyBoxMaterial = new RMaterial("skybox");

            skyBoxMaterial.Shader = skyBoxShader;
            skyBoxMaterial.SetTexture(RTextureLayer.DIFFUSE, skyBoxTexture);
            sky.Material = skyBoxMaterial;
        }
Beispiel #2
0
        public override void Init()
        {
            Engine.InitGameWindow(1920, 1080, RWindowStyle.Normal);
            GameWindow.VSync = OpenTK.VSyncMode.On;
            Engine.SetShowFPS(true);
            Engine.SetViewport(new RViewport(0, 0, 1920, 1080));
            //Engine.InitHDR();

            GameWindow.CursorVisible = true;
            GameWindow.Location      = new System.Drawing.Point(0, 0);
            sponza = Engine.Scene.Create <RMesh>("sponza");
            sponza.LoadSourceModel("/models/sponza.fbx");
            sponza.CullEnable  = false;
            sponza.CullMode    = RCullMode.None;
            sponza.Scale       = Vector3.One;
            sponza.Position    = Vector3.Zero;
            sponza.BlendEnable = false;
            var cam = Engine.GetCamera();

            //cam.LookAt(cam.Position - Vector3.UnitZ);
            cam.Position = new Vector3(0, 1.5f, 0);
            cam.Near     = 0.01f;
            cam.Far      = 10000f;
            //cam.ViewDirection = Vector3.Normalize(cam.Position - Vector3.UnitZ);
            cam.Update();

            font = RScreen.Instance.LoadFont("/vcr_osd_mono.ttf", 16);

            RTexture2D posX = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posX", "/textures/sky-posX.png");
            RTexture2D posY = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posY", "/textures/sky-posY.png");
            RTexture2D posZ = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posZ", "/textures/sky-posZ.png");
            RTexture2D negX = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negX", "/textures/sky-negX.png");
            RTexture2D negY = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negY", "/textures/sky-negY.png");
            RTexture2D negZ = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negZ", "/textures/sky-negZ.png");

            var skyboxTexture = new RTexture3D();

            skyboxTexture.Create(RPixelFormat.Rgb, ref posX, ref posY, ref posZ, ref negX, ref negY, ref negZ);

            Engine.Atmosphere.CreateSkyBox(skyboxTexture);
            GameWindow.Visible = true;
        }
Beispiel #3
0
        public void CreateSkyBox(RTexture3D skyBoxTexture)
        {
            skybox = new RShader();
            skybox.Load(@"
#include ""headers.glsl""
uniform mat4 proj : PROJECTION;
uniform mat4 mv : MODELVIEW;

smooth out vec3 eye;

void main()
{
    mat3 imv = mat3(inverse(mv));
    mat4 inverseProjection = inverse(proj);
    vec3 unprojected = (inverseProjection * vec4(r_Position, 1.0)).xyz;
    eye = imv * unprojected;

    gl_Position = vec4(r_Position, 1.0);
}
", @"

smooth in vec3 eye;
uniform samplerCube diffuse;
out vec4 fragColor;
void main()
{
    fragColor = texture(diffuse, eye);
}
", null);
            sky = RScene.Instance.CreateMeshBuilder("skybox");
            sky.CreateBox(Vector3.Zero, Vector3.One, true);
            sky.Matrix     = Matrix.Identity;
            sky.DepthWrite = false;
            RMaterial skyBoxMaterial = new RMaterial("skybox");

            skyBoxMaterial.Shader = skybox;
            skyBoxMaterial.SetTexture(RTextureLayer.DIFFUSE, skyBoxTexture);
            sky.Material = skyBoxMaterial;
        }
Beispiel #4
0
        public override void Init()
        {
            Engine.InitGameWindow(1280, 720, RWindowStyle.Normal);
            GameWindow.VSync = OpenTK.VSyncMode.On;
            Engine.SetShowFPS(true);
            Engine.SetViewport(new RViewport(0, 0, 1280, 720));
            Engine.InitHDR();
            GameWindow.CursorVisible = true;
            sponza = Engine.Scene.Create <RMesh>("sponza");
            sponza.LoadSourceModel("/models/sponza.fbx");
            sponza.CullEnable = false;
            sponza.CullMode   = RCullMode.None;
            sponza.SetScale(1f);
            sponza.SetPosition(0, 0, 0);
            sponza.BlendEnable = false;
            var cam = Engine.GetCamera();

            cam.SetPosition(0, 20, 1f);
            cam.LookAt(Vector3.Zero);
            cam.SetClipPlanes(0.01f, 10000f);

            font = RScreen.Instance.LoadFont("/vcr_osd_mono.ttf", 16);

            RTexture2D posX = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posX", "/textures/sky-posX.png");
            RTexture2D posY = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posY", "/textures/sky-posY.png");
            RTexture2D posZ = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("posZ", "/textures/sky-posZ.png");
            RTexture2D negX = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negX", "/textures/sky-negX.png");
            RTexture2D negY = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negY", "/textures/sky-negY.png");
            RTexture2D negZ = (RTexture2D)Engine.Textures.CreateTexture <RTexture2D>("negZ", "/textures/sky-negZ.png");

            var skyboxTexture = new RTexture3D();

            skyboxTexture.Create(RPixelFormat.Rgb, ref posX, ref posY, ref posZ, ref negX, ref negY, ref negZ);

            Engine.Atmosphere.CreateSkyBox(skyboxTexture);
        }