Hello!Can anyone suggest me how to do a "highlighting" effect on a sprite when it is hovered? (i am using libGDX)I know how to check if mouse is pointing a sprite, but i don't know how to do this effect.

Thank you!

Getting a project done is by far the most hard thing in game development.

Using shaders isn't necessarily overkill, as it leads to less overdraw and thus potentially much better performance (especially on limited systems like Android or WebGL). It really depends on your game and how you plan to implement the feature.

If you are using GL11 then you can work with plain old texture combiners, which should be more performant than glBlendFunc and multiple draws.

I am using GL2.0. This really can't be achived by just setting a shader to the batch, draw the sprite, then set the shader to null? I need to do this "brightening" only to the selected sprite, so a ShaderBatch won't help me very much...

Still, thanks for the advice.

Getting a project done is by far the most hard thing in game development.

the button is a graphic which you will save as the "bright-version"normally you now render it with a color filter like "new Color(0.8f,0.8f,0.8f,0.8f)"on hover you dont use a color filter or set it to 1f

Sprite has setColor, if you just render, for example a textureregion, with a batch, there is a Color parmeter

I am using GL2.0. This really can't be achived by just setting a shader to the batch, draw the sprite, then set the shader to null? I need to do this "brightening" only to the selected sprite, so a ShaderBatch won't help me very much...

You can use setShader but it won't be as efficient. Every time it's called, matrix data is sent to the new shader. Ideally you will want to minimize the number of flushes and the amount of data being passed to the shaders per frame. Here is a breakdown of what's happening:

The ShaderBatch I posted doesn't add much overhead, and it's a bit more flexible than using a mesh (it's usable with Stage). If you want to optimize it further you can remove the "contrast" uniform, and you could also send the uniform data manually (instead of doing it every time begin() is called). I would suggest using my ShaderBatch instead of using multiple shader programs.

But i still want to learn how to use shaders in libGDX because lately i will want to add some shadows, and as i know, it is done using shaders. Can anyone point me to some good tutorials about shaders? (also, about meshes because i don't really know what that is)

Getting a project done is by far the most hard thing in game development.

btw do you guys know the easiest way, without shader, to colorize a sprite ?

I mean like "draw all pixels which arent alpha = 0, as RED (1,0,0,alpha)"to showcase that someone is getting hit for example

with the least lines of code in libgdx or pure opengl

its the equivalent of Slicks .drawFlash()and I looked at that code, somehting about MODULATE, but I didn't get it to work in libgdx, maybe because of the batch or maybe I copied one or two lines too many or too few

like this, when pink is actually transparent, as per png, and the white could be any specific color, in this case RED:

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org