Skip to content

Runtime generation of simple environment mapsΒ #17468

@viridia

Description

@viridia

What problem does this solve or what need does it fill?

This proposes to kill several birds with one stone:

  • Simplifying shaders by removing ambient lights and replacing them with simple 1x1 environment maps.
  • Implementing hemispherical lights.

Creating environment maps for Bevy is a difficult process, particularly on Mac where you have to compile multiple C++ packages to get the tooling needed to do the conversion. Other game frameworks such as three.js provide a means to generate environment maps from an image at runtime.

Ambient lights can be emulated by a 1x1 environment map, which would mean that we could remove the shader code for ambient lights, thereby reducing the lines of code for our standard shaders.

What solution would you like?

From the discord:

foo.insert(EnvironmentMapLight::solid_color(SLATE_BLUE.into()))
foo.insert(EnvironmentMapLight::hemispherical_gradient(BLUE.into(), BROWN.into()))

The idea is to provide methods for generating simple environment maps from a set of parameters.

We should also offer a means to generate an environment map from an equirectangular image, but that is a more advanced project, and should probably be a separate issue.

For backwards compatibility, the AmbientLight can be transformed into an environment map light, either via the constructor or perhaps by a hook of some kind.

What alternative(s) have you considered?

What I have done in the past is posted an image on Discord and had someone convert it to an environment map for me.

Additional context

Supersedes: #12027

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions