Skip to content

Commit

Permalink
Fix the placeholder normal map texture having incorrect content
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbot16 committed Mar 23, 2021
1 parent 306b490 commit b2ffbe1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public DeferredWorldRenderingPipeline(ProgramSet programs) {
GlStateManager.pixelStore(GL20C.GL_UNPACK_ALIGNMENT, 4);

// Create some placeholder PBR textures for now
normals = new SingleColorTexture(0xFF7F7FFF);
specular = new SingleColorTexture(0);
normals = new SingleColorTexture(127, 127, 255, 255);
specular = new SingleColorTexture(0, 0, 0, 0);
GlStateManager.activeTexture(GL20C.GL_TEXTURE0);

this.shadowMapRenderer = new EmptyShadowMapRenderer(2048);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL13C;

import java.nio.IntBuffer;
import java.nio.ByteBuffer;

public class SingleColorTexture extends GlResource {
public SingleColorTexture(int color) {
public SingleColorTexture(int red, int green, int blue, int alpha) {
super(GL11C.glGenTextures());
GlStateManager.bindTexture(getGlId());

IntBuffer pixel = createBuffer(color);
ByteBuffer pixel = BufferUtils.createByteBuffer(4);
pixel.put((byte) red);
pixel.put((byte) green);
pixel.put((byte) blue);
pixel.put((byte) alpha);
pixel.position(0);

GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
GL11C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
Expand All @@ -24,14 +29,6 @@ public SingleColorTexture(int color) {
GlStateManager.bindTexture(0);
}

private IntBuffer createBuffer(int color) {
IntBuffer pixel = BufferUtils.createIntBuffer(1);
pixel.put(color);
pixel.position(0);

return pixel;
}

public int getTextureId() {
return getGlId();
}
Expand Down

0 comments on commit b2ffbe1

Please sign in to comment.