Filkata
Member
I have made a relatively simple fog of war shader as in the above pic. I have created a texture the size of the screen filled with black and draw it as a sprite that moves with the camera. In a pixel shader I check the distance to the player (the ship) and determine the alpha of the pixel to create a transparent circle. Maybe there is a better way to do it and I would appreciate the tips on that but that is not the main point of the topic.
The issue is that on my PC it works perfectly, but it is wrong on my sister's laptop. There the circle is an elipse, it is bigger than it is supposed to and "lags behind" the player to the top and left more and more as you move to the bottom and the right of the screen. My first thought was it must be the resolution - but it works fine on all resolutions on my PC and on none of the ones I tested on her laptop.
The circle (inner one, as there is a second semi-transparent one) should be 290px in diameter, whereas it was approx 390x440px at 1366x768 resolution on her PC. This means 1:1 scaling, as I am using the resolution handling system from Pixelated Pope's tutorial.
This is the shader itself:
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 u_vCenter;
uniform float u_radius;
uniform vec2 u_vResoultion;
uniform vec4 u_vUVs;
void main()
{
float alpha = 1.0;
float texX = (v_vTexcoord.x - u_vUVs.x) / u_vUVs.z * u_vResoultion.x;
float texY = (v_vTexcoord.y - u_vUVs.y) / u_vUVs.w * u_vResoultion.y;
float margin = u_radius * 0.45;
float dist = distance(vec2(texX, texY), u_vCenter);
if (dist < u_radius)
{
alpha = 0.0;
}
else if (dist <= u_radius + margin)
{
alpha = 0.35 + sin((dist - u_radius) / margin * 1.57);
}
gl_FragColor = vec4(v_vColour.r, v_vColour.g, v_vColour.b, alpha) * texture2D( gm_BaseTexture, v_vTexcoord );
}
I have double checked the resolution, viewports and coordinated of the circle passed and I am stuck, I need some ideas on what the issue might be/how to debug it. The only method I know of debugging shaders is using the output color to convey info which is rather cumbersome.
My current theory is that the issue might be because the laptop has an integrated Intel graphics card, could this possibly cause the issue? Both computers I tested on use Windows 10. If you would like to help me test this possibility and you have a machine with an integrated graphics card, please check the below files (source and exe). Use the arrow keys to move the ship around and see if the fog of war circle follows it correctly or not.
Source
Windows executable
Many thanks in advance!