[SOLVED] Creating a dark fade (just forgot another "end")
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Creating a dark fade (just forgot another "end")
.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 2 times in total.
Re: Creating a dark fade
.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
Re: Creating a dark fade
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:
If you want to change the maxAlpha value on the fly, I'd recommend using a fragment shader instead of creating new textures.
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)
Re: Creating a dark fade
.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
Re: Creating a dark fade
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.
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.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.
Re: Creating a dark fade
.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Creating a dark fade
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 True 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.
Re: Creating a dark fade
.
Last edited by jdse03 on Wed Aug 03, 2022 12:56 am, edited 1 time in total.
Re: Creating a dark fade
.
Last edited by jdse03 on Wed Aug 03, 2022 12:55 am, edited 1 time in total.
Re: Creating a dark fade
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.
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.
BlendAlphaModeHowever the used BlendMode "premultiplied" does not exist anymore.
Who is online
Users browsing this forum: Google [Bot] and 4 guests