How to blur whore game screen

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Xkonti
Prole
Posts: 2
Joined: Fri Jun 14, 2013 9:23 pm

How to blur whore game screen

Post by Xkonti »

I'm writing tile-based game. Level contains few layers. I want to blur layers beneath player but I can't find any explanation how to blur screen.
I am thinking of something like that process:

- Draw layer 0
- Draw layer 1
- Draw layer 2
- Blur whole Screen
- Draw layer 3 (with player)
- Draw layer 4
- ... etc
- Draw GUI

Is it possible to achive blur that way? How can I do this?
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: How to blur whore game screen

Post by Inny »

It sounds like you need to use Shaders (PixelEffects in 0.8), which you can read up on here: http://love2d.org/wiki/PixelEffect

Basically what you'd want to do is set a pixel effect to start bluring. Draw layers to be blurred. Then remove the pixel effect, and draw the player and remaining layers. The actual shader, theres a "Share a Shader" thread you can go looking for here on the love forum, where there might be one that does what you want.

Incidentally, whole is spelled with an 'l' :nyu:
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: How to blur whore game screen

Post by adnzzzzZ »

First you have to wait until she's playing a game in the bathroom. When that happens, you invade and lock her in with the shower on on super hot mode. After a few minutes her game screen will surely be blurred.

Code: Select all

-- Simple 3x3 box blur
simple_blur = love.graphics.newPixelEffect[[
    extern vec2 image_size;
    extern number intensity = 1.0;

    vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pc) {
        vec2 offset = vec2(1.0)/image_size;
        color = Texel(tex, tc);

        color += Texel(tex, tc + intensity*vec2(-offset.x, offset.y));
        color += Texel(tex, tc + intensity*vec2(0.0, offset.y));
        color += Texel(tex, tc + intensity*vec2(offset.x, offset.y));

        color += Texel(tex, tc + intensity*vec2(-offset.x, 0.0));
        color += Texel(tex, tc + intensity*vec2(0.0, 0.0));
        color += Texel(tex, tc + intensity*vec2(offset.x, 0.0));

        color += Texel(tex, tc + intensity*vec2(-offset.x, -offset.y));
        color += Texel(tex, tc + intensity*vec2(0.0, -offset.y));
        color += Texel(tex, tc + intensity*vec2(offset.x, -offset.y));

        return color/9.0;
    }
]]
Xkonti
Prole
Posts: 2
Joined: Fri Jun 14, 2013 9:23 pm

Re: How to blur whore game screen

Post by Xkonti »

So I have to draw SpriteBatch with enabled blur shader or draw rectangle with shader over previously drawn layer?
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: How to blur whore game screen

Post by adnzzzzZ »

I don't understand your question, but one way to do it would be to set the pixel effect and draw your first blurred layers. Then you remove the pixel effect and draw the rest.

Code: Select all

function love.draw()
    love.graphics.setPixelEffect(blur)
    drawLayersThatShouldBeBlurred()
    love.graphics.setPixelEffect()
    drawLayersThatShouldntBeBlurredAndPlayer()
    drawGUI()
end
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: How to blur whore game screen

Post by davisdude »

If you're not already using it you could check out a system I came up with to layer your tiles: http://www.love2d.org/wiki/Layering_Tiles
In the draw_map you may want to make an argument called 'blurry_layer' or something that makes since to you. Then change the code to this:

Code: Select all

function draw_map( blurry_layer )
    for l = 1, #layers do
        if l == blurry_layer then
            --put in your particle effect.
        end
        for y = 1, layers[l].map_display_h do
            for x = 1, layers[l].map_display_w do
                love.graphics.draw(
                tile[layers[l][y+layers[l].map_y][x+layers[l].map_x]], 
                (x*layers[l].tile_w)+layers[l].map_offset_x, 
                (y*layers[l].tile_h)+layers[l].map_offset_y)
            end
        end
    end
end
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 3 guests