Pixel shader code screen y coordinates flipped?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
manolo0815
Prole
Posts: 1
Joined: Fri Dec 02, 2016 8:55 pm

Pixel shader code screen y coordinates flipped?

Post by manolo0815 »

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 :huh:

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;
	}
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...
  • 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...
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Pixel shader code screen y coordinates flipped?

Post by slime »

Which version of love are you using? 0.10.0 and newer's screen coordinates should be y-down (with (0, 0) representing the top left) in all situations. Prior to 0.10.0 it was a bit inconsistent depending on the version and whether you were rendering to a canvas or the main screen.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 65 guests