def fog_on_off(self): if self.has_gl: if not self.fogmode: self.has_fog = 1 glEnable(GL_FOG) glFogf(GL_FOG_MODE, GL_LINEAR) glHint(GL_FOG_HINT, GL_NICEST) """ glFogf(GL_FOG_DENSITY,0.2) c=self.camera.GetDistance() s=self.slab z=self.zpos glFogf(GL_FOG_START, c-z-s/2.) glFogf(GL_FOG_END, 2000) self.renwin.Render() """ self.update_fog_dist() self.update_fog_density() self.itf.dist.configure(state=tk.NORMAL) self.itf.density.configure(state=tk.NORMAL) self.fogmode = 1 else: glDisable(GL_FOG) self.renwin.Render() self.itf.dist.configure(state=tk.DISABLED) self.itf.density.configure(state=tk.DISABLED) self.fogmode = 0
def fog_on_off(self): if self.has_gl : if not self.fogmode: self.has_fog=1 glEnable(GL_FOG) glFogf(GL_FOG_MODE, GL_LINEAR) glHint(GL_FOG_HINT, GL_NICEST) """ glFogf(GL_FOG_DENSITY,0.2) c=self.camera.GetDistance() s=self.slab z=self.zpos glFogf(GL_FOG_START, c-z-s/2.) glFogf(GL_FOG_END, 2000) self.renwin.Render() """ self.update_fog_dist() self.update_fog_density() self.itf.dist.configure(state=tk.NORMAL) self.itf.density.configure(state=tk.NORMAL) self.fogmode=1 else: glDisable(GL_FOG) self.renwin.Render() self.itf.dist.configure(state=tk.DISABLED) self.itf.density.configure(state=tk.DISABLED) self.fogmode=0
def update_fog_dist(self, obj=None, event=None): """ changes fog of rendering""" c = self.camera.GetDistance() fd = self.itf.fogdivar.get() if self.has_gl: glFogf(GL_FOG_START, c - fd) glFogf(GL_FOG_END, 5 * c) self.renwin.Render()
def update_fog_dist(self,obj=None,event=None): """ changes fog of rendering""" c=self.camera.GetDistance() fd=self.itf.fogdivar.get() if self.has_gl: glFogf(GL_FOG_START,c-fd) glFogf(GL_FOG_END, 5*c) self.renwin.Render()
def make_fog(self): if self.has_gl: self.has_fog = 1 glEnable(GL_FOG) glFogf(GL_FOG_MODE, GL_LINEAR) glFogf(GL_FOG_DENSITY, 0.2) glHint(GL_FOG_HINT, GL_NICEST) c = self.camera.GetDistance() s = self.slab z = self.zpos glFogf(GL_FOG_START, c - z - s / 2.) glFogf(GL_FOG_END, c - z + s / 2.) self.renwin.Render()
def make_fog(self): if self.has_gl : self.has_fog=1 glEnable(GL_FOG) glFogf(GL_FOG_MODE, GL_LINEAR) glFogf(GL_FOG_DENSITY,0.2) glHint(GL_FOG_HINT, GL_NICEST) c=self.camera.GetDistance() s=self.slab z=self.zpos glFogf(GL_FOG_START, c-z-s/2.) glFogf(GL_FOG_END, c-z+s/2.) self.renwin.Render()
def processFrame(self, timePassedSecs): """ draws a scene """ # update the model view matrix self.sceneCamera.updateKeys() self.sceneCamera.update() # process queued GLObject events GLObject.signalsEmit() # enable some default scene states glEnable(GL_DEPTH_TEST) ######## SHADOW MAP RENDERING START ######## # offset the geometry slightly to prevent z-fighting # note that this introduces some light-leakage artifacts glEnable(GL_POLYGON_OFFSET_FILL) glPolygonOffset(1.1, 4096.0) # cull front faces for shadow rendering, # this moves z-fighting to backfaces. glCullFace(GL_FRONT) # enable depth rendering shader. # FIXME: support segment geometry shader! # geometry shader could change the shadow shape! self.depthShader.enable() map(_updateLightShadowMap, self.lights) glBindFramebuffer(GL_FRAMEBUFFER, 0) glDisable(GL_POLYGON_OFFSET_FILL) ######## SHADOW MAP RENDERING STOP ######## #### TODO: FOG: integrate FOG #### glEnable(GL_FOG) glFogi(GL_FOG_MODE, GL_EXP2) # approximate the atmosphere's filtering effect as a linear function sunDir = array([4.0, 4.0, 4.0, 0.0], float32) # TODO: FOG: what is the sun dir ? skyColor = array([0.8, sunDir[1] * 0.1 + 0.7, sunDir[1] * 0.4 + 0.5, 1.0], float32) glClearColor(*skyColor) glFogf(GL_FOG_DENSITY, 0.4) glFogf(GL_FOG_START, 16.0) glFogf(GL_FOG_END, self.farClip) glFogfv(GL_FOG_COLOR, skyColor) # fill projection matrix glMatrixMode(GL_PROJECTION) glLoadMatrixf(self.projectionMatrix) glMatrixMode(GL_MODELVIEW) # draw stuff in 3d projection lastCam = None glPushAttrib(GL_COLOR_BUFFER_BIT) for (fbo, draw, cam) in self.sceneFBOS: # render to fbo fbo.enable() if cam != lastCam: cam.enable() lastCam = cam draw() # disable render to texture FBO.disable() glPopAttrib() glViewport(0, 0, self.winSize[0], self.winSize[1]) #### TODO: FOG: integrate FOG #### glDisable(GL_FOG) # change to orthogonal projection glMatrixMode(GL_PROJECTION) glLoadMatrixf(self.orthoMatrix) glMatrixMode(GL_MODELVIEW) glLoadIdentity() # no depth test needed in orthogonal rendering glDisable(GL_DEPTH_TEST) # draw orthogonal to the screen self.orthogonalPass()
def fog(cls, param: FogParam, value): if isinstance(value, Iterable): glFogfv(param.value, value) else: glFogf(param.value, value)
def update_fog_density(self, obj=None, event=None): """ changes fog of rendering""" dens = self.itf.fogdevar.get() / 100. if self.has_gl: glFogf(GL_FOG_DENSITY, dens) self.renwin.Render()
def update_fog_density(self,obj=None,event=None): """ changes fog of rendering""" dens=self.itf.fogdevar.get()/100. if self.has_gl: glFogf(GL_FOG_DENSITY,dens) self.renwin.Render()