public override IResource create(ResourceManager mgr) { SkyBox m = new SkyBox(); JsonObject cubemap = descriptor["cubemap"]; List <String> faces = new List <string>(); faces.Add(Path.Combine(path, (string)cubemap["+x"])); faces.Add(Path.Combine(path, (string)cubemap["-x"])); faces.Add(Path.Combine(path, (string)cubemap["+y"])); faces.Add(Path.Combine(path, (string)cubemap["-y"])); faces.Add(Path.Combine(path, (string)cubemap["+z"])); faces.Add(Path.Combine(path, (string)cubemap["-z"])); CubemapTextureDescriptor td = new CubemapTextureDescriptor(faces); CubemapTexture tex = mgr.getResource(td) as CubemapTexture; if (tex == null) { return(null); } m.mesh.material = new Material(name); m.mesh.material.myFeatures |= Material.Feature.Skybox; m.mesh.material.myTextures[(int)Material.TextureId.Skybox] = new TextureAttribute("skybox", tex); return(m); }
public override void updateRenderState(Material m, RenderState rs) { CubemapTexture cubemap = m.myTextures[(int)Material.TextureId.Skybox].value() as CubemapTexture; rs.setTexture((int)cubemap.id(), 0, TextureTarget.TextureCubeMap); rs.setUniform(new UniformData(20, Uniform.UniformType.Int, 0)); // we know this location from the shader rs.setVertexBuffer(SkyBox.theVbo.id, 0, 0, V3.stride); rs.setIndexBuffer(SkyBox.theIbo.id); }
public override IResource create(ResourceManager mgr) { CubemapTexture t = new CubemapTexture(myFaces, myFlip); if (t.isValid == false) { return(null); } if (myObjName != "") { t.setName(myObjName); } return(t); }