-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: making object's color brighter / less saturated #266
Comments
I never understood the tinting model in AGS, frankly: no clue what the math there is. That said, it's true that in this model you can only go darker than the original image, that's because we use the tint as a multiplier for the texture color.
vColor is the variable that holds the incoming tint, and col is the texture color, so you can replace col * vColor with your chosen math (and if you want a shader that is compatible with mobile as well, take a look at the example shaders in the demo game: https://github.com/tzachshabtay/MonoAGS/blob/master/Source/Demo/DemoQuest/Shaders.cs).
Thinking about how to make it built in to allow to brighten an image, and saw the answer here which says that we can pass a color brighter than white: https://gamedev.stackexchange.com/questions/73861/most-efficient-way-of-brighten-and-darken-sprites-with-opengl-2-0 |
No, it's not that. This is just another way to define color, but the range of resulting tints, so to speak, is the same as with FromArgb. What I am looking for is some kind of blending operation that desaturates image, but as you say Tint is using multiplication, then it is something different. BTW, that reminds me, do you have plans for making a "blend operation" component or property for objects, or you leave that for shaders? This was one of the feature requests to AGS for years to have a selection of blends for an object. PS. For the reference, this is how AGS tinting looks like in OpenGL shader: https://github.com/adventuregamestudio/ags/blob/master/Engine/gfx/ali3dogl.cpp#L635 |
So I mentioned about how we can make the brightness built in, in the same way we can also add a saturation modifier, and add it to the built in shader (this looks like a good starting point: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Shaders/Builtin/Functions/saturation.glsl). At that point, though, it would be a waste to have all effects in the built-in shader when usually they will not be used, so we'd want this feature (#47) to combine multiple shaders.
Yes: #97 I don't think you can really do blending modes in shaders alone (at least in OpenGL), as the result of the fragment shader is passed to the blending function in the OpenGL pipeline (which you set) which is outside of the scope of the shader. For the basic blending modes, we might not even need to update the shader code, but just need to supply different component to the blending function (it's actually 3 different components that need to be set: blend src, blend dst and blend operation, iirc). Another problem with the blending modes is how to make it work with pre-multiplied alphas: #251
Hmmm, noticed that |
I've added a brightness property in this branch: I've also added a demo for it in the features -> tweens panel. As for the saturation, as far as I can see, the existing FromHSLA already allows you to make the image less saturated (take a look at the saturation tween in the same panel and tell me what you think). |
I already replied to this above, and I think there is a misunderstanding here. FromHSLA function simply lets you choose color in a different way. The question is in what changes are applied to source image pixels. It was not easy to understand what is going on in the game, but from the code it's clear that the Saturation tween is changing the saturation in the tint, not saturation of original image pixels. Which is not the same thing. I was not much sure about actual formulas, but suddenly found it is possible to see how saturation work by playing with color wheel in the image editor. To elaborate, if original color components have value R, G, B, and , for example, R is highest of all 3, then at saturation = 100 the color will be (R, G, B), and at saturation = 0 the color will be (R,R,R). At saturation = 50 the color is (R, (R - G / 2), (R - B / 2)). And so on. By the way, this also means that for colors, which highest component is equal to 255, it is possible to achieve de-saturation effect using the Brightness property you added, because highest component won't be able to change further. It's just that saturation loss won't be accurately proportional to brightness parameter. |
So, I was experimenting with Tint a bit, and found that tint's alpha means not the opacity of applied tint, but rather than opacity of an object itself (along with its own Opacity).
Note, this is different to how tints worked in AGS, where tint had "saturation" argument, something like "tint's amount". Not sure it was mathematically correct alpha, but idea was that "tint" is like another layer of color applied over an object, which may be more or less opaque.
For example, in AGS I could Tint an object or character with RGB (255,255,255) and saturation 50%, and that would make character loose half of its original saturation (bit brighter and less colored).
In MonoAGS with the default tint corresponding to normal object image = 255,255,255,255, this means that using tint I can only make object darker.
Is there any means to reduce object's saturation? I am trying to make something look like it's far away, in a "fog".
The text was updated successfully, but these errors were encountered: