Okay it is working very well now! Thank you so much! Here’s some of my code in case you wanted to see the final result:
loadPrcFileData('', 'win-size 1280 800')
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
mybuffer = base.win.makeTextureBuffer("oculus", 1024, 512)
mybuffer.setSideBySideStereo(True)
mybuffer.setSort(-100)
disp = mybuffer.makeDisplayRegion()
disp.setCamera(base.cam)
base.camLens.setInterocularDistance(5)
tex = mybuffer.getTexture()
tex.setWrapU(Texture.WM_border_color)
tex.setWrapV(Texture.WM_border_color)
cm = CardMaker('card')
cm.setFrameFullscreenQuad()
card = render2d.attachNewNode(cm.generate())
card.setShader(Shader.load("myfilter.sha"))
card.setShaderInput("tex", tex)
self.disableMouse()
self.accept("escape",sys.exit)
self.environ = self.loader.loadModel("models/environment")
self.environ.reparentTo(self.render)
self.environ.setScale(0.25, 0.25, 0.25)
self.environ.setPos(-8, 42, 0)
self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
self.pandaActor = Actor("models/panda-model",{"walk": "models/panda-walk4"})
self.pandaActor.setScale(0.005, 0.005, 0.005)
self.pandaActor.reparentTo(self.render)
self.pandaActor.loop("walk")
pandaPosInterval1 = self.pandaActor.posInterval(13,Point3(0, -10, 0),startPos=Point3(0, 10, 0))
pandaPosInterval2 = self.pandaActor.posInterval(13,Point3(0, 10, 0),startPos=Point3(0, -10, 0))
pandaHprInterval1 = self.pandaActor.hprInterval(3,Point3(180, 0, 0),startHpr=Point3(0, 0, 0))
pandaHprInterval2 = self.pandaActor.hprInterval(3,Point3(0, 0, 0),startHpr=Point3(180, 0, 0))
self.pandaPace = Sequence(pandaPosInterval1,pandaHprInterval1,pandaPosInterval2,pandaHprInterval2,name="pandaPace")
self.pandaPace.loop()
def spinCameraTask(self, task):
angleDegrees = task.time * 6.0
angleRadians = angleDegrees * (pi / 180.0)
camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 10)
camera.setHpr(angleDegrees, -30, 0)
return Task.cont
and the shader:
//Cg
void vshader(
float4 vtx_position : POSITION,
float2 vtx_texcoord0 : TEXCOORD0,
out float4 l_position : POSITION,
out float2 l_texcoord0 : TEXCOORD0,
uniform float4 texpad_tex,
uniform float4x4 mat_modelproj)
{
l_position=mul(mat_modelproj, vtx_position);
l_texcoord0 = vtx_position.xz * texpad_tex.xy + texpad_tex.xy;
}
void fshader(float2 l_texcoord0 : TEXCOORD0,
out float4 o_color : COLOR,
uniform sampler2D k_tex : TEXUNIT0)
{
float2 distor = float2(1.8,1.2);
if (l_texcoord0.x < .5) {
float2 diffed = float2(l_texcoord0.x-.255,l_texcoord0.y-.5);
float dist = (diffed.x*diffed.x)+(diffed.y*diffed.y);
float trans = (distor.x*(dist*dist))+(distor.y*(dist))+1;
float2 res = float2((diffed.x*trans)+.255,(diffed.y*trans)+.5);
if (res.x < .5) {
float4 c = tex2D(k_tex, res);
o_color = c;
} else {o_color = float4(0,0,0,1);}
} else {
float2 diffed = float2(l_texcoord0.x-.745,l_texcoord0.y-.5);
float dist = (diffed.x*diffed.x)+(diffed.y*diffed.y);
float trans = (distor.x*(dist*dist))+(distor.y*(dist))+1;
float2 res = float2((diffed.x*trans)+.745,(diffed.y*trans)+.5);
if (res.x > .5) {
float4 c = tex2D(k_tex, res);
o_color = c;
} else {o_color = float4(0,0,0,1);}
}
}