예제 #1
0
def posteriseAndEdge():
    """This method creates and returns a post-process effect that posterises
    the back buffer and draws black edges.  It does this by using a Kuwahara
    filter, which is a noise-reduction filter that preserves edges. It then
    performs edge detection and dilation and blends the results back over the
    posterised back buffer."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    backBufferCopyB = rt('PostProcessing/backBufferCopyB')
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    c = buildBackBufferCopyPhase(backBufferCopy)
    c2 = buildBackBufferCopyPhase(backBufferCopyB)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    computeMeanVariance = buildMeanVariancePhase(downSample1.texture, downSample1B)
    selectVariance = buildVarianceSelectPhase(downSample1B.texture, None)
    s = build9TapFilterPhase(backBufferCopyB.texture, backBufferCopy, edgeDetectFilter)
    d = buildEdgeDilationPhase(backBufferCopy.texture, backBufferCopyB)
    t = buildTransferPhase(backBufferCopyB.texture, BW_BLEND_ZERO, BW_BLEND_SRCCOLOR)
    e = Effect()
    e.name = 'Posterise and Edge'
    e.phases = [c,
     c2,
     d0,
     computeMeanVariance,
     selectVariance,
     s,
     d,
     t]
    return e
예제 #2
0
def bloom(filterMode=0,
          attenuation=(1, 1, 1, 1),
          numPasses=3,
          width=1.0,
          power=8):
    """This method creates and returns a bloom post-process effect.  It assumes
    the scene has been captured and downsampled into the downSample3 render target."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    c0 = buildColourScalePhase(downSample3.texture, computeBuffer2)
    c0.material.power = power
    phases = [c0]
    for n in xrange(0, numPasses):
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True,
                            filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False,
                            filterMode, width)
        phases.append(bh)
        phases.append(bv)
        width *= 2.0

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA,
                           BW_BLEND_ONE)
    phases.append(t)
    e = Effect()
    e.name = 'Bloom'
    e.phases = phases
    return e
예제 #3
0
def playerFader():
    """This method creates and returns a post-process effect that fades
    out the player when they get too close to the camera.
    This effect only works in the client, as there is no player in the tools."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    e.name = 'Player Fader'
    try:
        from _PostProcessing import PlayerFader
        p = PlayerFader()
    except:
        p = None

    if p is not None:
        c = buildBackBufferCopyPhase(backBufferCopy)
        p.renderTarget = backBufferCopy
        p.clearRenderTarget = False
        p.name = 'Player Fader'
        t = buildTransferPhase(backBufferCopy.texture, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
        t.material.alphaOverdrive = 255.0
        t.material.alpha = p.opacity
        t.material.alphaTestEnable = True
        t.material.alphaReference = 1
        e.bypass = p.opacity
        e.phases = [c, p, t]
    else:
        e.phases = []
    return e
예제 #4
0
def depthOfFieldMultiBlur():
    """This method creates and returns a post-process effect that performs
    depth-of-field, using 3 different sized blur textures, and blends them
    together.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    downSampleBlur1 = rt('PostProcessing/downSampleBlur1')
    downSampleBlur2 = rt('PostProcessing/downSampleBlur2')
    downSampleBlur3 = rt('PostProcessing/downSampleBlur3')
    c = buildBackBufferCopyPhase(backBufferCopy)
    b = buildPhase(backBufferCopy.texture, None,
                   'shaders/post_processing/depth_of_field3.fx',
                   straightTransfer4Tap, BW_BLEND_SRCALPHA,
                   BW_BLEND_INVSRCALPHA)
    b.name = 'depth of field (multi-blur)'
    m = b.material
    m.depthBlurTexture = fpComputeBuffer1.texture
    m.blurTexture1 = downSampleBlur1.texture
    m.blurTexture2 = downSampleBlur2.texture
    m.blurTexture3 = downSampleBlur3.texture
    e = Effect()
    e.name = 'Depth of Field (multi-blur)'
    e.phases = [c, b]
    return e
예제 #5
0
def blur(filterMode=0, attenuation=(1, 1, 1, 1), numPasses=1, width=1.0):
    """This method creates and returns a blur post-process effect.  It assumes
    the scene has been captured and downsampled into the downSample3 render target."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    phases = []
    if numPasses > 0:
        bh = buildBlurPhase(downSample3.texture, computeBuffer1, True,
                            filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False,
                            filterMode, width)
        phases.append(bh)
        phases.append(bv)
    if numPasses > 1:
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True,
                            filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False,
                            filterMode, width)
        for n in xrange(1, numPasses):
            phases.append(bh)
            phases.append(bv)

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA,
                           BW_BLEND_ZERO)
    phases.append(t)
    e = Effect()
    e.name = 'Blur'
    e.phases = phases
    return e
예제 #6
0
def posteriseAndEdge():
    """This method creates and returns a post-process effect that posterises
    the back buffer and draws black edges.  It does this by using a Kuwahara
    filter, which is a noise-reduction filter that preserves edges. It then
    performs edge detection and dilation and blends the results back over the
    posterised back buffer."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    backBufferCopyB = rt('PostProcessing/backBufferCopyB')
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    c = buildBackBufferCopyPhase(backBufferCopy)
    c2 = buildBackBufferCopyPhase(backBufferCopyB)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    computeMeanVariance = buildMeanVariancePhase(downSample1.texture, downSample1B)
    selectVariance = buildVarianceSelectPhase(downSample1B.texture, None)
    s = build9TapFilterPhase(backBufferCopyB.texture, backBufferCopy, edgeDetectFilter)
    d = buildEdgeDilationPhase(backBufferCopy.texture, backBufferCopyB)
    t = buildTransferPhase(backBufferCopyB.texture, BW_BLEND_ZERO, BW_BLEND_SRCCOLOR)
    e = Effect()
    e.name = 'Posterise and Edge'
    e.phases = [c,
     c2,
     d0,
     computeMeanVariance,
     selectVariance,
     s,
     d,
     t]
    return e
예제 #7
0
def multiBlur(filterMode = 0):
    """This method creates and returns an effect that down-samples and
    blurs the back-buffer.  *It relies on the down sample buffers already
    having been created*.  It fills the     downSampleBlur1/2/3 render targets."""
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    downSample2B = rt('PostProcessing/downSample2B')
    downSample3B = rt('PostProcessing/downSample3B')
    downSampleBlur1 = rt('PostProcessing/downSampleBlur1')
    downSampleBlur2 = rt('PostProcessing/downSampleBlur2')
    downSampleBlur3 = rt('PostProcessing/downSampleBlur3')
    bh1 = buildBlurPhase(downSample1.texture, downSample1B, True, filterMode, 1.0)
    bv1 = buildBlurPhase(downSample1B.texture, downSampleBlur1, False, filterMode, 1.0)
    bh2 = buildBlurPhase(downSampleBlur1.texture, downSample2B, True, filterMode, 1.0)
    bv2 = buildBlurPhase(downSample2B.texture, downSampleBlur2, False, filterMode, 1.0)
    bh2a = buildBlurPhase(downSampleBlur2.texture, downSample2B, True, filterMode, 1.0)
    bv2a = buildBlurPhase(downSample2B.texture, downSampleBlur2, False, filterMode, 1.0)
    bh3 = buildBlurPhase(downSampleBlur2.texture, downSample3B, True, filterMode, 1.0)
    bv3 = buildBlurPhase(downSample3B.texture, downSampleBlur3, False, filterMode, 1.0)
    bh3a = buildBlurPhase(downSampleBlur3.texture, downSample3B, True, filterMode, 1.0)
    bv3a = buildBlurPhase(downSample3B.texture, downSampleBlur3, False, filterMode, 1.0)
    e = Effect()
    e.name = 'Multi Blur'
    phases = [bh1,
     bv1,
     bh2,
     bv2,
     bh3,
     bv3,
     bh3a,
     bv3a]
    e.phases = phases
    return e
예제 #8
0
def streak():
    """This method creates and returns a variation on the standard bloom
    post-process effect.  It only performs horizontal blurs, thus producing
    more of a streak than a blur."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    c0 = buildColourScalePhase(downSample3.texture, computeBuffer2)
    phases = [c0]
    width = 1.0
    for i in xrange(0, 2):
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True, 0,
                            width)
        phases.append(bh)
        bh2 = buildBlurPhase(computeBuffer1.texture, computeBuffer2, True, 0,
                             width * 2.0)
        phases.append(bh2)
        width *= 4.0

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA,
                           BW_BLEND_ONE)
    phases.append(t)
    e = Effect()
    e.name = 'Bloom (Streak)'
    e.phases = phases
    return e
예제 #9
0
def multiBlur(filterMode = 0):
    """This method creates and returns an effect that down-samples and
    blurs the back-buffer.  *It relies on the down sample buffers already
    having been created*.  It fills the     downSampleBlur1/2/3 render targets."""
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    downSample2B = rt('PostProcessing/downSample2B')
    downSample3B = rt('PostProcessing/downSample3B')
    downSampleBlur1 = rt('PostProcessing/downSampleBlur1')
    downSampleBlur2 = rt('PostProcessing/downSampleBlur2')
    downSampleBlur3 = rt('PostProcessing/downSampleBlur3')
    bh1 = buildBlurPhase(downSample1.texture, downSample1B, True, filterMode, 1.0)
    bv1 = buildBlurPhase(downSample1B.texture, downSampleBlur1, False, filterMode, 1.0)
    bh2 = buildBlurPhase(downSampleBlur1.texture, downSample2B, True, filterMode, 1.0)
    bv2 = buildBlurPhase(downSample2B.texture, downSampleBlur2, False, filterMode, 1.0)
    bh2a = buildBlurPhase(downSampleBlur2.texture, downSample2B, True, filterMode, 1.0)
    bv2a = buildBlurPhase(downSample2B.texture, downSampleBlur2, False, filterMode, 1.0)
    bh3 = buildBlurPhase(downSampleBlur2.texture, downSample3B, True, filterMode, 1.0)
    bv3 = buildBlurPhase(downSample3B.texture, downSampleBlur3, False, filterMode, 1.0)
    bh3a = buildBlurPhase(downSampleBlur3.texture, downSample3B, True, filterMode, 1.0)
    bv3a = buildBlurPhase(downSample3B.texture, downSampleBlur3, False, filterMode, 1.0)
    e = Effect()
    e.name = 'Multi Blur'
    phases = [bh1,
     bv1,
     bh2,
     bv2,
     bh3,
     bv3,
     bh3a,
     bv3a]
    e.phases = phases
    return e
예제 #10
0
def blur(filterMode = 0, attenuation = (1, 1, 1, 1), numPasses = 1, width = 1.0):
    """This method creates and returns a blur post-process effect.  It assumes
    the scene has been captured and downsampled into the downSample3 render target."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    phases = []
    if numPasses > 0:
        bh = buildBlurPhase(downSample3.texture, computeBuffer1, True, filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False, filterMode, width)
        phases.append(bh)
        phases.append(bv)
    if numPasses > 1:
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True, filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False, filterMode, width)
        for n in xrange(1, numPasses):
            phases.append(bh)
            phases.append(bv)

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA, BW_BLEND_ZERO)
    phases.append(t)
    e = Effect()
    e.name = 'Blur'
    e.phases = phases
    return e
예제 #11
0
def sharpen():
    """This method creates and returns a post-process effect that sharpens
    the back buffer.  It does this by using a generic sharpening filter kernel.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    s = build9TapFilterPhase(backBufferCopy.texture, None, sharpFilter)
    e = Effect()
    e.name = 'Sharpen'
    e.phases = [c, s]
    return e
예제 #12
0
def colourCorrectHSV():
    """This method creates and returns a post-process effect that performs
    hsv colour correction, or tone mapping, based on the colour_correct_hsv.fx effect.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    e.name = _hsvColourCorrectEffectName
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildHSVColourCorrectionPhase(backBufferCopy.texture, None)
    e.phases = [c, p]
    return e
예제 #13
0
def sharpen():
    """This method creates and returns a post-process effect that sharpens
    the back buffer.  It does this by using a generic sharpening filter kernel.
    """
    backBufferCopy = rt("PostProcessing/backBufferCopy")
    c = buildBackBufferCopyPhase(backBufferCopy)
    s = build9TapFilterPhase(backBufferCopy.texture, None, sharpFilter)
    e = Effect()
    e.name = "Sharpen"
    e.phases = [c, s]
    return e
예제 #14
0
def colourCorrect(texName = 'system/maps/post_processing/colour_correct.dds'):
    """This method creates and returns a post-process effect that performs
    colour correction, or tone mapping, based on the colour_correct.fx effect.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    e.name = _colourCorrectEffectName
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildColourCorrectionPhase(backBufferCopy.texture, texName, None)
    e.phases = [c, p]
    return e
예제 #15
0
def emboss():
    """This method creates and returns a post-process effect that performs
    greyscale embossing using a simple filter-kernel."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    g = buildGreyscalePhase(backBufferCopy.texture, None)
    s = build9TapFilterPhase(backBufferCopy.texture, None, embossFilter)
    e = Effect()
    e.name = 'Emboss'
    e.phases = [c, g, c, s]
    return e
예제 #16
0
def edgeDetect():
    """This method creates and returns a post-process effect that performs
    edge detection and dilation of the resultant edges."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    s = build9TapFilterPhase(backBufferCopy.texture, None, edgeDetectFilter)
    d = buildEdgeDilationPhase(backBufferCopy.texture, None)
    e = Effect()
    e.name = 'Edge Detect'
    e.phases = [c, s, c, d]
    return e
예제 #17
0
파일: fxaa.py 프로젝트: webiumsk/WOT-0.9.12
def FXAA():
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    lum = buildPhase(backBufferCopy.texture, None, 'shaders/anti_aliasing/fxaa_worldeditor_integration_luminance.fx', straightTransfer4Tap, BW_BLEND_ONE, BW_BLEND_ZERO)
    lum.name = 'luminance'
    lum.renderTarget = backBufferCopy
    r = buildPhase(backBufferCopy.texture, None, 'shaders/anti_aliasing/fxaa_worldeditor_integration.fx', straightTransfer4Tap, BW_BLEND_ONE, BW_BLEND_ZERO)
    r.name = 'transfer'
    e = Effect()
    e.name = 'FXAA'
    e.phases = [c, lum, r]
    return e
예제 #18
0
def depthOfFieldVariableCoC():
    """This method creates and returns a post-process effect that performs
    depth-of-field, using a variable-sized convolution kernel.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    c = buildBackBufferCopyPhase(backBufferCopy)
    t = buildDOFVariableCoCPhase(backBufferCopy.texture, fpComputeBuffer1.texture, None, stochasticSample)
    e = Effect()
    e.name = 'Depth of Field (variable filter)'
    e.phases = [c, t]
    return e
예제 #19
0
def distortionTransfer(distortionTexture):
    """This method creates and returns a post-process effect that redraws
    the screen, using a normal map to distort the image.  Use this for
    a fish-eye effect, full-screen shimmer/distort etc.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    r = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/legacy/transfer_distort.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    r.name = 'distort and transfer'
    r.material.distortionTexture = distortionTexture
    e = Effect()
    e.name = 'Distort and Transfer'
    e.phases = [c, r]
    return e
예제 #20
0
def emboss():
    """This method creates and returns a post-process effect that performs
    greyscale embossing using a simple filter-kernel."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    g = buildGreyscalePhase(backBufferCopy.texture, None)
    s = build9TapFilterPhase(backBufferCopy.texture, None, embossFilter)
    e = Effect()
    e.name = 'Emboss'
    e.phases = [c,
     g,
     c,
     s]
    return e
예제 #21
0
def edgeDetect():
    """This method creates and returns a post-process effect that performs
    edge detection and dilation of the resultant edges."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    s = build9TapFilterPhase(backBufferCopy.texture, None, edgeDetectFilter)
    d = buildEdgeDilationPhase(backBufferCopy.texture, None)
    e = Effect()
    e.name = 'Edge Detect'
    e.phases = [c,
     s,
     c,
     d]
    return e
예제 #22
0
def rainbow():
    """This method creates and returns a post-process effect that draws
    a rainbow, using the angle between the camera and the sun and a MIE
    scattering diagram lookup texture.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    r = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/legacy/rainbow.fx', straightTransfer4Tap, BW_BLEND_ONE, BW_BLEND_ONE)
    r.name = 'decode lee diagram'
    r.material.lookupTexture = 'system/maps/post_processing/lee_diagram.bmp'
    e = Effect()
    e.name = 'Rainbow'
    e.phases = [c, r]
    return e
예제 #23
0
def lensExplicit():
    """This method creates and returns a post-process effect that performs
    lens simulation. It allows direct control over the depth-of-field area
    and the falloff gradients.  It outputs to an intermediate buffer,
    designed for use by one of the depth-of-field simulations.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    c = buildBackBufferCopyPhase(backBufferCopy)
    w = buildExplicitLensSimulationPhase(backBufferCopy.texture, fpComputeBuffer1)
    e = Effect()
    e.name = 'Explicit Lens Simulation'
    e.phases = [c, w]
    return e
예제 #24
0
def filmGrain():
    """This method creates and returns a post-process effect that draws
    film grain, using 7 texture maps and a 'punch card' texture.  The
    'punch card' is a 7 * n bmp that describes the position on-screen
    of each of the 7 maps at any time..
    """
    textures = []
    base = 'system/maps/post_processing/film_grain/'
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    bbc = buildBackBufferCopyPhase(backBufferCopy)
    c = buildColourCorrectionPhase(
        backBufferCopy.texture,
        'system/maps/post_processing/film_grain/colour_correct_oldfilm.bmp',
        None)
    for i in xrange(0, 2):
        textures.append('%sscratch_0%s.tga' % (base, str(i + 1)))

    for i in xrange(0, 4):
        textures.append('%sdirt_0%s.tga' % (base, str(i + 1)))

    punchcard = base + 'oldfilm_punchcard.bmp'
    fg = buildFilmGrainPhase(textures, punchcard, None,
                             'shaders/post_processing/legacy/film_grain.fx',
                             straightTransfer4Tap, BW_BLEND_SRCALPHA,
                             BW_BLEND_INVSRCALPHA)
    textures = []
    for i in xrange(2, 4):
        textures.append('%sscratch_0%s.tga' % (base, str(i + 1)))

    for i in xrange(4, 8):
        textures.append('%sdirt_0%s.tga' % (base, str(i + 1)))

    punchcard = base + 'oldfilm_punchcard.bmp'
    fg2 = buildFilmGrainPhase(textures, punchcard, None,
                              'shaders/post_processing/legacy/film_grain.fx',
                              straightTransfer4Tap, BW_BLEND_SRCALPHA,
                              BW_BLEND_INVSRCALPHA)
    fg2.material.punchcardOffset = 0.5
    v = buildVignettePhase()
    e = Effect()
    e.name = _effectName
    e.phases = [bbc, c, fg, fg2, v]
    fg.material.alpha = 0.3
    fg.material.speed = 0.3
    fg.material.scale = 50.0
    fg2.material.alpha = 0.12
    fg.material.speed = 0.01
    fg2.material.scale = 21.0
    return e
예제 #25
0
def lensSimulation():
    """This method creates and returns a post-process effect that performs
    lens simulation. It does this mathematically via the thin-lens formula,
    simulating focal length, aperture and zFocus.  It outputs to an
    intermediate buffer, designed for use by one of the depth-of-field
    simulations.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    c = buildBackBufferCopyPhase(backBufferCopy)
    w = buildThinLensSimulationPhase(backBufferCopy.texture, fpComputeBuffer1)
    e = Effect()
    e.name = 'Thin Lens Simulation'
    e.phases = [c, w]
    return e
예제 #26
0
def hatching(texName = 'system/maps/post_processing/hatching.dds'):
    """This method creates and returns a post-process effect that performs
    hatching, or a pencil sketch effect.  It requires the back buffer,
    and a texture containing 3 individual channels of response to the
    different information created by processing the back buffer
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/legacy/hatching.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    p.name = 'hatching'
    p.material.hatchTexture = 'system/maps/post_processing/hatch.bmp'
    p.material.offsetTexture = 'system/maps/post_processing/hatch_offset.bmp'
    e = Effect()
    e.name = 'Hatching'
    e.phases = [c, p]
    return e
예제 #27
0
def shimmer():
    """This method creates and returns a post-process effect that emulates
    heat shimmer.  It uses the mask created by shimmer objects (those that
    use the shimmer channel, and output alpha)."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    c = pre = buildBackBufferCopyPhase(backBufferCopy)
    p = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/heat_shimmer.fx')
    p.name = 'heat shimmer'
    p.filterQuad = VisualTransferMesh('system/models/fx_shimmer_transfer.visual')
    e.phases = [c, p]
    e.name = 'Heat Shimmer'
    e.bypass = Math.Vector4Combiner()
    e.bypass.a = Math.Vector4(0, 0, 0, 0)
    e.bypass.b = BigWorld.PyShimmerCountProvider()
    return e
예제 #28
0
def hatching(texName = 'system/maps/post_processing/hatching.dds'):
    """This method creates and returns a post-process effect that performs
    hatching, or a pencil sketch effect.  It requires the back buffer,
    and a texture containing 3 individual channels of response to the
    different information created by processing the back buffer
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/legacy/hatching.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    p.name = 'hatching'
    p.material.hatchTexture = 'system/maps/post_processing/hatch.bmp'
    p.material.offsetTexture = 'system/maps/post_processing/hatch_offset.bmp'
    e = Effect()
    e.name = 'Hatching'
    e.phases = [c, p]
    return e
예제 #29
0
def posterise():
    """This method creates and returns a post-process effect that posterises
    the back buffer.  It does this by using a Kuwahara filter, which is a
    noise-reduction filter that preserves edges."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    c = buildBackBufferCopyPhase(backBufferCopy)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    computeMeanVariance = buildMeanVariancePhase(downSample1.texture,
                                                 downSample1B)
    selectVariance = buildVarianceSelectPhase(downSample1B.texture, None)
    e = Effect()
    e.name = 'Posterise'
    e.phases = [c, d0, computeMeanVariance, selectVariance]
    return e
예제 #30
0
def distortionTransfer(distortionTexture):
    """This method creates and returns a post-process effect that redraws
    the screen, using a normal map to distort the image.  Use this for
    a fish-eye effect, full-screen shimmer/distort etc.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    r = buildPhase(backBufferCopy.texture, None,
                   'shaders/post_processing/legacy/transfer_distort.fx',
                   straightTransfer4Tap, BW_BLEND_SRCALPHA,
                   BW_BLEND_INVSRCALPHA)
    r.name = 'distort and transfer'
    r.material.distortionTexture = distortionTexture
    e = Effect()
    e.name = 'Distort and Transfer'
    e.phases = [c, r]
    return e
예제 #31
0
def FXAA():
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    c = buildBackBufferCopyPhase(backBufferCopy)
    lum = buildPhase(
        backBufferCopy.texture, None,
        'shaders/anti_aliasing/fxaa_worldeditor_integration_luminance.fx',
        straightTransfer4Tap, BW_BLEND_ONE, BW_BLEND_ZERO)
    lum.name = 'luminance'
    lum.renderTarget = backBufferCopy
    r = buildPhase(backBufferCopy.texture, None,
                   'shaders/anti_aliasing/fxaa_worldeditor_integration.fx',
                   straightTransfer4Tap, BW_BLEND_ONE, BW_BLEND_ZERO)
    r.name = 'transfer'
    e = Effect()
    e.name = 'FXAA'
    e.phases = [c, lum, r]
    return e
예제 #32
0
def shimmer():
    """This method creates and returns a post-process effect that emulates
    heat shimmer.  It uses the mask created by shimmer objects (those that
    use the shimmer channel, and output alpha)."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    c = pre = buildBackBufferCopyPhase(backBufferCopy)
    p = buildPhase(backBufferCopy.texture, None,
                   'shaders/post_processing/heat_shimmer.fx')
    p.name = 'heat shimmer'
    p.filterQuad = VisualTransferMesh(
        'system/models/fx_shimmer_transfer.visual')
    e.phases = [c, p]
    e.name = 'Heat Shimmer'
    e.bypass = Math.Vector4Combiner()
    e.bypass.a = Math.Vector4(0, 0, 0, 0)
    e.bypass.b = BigWorld.PyShimmerCountProvider()
    return e
예제 #33
0
def posterise():
    """This method creates and returns a post-process effect that posterises
    the back buffer.  It does this by using a Kuwahara filter, which is a
    noise-reduction filter that preserves edges."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    downSample1 = rt('PostProcessing/downSample1')
    downSample1B = rt('PostProcessing/downSample1B')
    c = buildBackBufferCopyPhase(backBufferCopy)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    computeMeanVariance = buildMeanVariancePhase(downSample1.texture, downSample1B)
    selectVariance = buildVarianceSelectPhase(downSample1B.texture, None)
    e = Effect()
    e.name = 'Posterise'
    e.phases = [c,
     d0,
     computeMeanVariance,
     selectVariance]
    return e
예제 #34
0
def filmGrain():
    """This method creates and returns a post-process effect that draws
    film grain, using 7 texture maps and a 'punch card' texture.  The
    'punch card' is a 7 * n bmp that describes the position on-screen
    of each of the 7 maps at any time..
    """
    textures = []
    base = 'system/maps/post_processing/film_grain/'
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    bbc = buildBackBufferCopyPhase(backBufferCopy)
    c = buildColourCorrectionPhase(backBufferCopy.texture, 'system/maps/post_processing/film_grain/colour_correct_oldfilm.bmp', None)
    for i in xrange(0, 2):
        textures.append('%sscratch_0%s.tga' % (base, str(i + 1)))

    for i in xrange(0, 4):
        textures.append('%sdirt_0%s.tga' % (base, str(i + 1)))

    punchcard = base + 'oldfilm_punchcard.bmp'
    fg = buildFilmGrainPhase(textures, punchcard, None, 'shaders/post_processing/legacy/film_grain.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    textures = []
    for i in xrange(2, 4):
        textures.append('%sscratch_0%s.tga' % (base, str(i + 1)))

    for i in xrange(4, 8):
        textures.append('%sdirt_0%s.tga' % (base, str(i + 1)))

    punchcard = base + 'oldfilm_punchcard.bmp'
    fg2 = buildFilmGrainPhase(textures, punchcard, None, 'shaders/post_processing/legacy/film_grain.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    fg2.material.punchcardOffset = 0.5
    v = buildVignettePhase()
    e = Effect()
    e.name = _effectName
    e.phases = [bbc,
     c,
     fg,
     fg2,
     v]
    fg.material.alpha = 0.3
    fg.material.speed = 0.3
    fg.material.scale = 50.0
    fg2.material.alpha = 0.12
    fg.material.speed = 0.01
    fg2.material.scale = 21.0
    return e
예제 #35
0
def scotopicVision(
    colName="system/maps/post_processing/scotopic_vision.dds", noiseName="system/maps/post_processing/noise.texanim"
):
    """This method creates and returns a post-process effect that simulates
    scotopic vision, or human night vision.
    """
    backBufferCopy = rt("PostProcessing/backBufferCopy")
    backBufferCopyB = rt("PostProcessing/backBufferCopyB")
    e = Effect()
    e.name = "Scotopic Vision"
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildColourCorrectionPhase(backBufferCopy.texture, colName, backBufferCopyB)
    t = buildPhase(backBufferCopy.texture, None, "shaders/post_processing/legacy/scotopic_vision.fx")
    t.name = "scotopic vision"
    t.material.noiseTexture = noiseName
    t.material.colouredTexture = backBufferCopyB.texture
    v = buildVignettePhase()
    e.phases = [c, p, t, v]
    return e
예제 #36
0
def downSample():
    """This method creates and returns an effect that down-samples the back-
    buffer.  This effect by itself doesn't achieve anything on its own,
    however having downsampled versions of the scene are usually for other
    effects.  It fills the downSample1/2/3 render targets and also leaves
    a copy of the back buffer in the backBufferCopy render target."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    downSample1 = rt('PostProcessing/downSample1')
    downSample2 = rt('PostProcessing/downSample2')
    downSample3 = rt('PostProcessing/downSample3')
    pre = buildBackBufferCopyPhase(backBufferCopy)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    d1 = buildDownSamplePhase(downSample1.texture, downSample2)
    d2 = buildDownSamplePhase(downSample2.texture, downSample3)
    e = Effect()
    e.name = 'Down Sample'
    phases = [pre, d0, d1, d2]
    e.phases = phases
    return e
예제 #37
0
def downSample():
    """This method creates and returns an effect that down-samples the back-
    buffer.  This effect by itself doesn't achieve anything on its own,
    however having downsampled versions of the scene are usually for other
    effects.  It fills the downSample1/2/3 render targets and also leaves
    a copy of the back buffer in the backBufferCopy render target."""
    backBufferCopy = rt("PostProcessing/backBufferCopy")
    downSample1 = rt("PostProcessing/downSample1")
    downSample2 = rt("PostProcessing/downSample2")
    downSample3 = rt("PostProcessing/downSample3")
    pre = buildBackBufferCopyPhase(backBufferCopy)
    d0 = buildDownSamplePhase(backBufferCopy.texture, downSample1)
    d1 = buildDownSamplePhase(downSample1.texture, downSample2)
    d2 = buildDownSamplePhase(downSample2.texture, downSample3)
    e = Effect()
    e.name = "Down Sample"
    phases = [pre, d0, d1, d2]
    e.phases = phases
    return e
예제 #38
0
def depthOfFieldBokehControl():
    """Bokeh Control.  This method creates and returns a post-process
    effect that performs depth-of-field using variable-sized point
    sprites to draw artist-supplied bokeh.  It uses the alpha to
    accumulate into a buffer.
    It only draws far away blurs, to minimise the size of the render
    target, which is a major impact on performance for this technique.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    bkComputeBuffer = rt('PostProcessing/bkComputeBuffer')
    c = buildBackBufferCopyPhase(backBufferCopy)
    b = buildDOFBokehControlPhase(backBufferCopy.texture, fpComputeBuffer1.texture, bkComputeBuffer)
    t = buildDOFBokehControlTransferPhase(bkComputeBuffer.texture, fpComputeBuffer1.texture)
    e = Effect()
    e.name = 'Depth of Field (bokeh control)'
    e.phases = [c, b, t]
    m = b.material
    m.bokehTexture = 'system/maps/post_processing/bokeh2.tga'
    return e
예제 #39
0
def scotopicVision(colName='system/maps/post_processing/scotopic_vision.dds',
                   noiseName='system/maps/post_processing/noise.texanim'):
    """This method creates and returns a post-process effect that simulates
    scotopic vision, or human night vision.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    backBufferCopyB = rt('PostProcessing/backBufferCopyB')
    e = Effect()
    e.name = 'Scotopic Vision'
    c = buildBackBufferCopyPhase(backBufferCopy)
    p = buildColourCorrectionPhase(backBufferCopy.texture, colName,
                                   backBufferCopyB)
    t = buildPhase(backBufferCopy.texture, None,
                   'shaders/post_processing/legacy/scotopic_vision.fx')
    t.name = 'scotopic vision'
    t.material.noiseTexture = noiseName
    t.material.colouredTexture = backBufferCopyB.texture
    v = buildVignettePhase()
    e.phases = [c, p, t, v]
    return e
예제 #40
0
def playerFader():
    """This method creates and returns a post-process effect that fades
    out the player when they get too close to the camera.
    This effect only works in the client, as there is no player in the tools."""
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    e = Effect()
    e.name = 'Player Fader'
    try:
        from _PostProcessing import PlayerFader
        p = PlayerFader()
    except:
        p = None

    if p is not None:
        c = buildBackBufferCopyPhase(backBufferCopy)
        p.renderTarget = backBufferCopy
        p.clearRenderTarget = False
        p.name = 'Player Fader'
        t = buildTransferPhase(backBufferCopy.texture, BW_BLEND_SRCALPHA,
                               BW_BLEND_INVSRCALPHA)
        t.material.alphaOverdrive = 255.0
        t.material.alpha = p.opacity
        t.material.alphaTestEnable = True
        t.material.alphaReference = 1
        e.bypass = p.opacity
        e.phases = [c, p, t]
    else:
        e.phases = []
    return e
예제 #41
0
def depthOfFieldMultiBlur():
    """This method creates and returns a post-process effect that performs
    depth-of-field, using 3 different sized blur textures, and blends them
    together.
    """
    backBufferCopy = rt('PostProcessing/backBufferCopy')
    fpComputeBuffer1 = rt('PostProcessing/fpComputeBuffer1')
    downSampleBlur1 = rt('PostProcessing/downSampleBlur1')
    downSampleBlur2 = rt('PostProcessing/downSampleBlur2')
    downSampleBlur3 = rt('PostProcessing/downSampleBlur3')
    c = buildBackBufferCopyPhase(backBufferCopy)
    b = buildPhase(backBufferCopy.texture, None, 'shaders/post_processing/depth_of_field3.fx', straightTransfer4Tap, BW_BLEND_SRCALPHA, BW_BLEND_INVSRCALPHA)
    b.name = 'depth of field (multi-blur)'
    m = b.material
    m.depthBlurTexture = fpComputeBuffer1.texture
    m.blurTexture1 = downSampleBlur1.texture
    m.blurTexture2 = downSampleBlur2.texture
    m.blurTexture3 = downSampleBlur3.texture
    e = Effect()
    e.name = 'Depth of Field (multi-blur)'
    e.phases = [c, b]
    return e
예제 #42
0
def bloom(filterMode = 0, attenuation = (1, 1, 1, 1), numPasses = 3, width = 1.0, power = 8):
    """This method creates and returns a bloom post-process effect.  It assumes
    the scene has been captured and downsampled into the downSample3 render target."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    c0 = buildColourScalePhase(downSample3.texture, computeBuffer2)
    c0.material.power = power
    phases = [c0]
    for n in xrange(0, numPasses):
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True, filterMode, width)
        bh.material.attenuation = attenuation
        bv = buildBlurPhase(computeBuffer1.texture, computeBuffer2, False, filterMode, width)
        phases.append(bh)
        phases.append(bv)
        width *= 2.0

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA, BW_BLEND_ONE)
    phases.append(t)
    e = Effect()
    e.name = 'Bloom'
    e.phases = phases
    return e
예제 #43
0
def streak():
    """This method creates and returns a variation on the standard bloom
    post-process effect.  It only performs horizontal blurs, thus producing
    more of a streak than a blur."""
    downSample3 = rt('PostProcessing/downSample3')
    computeBuffer1 = rt('PostProcessing/computeBuffer1')
    computeBuffer2 = rt('PostProcessing/computeBuffer2')
    c0 = buildColourScalePhase(downSample3.texture, computeBuffer2)
    phases = [c0]
    width = 1.0
    for i in xrange(0, 2):
        bh = buildBlurPhase(computeBuffer2.texture, computeBuffer1, True, 0, width)
        phases.append(bh)
        bh2 = buildBlurPhase(computeBuffer1.texture, computeBuffer2, True, 0, width * 2.0)
        phases.append(bh2)
        width *= 4.0

    t = buildTransferPhase(computeBuffer2.texture, BW_BLEND_SRCALPHA, BW_BLEND_ONE)
    phases.append(t)
    e = Effect()
    e.name = 'Bloom (Streak)'
    e.phases = phases
    return e
예제 #44
0
def registrationTest():
    """This method creates and returns an effect that tests
    whether or not the transfer registration is correct.  It
    copies the back buffer and transfers it back over itself
    a few times in order to see if any pixels are shifted. In
    theory this should produce no visual effect at all"""
    c = buildBackBufferCopyPhase(backBufferCopy)
    t = buildTransferPhase(backBufferCopy.texture)
    e = Effect()
    e.name = 'Test Registration'
    phases = [c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t,
     c,
     t]
    e.phases = phases
    import Math
    e.bypass = Math.Vector4LFO()
    e.bypass.period = 2.0
    e.bypass.waveform = 'SQUARE'
    return e