Implement Properly Lighting OBJs and Satin Shader
Adds light sources (e.g. torches) affecting obj rendering, as well as time of day affecting the brightness of an object.
Attempts to match vanilla lighting on the obj rendering given it's origin pos.
Old behavior is available with the new function
public void draw(MatrixStack stack, Matrix4f viewMatrix, Vec3d origin, float lightLevel)
using this will completely restore behavior before lighting changes
ObjFile obj = ...;
obj.draw(stack, viewMatrix, origin, 1.f);
Additionally, if the obj is appended to an entity or block, it may be good to use their brightness value,
block.getBrightness();
entity.getBrightnessAtEyes();
Also adds a hook on ObjFile to add a custom shader for people who want to implement a shader on the obj model.
protected ShaderProgram getNormalLitShader()
For people who are inclined to add a custom shader use src/resources/assets/renderer/shaders/core/obj.* as a basis and use Satin as a tool to load core shaders to load as a ShaderProgram.
you can just use the original type as the return type of the method, there is no need to extend it Am 30. Juli 2023, 14:21 +0200 schrieb Matthew Periut @.***>:
@matthewperiut commented on this pull request. In TestMod/src/main/java/me/x150/testmod/client/TestModClient.java:
@Overridepublic void reload(ResourceManager manager) {Identifier basePath = new Identifier("testmod", "obj");ObjFile.ResourceProvider provider = TestLocalResourceProvider.ofResourceManager(manager, basePath);try {testObj = new ObjFile("cubesphere.obj", (ObjFile.ResourceProvider) provider);} catch (IOException e) {throw new RuntimeException(e);}}});}public interface TestLocalResourceProvider extends ObjFile.ResourceProvider {upon further inspection, I'm extending ObjFile.ResourceProvider exclusively so I can pass it into new ObjFile, and I'm not sure how to approach it otherwise. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
Current implementation looks like this:
https://github.com/0x3C50/Renderer/assets/18296791/05894d23-deea-4a10-b840-fb95647a19ba