• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

[SOLVED] Shader issue

w0rm

Member
I have a project where I have set a shader to draw a circle segment. I'm using a sprite with size of 1x1 pixel for this and scale it to proper size. Everything works fine but the whole thing gets nuts the minute I add a second sprite to the project. After that my shader code is still applied but all the calculations within shader code go crazy. By removing the additional sprite from the project everything goes back to normal.

I don't get this problem. There's absolutely no reference to the second sprite anywhere in the object, code or anywhere.

EDIT:
Exactly same thing seem to happen with GMS2.
 
Last edited:

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Unfortunately, as you've not shown your shader code, it is close to impossible to tell what you might be doing wrong, but I'd guess that your texture coordinates are absolute rather than based on sprite UVs
 

w0rm

Member
Actually after playing with this issue for several hours I was able to figure out a workaround. The problem is fixed if I add a separate texture group for the sprite used with the shader and keep all other sprites in default texture group. I think this must have something to do with internals on how GMS works.
 

w0rm

Member
Unfortunately, as you've not shown your shader code, it is close to impossible to tell what you might be doing wrong, but I'd guess that your texture coordinates are absolute rather than based on sprite UVs
I guess you refer to the same topic which is mentioned here under section "Rainbow shader"? I think this actually might be the case here! I'll try to figure out. Thx for the tip!!
 

w0rm

Member
Unfortunately, as you've not shown your shader code, it is close to impossible to tell what you might be doing wrong, but I'd guess that your texture coordinates are absolute rather than based on sprite UVs
Indeed this was the issue. Fix was to add the following in shader to normalize v_vTexcoord as explained in the tutorial linked earlier:

Code:
    vec2 v_vTexcoordN = vec2( (v_vTexcoord.x - u_uv[0] ) / (u_uv[2] - u_uv[0]),
                              (v_vTexcoord.y - u_uv[1] ) / (u_uv[3] - u_uv[1]) );
Thanks @YellowAfterlife

EDIT:
And yes, there's probably more efficient way to normalize but I'm not shader expert :)
 
Top