material albedo
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-19 15:29:28 -04:00
parent 8f8e3165bf
commit 636c0b1537
6 changed files with 32 additions and 4 deletions

View File

@ -45,7 +45,7 @@ void main(){
); );
//calculate final color //calculate final color
vec3 finalColor = light; vec3 finalColor = material.albedo * light;
//this final calculation is for transparency //this final calculation is for transparency
FragColor = vec4(finalColor, texture(material.diffuse, TexCoord).a); FragColor = vec4(finalColor, texture(material.diffuse, TexCoord).a);

View File

@ -54,7 +54,7 @@ void main(){
); );
//calculate final color //calculate final color
vec4 finalColor = vec4(light,textureColor.a); vec4 finalColor = vec4(material.albedo * light,textureColor.a);
//calculate weight function //calculate weight function
float weight = clamp(pow(min(1.0, finalColor.a * 10.0) + 0.01, 3.0) * 1e8 * float weight = clamp(pow(min(1.0, finalColor.a * 10.0) + 0.01, 3.0) * 1e8 *

View File

@ -22,4 +22,9 @@ struct Material {
* The reflectivity value * The reflectivity value
*/ */
float reflectivity; float reflectivity;
/**
* The albedo of the material
*/
vec3 albedo;
}; };

View File

@ -1903,6 +1903,7 @@ Materials read some properties from assimp data
OpenGLState VAO caching OpenGLState VAO caching
Ambient light sent in dedicated variable to shader Ambient light sent in dedicated variable to shader
Major lighting shader organization rework Major lighting shader organization rework
Material albedo work

View File

@ -16,7 +16,6 @@ public class SynchronizationProtocol implements ClientProtocolTemplate<Synchroni
@Override @Override
public void handleSyncMessage(SynchronizationMessage message) { public void handleSyncMessage(SynchronizationMessage message) {
Globals.profiler.beginCpuSample("SynchronizationProtocol.handleSynchronizationMessage");
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
case CLIENTREQUESTBTREEACTION: case CLIENTREQUESTBTREEACTION:
case UPDATECLIENTSTATE: case UPDATECLIENTSTATE:
@ -33,7 +32,6 @@ public class SynchronizationProtocol implements ClientProtocolTemplate<Synchroni
case LOADSCENE: case LOADSCENE:
throw new UnsupportedOperationException("Received synchronization message on the client of unsupported type: " + message.getMessageSubtype()); throw new UnsupportedOperationException("Received synchronization message on the client of unsupported type: " + message.getMessageSubtype());
} }
Globals.profiler.endCpuSample();
} }
} }

View File

@ -6,6 +6,7 @@ import electrosphere.renderer.OpenGLState;
import electrosphere.renderer.texture.Texture; import electrosphere.renderer.texture.Texture;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
import org.joml.Vector3f;
import org.lwjgl.PointerBuffer; import org.lwjgl.PointerBuffer;
import org.lwjgl.assimp.AIMaterial; import org.lwjgl.assimp.AIMaterial;
import org.lwjgl.assimp.AIMaterialProperty; import org.lwjgl.assimp.AIMaterialProperty;
@ -79,6 +80,11 @@ public class Material {
*/ */
private double reflectivity = Material.DEFAULT_REFLECTIVITY; private double reflectivity = Material.DEFAULT_REFLECTIVITY;
/**
* The albedo of the model
*/
private Vector3f albedo = new Vector3f(1);
/** /**
* A material that contains textures * A material that contains textures
*/ */
@ -281,6 +287,22 @@ public class Material {
specular = t; specular = t;
} }
/**
* Sets the albedo of the material
* @param albedo The albedo
*/
public void setAlbedo(Vector3f albedo){
this.albedo.set(albedo);
}
/**
* Gets the albedo of the material
* @return The albedo
*/
public Vector3f getAlbedo(){
return this.albedo;
}
/** /**
* Sets the texture pointer * Sets the texture pointer
* @param pointer The texture pointer * @param pointer The texture pointer
@ -354,6 +376,8 @@ public class Material {
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
openGLState.getActiveShader().setUniform(openGLState, "material.reflectivity", (float)this.reflectivity); openGLState.getActiveShader().setUniform(openGLState, "material.reflectivity", (float)this.reflectivity);
Globals.renderingEngine.checkError(); Globals.renderingEngine.checkError();
openGLState.getActiveShader().setUniform(openGLState, "material.albedo", this.albedo);
Globals.renderingEngine.checkError();
} }
/** /**