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

[feat] Bedrock Sun Glare and Sky Color #224

Merged
merged 6 commits into from Feb 25, 2023

Conversation

lonefelidae16
Copy link
Contributor

close #110

The feature of Bedrock Sun Glare and Sky Color. This is enabled by the sunlightIntensity value and bedrockShading option in the Visual Improvements settings.

Translation keys have been updated. Please check lang/en_us.json.


Behavior

This is disabled by default when the external shader is turned on. It cannot be forced to be enabled at the moment.

Use Reflection to detect whether the external shader is present or not.

  • With Iris Shaders: this is enabled while the external shader is not present.
  • With optifabric: this is disabled because it’s implemented in bedrockShading package.

Changes

  • new configurable parameter

    • int BedrockifyClientSettings#sunlightIntensity: 0 - 100, default 50
  • update dependencies

    • build.gradle
      • fabric loom 1.1-SNAPSHOT
      • add a sourceSet of the test
      • add Modrinth’s maven repo
      • add Iris, JUnit
    • gradle.properties
      • add a property of Iris version
  • update lang/en_us.json

    • edit bedrockify.options.bedrockShading
    • add bedrockify.options.sunlightIntensity
    • add tooltip texts:
      • bedrockify.options.bedrockShading.tooltip
      • bedrockify.options.sunlightIntensity.tooltip
  • update SettingsGUI

    • add tooltip for options:
      • bedrockShading
      • sunlightIntensity
  • update BedrockifyClient

    • register a new method in END_CLIENT_TICK:
      • BedrockSunGlareShading#tick
  • registered new mixins

    • mixin.client.features.bedrockShading.sunGlare.ClientWorldMixin
      • to modify the Sky color
    • mixin.client.features.bedrockShading.sunGlare.WorldRendererMixin
      • to modify the Sun radius
  • moved mixins

    • mixin.client.features.bedrockShading.AbstractQuadRendererMixin -> lightBlock.AbstractQuadRendererMixin
    • mixin.client.features.bedrockShading.BlockModelRendererMixin -> lightBlock.BlockModelRendererMixin
    • mixin.client.features.bedrockShading.FluidRendererMixin -> lightBlock.FluidRendererMixin
  • new files

    • client.features.bedrockShading.BedrockSunGlareShading
      • helper class that calculate angle diff
    • test.client.features.bedrockShading.sunGlare.IrisCompatTest
      • > ./gradlew test

The feature of Bedrock Sun Glare and Sky Color. This is enabled by the `sunlightIntensity` value and `bedrockShading` option in the Visual Improvements settings.

* new configurable parameters
  - int `BedrockifyClientSettings#sunlightIntensity`: 0 - 100, default 50

* update `lang/en_us.json`
  - edit `bedrockify.options.bedrockShading`
  - add `bedrockify.options.sunlightIntensity`
  - add tooltip texts:
    + `bedrockify.options.bedrockShading.tooltip`
    + `bedrockify.options.sunlightIntensity.tooltip`

* update `BedrockifyClientSettings`
  - add a field `sunlightIntensity`

* update `SettingsGUI`
  - add tooltip for the options:
    + `bedrockShading`
    + `sunlightIntensity`

* registered new mixins
  - `mixin.client.features.bedrockShading.sunGlare.ClientWorldMixin`
    + to modify the Sky color
  - `mixin.client.features.bedrockShading.sunGlare.WorldRendererMixin`
    + to modify the Sun radius

* moved mixins
  - `mixin.client.features.bedrockShading.AbstractQuadRendererMixin` -> `lightBlock.AbstractQuadRendererMixin`
  - `mixin.client.features.bedrockShading.BlockModelRendererMixin` -> `lightBlock.BlockModelRendererMixin`
  - `mixin.client.features.bedrockShading.FluidRendererMixin` -> `lightBlock.FluidRendererMixin`

* new files
  - `client.features.bedrockShading.BedrockSunGlareShading`
    + helper class that calculate angle diff
Make it compatible with shader mods.

* update `BedrockSunGlareShading`
  - inner classes:
    + enum `ShaderState`: shows the state of custom shader
    + class `ClassMethodHolder`: holds class name, method name, args and predicate
  - fields:
    + ShaderState `shaderState`: to determine the state of custom shader
    + Map `MOD_ID_CLASS_MAP`: uses with Reflection
  - methods:
    + void `reloadCustomShaderState`: notifies changed the shader state
    + boolean `isEnabled` -> `shouldApplyShading`: gets whether can apply this feature
    + ShaderState `fetchShaderStateInternal`: gets the state of custom shader

* update `mixin.client.features.bedrockShading.sunGlare.WorldRendererMixin`
  - new method `bedrockify$reloadWorldRendererCallback`: to reload the state of custom shader
Adds a test case to be compatible with Iris shaders using Reflection.

* update dependencies
  - `build.gradle`
    + fabric loom 1.1-SNAPSHOT
    + add a sourceSet of the test
    + add Modrinth's maven repo
    + add Iris, JUnit
  - `gradle.properties`
    + add a property of Iris version

* new files
  - `test.client.features.bedrockShading.sunGlare.IrisCompatTest`
    + > ./gradlew test
Update the sun vector after client tick due to the sun does not move so fast.

Update the dot product only once when executed `WorldRenderer#renderSky`.

* update `BedrockSunGlareShading`
  - fields:
    + float `sunAngleDiff`
    + Vector3f `sunVector3f`
    + MinecraftClient `client`
  - methods:
    + void `tick`
    + void `updateAngleDiff`
    + static float `getSunAngleDiffClamped(float)` -> float `getSunAngleDiff()`

* update `BedrockifyClient`
  - register a new method in `END_CLIENT_TICK`:
    + `BedrockSunGlareShading#tick`

* update `WorldRendererMixin`
  - method name has changed: `bedrockify$storeSunAngleDiff` -> `bedrockify$updateSunAngleDiff`
  - mixin injection point has changed: `HEAD` -> `BEFORE_INVOKE` target = `ClientWorld#getSkyColor`
* update `en_us.json`
  - the word "vanilla rendering" might not be user friendly

* update `IrisCompatTest.java`
  - add JavaDoc
  - add affected class info to error message

* update `BedrockSunGlareShading.java`
  - update JavaDoc
  - add new const: ClassMethodHolder `ClassMethodHolder#CONDITION_TRUE`

* update `ClientWorldMixin.java`
  - does not require to extend super class
@lonefelidae16
Copy link
Contributor Author

I know there is another way to inject into other mods that uses Pseudo annotation instead of Reflection. BedrockIfy has a great mechanism for applying Mixins provided by BedrockIfyMixinPlugin.java and it will make users can be forced to enable this feature regardless of whether the external shader is present.

If more flexibility is needed in the future version, this may be discussed as a way to also obtain the sun angle that is changed by the shaders.

Copy link
Owner

@juancarloscp52 juancarloscp52 left a comment

Choose a reason for hiding this comment

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

I've finally been able to take a look at it, sorry for the delay... Looks great, works great. Thanks :)

@juancarloscp52 juancarloscp52 merged commit 180c2ea into juancarloscp52:1.19.3 Feb 25, 2023
@lonefelidae16 lonefelidae16 deleted the feat/sun-glare branch February 26, 2023 01:54
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.

Behavior of the sun in bedrock
2 participants