Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow for buildings #668

Closed
wants to merge 1 commit into from
Closed

Shadow for buildings #668

wants to merge 1 commit into from

Conversation

Gustl22
Copy link

@Gustl22 Gustl22 commented Feb 20, 2019

See #575.
Activate with BuildingLayer.SHADOW = true;

Troubleshooting:

  • OffscreenRenderer not works together with ShadowRenderer yet. Colors have to be cleared correcltly and must be mixed in another way.
  • ExtrusionRenderer uses the call ebs[i] = null; this must be removed to allow render buildings twice: once from light, once from users view; may even is not necessary (thanks to garbage collecting)
  • Some hack implementation of setting the light MVP to current tile. See ExtrusionRenderer.setMatrix()

Have fun :)

@Gustl22
Copy link
Author

Gustl22 commented Feb 20, 2019

Without With shadow

@devemux86 devemux86 added this to the 0.11.0 milestone Feb 20, 2019
devemux86 pushed a commit that referenced this pull request Feb 20, 2019
Co-authored-by: Izumi Kawashima <[email protected]>
@devemux86
Copy link
Collaborator

Exceptional result and you know that I am strict in PR reviews!

I like the #ifdef SHADOW for having versatile shaders.
Just reversed some if-else so that the fallback is on GL20.

Merged via b4a98ef.

@devemux86 devemux86 closed this Feb 20, 2019
@Gustl22 Gustl22 deleted the shadow branch February 20, 2019 21:25
@@ -319,7 +347,8 @@ public void render(GLViewport v) {
}

/* just a temporary reference! */
ebs[i] = null;
/* But for shadows we use them multiple times */
//ebs[i] = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep here the null set as before, when not using shadows?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That needs an extra local variable. E.g. such as "mMultipleRenders". But is this really needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case mShader is available and could use a check like in line:373?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, but not the cleanest solution :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with Android Studio Profiler and I couldn't notice any remarkable memory regression when holding ExtrusionBuckets in ebs. If really needed, we should null all not used entries of mExtrusionBucketSet in BuildingRenderer.update after new ExtrusionBuckets are assigned (use activeTile count to null the rest).

for(int i = activeTiles; i < mExtrusionBucketSet.length && mExtrusionBucketSet[i] != null; i++) {
    mExtrusionBucketSet[i] = null;
}

But may it's not even needed or even costs more performance to explicitly nulling them, e.g. tags of MapElement aren't nulled either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants