Hello Guest

Recent Posts

Pages: 1 ... 8 9 [10]
91
Hello, just wondering what the latest situation is with using OpenGL within a JavaFX app?

2 ideas come to mind.

1. Is it possible to get the GL context used by JavaFX and initalise LWJGL with it and call GL from there? This uses JavaFX's scene update mechanism to trigger rendering on a control/canvas.

2. Separate rendering threads (JavaFX's own and my own). Does JavaFX allow the creation of a control driven by a separate GL thread, somewhat like what SWT GLCanvas allows?

Thanks.
92
Vulkan / VK_KHR_ray_tracing) Extension Support
« Last post by ItsMike54 on April 19, 2020, 19:41:30 »
Hi all, I've been doing a lot of tests using Vulkan, and I'm really excited about it. Now as many may know, Khronos Group released their cross-platform attracting extensions at last, so I was wondering maybe when LWJGL will add support+demos for the extensions.
See here for what I'm speaking of, https://www.phoronix.com/scan.php?page=article&item=vulkan-ray-tracing&num=1
93
OpenGL / Re: BlockIndex-Issues with Uniform Buffer Object
« Last post by Source_of_Truth on April 15, 2020, 15:37:33 »
Hm, no, that is a misunderstanding. I do bind this, but somewhere else. I updated the original post, so my question remains?
94
OpenGL / Re: BlockIndex-Issues with Uniform Buffer Object
« Last post by KaiHH on April 15, 2020, 15:31:08 »
The uniform block index you get with glGetUniformBlockIndex() is _NOT_ the binding location you use to bind to the shader.
You must query the bind location via glUniformBlockBinding() taking the index as one of the parameters.
Read: https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
95
OpenGL / [Solved] BlockIndex-Issues with Uniform Buffer Object
« Last post by Source_of_Truth on April 15, 2020, 15:18:40 »
Hello people of the LWJGL-forum, I got a question.

My shader programs, consisting of the usual vertex and fragment parts, employ uniform buffer objects. Now, the pipeline I established for handling UBOs has proven very successful thus far, but now I have hit a weird conundrum that I cannot explain.
In this exact, scenario, there are two UBOs, one in the vertex-shader:

Code: [Select]
(...)
layout (std140) uniform Matrices {
mat4 viewMatrix;
mat4 projectionMatrix;
vec3 camPosition;
};
(...)

and one in the fragment-shader:
Code: [Select]
(...)
layout (std140) uniform SpecialData{
float arrA[16];
float arrB[24];
};
(...)

As usual with OpenGL-Problems, if you got a bug then you either get garbage or nothing. In my case, it was nothing. Expecting my data to be at fault, I wrote tests that verified that the data I was giving to the card was correct. Yes, I have decided to go with std140 layout and, yes, I am aware of the waste-of-space that comes with that, especially with float-arrays that I am employing here. To my knowledge, that should be irrelevant to the problem I am facing.

This is the relevant code that produces the mapping between the blocks and their binding points after the shader programm has been linked and validated.
Code: [Select]
int uniformBlockLocation = glGetUniformBlockIndex(programId, uniformBlockName);
if (uniformBlockLocation == GL_INVALID_VALUE || uniformBlockLocation == GL_INVALID_OPERATION)
   throw new ShaderError("Shader program '" + programDescription.programName + "' is in an illegal state!");
if (uniformBlockLocation != -1) {
   (...) // associate 'uniformBlockName' with 'uniformBlockLocation'
} else {
    //driver eliminated this variable, it was not needed/used
    System.err.println("Warning: Uniform Block '" + uniformBlockName + "' in Shader Program '" + programDescription.programName + "' was eliminated by the driver!");
}

For reference, I later employ this association-data to link a uniform block with a binding point like this
Code: [Select]
if(/* association exists */) {
   //associate shader's uniform block to a specific binding point (at which a buffer resides):
   var index = /*get computed 'uniformBlockLocation' earlier */
   glUniformBlockBinding(id, index, block.bindingPoint);
} else {
   System.err.println("Uniform Block '" + uniformBlockName + "' does not exist within this shader-program.");
}
if( /* association exists */ ) {
   glUniformBlockBinding(id, getAssociationFor(uniformBlockName) /* returns previously stored result from 'glGetUniformBlockIndex' */, block.bindingPoint);
} else {
   System.err.println("Uniform Block '" + uniformBlockName + "' does not exist within this shader-program.");
}

while the buffer itself was also associated with the binding point:

Code: [Select]
var bufferHandle = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, bufferHandle);
glBufferData(GL_UNIFORM_BUFFER, data, GL_STATIC_DRAW); //send data
glBindBuffer(GL_UNIFORM_BUFFER, 0); //is this wrong?
(...)
glBindBufferBase(GL_UNIFORM_BUFFER, block.bindingPoint, bufferHandle );

Now, since stuff has stopped working once I started using two UBOs and the data looks good, I thought the most likely issue is how I bind them. Perhaps I simply mixed up some stuff but it worked by accident thus far (classical case of 0 is the default)?

I am on an OpenGL 4.4 by the way:

Code: [Select]
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);


Rephrasing this into questions:

1.) am I understanding the relationship between the buffer's handle, the binding point and the uniform block index correctly?
2.) must certain things be bound (e.g.) the buffer while calling any binding-point related functions?


96
OpenGL / Re: Is there a way to Anti-alias Transparent Textures ?
« Last post by Jehan on April 15, 2020, 14:44:24 »
Hi KaiHH,

thank you for your help.

So I used the alpha to coverage technique as it is written in your link.

To be able to use this technique I must first use the anti-aliasing multi-sample (4x at least),
and I have to render directly to the screen, not to an FBO.

First, I delete these lines in fragment shader : (alpha testing)

Code: [Select]
if (textureColour.a<0.5)
{
discard;
}

I enable GL13.GL_SAMPLE_ALPHA_TO_COVERAGE and disable it before and after rendering my triangles.
like this:

Code: [Select]
GL11.glEnable(GL13.GL_SAMPLE_ALPHA_TO_COVERAGE);
// render
GL11.glDisable(GL13.GL_SAMPLE_ALPHA_TO_COVERAGE);

The result is as follows:



Then I use the function fwidth () in my fragment shader to average colors.
The fwidth () function returns the sum of the pixel’s partial derivatives for a value, usually described as the equivalent of abs (ddx (value)) + abs (ddy (value)). Those two functions, ddx () and ddy (), are partial derivative functions.

Like this:

Code: [Select]
textureColour.a = (textureColour.a - 0.4) / max(fwidth(textureColour.a), 0.0001) + 0.5;
0.4 and 0.5 are taken arbitrarily.

The result is as follows:



thirdly, I add this line (before the last one) to manage the cases of disappearance of the intensity of the triangle when the mipmaping level is high (lowest resolutions of pictures)

like this:

Code: [Select]
float mipmapLevel = textureQueryLod(modelTexture, pass_textureCoords).x;

textureColour.a *= 1 + max(0, mipmapLevel) * 0.0;


so this :
Code: [Select]
if (textureColour.a<0.5)
{
discard;
}
became :
Code: [Select]
float mipmapLevel = textureQueryLod(modelTexture, pass_textureCoords).x;

textureColour.a *= 1 + max(0, mipmapLevel) * 0.0;

textureColour.a = (textureColour.a - 0.4) / max(fwidth(textureColour.a), 0.0001) + 0.5;
in my fragment shader with alpha to coverage enabled.

Hope this post can be useful for others ...
97
OpenAL / Re: OpenAL play only when the camera is in the right dirction
« Last post by Achivai on April 14, 2020, 21:04:10 »
I have the same problem. The sounds are working and they are directional, it's just that they aren't affected by my camera rotation at all.

The code I'm using is:
Code: [Select]
Matrix4f matr = Maths.createViewMatrix(MainGameLoop.camera);
Matrix4f invCam = new Matrix4f();
Matrix4f.invert(matr, invCam);
Vector4f at = new Vector4f(0, 0, -1, 0);
Matrix4f.transform(invCam, at, at);
Vector4f up = new Vector4f(0, 1, 0, 0);
Matrix4f.transform(invCam, up, up);

playerOrientation[0] = at.x; // x
playerOrientation[1] = at.y; // y
playerOrientation[2] = at.z; // z

playerOrientation[3] = up.x; // x
playerOrientation[4] = up.y; // y
playerOrientation[5] = up.z; // z

alListenerf(AL_ORIENTATION, playerOrientation[0]);
98
OpenGL / Re: Is there a way to Anti-alias Transparent Textures ?
« Last post by KaiHH on April 14, 2020, 18:23:07 »
There is a great post on the problem of alpha tested aliasing and techniques to improve it. The article mentions Unity but the ideas can be implemented in any shader language: https://medium.com/@bgolus/anti-aliased-alpha-test-the-esoteric-alpha-to-coverage-8b177335ae4f
99
OpenGL / Re: Is there a way to Anti-alias Transparent Textures ?
« Last post by Jehan on April 14, 2020, 17:26:28 »
100
OpenGL / Is there a way to Anti-alias Transparent Textures ?
« Last post by Jehan on April 14, 2020, 17:19:54 »
Hi everyone, thank you for answers ...

I'm trying to make a 3D game.. with 2D entities implemented in this 3D world...

With my 3D model entities, I can set up antialias for edges of my polygons like this :

Code: [Select]
ContextAttribs attribs = new ContextAttribs(3,3)
.withForwardCompatible(true)
.withProfileCore(true);

try
{
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat().withDepthBits(24), attribs);
Display.setTitle("display");
GL11.glEnable(GL13.GL_MULTISAMPLE);
}

But my 2D entities, are just pictures(with an alpha channel) bound in a simple vertex quad.
for example my picture is a picture of a tree surrounded by transparency.
I'm not really using blending but I discard "alpha < 0.5" pixels of my picture in my fragment shader like this :

Code: [Select]
vec4 textureColour = texture(modelTexture,pass_textureCoords);
if (textureColour.a<0.5){
discard;
}

that way I can see my tree in my 3D world and the transparency around the tree is transparent.
so the rendering is like this : (see attachment)

But for exemple the edge of my tree trunk  (the transition from drawing to transparency) is very hard,
and I would like to make it softer !

so my question is :
does LWJGL offer a way to do anti-aliasing on the edge of things drawn in pictures as it does for the edges of polygons ?
or do I have to use blending with GL_BLEND ?

Thankyou ! and Have a good Day !


Pages: 1 ... 8 9 [10]