Hello Guest

load hdr as cube map

  • 1 Replies
  • 367 Views
load hdr as cube map
« on: November 16, 2019, 12:54:57 »
i am trying to load 360 hdr as cube map and i getting a black screen
here is the code
Code: [Select]
public int loadCubeMap2(String[] textureFiles) {
int texID = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);
TextureDatatemp data = decodeTextureFile2("res/newport_loft.hdr");
for (int i = 0; i < 6; i++) {

GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL30.GL_RGB16F, data.getWidth(),
data.getHeight(), 0, GL11.GL_RGB, GL11.GL_FLOAT, data.getBuffer());
}
//GL30.glGenerateMipmap(GL13.GL_TEXTURE_CUBE_MAP);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
textures.add(texID);
return texID;
}

private TextureDatatemp decodeTextureFile2(String fileName) {
STBImage.stbi_set_flip_vertically_on_load(true);
IntBuffer width = BufferUtils.createIntBuffer(1);
IntBuffer height = BufferUtils.createIntBuffer(1);
IntBuffer nrComponents = BufferUtils.createIntBuffer(1);
FloatBuffer data = STBImage.stbi_loadf(fileName, width, height, nrComponents, 0);
if (data == null) {
throw new RuntimeException("Failed to load image: " + stbi_failure_reason());
}

return new TextureDatatemp(width.get(0), height.get(0),data);
}

here is the result
what i am messing?

Re: load hdr as cube map
« Reply #1 on: November 16, 2019, 12:55:27 »
i am trying to load 360 hdr as cube map and i getting a black screen
here is the code
Code: [Select]
public int loadCubeMap2(String[] textureFiles) {
int texID = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);
TextureDatatemp data = decodeTextureFile2("res/newport_loft.hdr");
for (int i = 0; i < 6; i++) {

GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL30.GL_RGB16F, data.getWidth(),
data.getHeight(), 0, GL11.GL_RGB, GL11.GL_FLOAT, data.getBuffer());
}
//GL30.glGenerateMipmap(GL13.GL_TEXTURE_CUBE_MAP);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
textures.add(texID);
return texID;
}

private TextureDatatemp decodeTextureFile2(String fileName) {
STBImage.stbi_set_flip_vertically_on_load(true);
IntBuffer width = BufferUtils.createIntBuffer(1);
IntBuffer height = BufferUtils.createIntBuffer(1);
IntBuffer nrComponents = BufferUtils.createIntBuffer(1);
FloatBuffer data = STBImage.stbi_loadf(fileName, width, height, nrComponents, 0);
if (data == null) {
throw new RuntimeException("Failed to load image: " + stbi_failure_reason());
}

return new TextureDatatemp(width.get(0), height.get(0),data);
}

here is the result https://ibb.co/PF734h0
what i am messing?