Hey! Thanks for responding. I've decided to have another go and have made little success. I have the location of the projection, view and model set up using the Thinmatrix code along with the functions from that tutorial. The matrices are assigned in its own function, like loadTransformationMatrix, loadProjectionMatrix etc. The staticShader class that sends data to the uniforms is extended by the shaderProgram class, which holds functions such as loadFloat and loadVector, which does all the uploading to the uniforms in the shader. The vert and frag shaders seem to be registering. I have a location_albedo setup to read the albedo from the fragment shader, and I made a new function called loadPBR() which holds the super.loadVector("location_albedo" new Vector3f(10,2,0)); I can change the color of the sphere from this function but with no lighting, and nothing is registering the normals(?) This seems to work except there is no lighting been applied, and the previous lighting was setup in a loop like so:
for(int i=0;i<MAX_LIGHTS;i++) {
location_lightPosition = super.getUniformLocation("lightPositions[" + i + "]");
location_lightColour = super.getUniformLocation("lightColors[" + i + "]");
}
I'm unsure how I'm supposed to send data to the uniforms through a loop. The uniforms are a vec3, so I supposed I could use a loop and have the super.loadVector(location_lightPosition
)... inside the loop similar to the one above.
Inside the loadPBR function I have also setup:
super.loadVector(location_albedo, new Vector3f(1,3,20));
super.loadFloat(location_metallic, 0.3f);
super.loadFloat(location_roughness, 0.4f);
super.loadFloat(location_ao, 0.4f);
The function is setup in the staticShader class and is initialized in the renderer class. I'm unsure if this is the right place to initialize the loadPBR function.
This is the code in the staticShader class, I've currently got these assigned.
@Override
protected void bindAttributes() {
//bind attributes ex super.bindAttribute(0, "position");
//super.bindAttribute(0, "position");
//super.bindAttribute(1, "textureCoordinates");
super.bindAttribute(0, "aPos");
super.bindAttribute(1, "aTexCoords");
super.bindAttribute(2, "aNormal");
}
@Override
protected void getAllUniformLocations() {
// uniform locations ex. location_transformationMatrix = super.getUniformLocation("transformationMatrix");
//location_transformationMatrix = super.getUniformLocation("model");
location_model = super.getUniformLocation("model");
location_projectionMatrix = super.getUniformLocation("projection");
location_viewMatrix = super.getUniformLocation("view");
location_camPos = super.getUniformLocation("camPos");
location_albedo = super.getUniformLocation("albedo");
location_metallic = super.getUniformLocation("metallic");
location_roughness = super.getUniformLocation("roughness");
location_ao = super.getUniformLocation("ao");
for(int i=0;i<MAX_LIGHTS;i++) {
location_lightPosition = super.getUniformLocation("lightPositions[" + i + "]");
location_lightColour = super.getUniformLocation("lightColors[" + i + "]");
}
}
the camPos is currently doing nothing, which means I might have to revise over the learnOpengl website as to how the camPos is being applied.
Heres a link to the full code I'm working on.
https://github.com/winnieTheWind/PBRtestMy apologies if the code is a bit bloated. Any help would be much appreciated. Thanks!
Winston