[SOLVED] Creating a dark fade (just forgot another "end")

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.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

[SOLVED] Creating a dark fade (just forgot another "end")

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 2 times in total.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

Re: Creating a dark fade

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Creating a dark fade

Post by grump »

I'm not quite sure what you mean by "weird jumps". Is the dark rectangle in the middle of your image supposed to cover the whole image? Can you show the image without the fade for comparison?

Doing this with setPixel is quite inefficient. setPixel is very slow.
This is a shorter and faster replacement for your nested loop:

Code: Select all

data:mapPixel(function(x, y, r, g, b, a)
	return 0, 0, 0, math.min(y, maxAlpha)
end)
If you want to change the maxAlpha value on the fly, I'd recommend using a fragment shader instead of creating new textures.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

Re: Creating a dark fade

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Creating a dark fade

Post by grump »

jdse03 wrote: Sun Oct 01, 2017 6:06 pm I am only using setPixel when creating the image, which is at the start of the game, but thanks for the tip to improve performance.
It's not only about performance, but also about brevity. Why use complicated code when simple code does the same task, and faster to boot.
With "jumps" I mean the fact that it does not get darker but gets brighter/darker randomly when I want a smooth transition from bright to dark. On the first picture you can see how it gets darker first and suddenly gets brighter again for no reason.
You should show the code where you're drawing the fade image over the scene. And please, an image without the fade. It's not entirely clear from your image what is background and what is fade, at least not for me. I don't see the random jumps, but (and that's only a guess) it kinda looks like the fade is being drawn twice/mirror wrapped vertically around the center.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

Re: Creating a dark fade

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Creating a dark fade

Post by zorg »

Kinda looks like you're using a tile-based approach, and your issue may or may not be relevant to that; since from what i see, the brighter part starts just at the start of the lower row of "blocks"...
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

Re: Creating a dark fade

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:56 am, edited 1 time in total.
jdse03
Prole
Posts: 18
Joined: Sun Oct 01, 2017 4:45 pm

Re: Creating a dark fade

Post by jdse03 »

.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Creating a dark fade

Post by grump »

Have you tried drawing only the fade image over a white background to see what that looks like?
Or try to use a more visible image in place of the fade, that will help you understand what you're looking at. Like a colored grid or something.
However the used BlendMode "premultiplied" does not exist anymore.
BlendAlphaMode
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests