def set_envmap(self, envmap): fmt = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT) em = np.zeros(envmap.shape[:2] + (4, ), dtype=np.float32) em[:, :, :3] = envmap em[:, :, 3] = 1 self.envmap = cl.Image(context, mf.READ_ONLY | mf.COPY_HOST_PTR, fmt, shape=em.shape[:2], hostbuf=em) self.sampler = cl.Sampler(context, True, cl.addressing_mode.CLAMP, cl.filter_mode.LINEAR) def set_molecule(self, mol): self.mol = mol self.spheredata = cl.Buffer(context, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=self.mol.spheredata) def load_molecule(self, filename): self.set_molecule(Molecule(filename)) if __name__ == "__main__": from pfmloader import load_pfm r = CLRender() r.set_molecule(Molecule('data/sugars/sucrose.pdb')) r.set_envmap(load_pfm('data/probes/stpeters_probe.pfm')) r.compute()
def load_envmap(self, filename): envmap = load_pfm(filename) self.clrender.set_envmap(envmap) self.glrender.set_envmap(envmap)
for e in [e3]: print (e.profile.END - e.profile.START)*1e-9 glBindTexture(GL_TEXTURE_2D, self.dstTex) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, N, N, GL_RGBA, GL_UNSIGNED_BYTE, self.dst) def set_envmap(self, envmap): fmt = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT) em = np.zeros(envmap.shape[:2] + (4,), dtype=np.float32) em[:,:,:3] = envmap; em[:,:,3] = 1; self.envmap = cl.Image(context, mf.READ_ONLY | mf.COPY_HOST_PTR, fmt, shape=em.shape[:2], hostbuf=em) self.sampler = cl.Sampler(context, True, cl.addressing_mode.CLAMP, cl.filter_mode.LINEAR) def set_molecule(self, mol): self.mol = mol self.spheredata = cl.Buffer(context, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf = self.mol.spheredata) def load_molecule(self, filename): self.set_molecule(Molecule(filename)) if __name__ == "__main__": from pfmloader import load_pfm r = CLRender() r.set_molecule(Molecule('data/sugars/sucrose.pdb')) r.set_envmap(load_pfm('data/probes/stpeters_probe.pfm')) r.compute()