Anomalies with bloom filter

I have found two strange things that I consider as… anomalies or potential bugs:

  • bloom filter doesn’t work with render.setShaderAuto();
  • bloom disables antialiasing.
    Since I don’t use shader generator often, I am not sure why this happens.
    Here is the code sample, tested on ATI X1600 (driver 9.3) with Panda 1.6.0:
from direct.filter.CommonFilters import CommonFilters
from direct.gui.DirectGui import OnscreenText
from pandac.PandaModules import *
import sys

loadPrcFileData("", "framebuffer-multisample 1")
loadPrcFileData("", "multisamples 2")

import direct.directbase.DirectStart

render.setAntialias(AntialiasAttrib.MMultisample)
base.setBackgroundColor(0, 0, 0.1)


# instructions
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1), mayChange=1,
                        pos=(-1, pos), align=TextNode.ALeft, scale = .05,
                        shadow=(0,0,0,1), shadowOffset=(0.1,0.1))
inst1 = addInstructions(0.95, "1 : toggle interval (currently OFF)")
inst2 = addInstructions(0.90, "2 : toggle shader generator (currently OFF)")
inst3 = addInstructions(0.85, "3 : toggle bloom (currently OFF)")
inst4 = addInstructions(0.80, "Escape : exit")

#model
model = loader.loadModel("box")
model.flattenStrong()
model.reparentTo(render)
model.setScale(2)

# hpr interval
ival = model.hprInterval(30, Point3(360, 0, 0))
def toggleIval():
    global ival
    if ival.isPlaying():
        ival.pause()
        inst1.setText("1 : toggle interval (currently OFF)")
    else:
        ival.resume()
        inst1.setText("1 : toggle interval (currently ON)")
base.accept("1", toggleIval)
ival.loop()
ival.pause()

# shader generator
autoshader_on = False
def toggleShaderGen():
    global autoshader_on
    if autoshader_on:
        render.setShaderOff()
        inst2.setText("2 : toggle shader generator (currently OFF)")
    else:
        render.setShaderAuto()
        inst2.setText("2 : toggle shader generator (currently ON)")
    autoshader_on = not autoshader_on
base.accept("2", toggleShaderGen)
#toggleShaderGen()

# bloom
filters = CommonFilters(base.win, base.cam)
bloom_on = False
def toggleBloom():
    global bloom_on
    if bloom_on:
        filters.delBloom()
        inst3.setText("3 : toggle bloom (currently OFF)")
    else:
        filters.setBloom(blend=(0, 0, 0, 1),
                        desat=-0.5,
                        intensity=3.0,
                        size=1)
        inst3.setText("3 : toggle bloom (currently ON)")
    bloom_on = not bloom_on
base.accept("3", toggleBloom)
#toggleBloom()

# camera
base.cam.setPos(5, -10, 10)
base.cam.lookAt(model)

base.accept("escape", sys.exit)
run()

Nah. A real bloom filter only applies bloom to specular colors. The bloom filter can only know where there are speculars by asking the ShaderGenerator. If this is not enabled, it will start guessing where the speculars are (in this case obviously wrongly).
So, you should enable some specular color or glow maps on the model, I’m sure that will fix it.

As for the question about antialiasing, I think it’s because you called render.setAntialias - this does not apply to the quad the CommonFilters is rendering into.
Try enabling antialiasing with cf.finalQuad.setAntialias.
Arguably, a bug in panda because it doesn’t automatically do this when render has antialias enabled - but this would be hard to implement correctly.
(this is just a theory, I’m not sure if I’m actually correct about this.)

Thank you, pro-rsoft!

It didn’t work though… Antialiasing doesn’t work with bloom :frowning:

Same for me in 1.7.0.
(GF9600GT, Kubuntu, lastest propertiary drivers)
prc:

framebuffer-multisample #t
multisamples 4

program:

render.setAntialias(AntialiasAttrib.MAuto)

gives good result (both images are scaled im gimp with filters turned off):
img87.imageshack.us/i/screen5max.png/
now adding:

filters = CommonFilters(base.win, base.cam)
filters.setBloom(intensity = 1.0, size = "medium")

and this is result:
img217.imageshack.us/i/screen4max.png/

also filters.finalQuad.setAntialias(AntialiasAttrib.MAuto) doesn’t change anything.

I’ve noticed the same behaviour. v1.7.0 Mac, bot-built late February.

In my Config:

framebuffer-multisample #t
multisamples 16

AA always on:

render.setAntialias(AntialiasAttrib.MAuto)

With 0 intensity Bloom on:

self.postprod = CommonFilters(base.win, base.cam)
self.postprod.setBloom(blend=(0.5,0.5,0.5,0.0), mintrigger=0.99, maxtrigger=1.0, desat=0.0, intensity=0.0, size="small") # 1.75

I get a aliased picture, 640x480 doubled in size, pixel repetition:

With Bloom off AA is on: