Jump to content

[1.8] Ambient occlusion and sloping faces


gcewing

Recommended Posts

I'm porting my roof blocks from Greg's Blocks to 1.8, and I'm having trouble with ambient occlusion. It doesn't seem to be possible to get it to work correctly for faces that are not axis-aligned.

 

In this screenshot, you can see places where the lower edges of roof blocks are incorrectly shaded, because the rendering system thinks that the cobblestone block below the roof block is casting a shadow on it. This happens because the roof block is not opaque, so it includes the block below in AO calculations rather than the block below and in front. The same thing causes the ridge blocks on top to be shaded too darkly, because they have opaque blocks underneath them.

 

AmbientOcclusionErrors.png

 

In my 1.7 rendering code, I dealt with this by only using AO for the exterior axis-aligned faces and not the sloping ones. But the 1.8 rendering system only allows AO to be turned on or off for the whole model, not individual faces, and unless I'm missing something, only allows one BakedModel to be rendered per block.

 

Anyone have any suggestions?

Link to comment
Share on other sites

Hi

 

Unfortunately I think you're right, there's no easy way.  A TileEntitySpecialRenderer would let you render the two parts separately (AO in block, sloped in TESR) but that's pretty inefficient if you have a lot of roof...

 

You might be able to do something in multiple rendering layers using this forge extension - i.e. Render your AO in the CUTOUT and the non-AO in the CUTOUT MIPPED, by returning a different ISmartBlockModel for the two passes.

 

Block::

    /**
     * Queries if this block should render in a given layer.
     * ISmartBlockModel can use MinecraftForgeClient.getRenderLayer to alter their model based on layer
     */
    public boolean canRenderInLayer(EnumWorldBlockLayer layer)
    {
        return getBlockLayer() == layer;
    }

 

-TGG

Link to comment
Share on other sites

You might be able to do something in multiple rendering layers using this forge extension - i.e. Render your AO in the CUTOUT and the non-AO in the CUTOUT MIPPED,

I thought about that, but the layer is ultimately going to be dictated by the base material, e.g. if the block is made from tinted glass, it's going to have to be rendered in the alpha transparency layer. So I'm not really free to (ab)use the layers that way.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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 Terms of Use.