Cross fade with mask in love2d?

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
Posts: 1
Joined: Thu Nov 19, 2020 1:08 pm

Cross fade with mask in love2d?

Post by ydb-beep » Thu Nov 19, 2020 1:23 pm

Hi, everyone
I'm trying to make an visual novel engine with love2d.I found a transition effect in the begin of the game Subarashiki Hibi,
which made up from two images, one is normal background ,and the other is a black&white image,called mask.
the darker places in mask will show up earlier during transition.

I also looked at the source code of onscripter ,which has a same effect called Cross fade with mask.the code do some alpha blending in c,
and I can't figure out how to do the same thing in love2d.Here come's the code:

if ( (trans_mode == ALPHA_BLEND_FADE_MASK ||
trans_mode == ALPHA_BLEND_CROSSFADE_MASK) && mask_surface ){
for ( i=0; i<rect.h ; i++ ) {
ONSBuf *mask_buffer = (ONSBuf *)mask_surface->pixels + mask_surface->w * ((rect.y+i)%mask_surface->h);

int j2 = rect.x;
for ( j=0 ; j<rect.w ; j++ ){
Uint32 mask2 = 0;
Uint32 mask = *(mask_buffer + j2) & lowest_mask;
if ( mask_value > mask ){
mask2 = mask_value - mask;
if ( mask2 & overflow_mask ) mask2 = lowest_mask;
src1_buffer++; src2_buffer++; dst_buffer++;

if (j2 >= mask_surface->w) j2 = 0;
else j2++;
src1_buffer += screen_width - rect.w;
src2_buffer += screen_width - rect.w;
dst_buffer += screen_width - rect.w;

can anyone help me ? sorry for my poor english ,and thanks a lot!

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 59 guests