Hello Guest

Recent Posts

Pages: [1] 2 3 ... 10
1
I am trying to read a ton of floats from a compute shader into a buffer. I simply have no idea how to do this, and I have searched and tried to follow things such as tutorials and other forums. Sadly, I just don't understand how to read my data from my Compute Shader into a FloatBuffer.

Compute Shader:
Code: [Select]
#version 430

uniform vec3 startPos;
uniform int xSize;
uniform int ySize;
uniform int zSize;


layout(std430, binding = 1) buffer Vals
{
float vals[];

};


uniform Vals {
uniform float vals[];
};

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

vec3 random3(vec3 c) {
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
vec3 r;
r.z = fract(512.0*j);
j *= .125;
r.x = fract(512.0*j);
j *= .125;
r.y = fract(512.0*j);
return r-0.5;
}

/* skew constants for 3d simplex functions */
const float F3 =  0.3333333;
const float G3 =  0.1666667;

/* 3d simplex noise */
float simplex3d(vec3 p) {
/* 1. find current tetrahedron T and it's four vertices */
/* s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices */
/* x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertices*/

/* calculate s and x */
vec3 s = floor(p + dot(p, vec3(F3)));
vec3 x = p - s + dot(s, vec3(G3));

/* calculate i1 and i2 */
vec3 e = step(vec3(0.0), x - x.yzx);
vec3 i1 = e*(1.0 - e.zxy);
vec3 i2 = 1.0 - e.zxy*(1.0 - e);

/* x1, x2, x3 */
vec3 x1 = x - i1 + G3;
vec3 x2 = x - i2 + 2.0*G3;
vec3 x3 = x - 1.0 + 3.0*G3;

/* 2. find four surflets and store them in d */
vec4 w, d;

/* calculate surflet weights */
w.x = dot(x, x);
w.y = dot(x1, x1);
w.z = dot(x2, x2);
w.w = dot(x3, x3);

/* w fades from 0.6 at the center of the surflet to 0.0 at the margin */
w = max(0.6 - w, 0.0);

/* calculate surflet components */
d.x = dot(random3(s), x);
d.y = dot(random3(s + i1), x1);
d.z = dot(random3(s + i2), x2);
d.w = dot(random3(s + 1.0), x3);

/* multiply d by w^4 */
w *= w;
w *= w;
d *= w;

/* 3. return the sum of the four surflets */
return dot(d, vec4(52.0));
}


void main() {

vals[gl_GlobalInvocationID.x + gl_GlobalInvocationID.y * xSize + gl_GlobalInvocationID.z * xSize * ySize] = simplex3d(gl_GlobalInvocationID);


}


The Java Code:
Code: [Select]
package shaders;

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GL31;
import org.lwjgl.opengl.GL33;
import org.lwjgl.opengl.GL42;
import org.lwjgl.opengl.GL43;





import math.Vector3f;

public class SimplexNoiseComputeShader extends ComputeShaderProgram {

private static final String shaderFile = "src/shaders/SimplexNoiseComputeShader.txt";

private int location_startPos;
private int location_xSize;
private int location_ySize;
private int location_zSize;


private boolean isDone = false;

public FloatBuffer vals;

private int xSize;
private int ySize;
private int zSize;


private int totalSize;

private int ubo;

public SimplexNoiseComputeShader(Vector3f startPos, int xSize, int ySize, int zSize) {
super(shaderFile);

this.xSize = xSize;
this.ySize = ySize;
this.zSize = zSize;

totalSize = xSize * ySize * zSize;


// TODO Auto-generated constructor stub
//Load the start position for our compute shader
location_startPos = super.getUniformLocation("startPos");

location_xSize = super.getUniformLocation("xSize");
location_ySize = super.getUniformLocation("ySize");
location_zSize = super.getUniformLocation("zSize");


super.loadVector3f(location_startPos, startPos);
super.loadInt(location_xSize, xSize);
super.loadInt(location_ySize, ySize);
super.loadInt(location_zSize, zSize);




//start the compute shader!
start();
run();



//ByteBuffer bb = GL30.glMapBufferRange(ssbo, 0, totalSize, GL15.GL_READ_ONLY);
//vals = bb.asFloatBuffer();


//clean up the compute shader
CleanUp();
isDone = true;


}

private void run() {
GL43.glDispatchCompute(xSize, ySize, zSize);
}





}

2
hello,
I have a problem with stereo sound since 17w43b snapshot (1.13). I have report this bug in bugtracker here : https://bugs.mojang.com/browse/MC-121364 (Works As Intended)

And there are unclear explanations in the comments about OpenAL but I don't understand, I tried the little stuff that I understood but nothing works... unless I did wrong, it's so unclear.

To explain, the sound direction is strange. It is practically mono when a noise is heard perfectly at left or right.

For exemple a sound from TNT Explosion heard at left : https://i.imgur.com/3BPI9RX.jpg

Seen like that it can seem light, but it's very horrible and disturbing in real.

I find absolutely nothing in internet, or even someone else to talk about this problem from new LWJGL 3. So if someone had this problem and settled it would be nice to manifest! (Help me please).

Sorry for my bad english
3
Vulkan / Re: Kotlin ImGui, doesn't receive input.
« Last post by elect on July 13, 2018, 12:35:23 »
Yeah I saw that the newFrame() is called by the buildCommandBuffer(), but I didn't though the commandBuffer would be rebuilt every frame.

I also had the same though, so I directly break it to check if it was really called every time

For the record : the demo do that to update the scisors and eventually resize the buffers. I think a better approach would be to rebuilt it only when something is moved/resized on the UI.

I totally agree
4
Vulkan / Re: Kotlin ImGui, doesn't receive input.
« Last post by ealrann on July 13, 2018, 12:23:28 »
Ok, now I understand.
Yeah I saw that the newFrame() is called by the buildCommandBuffer(), but I didn't though the commandBuffer would be rebuilt every frame.

For the record : the demo do that to update the scisors and eventually resize the buffers. I think a better approach would be to rebuilt it only when something is moved/resized on the UI.
5
Vulkan / Re: Kotlin ImGui, doesn't receive input.
« Last post by elect on July 13, 2018, 10:30:27 »
Well, while packing my project in order to send it to you, I found my problem.

Glad you got it

I added a call to newFrame() (method from the demo) in my main loop, and now it works.
So, I don't really understand how the demo can work without that, I guess I need time to learn ImGui.

Actually the demo is calling
Code: [Select]
newFrame() here (called in turn by buildCommandBuffers())


Anyway, thank you for your help Elect, and thank you for your jvm binding.

Thanks but I did nothing  :D.

Anyway, since you got imgui working with vk before me, I'm interested in your implementation.. did you mirrored + or - Sasha example structure? Does it work nice for your project?
6
Vulkan / Re: Kotlin ImGui, doesn't receive input.
« Last post by ealrann on July 13, 2018, 09:30:00 »
Well, while packing my project in order to send it to you, I found my problem.
I added a call to newFrame() (method from the demo) in my main loop, and now it works.
So, I don't really understand how the demo can work without that, I guess I need time to learn ImGui.

Anyway, thank you for your help Elect, and thank you for your jvm binding.
7
Vulkan / Re: Kotlin ImGui, doesn't receive input.
« Last post by elect on July 13, 2018, 07:53:33 »
Anyway, this is the point where the mouse position and the status of the mouse buttons get passed to imgui. Print them out to check if they are really getting updated
8
Vulkan / Re: Kotlin ImGui, don't receive input.
« Last post by elect on July 12, 2018, 21:09:30 »
Hi ealrann,


can you show some code? Is your project open?
9
Vulkan / Kotlin ImGui, doesn't receive input.
« Last post by ealrann on July 12, 2018, 14:52:06 »
Hello,

I'm trying to use the Kotlin jvm port of ImGui (https://github.com/kotlin-graphics/imgui), with LWJGL/Vulkan.

I ported the code a CPP demo : https://github.com/SaschaWillems/Vulkan/blob/master/examples/imgui/main.cpp. I rendered it above one of my project, looks good.

The main problem is: ImGui doesn't catch the inputs. Every frame I set the io.MouseDown and the io.MousePos, but nothing happen (while my game is catching the inputs correctly). I directly get them from glfwGetCursorPos().
I think I missed something like (but it doesn't appear in the cpp demo, whatever..)
each frame, I added a call to :
      ImGui.INSTANCE.render();
      then => updateBuffers(); (from the demo code, the one that call the imgui.getDrawData()).

But still, nothing move in my UI.

Any idea would be welcome  :)

I didn't paste much code. Since vulkan is very verbose, I don't even know what copy/paste. Don't hesitate to tell me if you want more info/code.
10
Vulkan / Re: Vulkan gui ?
« Last post by ealrann on July 12, 2018, 14:12:58 »
Hi Elect,

Thanks for your answer, Yeah, I'm currently using your port  ;D. I'm a bit stuck right now, and I'd like to ask you some questions, but it's off topic here ; I'll make a new one.

Sorry, I don't think I will have enough time to help. Besides, not sure I could since I don't really know ImGui or Kotlin. But I downloaded the sources, and I try to debug a bit. Who knows, maybe my tries with Vulkan will help...
Pages: [1] 2 3 ... 10