Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@almarklein
Copy link
Member

@almarklein almarklein commented Dec 24, 2024

This PR refactors the internals of the rendering engine, mainly the environment.py and the pipeline.py, mainly affecting how cache invalidation works.

The main purpose is to make it possible to use multiple different blend_mode settings in a single draw. This is a requirement for #492 e.g. to better support overlays.

For renderstate:

  • Rename environment to renderstate.
  • Refactor renderstate objects so the code is more clear.
    • In particular, create a renderstate object for each purpose,
    • And a combined renderstate object that wraps these.
  • Refactor renderstate lifetime
    • The renderer takes responsibility for storing and clearing them.
    • Still support re-using these objects using a WeakValueDictionary.

For pipeline.py:

  • Introduce object WeakAssociativeContainer to bind something to the lifetime of multiple objects at the same time.
  • Use WeakAssociativeContainer to store pipeline-container-group objects on wobject+renderstate.
  • PipelineContainer objects are now simpler because there is one for each specific wobject-renderstate combination, instead of having to manage differerent render states.

@almarklein
Copy link
Member Author

almarklein commented Jan 14, 2025

Weird error with shadows. On the first frame the lights are not entirely on or something:
image

vs the second frame

image

Edit: fixed. It was because the environment/renderstate was created earlier, so that the lights were using un-updated values.

@almarklein almarklein marked this pull request as ready for review January 14, 2025 13:29
@almarklein almarklein requested a review from Korijn as a code owner January 14, 2025 13:29
@Korijn
Copy link
Collaborator

Korijn commented Jan 14, 2025

Weird error with shadows. On the first frame the lights are not entirely on or something
Edit: fixed. It was because the environment/renderstate was created earlier, so that the lights were using un-updated values.

Funny! I ran into exactly the same issue with #911 :)

@hmaarrfk
Copy link
Contributor

Thank you releasing 0.7.0 before this refactor!

@Korijn Korijn enabled auto-merge (squash) January 15, 2025 09:37
@Korijn Korijn merged commit 57c329e into main Jan 15, 2025
14 checks passed
@Korijn Korijn deleted the environment branch January 15, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants