From 7ef5266e7d582f9b129da9d0ade0cc93d9f6f9a4 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 30 Apr 2008 21:11:20 +0000 Subject: [PATCH] Added support for negative glow maps --- direct/src/filter/FilterManager.py | 18 +++++++++++------- direct/src/filter/filter-bloomi.sha | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/direct/src/filter/FilterManager.py b/direct/src/filter/FilterManager.py index 8f3c219776..e8e3847d9c 100644 --- a/direct/src/filter/FilterManager.py +++ b/direct/src/filter/FilterManager.py @@ -33,7 +33,7 @@ class FilterManager(DirectObject): notify = None - def __init__(self, win, cam): + def __init__(self, win, cam, forcex=0, forcey=0): """ The FilterManager constructor requires you to provide a window which is rendering a scene, and the camera which is @@ -60,6 +60,8 @@ class FilterManager(DirectObject): # Instance Variables. self.win = win + self.forcex = forcex + self.forcey = forcey self.engine = win.getGsg().getEngine() self.region = region self.wclears = self.getClears(self.win) @@ -106,8 +108,10 @@ class FilterManager(DirectObject): """ Calculate the size of the desired window. Not public. """ - winx = self.win.getXSize() - winy = self.win.getYSize() + winx = self.forcex + winy = self.forcey + if (winx == 0): winx = self.win.getXSize() + if (winy == 0): winy = self.win.getYSize() if (div != 1): winx = ((winx+align-1) / align) * align @@ -121,7 +125,7 @@ class FilterManager(DirectObject): return winx,winy - def renderSceneInto(self, depthtex=False, colortex=False, auxtex=False, auxbits=0, textures=None): + def renderSceneInto(self, depthtex=None, colortex=None, auxtex=None, auxbits=0, textures=None): """ Causes the scene to be rendered into the supplied textures instead of into the original window. Puts a fullscreen quad @@ -167,14 +171,14 @@ class FilterManager(DirectObject): depthtex = textures.get("depth", None) auxtex = textures.get("aux", None) - if (colortex == None): colortex = Texture("filter-base-color") + if (colortex == None): + colortex = Texture("filter-base-color") texgroup = (depthtex, colortex, auxtex, None) # Choose the size of the offscreen buffer. - winx = self.win.getXSize() - winy = self.win.getYSize() + (winx, winy) = self.getScaledSize(1,1,1) buffer = self.createBuffer("filter-base", winx, winy, texgroup) if (buffer == None): diff --git a/direct/src/filter/filter-bloomi.sha b/direct/src/filter/filter-bloomi.sha index 37d6556377..8b58c21669 100644 --- a/direct/src/filter/filter-bloomi.sha +++ b/direct/src/filter/filter-bloomi.sha @@ -60,22 +60,22 @@ void fshader(float2 l_texcoordNW : TEXCOORD0, uniform float4 k_desat ) { - float4 inputNW = tex2D(k_src, l_texcoordNW); + float4 inputNW = tex2D(k_src, l_texcoordNW) - float4(0,0,0,0.5); float briteNW = dot(inputNW, k_blend); float scaleNW = saturate((briteNW - k_trigger.x) * k_trigger.y); float4 colorNW = scaleNW * lerp(inputNW, float4(1,1,1,1), k_desat.x); - float4 inputNE = tex2D(k_src, l_texcoordNE); + float4 inputNE = tex2D(k_src, l_texcoordNE) - float4(0,0,0,0.5); float briteNE = dot(inputNE, k_blend); float scaleNE = saturate((briteNE - k_trigger.x) * k_trigger.y); float4 colorNE = scaleNE * lerp(inputNE, float4(1,1,1,1), k_desat.x); - float4 inputSW = tex2D(k_src, l_texcoordSW); + float4 inputSW = tex2D(k_src, l_texcoordSW) - float4(0,0,0,0.5); float briteSW = dot(inputSW, k_blend); float scaleSW = saturate((briteSW - k_trigger.x) * k_trigger.y); float4 colorSW = scaleSW * lerp(inputSW, float4(1,1,1,1), k_desat.x); - float4 inputSE = tex2D(k_src, l_texcoordSE); + float4 inputSE = tex2D(k_src, l_texcoordSE) - float4(0,0,0,0.5); float briteSE = dot(inputSE, k_blend); float scaleSE = saturate((briteSE - k_trigger.x) * k_trigger.y); float4 colorSE = scaleSE * lerp(inputSE, float4(1,1,1,1), k_desat.x);