New answers tagged

0

OpenGL uses column-major matrices, but as I understand from your code you pass row-major matrices. So in GLSL scale[0] is the first column of scale matrix.


0

There are two really good tutorials on the internet about how to improve performance, both by a guy called ThinMatrix. The first is mostly what you are looking for, but if you want to make it SUPER efficient you can also take a look at second one: First: https://youtu.be/X6KjDwA7mZg Second: https://youtu.be/Rm-By2NJsrc


3

For this problem specifically: screenX = ((glX + 1) / 2.0) * maxScreenX; screenY = ((glY + 1) / 2.0) * maxScreenY; In general, the solution for going from coordinate system A to coordinate system B is: B = ((A - minA) / (maxA - minA)) * (maxB - minB) + minB; For instance substituting into your example with B as screenX & A as glX, we'd get: ...


0

You should scale your UV (float2 uv) to range [-1,+1] per x,y component. Now you are passing probably UV in range [0,+1]. Also don't forget to flip y coordinate. It should looks like something: float3 GetWP(float2 uv, float sceneDepth) { uv.y = 1-uv.y; //flipping y uv = uv*2-1; // scaling to [-1,+1] float4 position = float4(uv, sceneDepth, 1.0);...


1

My answer contains the following assumptions: You want to get the the x,y-coordinates in order from the upper left to the bottom right, even if your viewport overlaps the map. If it overlaps, you want to look at the repeated map. Your viewport does not exceed the size of the map. var mapDimensions = {x: 20, y: 20}; // Width of the map var ...



Top 50 recent answers are included