public override void LoadAssets() { background = FullScreenQuad.create(this, "pedal_stomp_bg"); shoe = resourceFactory.Create("SceneTen/Shoe"); amp = resourceFactory.Create(this, "Amp"); wires = resourceFactory.Create(this, "Wires"); wireShadow = resourceFactory.Create(this, "WireShadow"); background.visible(false); shoe.SetActive(false); amp.SetActive(false); wires.SetActive(false); wireShadow.SetActive(false); // double the scale on all of these because the art is half-size shoe.transform.localScale = Vector3.one * 2; shoe.GetComponent<Sprite>().setScreenPosition(0, 164); amp.GetComponent<Sprite>().setScreenPosition(130, 50); amp.transform.localScale = Vector3.one * 2; wires.GetComponent<Sprite>().setScreenPosition(30, 30); wires.transform.localScale = Vector3.one * 2; wireShadow.GetComponent<Sprite>().setScreenPosition(30, 30); wireShadow.transform.localScale = Vector3.one * 2; pedalStomped = new PedalStomped(new List<Sprite> {ampSprite, wiresSprite, wireShadowSprite}); pedalUnStomped = new PedalUnStomped(new List<Sprite> {ampSprite, wiresSprite, wireShadowSprite}); stompFoot = new StompFoot(new List<Sprite> {shoeSprite}); retractFoot = new RetractFoot(new List<Sprite> {shoeSprite}); animatables = new[] {pedalStomped, pedalUnStomped, stompFoot, retractFoot}; }
public void LoadAssets() { background = FullScreenQuad.create("SceneTwelve/bgletgo"); bottomDither = resourceFactory.Create("SceneTwelve/BottomDither"); background.visible(false); bottomDither.SetActive(false); }
public void Setup() { background = FullScreenQuad.create(this, "head_closeup_bg"); faceLeftObject = resourceFactory.Create(this, "FaceLeft"); faceLeftObject.layer = 1; faceLeft.setWorldPosition(-50f, -60f, -1f); faceRightObject = resourceFactory.Create(this, "FaceRight"); faceRightObject.layer = 1; faceRight.setWorldPosition(10f, -60f, -1f); }
public override void Setup(float startTime) { endScene(); background = FullScreenQuad.create("TodoList/todo_bg"); spreadConfetti = new ScrollLetters(confetti); spreadConfetti.Setup(startTime); todoList = Sprite.create("TodoList/todo"); todoList.setCenterToViewportCoord(0.5f, 0.5f); todoList.setDepth(-1); }
public void Initialize() { //quad = new FullScreenQuad(game.GraphicsDevice); quad = new FullScreenQuad(game.Device); shader = BasicShader.LoadAutoreload(game, new System.IO.FileInfo( CompiledShaderCache.Current.RootShaderPath + "Particles\\BasicParticleAnimation.fx"), null, new[] { new ShaderMacro("CALCULATE_ACCELERATION", simulation) }); shader.SetTechnique("particleSimulation"); // shader.AddCustomIncludeHandler("generated.fx",generateIncludeCallback); //shader.InitFromEmbeddedFile(game, Assembly.GetExecutingAssembly(), "MHGameWork.TheWizards.Particles.Files.BasicParticleAnimation.fx", "..\\..\\NewModules\\Particles\\Files\\BasicParticleAnimation.fx", new EffectPool()); layout = FullScreenQuad.CreateInputLayout(game.Device, shader.GetCurrentPass(0)); positionTex = new Texture2D(game.Device, new Texture2DDescription() { ArraySize = 1, CpuAccessFlags = CpuAccessFlags.None, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Format = Format.R16G16B16A16_Float, Height = size, Width = size, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default //TODO: render the new position to the texture }); position2Tex = new Texture2D(game.Device, new Texture2DDescription() { ArraySize = 1, CpuAccessFlags = CpuAccessFlags.None, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Format = Format.R16G16B16A16_Float, Height = size, Width = size, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default }); velocityTex = new Texture2D(game.Device, new Texture2DDescription() { ArraySize = 1, CpuAccessFlags = CpuAccessFlags.None, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Format = Format.R16G16B16A16_Float, Height = size, Width = size, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default }); velocity2Tex = new Texture2D(game.Device, new Texture2DDescription() { ArraySize = 1, CpuAccessFlags = CpuAccessFlags.None, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Format = Format.R16G16B16A16_Float, Height = size, Width = size, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0), Usage = ResourceUsage.Default }); positionRv = new ShaderResourceView(game.Device, positionTex); position2Rv = new ShaderResourceView(game.Device, position2Tex); velocityRv = new ShaderResourceView(game.Device, velocityTex); velocity2Rv = new ShaderResourceView(game.Device, velocity2Tex); positionTarget = new RenderTargetView(game.Device, positionTex); positionTarget2 = new RenderTargetView(game.Device, position2Tex); velocityTarget = new RenderTargetView(game.Device, velocityTex); velocityTarget2 = new RenderTargetView(game.Device, velocity2Tex); }
public NeoDemo() { WindowCreateInfo windowCI = new WindowCreateInfo { X = 50, Y = 50, WindowWidth = 960, WindowHeight = 540, WindowInitialState = WindowState.Normal, WindowTitle = "Veldrid NeoDemo" }; GraphicsDeviceOptions gdOptions = new GraphicsDeviceOptions(false, null, false, ResourceBindingModel.Improved, true, true, _colorSrgb); #if DEBUG gdOptions.Debug = true; #endif VeldridStartup.CreateWindowAndGraphicsDevice( windowCI, gdOptions, VeldridStartup.GetPlatformDefaultBackend(), //GraphicsBackend.Metal, // GraphicsBackend.Vulkan, //GraphicsBackend.OpenGL, //GraphicsBackend.OpenGLES, out _window, out _gd); _window.Resized += () => _windowResized = true; _scene = new Scene(_gd, _window.Width, _window.Height); _sc.SetCurrentScene(_scene); _igRenderable = new ImGuiRenderable(_window.Width, _window.Height); _resizeHandled += (w, h) => _igRenderable.WindowResized(w, h); _scene.AddRenderable(_igRenderable); _scene.AddUpdateable(_igRenderable); Skybox skybox = Skybox.LoadDefaultSkybox(); _scene.AddRenderable(skybox); AddSponzaAtriumObjects(); _sc.Camera.Position = new Vector3(-80, 25, -4.3f); _sc.Camera.Yaw = -MathF.PI / 2; _sc.Camera.Pitch = -MathF.PI / 9; ShadowmapDrawer texDrawIndexeder = new ShadowmapDrawer(() => _window, () => _sc.NearShadowMapView); _resizeHandled += (w, h) => texDrawIndexeder.OnWindowResized(); texDrawIndexeder.Position = new Vector2(10, 25); _scene.AddRenderable(texDrawIndexeder); ShadowmapDrawer texDrawIndexeder2 = new ShadowmapDrawer(() => _window, () => _sc.MidShadowMapView); _resizeHandled += (w, h) => texDrawIndexeder2.OnWindowResized(); texDrawIndexeder2.Position = new Vector2(20 + texDrawIndexeder2.Size.X, 25); _scene.AddRenderable(texDrawIndexeder2); ShadowmapDrawer texDrawIndexeder3 = new ShadowmapDrawer(() => _window, () => _sc.FarShadowMapView); _resizeHandled += (w, h) => texDrawIndexeder3.OnWindowResized(); texDrawIndexeder3.Position = new Vector2(30 + (texDrawIndexeder3.Size.X * 2), 25); _scene.AddRenderable(texDrawIndexeder3); ShadowmapDrawer reflectionTexDrawer = new ShadowmapDrawer(() => _window, () => _sc.ReflectionColorView); _resizeHandled += (w, h) => reflectionTexDrawer.OnWindowResized(); reflectionTexDrawer.Position = new Vector2(40 + (reflectionTexDrawer.Size.X * 3), 25); _scene.AddRenderable(reflectionTexDrawer); ScreenDuplicator duplicator = new ScreenDuplicator(); _scene.AddRenderable(duplicator); _fsq = new FullScreenQuad(); _scene.AddRenderable(_fsq); CreateAllObjects(); ImGui.StyleColorsClassic(); }
public void createBackground() { room = FullScreenQuad.create(this, "hospital_bg"); }
void InitializeBehaviors() { Delegater delegater = repo.Delegater; /* * FPS */ fps = new FrameRateCounter(); delegater.Bind(Groups.FrameRate, fps); /* * Camera */ DefaultCamera camera = new DefaultCamera(GraphicsDevice) { ClearColor = Color.CornflowerBlue }; delegater.Bind(Groups.Camera, camera); /* * Background */ // bug: spritebatch.Begin(AlphaBlend) makes sure that this quad gets drawn in the background // which means that some important renderstates are getting set, but not by me FullScreenQuad background = new FullScreenQuad() { Top = new Color(25, 31, 32), Bottom = new Color(71, 81, 90), DrawOrder = 0 }; delegater.Bind(Groups.Background, background); /* * Statue */ StatueInformation statueInformation = new StatueInformation() { StatueSettings = StatueSettings[0] }; delegater.Bind(Groups.Statue, statueInformation); Statue statue = new Statue() { DrawOrder = 2 // to fix some troubles with blobs getting viewed through the statue }; delegater.Bind(Groups.Statue, statue); StatueMouseController statueController = new StatueMouseController(); delegater.Bind(Groups.Statue, statueController); /* * Game Information */ GameInformation gameInfo = new GameInformation() { GameMode = GameMode.Regular }; delegater.Bind(Groups.GameInformation, gameInfo); GameInformationDisplay gameInfoDisplay = new GameInformationDisplay() { DrawOrder = 3 }; delegater.Bind(Groups.GameInformation, gameInfoDisplay); /* * Blob Production */ DirtProducer blobProducer = new DirtProducer(); delegater.Bind(Groups.DirtProduction, blobProducer); /* * Game State Control */ GameStateController stateController = new GameStateController(); delegater.Bind(Groups.GameStateControl, stateController); /* * Menu stuff */ StatueInformation menuStatueInformation = new StatueInformation() { StatueSettings = StatueSettings[0] }; delegater.Bind(Groups.MenuStatuePreview, menuStatueInformation); Statue menuStatue = new Statue() { DrawOrder = 2 }; delegater.Bind(Groups.MenuStatuePreview, menuStatue); StatuePreviewSpinner statueSpinner = new StatuePreviewSpinner(); delegater.Bind(Groups.MenuStatuePreview, statueSpinner); MenuItemsDisplay menuItems = new MenuItemsDisplay() { DrawOrder = 3 }; delegater.Bind(Groups.MenuItemsDisplay, menuItems); /* * Intro */ Intro intro = new Intro(); delegater.Bind(Groups.Intro, intro); // omg, lousy hack.. these two lines makes sure we get to see the damn preview model in menu screen :P // im too tired to find the reason.. the code is such a mess already stateController.GameState = GameState.Playing; stateController.GameState = GameState.Menu; stateController.GameState = GameState.Intro; }
public void Destroy() { FullScreenQuad.Destroy(background); GameObject.Destroy(faceLeftObject); GameObject.Destroy(faceRightObject); }
/// <inheritdoc /> protected override void UnloadContent() { base.UnloadContent(); FullScreenQuad.Dispose(); EnvironmentMapRenderTarget.Dispose(); }
public Game( IAppConfig config, ILogger logger, ICamera camera, IWorld world, OpenGlContext context, IRenderer renderer, IRenderer ndcRenderer, IRenderer skyboxRenderer, ISkybox skybox) { _camera = camera; _logger = logger; _config = config; _title = config.WindowTitle; _context = context; ConfigureContext(); _skybox = skybox; _world = world; GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.FrontFace(FrontFaceDirection.Cw); GL.ClearColor(Color4.Green); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); _renderer = renderer; _ndcRenderer = ndcRenderer; _skyboxRenderer = skyboxRenderer; _skyboxRenderer.BeforeRender = () => { GL.DepthFunc(DepthFunction.Lequal); GL.CullFace(CullFaceMode.Front); }; _skyboxRenderer.AfterRender = () => { GL.CullFace(CullFaceMode.Back); }; _skyboxRenderer.AddToScene(skybox); _traffic = _world.Traffic; _renderer.AddToScene(_traffic); _renderer.AddToScene(_world.Renderables); _backbufferTexture = new Texture(_config.ResolutionWidth, config.ResolutionHeight); _worldRenderer = new BackBufferRenderer( _logger, _backbufferTexture, _config.ResolutionWidth, _config.ResolutionHeight, useDepthBuffer: true); _postprocessTexture = new Texture(_config.ResolutionWidth, _config.ResolutionHeight); _postprocessPipeline = new PostprocessPipeline(_logger, _config, _worldRenderer.Texture, _postprocessTexture); _fullscreenShader = new Shader("vs.vert", "fs.frag"); _fullscreenShader.SetUniformValue("tex", new IntUniform { Value = 0 }); _ndcTexture = _postprocessTexture; var fullScreenQuad = new FullScreenQuad(new[] { _ndcTexture }, _fullscreenShader); _ndcRenderer.AddToScene(fullScreenQuad); }
/// <summary> /// Draws the scene with an environment map. /// </summary> private void DrawEnvironmentMap() { #region Pass 1-6 GraphicsDevice.DepthStencilState = DepthStencilState.Default; // Draw to our cubemap from the robot position for (var face = CubeMapFace.PositiveX; face <= CubeMapFace.NegativeZ; face++) { // Set the render target as our cubemap face, we are drawing the scene in this texture GraphicsDevice.SetRenderTarget(EnvironmentMapRenderTarget, face); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1f, 0); SetCubemapCameraForOrientation(face); CubeMapCamera.BuildView(); // Draw our scene. Do not draw our tank as it would be occluded by itself // (if it has backface culling on) Scene.Draw(Matrix.Identity, CubeMapCamera.View, CubeMapCamera.Projection); } #endregion #region Pass 7 // Set the render target as null, we are drawing on the screen! GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1f, 0); // Draw our scene with the default effect and default camera Scene.Draw(Matrix.Identity, Camera.View, Camera.Projection); // Draw our sphere #region Draw Sphere Effect.CurrentTechnique = Effect.Techniques["EnvironmentMapSphere"]; Effect.Parameters["environmentMap"].SetValue(EnvironmentMapRenderTarget); Effect.Parameters["eyePosition"].SetValue(Camera.Position); var sphereWorld = Matrix.CreateTranslation(SpherePosition); // World is used to transform from model space to world space Effect.Parameters["World"].SetValue(sphereWorld); // InverseTransposeWorld is used to rotate normals Effect.Parameters["InverseTransposeWorld"]?.SetValue(Matrix.Transpose(Matrix.Invert(sphereWorld))); // WorldViewProjection is used to transform from model space to clip space Effect.Parameters["WorldViewProjection"].SetValue(sphereWorld * Camera.View * Camera.Projection); Sphere.Draw(Effect); #endregion #region Draw Robot // Set up our Effect to draw the robot Effect.CurrentTechnique = Effect.Techniques["EnvironmentMap"]; Effect.Parameters["baseTexture"].SetValue(BasicEffect.Texture); // We get the base transform for each mesh var modelMeshesBaseTransforms = new Matrix[Robot.Bones.Count]; Robot.CopyAbsoluteBoneTransformsTo(modelMeshesBaseTransforms); var worldMatrix = Matrix.CreateTranslation(RobotPosition); // World is used to transform from model space to world space Effect.Parameters["World"].SetValue(worldMatrix); // InverseTransposeWorld is used to rotate normals Effect.Parameters["InverseTransposeWorld"]?.SetValue(Matrix.Transpose(Matrix.Invert(worldMatrix))); // WorldViewProjection is used to transform from model space to clip space Effect.Parameters["WorldViewProjection"].SetValue(worldMatrix * Camera.View * Camera.Projection); Robot.Meshes.FirstOrDefault().Draw(); #endregion // Debug our cubemap! // Show a quad DebugTextureEffect.Parameters["World"].SetValue(QuadWorld); DebugTextureEffect.Parameters["cubeMapTexture"]?.SetValue(EnvironmentMapRenderTarget); FullScreenQuad.Draw(DebugTextureEffect); #endregion }
public Launcher() { // Window & Graphics Device // -------------------------------------------------- WindowCreateInfo windowCI = new WindowCreateInfo { X = 50, Y = 50, WindowWidth = 960, WindowHeight = 540, WindowInitialState = WindowState.Normal, WindowTitle = "Glitch Demo" }; GraphicsDeviceOptions gdOptions = new GraphicsDeviceOptions(false, null, false, ResourceBindingModel.Improved, true); #if DEBUG gdOptions.Debug = true; #endif VeldridStartup.CreateWindowAndGraphicsDevice( windowCI, gdOptions, //GraphicsBackend.Metal, //GraphicsBackend.Vulkan, GraphicsBackend.OpenGL, //GraphicsBackend.OpenGLES, out _window, out _gd); _window.Resized += () => _windowResized = true; // Project Manifest // -------------------------------------------------- ProjectManifest projectManifest; string currentDir = AppContext.BaseDirectory; string manifestName = null; foreach (var file in Directory.EnumerateFiles(currentDir + "Assets")) { if (file.EndsWith("manifest")) { if (manifestName != null) { string errorMessage = "Error: Multiple project manifests in this directory: " + currentDir; Console.WriteLine(errorMessage); throw new System.Exception(errorMessage); } manifestName = file; } } using (var fs = File.OpenRead(manifestName)) using (var sr = new StreamReader(fs)) using (var jtr = new JsonTextReader(sr)) { var js = new JsonSerializer(); try { projectManifest = js.Deserialize <ProjectManifest>(jtr); } catch (Exception e) { string errorMessage = "An error was encountered while loading the project manifest."; Console.WriteLine(errorMessage); Console.WriteLine(e); throw new System.NullReferenceException(errorMessage); } } // Initialize Game() // -------------------------------------------------- _game = new Game(); // Assembly & Asset System // -------------------------------------------------- AssemblyLoadSystem als = new AssemblyLoadSystem(); als.LoadFromProjectManifest(projectManifest, AppContext.BaseDirectory); _game.SystemRegistry.Register(als); AssetSystem assetSystem = new AssetSystem(Path.Combine(AppContext.BaseDirectory, projectManifest.AssetRoot), als.Binder); _game.SystemRegistry.Register(assetSystem); // Graphics System // -------------------------------------------------- _gs = new GraphicsSystem(_gd); _game.SystemRegistry.Register(_gs); // Scene // -------------------------------------------------- _scene = new Scene(_gd, _window.Width, _window.Height); // [For Debugging] - Custom SceneAsset Serializer // -------------------------------------------------- SceneAsset programaticSceneAsset = new SceneAsset(); programaticSceneAsset.Name = "MainMenu"; // Custom GameObject (for camera & skybox) GameObject go1 = new GameObject(); go1.Name = "PlayerCamera"; go1.Enabled = true; // Add custom camera to GameObject Camera camera = new Camera(); camera.WindowHeight = _window.Height; camera.WindowWidth = _window.Width; go1.AddComponent(camera); go1.Transform.LocalPosition = new Vector3(0f, 0f, 0f); // Add custom skybox to GameObject Skybox skybox = Skybox.LoadDefaultSkybox(_game.SystemRegistry); go1.AddComponent(skybox); // Custom GameObject (for sphere mesh) GameObject go2 = new GameObject(); go2.Name = "My Sphere"; go2.Enabled = true; // Add custom sphere MeshRenderer component to GameObject Vector3 scale2 = new Vector3(1f); Vector3 offset2 = new Vector3(0f, 0f, -5f); Quaternion rotation2 = Quaternion.Identity; var meshAssetID2 = new AssetID("Internal:SphereModel"); var meshAssetRef2 = new AssetRef <MeshData>(meshAssetID2); var textureAssetID2 = new AssetID("Textures/rust.jpg"); var textureAssetRef2 = new AssetRef <ImageSharpTexture>(textureAssetID2); go2.Transform.LocalPosition = offset2; go2.Transform.LocalRotation = rotation2; go2.Transform.LocalScale = scale2; MeshRenderer meshrenderer2 = new MeshRenderer(meshAssetRef2, textureAssetRef2); go2.AddComponent(meshrenderer2); // Custom GameObject (for plane mesh) GameObject go3 = new GameObject(); go3.Name = "My Plane Model"; go3.Enabled = true; // Add custom Plane MeshRenderer component to GameObject Vector3 scale3 = new Vector3(10f); Vector3 offset3 = new Vector3(0f, -1f, -5f); Quaternion rotation3 = Quaternion.Identity; var meshAssetID3 = new AssetID("Internal:PlaneModel"); var meshAssetRef3 = new AssetRef <MeshData>(meshAssetID3); var textureAssetID3 = new AssetID("Textures/Wood.png"); var textureAssetRef3 = new AssetRef <ImageSharpTexture>(textureAssetID3); go3.Transform.LocalPosition = offset3; go3.Transform.LocalRotation = rotation3; go3.Transform.LocalScale = scale3; MeshRenderer meshrenderer3 = new MeshRenderer(meshAssetRef3, textureAssetRef3); go3.AddComponent(meshrenderer3); // Custom GameObject (another sphere mesh) GameObject go4 = new GameObject(); go4.Name = "Another Sphere"; go4.Enabled = true; Vector3 scale4 = new Vector3(0.5f); Vector3 offset4 = new Vector3(2f, -0.5f, -3f); Quaternion rotation4 = Quaternion.Identity; var meshAssetID4 = new AssetID("Internal:SphereModel"); var meshAssetRef4 = new AssetRef <MeshData>(meshAssetID4); var textureAssetID4 = new AssetID("Textures/rust.jpg"); var textureAssetRef4 = new AssetRef <ImageSharpTexture>(textureAssetID4); go4.Transform.LocalPosition = offset4; go4.Transform.LocalRotation = rotation4; go4.Transform.LocalScale = scale4; MeshRenderer meshrenderer4 = new MeshRenderer(meshAssetRef4, textureAssetRef4); go4.AddComponent(meshrenderer4); // Add custom GameObject to SceneAsset SerializedGameObject sgo1 = new SerializedGameObject(go1); SerializedGameObject sgo2 = new SerializedGameObject(go2); SerializedGameObject sgo3 = new SerializedGameObject(go3); SerializedGameObject sgo4 = new SerializedGameObject(go4); programaticSceneAsset.GameObjects = new SerializedGameObject[4]; programaticSceneAsset.GameObjects[0] = sgo1; programaticSceneAsset.GameObjects[1] = sgo2; programaticSceneAsset.GameObjects[2] = sgo3; programaticSceneAsset.GameObjects[3] = sgo4; // Serialize SceneAsset LooseFileDatabase lfd = new LooseFileDatabase("/Assets"); StringWriter stringwriter = new StringWriter(new StringBuilder()); using (StreamWriter file = File.CreateText(@"DebugSceneAsset.json")) { JsonSerializer serializer = lfd.DefaultSerializer; serializer.Serialize(file, programaticSceneAsset); } // Scene Assets // -------------------------------------------------- SceneAsset sceneAsset; AssetID mainSceneID = projectManifest.OpeningScene.ID; if (mainSceneID.IsEmpty) { var scenes = assetSystem.Database.GetAssetsOfType(typeof(SceneAsset)); if (!scenes.Any()) { Console.WriteLine("No scenes were available to load."); throw new System.Exception("No scenes were available to load."); } else { mainSceneID = scenes.First(); } } var readSceneFromProgramaticAsset = true; sceneAsset = assetSystem.Database.LoadAsset <SceneAsset>(mainSceneID); _scene.LoadSceneAsset(readSceneFromProgramaticAsset ? programaticSceneAsset : sceneAsset); _gs.SetCurrentScene(_scene); // GUI // -------------------------------------------------- _igRenderable = new ImGuiRenderable(_window.Width, _window.Height); _resizeHandled += (w, h) => _igRenderable.WindowResized(w, h); _scene.AddRenderable(_igRenderable); _scene.AddUpdateable(_igRenderable); // Duplicate Screen (for post-processing filters) // -------------------------------------------------- ScreenDuplicator duplicator = new ScreenDuplicator(); _scene.AddRenderable(duplicator); // TODO: rename FullScreenQuad to FinalBufferObject or something _fsq = new FullScreenQuad(); _scene.AddRenderable(_fsq); CreateAllObjects(); }
protected override void UnloadContent() { base.UnloadContent(); FullScreenQuad.Dispose(); SceneRenderTarget.Dispose(); }
public SpotLightRenderer(DX11Game game, GBuffer gBuffer) { this.game = game; this.gBuffer = gBuffer; var device = game.Device; context = device.ImmediateContext; reloadShader(game); quad = new FullScreenQuad(device); layout = FullScreenQuad.CreateInputLayout(device, noShadowsShader.GetCurrentPass(0)); LightPosition = new Vector3(0, 6, 0); LightRadius = 6; LightIntensity = 1; SpotDirection = MathHelper.Down; SpotLightAngle = MathHelper.ToRadians(30); SpotDecayExponent = 1; Color = new Vector3(1, 1, 0.9f); shadowMap = new Texture2D(device, new Texture2DDescription { ArraySize = 1, BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = global::SlimDX.DXGI.Format.R32_Typeless, Width = shadowMapSize, Height = shadowMapSize, MipLevels = 1, Usage = ResourceUsage.Default, SampleDescription = new global::SlimDX.DXGI.SampleDescription(1, 0) }); shadowMapRV = new ShaderResourceView(device, shadowMap, new ShaderResourceViewDescription { Dimension = ShaderResourceViewDimension.Texture2D, Format = global::SlimDX.DXGI.Format.R32_Float, MipLevels = 1, MostDetailedMip = 0 }); shadowMapDSV = new DepthStencilView(device, shadowMap, new DepthStencilViewDescription { Dimension = DepthStencilViewDimension.Texture2D, Format = global::SlimDX.DXGI.Format.D32_Float }); LightCamera = new CustomCamera(); //var rasterizerInside = RasterizerState.FromDescription(device, new RasterizerStateDescription // { // CullMode = CullMode.Front // }); //var rasterizerOutside = RasterizerState.FromDescription(device, new RasterizerStateDescription //{ // CullMode = CullMode.Back //}); }