[SOLVED]Change color of sprite with shader.

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
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

[SOLVED]Change color of sprite with shader.

Post by AdrianN »

Hi, I'm making my game and I need to change the color of my sprite.

I'm testing in this page modified the huv and replace for another color, and work well

https://www.imgonline.com.ua/eng/replace-color.php

But I need to get the same result or similar dynamically ingame.

I'm search in the wiki and found about HSV but I'm new with shaders and no understand about it.

https://love2d.org/wiki/HSV_color

Sprite :

Image

Imgonline's output:

Image

Image


Update : Using a simple code I can change the color, but not that I choose.
Image
Attachments
game.love
(47.27 KiB) Downloaded 182 times
Last edited by AdrianN on Sat Feb 22, 2020 2:50 am, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Change color of sprite with shader.

Post by raidho36 »

You need to convert pixel color to HSV values. Then you modify these values as appropriate, such as by setting desired hue. Then you convert HSV back to RGB and that's your output pixel color.
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: Change color of sprite with shader.

Post by AdrianN »

raidho36 wrote: Fri Feb 21, 2020 6:11 am You need to convert pixel color to HSV values. Then you modify these values as appropriate, such as by setting desired hue. Then you convert HSV back to RGB and that's your output pixel color.
Thanks man, this is that I needed.

Searching in the forum I look this function
https://love2d.org/forums/viewtopic.php?p=38739#p38739


And work fine for me.
Attachments
game.love
(143.11 KiB) Downloaded 183 times
Post Reply

Who is online

Users browsing this forum: No registered users and 143 guests