Pixel shader code screen y coordinates flipped?
Posted: Fri Dec 02, 2016 9:33 pm
I've just recently been eqipping my game with some nice pixel shader effects. Everything was working fine until I installed it to the machine the game should run on. There, the effect was looking incredibly wrong! I found out that the coordinate system bottom and top (represented by screen_coords.y in the shader code) was flipped
Here's the pixel shader code:
Nothing very complex for my understanding. Essentially, it should just fade the color at the top of the screen towards dark. But on the gaming machine, it did a fade at the bottom! And this seems to be depending on the HW or graphics card driver...
I am using it for drawing a screen background into a canvas. On my development machine, I already noticed that top/bottom was flipped as I changed from rendering on the screen into the canvas, so the problem might also be a problem of the development machine...
Here's the pixel shader code:
Code: Select all
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
// This is for my development machine:
number bluefader = min(1,((love_ScreenSize.y - 0.15 * screen_coords.y)/love_ScreenSize.y));
// This is for the playing machine:
// number bluefader = min(1, 0.85 + (( 0.15 * screen_coords.y)/love_ScreenSize.y));
return pixel * color * bluefader;
}
I am using it for drawing a screen background into a canvas. On my development machine, I already noticed that top/bottom was flipped as I changed from rendering on the screen into the canvas, so the problem might also be a problem of the development machine...
- Did I do anything wrong?
- Is it somehow possible to detect at runtime where the origin is?
Idea It might be possible by making a temporary canvas, size 2x2 or so, draw a white rectangle on it with a test shader code and reading out the pixel values "by hand". But somehow, I feel like this can't be the right way to go...