[SOLVED] Problem with shaders (especially with texture_coords)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: [SOLVED] Problem with shaders (especially with texture_coords)
Not sure if I missed something, but can't you just create a mesh for the circle, rect etc. including the texture uvs/vertex colors or whatever you need?
Re: Problem with shaders (especially with texture_coords)
.. holy... Yes, that did it.... Care to explain why the old code did work for all my "sprites" (images) but not for the stuff like circles/rectangles but the one with the "* color" part does?pgimeno wrote: ↑Sun Nov 04, 2018 11:21 amThis will return always white. Maybe you meant?Code: Select all
vec4 pixel = Texel(image, uvs) * color;
Thanks!
Re: Problem with shaders (especially with texture_coords)
Sure. Don't confuse the texture texel colour with the tinting colour set by calling love.graphics.setColor.
love.graphics.setColor is used to tint whatever you draw. This tinting is done through component-wise multiplication of the texel colour and the setColor colour, and is performed in the shader. That colour is received in the 'color' parameter of the effect() function. According to the wiki, there is always a shader active, even if you don't define one. Take a look at the default LÖVE shader in love.graphics.newShader#Notes_2. Note how it multiplies by 'color' so that it can tint what you draw!
The texture in the default primitives (circle, rectangle, line...) is a 1x1 white pixel (I'm not 100% sure if that's the case, but you can certainly think of it this way). That means that its colour is R=1, G=1, B=1, A=1. Those values, multiplied by the setColor value, give you the setColor value unchanged, therefore all those primitives are drawn with that colour. So, when you draw a coloured primitive, what you're actually doing is tinting its white texture. And for that to work, the shader must support tinting.
The texture in your images is the image itself. If you don't multiply the texture colour by the 'color' parameter, you can't tint your images using love.graphics.setColor. I doubt you're using setColor for tinting your images (other than to set it to 1,1,1,1), that's why when drawing your images, you don't see a difference between the version that multiplies by 'color' and the version that doesn't.
Apologies if the explanation isn't too clear. I find it somewhat hard to explain.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [SOLVED] Problem with shaders (especially with texture_coords)
Just wanted to respond to this post as well; yes, afaik you can use custom meshes and even a 1*1px texture on it, with the correct uvs so that it'd work as "geometric primitives".
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.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests