Legacy GM Standard Hue Shift Shader Broken Since Upgrading GMS

RyanC

Member
Hi everyone, since I upgraded GMS from 1.4.1398 to the current version my Hue_Shift shader is giving a different result.

The hue is a completely different value and the shader is now drawing things darker too!
It cannot seem to make the color blue either, any ideas?
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
I would think that you'd need to post the shader code for people to look at before we can help at all, unless other users have experienced the same issue. Have you rolled back GMS to a previous version to make sure something has changed (you can get the links form the Release Notes)? If you do see a 100% difference between versions then you should probably file a bug report and include a link to the shader...
 

RyanC

Member
Yes it happened as soon as I updated, I even saved an executable of the same game version number before upgrading so I could test inconsistencies.
I think this is the standard hue_shift shader for most game engines.
Here is the hue_shift shader:

// Vertex GLSL ES
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;

v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

------------------------------------------------------------

// Fragment GLSL ES

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

const mat3 rgb2yiq = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);
const mat3 yiq2rgb = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.1070, 1.7046);
uniform float hue;


void main() {

vec3 yColor = rgb2yiq * (texture2D(gm_BaseTexture, v_vTexcoord).rgb*v_vColour.rgb);

float originalHue = atan(yColor.b, yColor.g);
float finalHue = originalHue + hue;

float chroma = sqrt(yColor.b*yColor.b+yColor.g*yColor.g);

vec3 yFinalColor = vec3(yColor.r, chroma * cos(finalHue), chroma * sin(finalHue));
gl_FragColor = vec4(yiq2rgb*yFinalColor, texture2D(gm_BaseTexture,v_vTexcoord).a);

}
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'm not a shader expert so hopefully someone else can look at that and see if the issue is there, although I would still file a bug report as it seems odd that this should change from one version to another.
 

RyanC

Member
Exactly, the color being different is bad enough, but the alpha value being lower is really strange!
I'm surprised this hasn't been raised already, because this is the standard hue shift method, as far as I'm aware.
 

FrostyCat

Redemption Seeker
Try swapping reds and blues in your shader. If it comes out correctly afterwards, file a bug citing a red-blue reversal. There is a mish-mash of RGB-BGR conversions in the runners, and a significant number of graphical bugs in GM's history have to do with not handling it properly.
 

RyanC

Member
Try swapping reds and blues in your shader. If it comes out correctly afterwards, file a bug citing a red-blue reversal. There is a mish-mash of RGB-BGR conversions in the runners, and a significant number of graphical bugs in GM's history have to do with not handling it properly.
Founds this in compile log:
AAPT err(18656407): C:\Users\Ryan\src\main\res\drawable-xxhdpi\icon.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited

I'm not too hot with shaders, I'm guessing it's something to do with these lines here though:

const mat3 rgb2yiq = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);
const mat3 yiq2rgb = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.1070, 1.7046);

any ideas what the variables are, 9 arguments doesn't make sense for 6 colors at all?
 
Last edited:

FrostyCat

Redemption Seeker
These are 3x3 transformation matrices to and from RGB and YIQ, they make perfect sense for colour models with 3 components.

A brief lookup for that warning indicates that it is caused by libpng not liking some of the metadata in its input. The typical solution is to use a batch tool like ImageMagick to purge the metadata. If it is GMS adding such metadata on as part of the compile, then this needs to be filed as a bug ASAP.
 

RyanC

Member
I've tried swapping them over and I get different colors but something is not right. perhaps I'm swapping the wrong ones or to many.

This is written everywhere, even all over wikipedia as being standard so if GM has moved away from this then why have we not been given the new formulas?

//const mat3 rgb2yiq = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);
//const mat3 yiq2rgb = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.1070, 1.7046);
 
Last edited:

RyanC

Member
Hey guys, really need some help on this one?
How is it possible that the standard color settings have changed due to upgrading to the latest stable version of GMS and I'm the only one it seems to have effected?
 
Last edited:
Top