Libgdx shader changes texture

In my libgdx project I use a custom shader to create different color variations of a single grayscale character. I have a class “Shader” which holds static String variables for the vertex and fragment shaders. For each person I basically create a new shader, by replacing strings in the fragment shader string. For some reason, … Continue reading “Libgdx shader changes texture”

LWJGL – Uniform buffer object doesn't work

I tried to implement uniform buffer object to my game, but for some reason I haven’t got it working. I don’t think it currently sends anything to shaders. Before UBO everything worked fine. This is fully temporary system. I just wanted to get it working. My UBO class: private int ubo; public void createUBO() { … Continue reading “LWJGL – Uniform buffer object doesn't work”

GLSL: Illegal non-directive after #

I am trying to learn opengl through java using LWJGL. When trying to compile shader programs I get the error java.lang.Exception: Error compiling shading code: 0:1(1): preprocessor error: Illegal non-directive after # I know nothing about C only Java. #version 330 layout (location =0) in vec3 position; void main() { gl_Position = vec4(position, 1.0); } … Continue reading “GLSL: Illegal non-directive after #”

Why is only the first shadow that I render at the correct position?

I am working on a Java + LWJGL Project. Currently I am trying to implement Variance Shadow Mapping, but only the first shadow map that I sample in my shader shows up at the correct position. Fragment shader: #version 330 core in vec2 passTexCoords; in vec4[4] shadowCoords; //Fragment color out vec4 out_Color; uniform sampler2D modelTexture; … Continue reading “Why is only the first shadow that I render at the correct position?”

LWJGL2 Multiple lights not working? All entities are black

So I’m following ThinMatrixs tutorial on multiple lights and point lights. I believe I’ve followed everything correctly. I first followed the multiple lights tutorial and none of the entities and terrain were being affected. I thought doing the next tutorial, having to do with attenuation, would resolve this problem. Now all my objects are shaded … Continue reading “LWJGL2 Multiple lights not working? All entities are black”

GLSL – Cannot convert from “const highp 4-component vec4” to “default out highp 3-component vec3”

I’m following’s tutorial on OpenGL and I’m stuck on the shader part. I’ve read around on forums on the error but I only find instances when people have used vec3’s as vec4’s hence the error but I don’t think I’ve made that error, at least not what I’ve managed to see: Vertex Shader: #version … Continue reading “GLSL – Cannot convert from “const highp 4-component vec4” to “default out highp 3-component vec3””

LWJGL GLSL Uniform Block Not Working

I’ve looked at a number of tutorials and example programs, but I still can’t seem to figure out what the problem is with my uniform blocks. I am trying to render some models using a viewMatrix, and it worked fine when it was outside of a uniform block, but moving the uniform variable into a … Continue reading “LWJGL GLSL Uniform Block Not Working”

GLSL fragment shader freezes the whole program

After a lot of debugging I found the lines in my shader code that stop the game from even loading correctly: out_Color = vec4(totalDiffuse,1.0) * textureColour + vec4(totalSpecular,1.0); out_Color = mix(vec4(skyColour,1.0), out_Color, visibility); out_Color = vec4(pass_tangent, 1.0); where out_Color is the output of the fragment shader. The code works when I either comment out the … Continue reading “GLSL fragment shader freezes the whole program”

OpenGL ES 3.0 Hello Triangle is Black

This is my first time working with Android and OpenGL ES, but I do have a fair bit of experience with straight OpenGL. I’m simply trying to draw a red triangle. No uniforms, only one vertex attribute. Vertex shader: #version 300 es in vec3 in_loc; void main() { = in_loc; } Fragment shader: #version … Continue reading “OpenGL ES 3.0 Hello Triangle is Black”