Jump to content

  • Log In with Google      Sign In   
  • Create Account

zgintasz

Member Since 27 Mar 2013
Offline Last Active Today, 05:18 AM

Posts I've Made

In Topic: GLSL rotated texture gets scaled when closer to 90 degree angle?

30 January 2016 - 06:45 AM

I fixed it, thank you! All I did was just change my mask to be a square:

cDhCooz.png

Basically, just added some empty space. Seems to be a really scammy solution, but hey, at least it works laugh.png


In Topic: GLSL rotated texture gets scaled when closer to 90 degree angle?

29 January 2016 - 04:47 PM

As I see in the video, X axis width stays the same no matter what the angle is and the same is for Y axis, height stays always the same and the mask just stretches. Maybe some multiplication in mat2() could help? I'm not even sure. Could there be something fishy with 'worldMaskSize'?

What do you mean rotate the actual quad? The only quad is a blurred map, can't really rotate it, because it has to stay in place with the map.


In Topic: GLSL rotated texture gets scaled when closer to 90 degree angle?

29 January 2016 - 01:52 PM

I changed my mask texture, so that it's longer and saw, that it doesn't get scaled with even 0 angle correctly. This line was causing it:

worldPos.x -= worldPlayerPos.x - vPosition.x;

I made it like this:

vec2 worldPos = vec2(vPosition);

 

I updated the original shader code in first post.

 

However, the rotation problem persisted. Here is a mask texture:

nzrtPLa.png

I tried replacing matrix calculation with yours provided, nothing changes. I made a quick video for you to be able to understand better:
https://vid.me/Xgj3


In Topic: GLSL rotated texture gets scaled when closer to 90 degree angle?

29 January 2016 - 01:02 AM

There is a mask texture, that is a quad. It basically calculates the UV coords for the mask texture. Note, that if the angle is 0, it works fine, so I suspect something fishy with the rotation part.

In Topic: Alpha mask dynamically rotated triangle

28 January 2016 - 02:35 PM

Yay, I solved it myself! rolleyes.gif

Here is my code, if someone from the future will need it

Vertex shader:

varying vec4 vPosition;

void main()
{
   ...
   vPosition = a_position;
} 

Fragment shader:

uniform vec2 worldMaskSize;
uniform vec2 worldPlayerPos;

void main(void)
{
vec4 texColor0 = texture2D(u_texture, vTexCoord);

vec2 worldPos = vec2(vPosition);


worldPos.x -= worldPlayerPos.x - vPosition.x;

worldPos.x += worldMaskSize.x / 2.0;
worldPos.y += worldMaskSize.y / 2.0;

vec2 maskTexCoord = vec2((worldPos.x - worldPlayerPos.x) / (worldMaskSize.x), (worldPos.y - worldPlayerPos.y - worldMaskSize.y) / (worldPlayerPos.y - worldPlayerPos.y - worldMaskSize.y));


vec4 mask = texture2D(u_mask, maskTexCoord);

gl_FragColor = vec4(texColor0.rgb, mask.r);

}

PARTNERS