public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(new DepthTest(true)); renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE)); shaderProgramPhong = contentLoader.Load <IShaderProgram>("phong.*"); var mesh = new DefaultMesh(); var roomSize = 8; //off-center plane var plane = Meshes.CreatePlane(roomSize, roomSize, 2, 2).Transform(Transformation.Translation(0, -roomSize / 2, 0)); mesh.Add(plane); //rotate plane to create box mesh.Add(plane.Transform(Transformation.Rotation(90f, Axis.Z))); mesh.Add(plane.Transform(Transformation.Rotation(180f, Axis.Z))); mesh.Add(plane.Transform(Transformation.Rotation(270f, Axis.Z))); mesh.Add(plane.Transform(Transformation.Rotation(90f, Axis.X))); mesh.Add(plane.Transform(Transformation.Rotation(-90f, Axis.X))); var sphere = Meshes.CreateSphere(1); sphere.SetConstantUV(Vector2.Zero); //all other meshes have texture coordinates mesh.Add(sphere); var suzanne = contentLoader.Load <DefaultMesh>("suzanne"); mesh.Add(suzanne.Transform(Transformation.Translation(2, 2, -2))); geometryPhong = VAOLoader.FromMesh(mesh, shaderProgramPhong); shaderProgramToon = contentLoader.Load <IShaderProgram>("toon.*"); geometryToon = VAOLoader.FromMesh(suzanne.Transform(Transformation.Translation(2, 0, 0)), shaderProgramToon); }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(BoolState <IDepthState> .Enabled); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); var mesh = contentLoader.Load <DefaultMesh>("suzanne.obj"); geometry = VAOLoader.FromMesh(mesh, shaderProgram); //per instance attributes var rnd = new Random(12); float Rnd01() => (float)rnd.NextDouble(); float RndCoord() => (Rnd01() - 0.5f) * 2.0f; var instancePositions = new Vector3[instanceCount]; var velocities = new Vector3[instanceCount]; for (int i = 0; i < instanceCount; ++i) { instancePositions[i] = new Vector3(RndCoord(), RndCoord(), RndCoord() + 1); velocities[i] = new Vector3(RndCoord(), RndCoord(), 0.0f).Normalized() * Rnd01(); } geometry.SetAttribute(shaderProgram.GetResourceLocation(ShaderResourceType.Attribute, "instancePosition"), instancePositions, VertexAttribPointerType.Float, 3, true); geometry.SetAttribute(shaderProgram.GetResourceLocation(ShaderResourceType.Attribute, "velocity"), velocities, VertexAttribPointerType.Float, 3, true); //TODO students: add per instance attribute speed here }
GameObject GetPBRModel(string meshFileName, string albedoMapFile, string normalMapFile, string metallicMapFile, string roughnessMapFile) { DefaultMesh mesh = contentLoader.Load <DefaultMesh>(meshFileName); VAO geom = VAOLoader.FromMesh(mesh, renderer.GetPBRShader()); GameObject go = new GameObject(); PBRMaterial mat = new PBRMaterial(); go.mesh = geom; go.material = mat; //mat.metal = 1.0f; //mat.metal = 0f; mat.roughness = 0; if (albedoMapFile != null) { ITexture2D albedoMap = contentLoader.Load <ITexture2D>(albedoMapFile); mat.albedoMap = albedoMap; } if (normalMapFile != null && normalMapFile != "") { ITexture2D normalMap = contentLoader.Load <ITexture2D>(normalMapFile); mat.normalMap = normalMap; } if (metallicMapFile != null) { ITexture2D metallicMap = contentLoader.Load <ITexture2D>(metallicMapFile); mat.metallicMap = metallicMap; } if (roughnessMapFile != null) { ITexture2D roughnessMap = contentLoader.Load <ITexture2D>(roughnessMapFile); mat.roughnessMap = roughnessMap; } return(go); }
public Deferred(IContentLoader contentLoader, Dictionary <Enums.EntityType, DefaultMesh> meshes) { _deferredProgram = contentLoader.Load <IShaderProgram>("deferred.*"); foreach (var meshContainer in meshes) { VAO geometry = VAOLoader.FromMesh(meshContainer.Value, _deferredProgram); if (meshContainer.Value is TBNMesh mesh) { var loc = _deferredProgram.GetResourceLocation(ShaderResourceType.Attribute, TBNMesh.TangentName); geometry.SetAttribute(loc, mesh.Tangent.ToArray(), VertexAttribPointerType.Float, 3); loc = _deferredProgram.GetResourceLocation(ShaderResourceType.Attribute, TBNMesh.BitangentName); geometry.SetAttribute(loc, mesh.Bitangent.ToArray(), VertexAttribPointerType.Float, 3); } _geometries.Add(meshContainer.Key, geometry); } _defaultMap = contentLoader.Load <ITexture2D>("Nvidia.png"); _projectilesGenerationNvidia = new ProjectileGeneration(contentLoader, meshes[Enums.EntityType.NvidiaParticle], Enums.EntityType.NvidiaParticle); _projectilesGenerationRadeon = new ProjectileGeneration(contentLoader, meshes[Enums.EntityType.RadeonParticle], Enums.EntityType.RadeonParticle); _addProjectilesNvidia = new AddWithDepthTest(contentLoader); _addProjectilesRadeon = new AddWithDepthTest(contentLoader); _tesselation = new Tesselation(contentLoader); _addTesselation = new AddWithDepthTest(contentLoader); }
public void ShaderChanged(string name, Shader shader) { if (ShaderName == name) { this.shader = shader; if (ReferenceEquals(shader, null)) { return; } Mesh mesh = Meshes.CreateQuad(10, 10, 10, 10); var sphere = Meshes.CreateSphere(0.5f, 2); sphere.SetConstantUV(new System.Numerics.Vector2(0.5f, 0.5f)); var xform = new Transformation(); xform.TranslateLocal(0, 2, -2); mesh.Add(sphere.Transform(xform)); xform.TranslateGlobal(0, 0, 2); mesh.Add(sphere.Transform(xform)); xform.TranslateGlobal(2, 0, -1); mesh.Add(sphere.Transform(xform)); geometry = VAOLoader.FromMesh(mesh, shader); } else if (ShaderDepthName == name) { this.shaderDepth = shader; if (ReferenceEquals(shaderDepth, null)) { return; } //todo: radeon cards make errors with geometry bound to one shader and use in other shaders because of binding id changes } }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(BoolState <IDepthState> .Enabled); renderState.Set(BoolState <IBackfaceCullingState> .Enabled); renderState.Set(BlendStates.AlphaBlend); shaderProgram = contentLoader.Load <IShaderProgram>("phong.*"); var mesh = new DefaultMesh(); var roomSize = 8; //off-center plane var plane = Meshes.CreatePlane(roomSize, roomSize, 2, 2).Transform(new Translation3D(0, -roomSize / 2, 0)); mesh.Add(plane); //rotate plane to create box mesh.Add(plane.Transform(new Rotation3D(Axis.Z, 90f))); mesh.Add(plane.Transform(new Rotation3D(Axis.Z, 180f))); mesh.Add(plane.Transform(new Rotation3D(Axis.Z, 270f))); mesh.Add(plane.Transform(new Rotation3D(Axis.X, 90f))); mesh.Add(plane.Transform(new Rotation3D(Axis.X, -90f))); var sphere = Meshes.CreateSphere(1); sphere.SetConstantUV(new Vector2(0, 0)); mesh.Add(sphere); var suzanne = contentLoader.Load <DefaultMesh>("suzanne"); mesh.Add(suzanne.Transform(new Translation3D(2, 2, -2))); geometry = VAOLoader.FromMesh(mesh, shaderProgram); }
public DeferredRenderer(IContentLoader contentLoader, IRenderState renderState) { renderState.Set <DepthTest>(new DepthTest(true)); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.Blend); GL.CullFace(CullFaceMode.Back); this.renderState = renderState; this.contentLoader = contentLoader; deferredParticleShader = contentLoader.Load <IShaderProgram>("deferred_particle.*"); shadowMapShaderParticle = contentLoader.Load <IShaderProgram>("shadowMapParticle.*"); shadowLightViewShaderParticle = contentLoader.Load <IShaderProgram>("shadowLightViewParticle.*"); deferredGeometryShader = contentLoader.Load <IShaderProgram>("deferred_geometry.*"); deferredPost = contentLoader.LoadPixelShader("deferred_post"); pointLightShader = contentLoader.Load <IShaderProgram>("def_pointLight.*"); shadowMapShader = contentLoader.Load <IShaderProgram>("shadowMap.*"); shadowLightViewShader = contentLoader.Load <IShaderProgram>("shadowLightView.*"); var lmesh = Meshes.CreateSphere(1, 2); pointLightSphere = VAOLoader.FromMesh(lmesh, pointLightShader); }
private void UpdateGeometry(Shader shader) { Mesh mesh = new Mesh(); var roomSize = 8; var plane = Meshes.CreateQuad(roomSize, roomSize, 2, 2); var xform = new Transformation(); xform.TranslateGlobal(0, -roomSize / 2, 0); mesh.Add(plane.Transform(xform)); xform.RotateZGlobal(90f); mesh.Add(plane.Transform(xform)); xform.RotateZGlobal(90f); mesh.Add(plane.Transform(xform)); xform.RotateZGlobal(90f); mesh.Add(plane.Transform(xform)); xform.RotateYGlobal(90f); mesh.Add(plane.Transform(xform)); xform.RotateYGlobal(180f); mesh.Add(plane.Transform(xform)); var sphere = Meshes.CreateSphere(1); mesh.Add(sphere); var suzanne = Obj2Mesh.FromObj(Resourcen.suzanne); mesh.Add(suzanne.Transform(System.Numerics.Matrix4x4.CreateTranslation(2, 2, -2))); geometry = VAOLoader.FromMesh(mesh, shader); }
public TextureRenderer2D(Vector2 position, Vector2 size, Texture texture, Shader shader) { _texture = texture; _shader = shader; DefaultMesh mesh = new DefaultMesh(); mesh.Position.Add(new Vector3(position.X, position.Y, 0)); //0 mesh.Position.Add(new Vector3(position.X + size.X, position.Y, 0)); //1 mesh.Position.Add(new Vector3(position.X + size.X, position.Y + size.Y, 0)); //2 mesh.Position.Add(new Vector3(position.X, position.Y + size.Y, 0)); //3 mesh.TexCoord.Add(new Vector2(0.0f, 0.0f)); mesh.TexCoord.Add(new Vector2(1.0f, 0.0f)); mesh.TexCoord.Add(new Vector2(1.0f, 1.0f)); mesh.TexCoord.Add(new Vector2(0.0f, 1.0f)); mesh.IDs.Add(0); mesh.IDs.Add(2); mesh.IDs.Add(1); mesh.IDs.Add(0); mesh.IDs.Add(3); mesh.IDs.Add(2); _geometry = VAOLoader.FromMesh(mesh, shader); }
public void ShaderChanged(string name, Shader shader) { if (ShaderName != name) { return; } this.shader = shader; if (ReferenceEquals(shader, null)) { return; } Mesh mesh = Obj2Mesh.FromObj(Resourcen.suzanne); geometry = VAOLoader.FromMesh(mesh, shader); //per instance attributes var rnd = new Random(12); Func <float> Rnd01 = () => (float)rnd.NextDouble(); Func <float> RndCoord = () => (Rnd01() - 0.5f) * 35.0f; var instancePositions = new Vector3[particelCount]; for (int i = 0; i < particelCount; ++i) { instancePositions[i] = new Vector3(RndCoord(), RndCoord(), RndCoord()); } geometry.SetAttribute(shader.GetAttributeLocation("instancePosition"), instancePositions, VertexAttribPointerType.Float, 3, true); }
uint CreateIrradianceMap(int frameBuffer, Matrix4x4 projection, Matrix4x4[] viewMatrices, uint cubeMap) { DefaultMesh cubeMesh = Meshes.CreateCubeWithNormals(); VAO renderIrradMapCube = VAOLoader.FromMesh(cubeMesh, irradianceMapShader); //Create Irradiance Texture int fbIrrWidth = 32; int fbIrrHeight = 32; int irradMap = CreateCubeMap(32, 32); GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer); //GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMap, irradMap, 0); //Render //Irradiance Map irradianceMapShader.Activate(); SetSampler(irradianceMapShader.ProgramID, 0, "environmentMap", cubeMap, TextureTarget.TextureCubeMap); irradianceMapShader.Uniform("projection", projection, true); GL.Viewport(0, 0, fbIrrWidth, fbIrrHeight); GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer); for (int i = 0; i < 6; i++) { irradianceMapShader.Uniform("view", viewMatrices[i], true); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMapPositiveX + i, irradMap, 0); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); renderIrradMapCube.Draw(); } GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); return((uint)irradMap); }
private void UpdateMesh(Shader shader) { Mesh mesh = Obj2Mesh.FromObj(Resourcen.suzanne); geometry = VAOLoader.FromMesh(mesh, shader); //per instance attributes var rnd = new Random(12); Func <float> Rnd01 = () => (float)rnd.NextDouble(); Func <float> RndCoord = () => (Rnd01() - 0.5f) * 8.0f; var instancePositions = new Vector3[particelCount]; for (int i = 0; i < particelCount; ++i) { instancePositions[i] = new Vector3(RndCoord(), RndCoord(), RndCoord()); } geometry.SetAttribute(shader.GetAttributeLocation("instancePosition"), instancePositions, VertexAttribPointerType.Float, 3, true); Func <float> RndSpeed = () => (Rnd01() - 0.5f); var instanceSpeeds = new Vector3[particelCount]; for (int i = 0; i < particelCount; ++i) { instanceSpeeds[i] = new Vector3(RndSpeed(), RndSpeed(), RndSpeed()); } geometry.SetAttribute(shader.GetAttributeLocation("instanceSpeed"), instanceSpeeds, VertexAttribPointerType.Float, 3, true); }
private Dictionary <IVertexArrayObject, int> PrepareVAOs(IEnumerable <Entity> entities) { Dictionary <IVertexArrayObject, int> simulatorVAOs = new Dictionary <IVertexArrayObject, int>(); Dictionary <Enums.EntityType, IVertexArrayObject> simVAOs = new Dictionary <Enums.EntityType, IVertexArrayObject>(); Dictionary <Enums.EntityType, List <Matrix4x4> > transformations = new Dictionary <Enums.EntityType, List <Matrix4x4> >(); Dictionary <Enums.EntityType, List <Vector4> > colors = new Dictionary <Enums.EntityType, List <Vector4> >(); Dictionary <Enums.EntityType, int> instanceCounts = new Dictionary <Enums.EntityType, int>(); foreach (var entity in entities) { if (!simVAOs.ContainsKey(entity.Type)) { Mesh mesh = null; switch (entity.Type) { case Enums.EntityType.Triangle: mesh = MeshCreator.CreateTriangle(); break; case Enums.EntityType.Tetrahedron: mesh = MeshCreator.CreateteTrahedron(); break; } if (mesh != null) { switch (_wrapper) { case RenderSimulator _: simVAOs.Add(entity.Type, VAOLoader.FromMesh <SimulatorVAO>(mesh, new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), new object[] { _wrapper })); break; case RenderTranslator _: simVAOs.Add(entity.Type, VAOLoader.FromMesh <TranslatorVAO>(mesh, new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), new object[] { _wrapper })); break; } transformations.Add(entity.Type, new List <Matrix4x4>()); colors.Add(entity.Type, new List <Vector4>()); instanceCounts.Add(entity.Type, 0); } } if (transformations.ContainsKey(entity.Type)) { transformations[entity.Type].Add(entity.Transformation); colors[entity.Type].Add(entity.Color); instanceCounts[entity.Type]++; } } foreach (var key in simVAOs.Keys) { simVAOs[key].SetAttribute("InstanceTransformation", new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), transformations[key], true); simVAOs[key].SetAttribute("Color", new Tuple <VertexShader, FragmentShader>(_vertex, _fragment), colors[key], true); simulatorVAOs.Add(simVAOs[key], instanceCounts[key]); } return(simulatorVAOs); }
private void UpdateRaytraceMesh() { DefaultMesh mesh = new DefaultMesh(); mesh.Add(Meshes.CreateCubeWithNormals(_voxelSize).Transform(Matrix4x4.CreateTranslation(_raytraceVoxelPosition))); _raytraceGeometry = VAOLoader.FromMesh(mesh, _raytraceShader); }
public VisualPlane(IRenderState renderState, IContentLoader contentLoader) { shdPlane = contentLoader.Load <IShaderProgram>("plane.*"); var mesh = Meshes.CreatePlane(2, 2, 1, 1); plane = VAOLoader.FromMesh(mesh, shdPlane); this.renderState = renderState; }
private void UpdateGeometry(Shader shader) { Mesh mesh = new Mesh(); //mesh.Add(Meshes.CreateSphere(.7f, 3)); mesh.Add(Obj2Mesh.FromObj(Resourcen.suzanne)); geometry = VAOLoader.FromMesh(mesh, shader); }
public ProjectileGeneration(IContentLoader contentLoader, DefaultMesh triangleMesh, Enums.EntityType triangleType) { _projectileGenerationProgram = contentLoader.Load <IShaderProgram>(new[] { "ProjectileGeneration.vert", "deferred.frag" }); _trianglesGeometry = VAOLoader.FromMesh(triangleMesh, _projectileGenerationProgram); _triangleType = triangleType; _add = new AddWithDepthTest(contentLoader); }
public SphereCut(IContentLoader contentLoader, float size) { _sphereCutProgram = contentLoader.Load <IShaderProgram>("imageOnGeometry.*"); var sphere = Meshes.CreateSphere(size, 5).SwitchHandedness(); _sphereGeometry = VAOLoader.FromMesh(sphere, _sphereCutProgram); }
public PBRRenderer(IRenderState renderState, IContentLoader contentLoader) { iblMapList = new List <IBLSetup>(); GL.Enable(EnableCap.DebugOutput); GL.Enable(EnableCap.TextureCubeMapSeamless); this.renderState = renderState; GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.TextureCubeMap); renderState.Set(new DepthTest(true)); //pbrShader = contentLoader.Load<IShaderProgram>("PBRLightingBasic.*"); pbrShader = contentLoader.Load <IShaderProgram>("PBRLighting.*"); //pbrShader = contentLoader.Load<IShaderProgram>("PBRReference.*"); skyboxShader = contentLoader.Load <IShaderProgram>("Skybox.*"); cubeProjectionShader = contentLoader.Load <IShaderProgram>("CubeMapProjection.*"); textureTest = contentLoader.Load <IShaderProgram>("DisplayTexture2D.*"); irradianceMapShader = contentLoader.Load <IShaderProgram>("IrradianceMap.*"); prefilterMapShader = contentLoader.Load <IShaderProgram>("PrefilterIBLMap.*"); integrationMapShader = contentLoader.Load <IShaderProgram>("BRDFIntegration.*"); dLight = new DirectionalLight(); dLight.direction = new Vector3(0, 1, -1); dLight.color = new Vector3(10); dLight.position = new Vector3(0, 1, -1); Vector3 startPos = new Vector3(0, 0, 0.5f); pointLights = new PointLight[4]; for (int i = 0; i < 4; i++) { pointLights[i] = new PointLight(); pointLights[i].color = new Vector3(1); pointLights[i].radius = 1; pointLights[i].position = startPos; } pointLights[0].position = new Vector3(-1, 1, 0.5f); pointLights[1].position = new Vector3(-1, -1, 0.5f); pointLights[2].position = new Vector3(1, -1, 0.5f); pointLights[3].position = new Vector3(1, 1, 0.5f); int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(PointLight)) * pointLights.Length; //Generate buffer and allocate memory ubo = GL.GenBuffer(); GL.BindBuffer(BufferTarget.UniformBuffer, ubo); GL.BufferData(BufferTarget.UniformBuffer, size, pointLights, BufferUsageHint.DynamicDraw); //Assign Buffer Block to ubo int uniformID = GL.GetUniformBlockIndex(pbrShader.ProgramID, "BufferPointLights"); GL.UniformBlockBinding(pbrShader.ProgramID, uniformID, 0); GL.BindBufferBase(BufferRangeTarget.UniformBuffer, 0, ubo); DefaultMesh cubeMesh = Meshes.CreateCubeWithNormals(); unitCube = VAOLoader.FromMesh(cubeMesh, cubeProjectionShader); renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE)); }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(new DepthTest(true)); renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE)); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); var mesh = contentLoader.Load <DefaultMesh>("suzanne"); geometryBody = VAOLoader.FromMesh(mesh, shaderProgram); }
public DirectionalShadowMapping(IContentLoader contentLoader, Dictionary <Enums.EntityType, DefaultMesh> meshes) { _depthShader = contentLoader.Load <IShaderProgram>("depth.*"); _shadowShader = contentLoader.LoadPixelShader("shadow.glsl"); foreach (var meshContainer in meshes) { _geometriesDepth.Add(meshContainer.Key, VAOLoader.FromMesh(meshContainer.Value, _depthShader)); } }
public VisualPlane() { var sVertex = Encoding.UTF8.GetString(Resourcen.plane_vert); var sFragment = Encoding.UTF8.GetString(Resourcen.plane_frag); shdPlane = ShaderLoader.FromStrings(sVertex, sFragment); var mesh = Meshes.CreateQuad(2, 2, 1, 1); plane = VAOLoader.FromMesh(mesh, shdPlane); }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(BoolState <IDepthState> .Enabled); renderState.Set(BoolState <IBackfaceCullingState> .Enabled); texDiffuse = contentLoader.Load <ITexture2D>("capsule0.jpg"); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); //load geometry var mesh = contentLoader.Load <DefaultMesh>("capsule.obj"); geometry = VAOLoader.FromMesh(mesh, shaderProgram); }
private void UpdateGeometry(Shader shader) { var mesh = new Mesh(); var sphere = Meshes.CreateSphere(1, 4); mesh.Add(sphere); var suzanne = Obj2Mesh.FromObj(Resourcen.suzanne); mesh.Add(suzanne.Transform(System.Numerics.Matrix4x4.CreateTranslation(2, 2, -2))); geometry = VAOLoader.FromMesh(mesh, shader); }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(new DepthTest(true)); renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE)); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); var mesh = Meshes.CreateCornellBox(); geometry = VAOLoader.FromMesh(mesh, shaderProgram); bufferMaterials.Set(Meshes.CreateCornellBoxMaterial(), BufferUsageHint.StaticDraw); }
public DeferedVisual(IRenderState renderState, IContentLoader contentLoader) { this.renderState = renderState; deferedDataProgram = contentLoader.Load <IShaderProgram>(new string[] { "lambert.vert", "deferedData.frag" }); deferedProgram = contentLoader.LoadPixelShader("defered.frag"); //deferedProgram = contentLoader.Load<IShaderProgram>("lambert.*"); var mesh = Meshes.CreateCornellBox(); //TODO: ATI seams to do VAO vertex attribute ordering different for each shader would need to create own VAO geometry = VAOLoader.FromMesh(mesh, deferedDataProgram); }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(new DepthTest(true)); renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE)); //texDiffuse = contentLoader.Load<ITexture2D>("capsule0"); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); //load geometry var mesh = contentLoader.Load <DefaultMesh>("suzanne"); geometry = VAOLoader.FromMesh(mesh, shaderProgram); }
public MainVisualHeightField(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(BoolState <IDepthState> .Enabled); renderState.Set(BoolState <IBackfaceCullingState> .Enabled); texDiffuse = contentLoader.Load <ITexture2D>("capsule0.jpg"); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); //load geometry var mesh = Meshes.CreatePlane(100, 100, 1024, 1024); geometry = VAOLoader.FromMesh(mesh, shaderProgram); camera = new CameraOrbit(); }
private void UpdateChunkDepthGeomatry(Vector3I position, VoxelMesh mesh) { VAO depthGeometry = VAOLoader.FromMesh(mesh.DefaultMesh, _depthShader); if (_chunkDepthGeometrys.ContainsKey(position)) { _chunkDepthGeometrys[position] = depthGeometry; } else { _chunkDepthGeometrys.Add(position, depthGeometry); } }
public MainVisual(IRenderState renderState, IContentLoader contentLoader) { renderState.Set(BoolState <IDepthState> .Enabled); renderState.Set(BoolState <IBackfaceCullingState> .Enabled); shaderProgram = contentLoader.Load <IShaderProgram>("shader.*"); var mesh = contentLoader.Load <DefaultMesh>("suzanne"); geometryBody = VAOLoader.FromMesh(mesh, shaderProgram); floorShaderProgram = contentLoader.Load <IShaderProgram>("floor.*"); floor = VAOLoader.FromMesh(Meshes.CreatePlane(100, 100, 1, 1).Transform(new Translation3D(new Vector3(0, -30, 0))), floorShaderProgram); waterCube = VAOLoader.FromMesh(Meshes.CreateCubeWithNormals(100).Transform(new Translation3D(new Vector3(-50, -50, 0))), floorShaderProgram); }