How to add a new shader and define new uniform variables - Fish-In-A-Suit/Conquest GitHub Wiki
Create and implement a shader
Create the shader file (text file, you can add extension like .vs for vertex shader etc) inside the shaders package
Add a private int field to represent id of that shader inside ShaderProgram (ex. vertexShaderID)
Add a public method of name createSHADERNAMEshader(String shaderPath) (ex. createVertexShader), which calls an another private method whose function is to create a new shader based on the shader type, compile the shader , attache the shader to the program and return the shaderID (which is in turn assigned to the private field of the class)
Call the method to create a new shader type, using FileUtilities.loadResource method to read the text file of the shader and pass the whole source code of the shader to this method (ex.shaderProgram.createVertexShader(FileUtilities.loadResource("/shaders/vertexShader.vs"));) inside Renderer.init
Create and define a new uniform variable
First of all, add that uniform variable to some shader
Use createUniform(String uniformName) to create the mapping ("tunnel") between that uniform location and the java code inside Renderer.defineUniformLocations (ex. shaderProgram.createUniform("viewMatrix");)
Send data to the uniform variable wherever necessary from the java code (for example, if you have the view matrix calculated inside the render method, then it would be logical to send this newly calculated data to the uniform in the next line of code). Use shaderProgram.setUniformMatrix (to send 4x4 matrix data) or shaderProgram.setUniformInt (to send integer data); ex. shaderProgram.setUniformMatrix("viewMatrix", viewMatrix); "viewMatrix" represents the name of the uniform which is to recieve the data, while viewMatrix represents the data to be sent to that uniform