Hello Guest

Recent Posts

Pages: [1] 2 3 ... 10
1
OpenGL / Re: Triangulation help needed
« Last post by Aisaaax on Today at 03:53:21 »
Post triangulation can you not take each triangle and subdivide to 3 smaller triangles by taking the mid point and connectiving each vertex of the triangle to the midpoint? You can then subdivide far enough to a point of minimium size
That's not optimal - results in much more triangles than the grid pattern would yeild.

Anyway, I came up with an algorithm, here it is: https://stackoverflow.com/questions/62527504/subdividing-and-triangulating-a-polygon
2
OpenGL / Saving compressed textures
« Last post by exp_function on June 30, 2020, 23:18:53 »
Hi,
I'm trying to get the compressed pixels using;
Code: [Select]
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texBuff);
int comSiz =  glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
ByteBuffer comBuf = ByteBuffer.allocateDirect(comSiz);
byte[] comByt = new byte[comSiz];
glGetCompressedTexImage(GL_TEXTURE_2D, 0, comBuf);
comBuf.get(comByt, 0, comSiz);

but I can only read zero values from both comByt and comBuf buffers. What could be the reason for that?
Thanks.
3
OpenGL / Re: Billboards - Best practices
« Last post by KaiHH on June 28, 2020, 13:57:31 »
This was not what I meant with the rectangle (from now on be simply called 'P') being perpendicular to the camera view direction or perpendicular to the camera near/flar plane's normal.
What you are talking about is basically having P's rotation constrained to the world's Y axis, but no rotation applied on the X or Z axes.
Or in other words: P will always "stand straight" in the world but will only rotate around the world's Y axis such that P's normal vector is collinear to the camera's view direction or the camera's near/far plane normal.

This can be achieved with:

R = P * V * M * (r(V)^-1)[col1 = (0, 1, 0, 0)]

where (X)[colN = V] is: X where the column with index N (0..3) is replaced by vector V.
This will constrain the rotation only around the Y axis.
So it's basically the same as the "always perpendicular to the camera's direction" but with the constraint of only allowing rotation around the Y axis of the object which is the additional operation on the inverse of r(V).
4
OpenGL / Re: Billboards - Best practices
« Last post by Source_of_Truth on June 27, 2020, 20:57:39 »
be perpendicular to the camera view direction

Exactly, I want to align the quad with the horizon regardless of camera angle, while keeping the "rotate it towards the camera's position"-part.
5
OpenGL / Re: Billboards - Best practices
« Last post by KaiHH on June 27, 2020, 20:50:20 »
You haven't really told how you actually want it to look like. But from your post, it seems, you want the character rectangle to always align with the camera plane (that is, be perpendicular to the camera view direction), so as to mimic the effect of the character simply having been rendered using a 2D projection without any 3D rotations.

You can achieve this by simply eliminating the rotational component of the view matrix.

So, assuming V is your view matrix (world -> camera space), M is your model matrix (model -> world) without any billboard rotations and P is your projection matrix, then the resulting matrix 'R' you need is:

R = P * V * M * r(V)^-1

where r(X) is the upper-left (rotational) part of the given matrix X without any translational component. And X^-1 is the inverse of X, which for orthonomal matrices (rotation without scaling) is simply the transpose of the matrix.
If you need to have your view matrix always separate you need to use the above equation.

However, if you want to factor-in the billboard transformations into V, then V will simply be the camera translation without any rotational component, leaving you with P, V (without any rotational component) and M when rendering your billboard character with P * V * M.
6
OpenGL / Billboards - Best practices
« Last post by Source_of_Truth on June 27, 2020, 19:25:42 »
I have implemented a spherical billboard via the vertex shader by applying additional rotations to the object being rendered. Basically, that means that I first compute the horizontal and vertical angles an object must be rotated to "face the camera", generating rotation matrices for them and then just updating gl_Position accordingly. For simplicity, assume it code looks like this:

Code: [Select]
gl_Position = projectionMatrix * viewMatrix * translationMatrix * rotationLeftRight * rotationUpDown * vec4(inVertexPosition, 1.0);

Low, let's since we are doing billboards, the object is a textued quad for now.

Consider for example this well-know face of evil which can be seen below. Let's say its located at (0,0,0) while our camera is at (0,0,1), looking towards it, aka into (0,0,-1). We can see that it is being rendered correctly (never mind the texture filter :o ).



Now, moving the camera to the left and updwards, from (0,0,-1) to something like (1,1,0) for example. We rotate the camera back towards more or less the origin and we arrive at the next image:



We see that the object remains facing towards us, while the terrain, rendered with a standard, non-billboarding shader, obviously does not (never mind that the object appears a little larger, I was not too precise when taking these example shots).

Now, not moving the camera but only rotating it to the right to face the edge of the map, the perspective matrix kicks in, "destroying" our billboarding sprite's effect, as seen in below:



Illustrating the problem in an easier to see manner, I have created this handy image, in which I have set transparent fragments to red, thus making the quad visible  ;).



Mathematically speaking, everything going on here is obviously correct, both the spherical billboard as well as the perspective matrix is doing its job. From a sprite's perspective however, said matrix is introducing a unwanted rotation once the object is no longer the center. Basically, it has tilted to the left as the camera went looking to the right, as that is the "job" of the perspective matrix, creating perspective. However, rendering the billboards utterly separate with a different perspective matrix "detaches" them from the rest of the scene and creates a whole new set of challenges, for example in regards to the depth buffer.

One possiblity to fix this would be to apply an additional rolling-rotation based on the horizontal viewing angle difference but when that thought came to my mind, I decided should stop and first ask around.

My question: I am approaching this in an entirely incorrect way?

7
OpenGL / SpotLight and PointLight diffuse component problem
« Last post by ReactiveTurtle on June 26, 2020, 11:49:40 »
Help. Diffuse component light only 180 degrees.
Shader Code:https://pastebin.com/ZEqnYULR
Used by LWJGL 3
8
OpenGL / Re: Triangulation help needed
« Last post by abcdef on June 24, 2020, 12:58:53 »
Post triangulation can you not take each triangle and subdivide to 3 smaller triangles by taking the mid point and connectiving each vertex of the triangle to the midpoint? You can then subdivide far enough to a point of minimium size
9
Lightweight Java Gaming Library / Disabling GeForce Experience
« Last post by SWinxy on June 19, 2020, 23:22:56 »
Because I'm not making a "game," but still require LWJGL, having a GeForce popup icon can be pretty annoying. Is there a way to disable it and tell it that it's not a game?
10
OpenGL / Triangulation help needed
« Last post by Aisaaax on June 17, 2020, 05:55:04 »
I'm not sure if it's the right forum for that, but here we go.

I get a random contour. I need to transform it into a polygon and display it in 3d space. (A)

Normally, I would do it through a standard ear-clipping algorhythm, and the result will be something like (B)

However due to a bug in the graphics drivers for the videocard I'm working on (VIVANTE), I can only triangulate small shapes like that. The reason is that when rendering, if a vertex of a mesh lies too far outside of frustum to the left or right - the position is calculated incorrectly. This results in wild flickering and deformation of large meshes on the screen.
It is a confirmed driver issue, and it doesn't happen on other platforms or even with the older version of drivers for the same videocard. Unfortunately, I can't use the old drivers, and the card manufacturer isn't likely to fix the bug, seeing it's been known for almost a decade.

So I have to use crutches. In other words - I have to split my mesh into several smaller triangles, something like (C)
So that at any point in time, the vertexes of the triangles rendered are not outside of frustum too far.

Unfortunately, there's really no way to do it otherwise that I see.

Can someone help me with an algorythm of splitting/triangulating mesh in such a way? Assume that all "squares" are N-by-N squares with N being specified by me.


Pages: [1] 2 3 ... 10