public LodLevel(Object3dInfo o3i, GenericMaterial gm, float distStart, float distEnd) { DistanceStart = distStart; DistanceEnd = distEnd; Info3d = o3i; Material = gm; ModelMatricesBuffer = new ShaderStorageBuffer(); RotationMatricesBuffer = new ShaderStorageBuffer(); Ids = new ShaderStorageBuffer(); }
public RainSystem(float maxRadius, float maxDrops, float speed, float strength) { Drops = new List <RainDrop>(); DropsBuffer = new ShaderStorageBuffer(); MaxRadius = maxRadius; MaxDrops = maxDrops; Strength = strength; LastUpdate = DateTime.Now; Game.OnUpdate += UpdateDrops; }
public RainSystem(float maxRadius, float maxDrops, float speed, float strength) { Drops = new List<RainDrop>(); DropsBuffer = new ShaderStorageBuffer(); MaxRadius = maxRadius; MaxDrops = maxDrops; Strength = strength; LastUpdate = DateTime.Now; Game.OnUpdate += UpdateDrops; }
public InstancedMesh3d(Object3dInfo objectInfo, GenericMaterial material) { ModelMatricesBuffer = new ShaderStorageBuffer(); RotationMatricesBuffer = new ShaderStorageBuffer(); Randomizer = new Random(); Transformations = new List<TransformationManager>(); Instances = 0; ObjectInfo = objectInfo; Material = material; UpdateMatrix(); }
public PassiveVoxelizer() { VoxelizerShader = ShaderProgram.Compile("Voxelizer.vertex.glsl", "Voxelizer.fragment.glsl"); BoxesSSBO = new ShaderStorageBuffer(); DrawingFramebuffer = new Framebuffer(256, 256, false) { ColorOnly = true, ColorInternalFormat = PixelInternalFormat.R8, ColorPixelType = PixelType.Byte, ColorPixelFormat = PixelFormat.Red }; }
public LodLevel(Object3dInfo o3i, GenericMaterial gm, float distStart, float distEnd) { DistanceStart = distStart; DistanceEnd = distEnd; Info3d = o3i; if (Info3d != null) { BoundingBoxInfo3d = Generators.Object3dGenerator.CreateCube(o3i.BoundingBoxMin, o3i.BoundingBoxMax, Vector2.One).AsObject3dInfo(); } else { BoundingBoxInfo3d = Object3dInfo.Empty; } Material = gm; ModelInfosBuffer = new ShaderStorageBuffer(); }
public ComputeBallsScene() { int instancesAxis = 10; int instances = instancesAxis * instancesAxis * instancesAxis; var ballInfo = Object3dInfo.LoadFromObjSingle(Media.Get("star3d.obj")); // var cb = Object3dGenerator.CreateCube(new Vector3(1000, 1000, 1000), new Vector2(1, 1)); // cb.FlipFaces(); // var sky = new Mesh3d(cb, new GenericMaterial(Color.Black)); // Add(sky); ballInfo.Normalize(); var instanced = new InstancedMesh3d(ballInfo, new GenericMaterial(new Vector4(0, 1, 0, 1))); var instanced2 = new InstancedMesh3d(ballInfo, new GenericMaterial(Color.Green)); //var model = Object3dInfo.LoadFromObjSingle(Media.Get("monkey.obj")); //var vrts = model.GetOrderedVertices(); //vrts = vrts.Distinct().ToList(); var bts3 = new List<Vector4>(); for(int x = 0; x < 20; x++) for(int y = 60; y > 0; y--) { bts3.Add(new Vector4(x, y, 0, 1)); } instanced2.UpdateMatrix(); Add(instanced2); instanced.Instances = instances; var SBuffer = new ShaderStorageBuffer(); var VBuffer = new ShaderStorageBuffer(); var PBuffer = new ShaderStorageBuffer(); GLThread.Invoke(() => { var cshader = new ComputeShader("AIPathFollower.compute.glsl"); var bts = new List<Vector4>(); var bts2 = new List<Vector4>(); var rand = new Random(); PBuffer.MapData(bts3.ToArray()); for(int x = 0; x < 12; x++) { for(int y = 0; y < 90; y++) { for(int z = 0; z < 12; z++) { instanced.Transformations.Add(new TransformationManager(new Vector3(x * 5, y + 300, z * 5), Quaternion.Identity, 1.5f)); bts.Add(new Vector4(x * 5, y + 300, z * 5, 1)); bts2.Add(new Vector4(0, 0, 0, 1)); } } } SBuffer.MapData(bts.ToArray()); VBuffer.MapData(bts2.ToArray()); instanced.UpdateMatrix(); GLThread.OnBeforeDraw += (o, e) => { cshader.Use(); instanced.ModelMatricesBuffer.Use(0); SBuffer.Use(1); VBuffer.Use(2); PBuffer.Use(3); cshader.SetUniform("BallsCount", instances); cshader.SetUniform("PathPointsCount", bts3.Count); cshader.SetUniform("Time", (float)(DateTime.Now - GLThread.StartTime).TotalMilliseconds / 1000); cshader.Dispatch(12, 90, 12); }; }); Add(instanced); }
public PostProcessing(int initialWidth, int initialHeight) { //FullScene3DTexture = new Texture3D(new Vector3(64, 64, 64)); TestBuffer = new ShaderStorageBuffer(); NumbersTexture = new Texture(Media.Get("numbers.png")); CShader = new ComputeShader("Blur.compute.glsl"); GLThread.Invoke(() => { TestBuffer.MapData(new Vector3[4]{ new Vector3(1, 0.25f, 1), new Vector3(0, 0.55f, 0.75f), new Vector3(1, 0.25f, 0), new Vector3(0.55f, 0, 0.75f) }); }); Width = initialWidth; Height = initialHeight; MSAAResolvingFrameBuffer = new Framebuffer(initialWidth, initialHeight); MSAAResolvingFrameBuffer.SetMultiSample(true); MRT = new MRTFramebuffer(initialWidth, initialHeight); BackMRT = new MRTFramebuffer(initialWidth / 4, initialHeight / 4); Pass1FrameBuffer = new Framebuffer(initialWidth, initialHeight); Pass2FrameBuffer = new Framebuffer(initialWidth, initialHeight); LightPointsFrameBuffer = new Framebuffer(initialWidth / 6, initialHeight / 6); BloomFrameBuffer = new Framebuffer(initialWidth / 4, initialHeight / 4); FogFramebuffer = new Framebuffer(initialWidth, initialHeight); SmallFrameBuffer = new Framebuffer(initialWidth / 10, initialHeight / 10); LastWorldPositionFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); RSMFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); SSReflectionsFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); VDAOFramebuffer = new Framebuffer(initialWidth / 1, initialHeight / 1); GlobalIlluminationFrameBuffer = new Framebuffer(initialWidth, initialHeight); //GlobalIlluminationFrameBuffer.ColorInternalFormat = PixelInternalFormat.R8; //GlobalIlluminationFrameBuffer.ColorPixelFormat = PixelFormat.Red; //GlobalIlluminationFrameBuffer.ColorPixelType = PixelType.UnsignedByte; GlobalIlluminationFrameBuffer.Use(); //BackDiffuseFrameBuffer = new Framebuffer(initialWidth / 2, initialHeight / 2); //BackNormalsFrameBuffer = new Framebuffer(initialWidth / 2, initialHeight / 2); ScreenSpaceNormalsWriterShader = ShaderProgram.Compile("Generic.vertex.glsl", "ScreenSpaceNormalsWriter.fragment.glsl"); BackDepthWriterShader = ShaderProgram.Compile("Generic.vertex.glsl", "BackDepthWriter.fragment.glsl"); BloomShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Bloom.fragment.glsl"); MSAAShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "MSAA.fragment.glsl"); SSAOShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "SSAO.fragment.glsl"); FogShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Fog.fragment.glsl"); LightPointsShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "LightPoints.fragment.glsl"); LensBlurShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "LensBlur.fragment.glsl"); HDRShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "HDR.fragment.glsl"); BlitShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Blit.fragment.glsl"); DeferredShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Deferred.fragment.glsl"); CombinerShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Combiner.fragment.glsl"); PathTracerOutputShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "Output.fragment.glsl"); GlobalIlluminationShaderX = ShaderProgram.Compile("PostProcess.vertex.glsl", "GlobalIllumination.fragment.glsl"); GlobalIlluminationShaderX.SetGlobal("SEED", "gl_FragCoord.x"); GlobalIlluminationShaderY = ShaderProgram.Compile("PostProcess.vertex.glsl", "GlobalIllumination.fragment.glsl"); GlobalIlluminationShaderY.SetGlobal("SEED", "gl_FragCoord.y"); RSMShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "RSM.fragment.glsl"); SSReflectionsShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "SSReflections.fragment.glsl"); VDAOShader = ShaderProgram.Compile("PostProcess.vertex.glsl", "VDAO.fragment.glsl"); //ReflectShader = ShaderProgram.Compile(Media.ReadAllText("PostProcess.vertex.glsl"), Media.ReadAllText("Reflect.fragment.glsl")); Object3dInfo postPlane3dInfo = new Object3dInfo(postProcessingPlaneVertices, postProcessingPlaneIndices); PostProcessingMesh = new Mesh3d(postPlane3dInfo, new GenericMaterial(Color.Pink)); }
public static FreeCamera SetUpFreeCamera() { CameraSavedViews = new Dictionary<int, TransformationManager>(); float aspect = Game.Resolution.Height > Game.Resolution.Width ? Game.Resolution.Height / Game.Resolution.Width : Game.Resolution.Width / Game.Resolution.Height; var freeCamera = new FreeCamera((float)Game.Resolution.Width / (float)Game.Resolution.Height, MathHelper.PiOver3 / 1); FreeCam = freeCamera; PickingResult = new ShaderStorageBuffer(); MousePicker = new ComputeShader("MousePicker.compute.glsl"); return freeCamera; }