Effect on textures

Hello everyone.

Here I have a sprite (sp1 4 frames) to which I want to add an effect (sp2 3 frames). The effect can be applied at any time and on any sprite, I am trying to apply the effect by superimposing 2 textures (sp3).
But I do not know how not to display the pixels of the effect that should not be taken into account.

I put images to illustrate. I hope I am clear in my request and sorry for my English, I use Google translate.

Thank you for your answers.

sp1
sp2
sp3

By tinkering I found a way to do it, but I’m not sure if it’s the best way to do it. Isn’t there a risk of taking too much time if many sprites use this effect ?

Do you have an idea to improve this portion of code:

Thanks.

Do you have an idea to improve this portion of code:

	Uint32 format;
	int w, h;
	SDL_BlendMode blendmodeSrc;

	SDL_Texture	*pTexture1	= IMG_LoadTexture(renderer, "sp1.png");
	SDL_Texture	*pTexture2	= IMG_LoadTexture(renderer, "sp2.png");

	SDL_QueryTexture(pTexture1, &format, NULL, &w, &h);

	SDL_Texture	*pTexture3	= SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_TARGET, w, h);
	SDL_Texture	*pTexture4	= SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_TARGET, w, h);

	SDL_SetTextureBlendMode(pTexture3, SDL_BLENDMODE_NONE);
	SDL_SetRenderTarget(renderer, pTexture3);

	blendmodeSrc	= SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_COLOR,	SDL_BLENDFACTOR_ZERO, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_DST_ALPHA, SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDOPERATION_ADD);

	SDL_SetTextureBlendMode(pTexture2, blendmodeSrc);

	SDL_RenderCopy(renderer, pTexture1, NULL, NULL);
	SDL_RenderCopy(renderer, pTexture2, NULL, NULL);

	SDL_SetRenderTarget(renderer, pTexture4);

	SDL_SetTextureBlendMode(pTexture3, SDL_BLENDMODE_BLEND);
	SDL_SetTextureBlendMode(pTexture4, SDL_BLENDMODE_NONE);

	SDL_RenderCopy(renderer, pTexture1, NULL, NULL);
	SDL_RenderCopy(renderer, pTexture3, NULL, NULL);

	SDL_SetRenderTarget(renderer, NULL);

	SDL_SetTextureBlendMode(pTexture4, SDL_BLENDMODE_BLEND);

Result :

Thanks