Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] OBJ Model Lighting


Recommended Posts

My few other obj models are not full blocks so I'm just discovering the issue now.


Some of the faces on my models are using the opposite sides lighting.



I figure its something off in my model or code but am unsure what it is.


OBJ: http://pastebin.com/YBWTKmWQ


newmtl mat_vault1
Ka 0.0 0.0 0.0
Kd 0.8 0.8 0.8
map_Ka multistorage:models/mat_vault1
map_Kd multistorage:models/mat_vault1

newmtl mat_vault2
Ka 0.0 0.0 0.0
Kd 0.8 0.8 0.8
map_Ka multistorage:models/mat_vault2
map_Kd multistorage:models/mat_vault2


Related Code:

// In Block
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
    OBJModel.OBJState newState;
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityVaultDoor && state.getBlock() == this) {
        newState = new OBJModel.OBJState(((TileEntityVaultDoor)tile).getGroup(), true, ((TileEntityVaultDoor)tile).getTransform());
    } else {
        newState = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true, new TRSRTransformation(TRSRTransformation.getMatrix(EnumFacing.NORTH)));
    return ((IExtendedBlockState)state).withProperty(OBJModel.OBJProperty.instance, newState);

// In TileEntity
public TRSRTransformation getTransform()
    if (this.transform == null) {
        Matrix4f matrix = new Matrix4f(TRSRTransformation.getMatrix(this.direction));
        matrix.setTranslation(new Vector3f(0.5F, 0.5F, 0.5F));
        this.transform = new TRSRTransformation(matrix);
    return this.transform;

public List<String> getGroup()
    if (this.group.isEmpty()) {
        EnumDoorPart part = this.vaultDoorType;
        if (part == EnumDoorPart.CONTROLLER_2X || part == EnumDoorPart.FILLER_2X) {
            this.group.add("2x2_" + (this.doorSection + 1));
        } else if (part == EnumDoorPart.CONTROLLER_3X || part == EnumDoorPart.FILLER_3X) {
            this.group.add("3x3_" + (this.doorSection + 1));
        } else {
            return Lists.newArrayList(OBJModel.Group.ALL);
    return this.group;


Image of Issue:

width=800 height=337https://lh3.googleusercontent.com/s-6tuHnyLzzn7HYjaSAWQp-sETX9Yop8EaPTUNEkun5zfXybKeNnkfJlHXr2cV164zfg3fpqH8ovHqHJCnW_1E7zwJ54IGnmF37Uqa4vbQpODcF4ZRaEF38UpsJW36d29SAOqfoynASpUSUUtg2_6GXI7NL6cpYSCg6CoyrrvLK7Oh2cS5TYVt5baVFILkGMUL5WmnxdIFR8J61MlR8veRO3Fnnjrw7VwAnU2LymFKGUSuV-uvlqADYACVz2ZhH_IMBxCdV2a0LqkSJcxXSb6wP_OamxuOUV6Ga-V03aRCyn0Xt164KKILqYDCHn4dFdwSVzbgDOBcXr3df6yIfOFQQ5pY8eAb5z6MtoVaYkHkEGdQ_AprLC2UxOuSkExuTdLfTGJ5R3lvk2dqn1mUgT3n7SHNJbhBQR0HkRrT7WcjPksS375b0J5Ge7NMpw4_0x8oXf6xrNXGM_w_bSrrQrl1XCORm4T4gHrhi0fTwFbtXiIPvPi7xs1DarLf22uRlhMNQwn5VzRh2K8RN8sywtInj-qe4uitkYA_5MGThZL65A-aYkvbOGq1eMQ8PoAtnHTZ7O=w1631-h688-no[/img]



Model Rotation; North, South, East, West



Model's front with room behind unlit

Model's front with room behind lit up

Inside of unlit room looking at Model's back


In the first row the first and last (north and west rotations) are correctly lit, while some the on the other two are wrong.

In the last row the middle (south and east rotations) are correctly lit, while some the on the other two are wrong.


Some north faces are using south lighting, and some west faces are using east lighting.

Link to comment
Share on other sites

Thank you for the reminder, when I place the final texture on the block I'd be wondering why it was darker, then trying to recall how I fixed it on the other models :)


Unfortunately that only control's the brightness of the texture, not how the shadows are applied.

Turning off the games smooth lighting "fixes" the issue.

So something is causing the shader to think the faces are on the opposite side of the block. I'm not sure if its a model issue or a Forge one.

I don't want to work on the final texture as model changes may be needed.



Had an idea, the faces that have the incorrect shading are outside of a single block bounds by 1/16 of a block.

I'll need to adjust one of the parts to test, but if that's the issue, it will be both nice to have solved and suck because my design will need to be changed.



Moving the parts back so they are inside of the block, corrected most of the improper shading, just some weirdness with the outside border. (could be a rounding issue causing it to be a hair out of the block still)


I gave a few other things a go:

-- useNeighborBrightness ; nope, it looks very bad.

-- setting the "ambient" flag to false; fixes the shading but causes the edges of other parts to turn black


Looks like the shader doesn't work with a opaque model that is bigger then a block. The model needs to be remade.



The shader doesn't like blocks bigger then one Minecraft bock.

So the model was resized to fit within a Minecraft block.


The odd shading still present after the downsize appears to be a float rounding error

I had to change matrix.setTranslation(new Vector3f(0.5F, 0.5F, 0.5F)); to matrix.setTranslation(new Vector3f(0.5001F, 0.5001F, 0.5001F));


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.