Compare commits

...
5 Commits
Author SHA1 Message Date
koka 448e2febff Keep soil matte and align solar wave glints with native sunset in beta.150
Build Sanctuary / build (push) Waiting to run
2026-09-18 21:47:33 +02:00
koka 1c23d0c17e Separate PBR and SSR ranges and remove foliage sheen in beta.149
Build Sanctuary / build (push) Waiting to run
2026-09-18 20:40:47 +02:00
koka 6f871446bb Balance PBR at 50 percent and soften solar water highlights in beta.148
Build Sanctuary / build (push) Waiting to run
2026-09-18 20:12:08 +02:00
koka 96a36d99be Fix close PBR flicker, soften moonlight and extend range in beta.147
Build Sanctuary / build (push) Waiting to run
2026-09-18 19:56:03 +02:00
koka cf9a670f44 Prepare beta.146 reflections and water blending
Build Sanctuary / build (push) Waiting to run
2026-09-18 19:40:25 +02:00
34 changed files with 1031 additions and 76 deletions
+35 -2
View File
@@ -1,5 +1,38 @@
# Sanctuary
## beta.150 — Terre mate et reflets du coucher de soleil (pack local)
Terre mate avec relief conservé. Le soleil et son reflet se colorent ensemble
en suivant la couleur et la transition du coucher de soleil natif de Minecraft.
Les accents lumineux suivent les normales animées des vaguelettes et leur
orientation vers le soleil et la caméra. [Contrat et vérifications](docs/matte-dirt-beta150.md).
## beta.149 — Distances PBR / SSR et feuillage (pack local)
Deux distances séparées, 64 blocs par défaut chacune, jusqu’à 256 blocs.
Option renommée « SSR » et suppression du voile spéculaire sur le feuillage.
[Contrat et vérifications](docs/independent-distances-beta149.md).
## beta.148 — PBR 50 % et soleil diffus (pack local)
PBR à 50 %, reflet solaire plus doux avec fusion par texel préservant
la texture de l’eau. SSR à 20 %, portée commune jusqu’à 256 blocs.
[Contrat et vérifications](docs/pbr-soft-sun-beta148.md).
## beta.147 — PBR proche, lune et portée 256 (pack local)
Correction du scintillement à très courte distance, reflet lunaire adouci
et distance commune PBR/SSR jusqu’à 256 blocs.
[Contrat et vérifications](docs/pbr-close-range-beta147.md).
## beta.146 — Reflets et transitions de l’eau (pack local)
Correction du masquage des personnages en F5 et sélection stricte des surfaces PBR.
PBR à 80 % et SSR à 20 % par défaut, distance commune PBR/SSR
(16/32/64/128 blocs), reflet solaire large et blanc avec léger bloom des matières.
Eau naturelle selon le type de monde et mélange 1/3/5/9/17 blocs.
[Contrat et vérifications](docs/reflections-water-beta146.md).
## beta.145 — PBR de l’eau et reflets pixélisés (livraison locale)
L’eau et le verre rejoignent le PBR natif. L’option expérimentale de reflets
@@ -2328,7 +2361,7 @@ Depuis beta.090, la cible est **Minecraft 26.3 finale**, publiée le 15 septembr
| Fabric API | 0.160.5+26.3 |
| Fabric Loom | 1.17.20 |
| Gradle Wrapper | 9.5.1, distribution vérifiée par SHA-256 |
| Sanctuary / pack | beta.122 |
| Sanctuary / pack | beta.150 |
Java 25 et Python 3.11 ou plus récent sont nécessaires. Le script pack utilise
uniquement la bibliothèque standard et repère aussi une installation Python
@@ -2357,7 +2390,7 @@ décrits dans [Validation](docs/testing.md).
Résultats :
- `mods/sanctuary/build/libs/sanctuary-beta.122.jar` : mod à installer avec
- `mods/sanctuary/build/libs/sanctuary-beta.150.jar` : mod à installer avec
Fabric API sur la version Minecraft indiquée.
- `build/packwiz/` : pack de développement complet, avec le mod construit et
l'index vérifié. Voir [Installation packwiz](packwiz/README.md).
+68
View File
@@ -0,0 +1,68 @@
# RENDER-149 — Distances PBR et SSR indépendantes
Branche `codex/separate-reflection-distances-beta149`, socle beta.148 `6f87144`.
- Deux réglages : Distance PBR et Distance SSR, chacun à 64 blocs par défaut.
Choix 16, 32, 64, 128, 256 blocs, enregistrés séparément.
- Le PBR conserve son propre fondu et sa propre limite de portée. Le SSR
utilise sa distance pour les surfaces réfléchissantes et sa recherche de
paysage. Le maillage et la sélection des surfaces couvrent le maximum des
deux portées actives, afin que réduire l’une ne coupe pas l’autre.
- Ancien défaut commun 32 migré une fois vers PBR 64 ; nouveau réglage SSR 64.
Les anciennes valeurs PBR différentes de 32 restent conservées. Après la
migration, un choix explicite 32 est conservé comme les autres valeurs.
- Option nommée exactement « SSR » en français et en anglais, sans la mention
« expérimental ». Les autres options expérimentales du jeu sont inchangées.
- Intensités PBR 50 % et SSR 20 %, rendu solaire diffus de beta.148 conservés.
SSR conserve sa dépendance au PBR et les limites du paysage visible/chargé
et du budget de maillage.
- Les feuilles (et fibres de laine, même profil entièrement mat) ne reçoivent
plus de large éclat spéculaire blanc. Leur relief normal reste présent.
La pierre et le bois retrouvent exactement leur poids spéculaire précédent,
comme les surfaces polies, les métaux, l’eau et le verre. La suppression
concerne les profils non métalliques de rugosité 0,98, avec transition 0,90–0,98.
## Vérifications
Contrôles de persistance indépendante, valeurs par défaut et libellés FR/EN.
Scènes graphiques avec PBR variable/SSR 256 puis PBR 256/SSR variable.
- Suite PBR/préférences Vulkan réussie : deux défauts 64 et persistance
indépendante sur 16/32/64/128/256 ; libellés FR/EN et nom SSR vérifiés.
Journal : `build/beta149-pbr-vulkan.log`.
- Suites SSR Vulkan et OpenGL réussies avec les portées dissociées, F5,
intersections, eau/verre/métal, soleil/lune, OFF/zéro et rechargement.
Journaux : `build/beta149-ssr-vulkan.log`, `build/beta149-ssr-opengl.log`.
Ces passes précèdent l’ajustement final du profil entièrement mat.
- Suite PBR Vulkan finale avec feuillage réussie : 170 172 pixels de feuilles
contrôlés, saturation relative 1,00007, relief visible sur 63 236 pixels.
Journal : `build/beta149-foliage-vulkan.log` ; captures correspondantes
dans `build/evidence/beta149-foliage-vulkan/`.
- Bois et briques après recentrage sur le feuillage : aucun pixel modifié
par rapport à la capture précédant l’ajustement, sur les zones de contrôle
de 26 304 et 40 896 pixels respectivement.
- `./gradlew check build` exécuté dans l’instantané isolé : 252 tests serveur,
229 réussis et 23 échecs, mêmes identifiants qu’en beta.148. Aucun nouvel échec.
Journal : `build/beta149-check-build-isolated.log` ; comparaison :
`build/beta149-server-failures.json`. L’ajustement final du feuillage concerne
seulement le shader et son test client. Le contrôle global reste en échec.
- Suite PBR OpenGL finale réussie également : 170 199 pixels de feuilles,
saturation relative 1,00001, relief visible sur 63 263 pixels.
Journal : `build/beta149-foliage-opengl.log` ; captures correspondantes
dans `build/evidence/beta149-foliage-opengl/`.
- Assemblage final réussi : `./gradlew build assemblePack -x :sanctuary:check`,
sans répéter les contrôles purs/serveur exécutés dans l’instantané.
Journal : `build/beta149-build-pack.log`. Cette exclusion ne transforme
pas le contrôle complet en réussite.
## Artefact
[Sanctuary-beta.149.mrpack](../build/Sanctuary-beta.149.mrpack), copié aussi dans
`sanctuary-beta/build/` avec les autres versions. Archive vérifiée, un seul JAR
Sanctuary beta.149 identique au JAR construit, shaders identiques aux sources,
libellés SSR et deux portées FR/EN vérifiés. Minecraft 26.3 / Loader 0.19.5.
Taille : 10 520 465 octets. SHA-256 :
`ef5519d9a0e2006b865b62371a6f8712db02ab138aa9698339d6fdb02fb4befa`.
Reçu : `build/beta149-artifacts.json`. Aucune installation Prism ni publication.
+96
View File
@@ -0,0 +1,96 @@
# RENDER-150 — Terre mate et reflets solaires colorés
Branche `codex/matte-dirt-beta150`, socle beta.149 `1c23d0c`.
La terre sèche utilise un profil entièrement mat (rugosité 0,98, métal 0),
comme le feuillage corrigé en beta.149. Cela enlève l’éclat blanc/gris diffus
sans supprimer les normales ni le contraste de relief. Le SSR de ces matières
est également atténué par leur rugosité, sans changer son réglage global.
Blocs concernés : dirt, coarse_dirt, rooted_dirt, grass_block, dirt_path,
farmland, podzol et mycelium. Les faces terreuses suivent ainsi le même profil.
Les autres profils de matière sont inchangés.
Le disque du soleil et son reflet utilisent la même couleur native
`SkyRenderState.sunriseAndSunsetColor`, issue de l’attribut environnemental
Minecraft `SUNRISE_SUNSET_COLOR`. Son alpha pilote la transition depuis le
blanc : aucune palette horaire ou altitude artificielle. Le soleil reste
neutre tant que le dégradé natif est absent et se colore avec le ciel.
La teinte solaire est convertie en lumière linéaire pour le PBR. Le mixin
modifie seulement la couleur du disque solaire, préserve l’alpha de pluie,
la texture native et la lune, et respecte la désactivation globale de Vanilla Light.
La fusion diffuse de l’eau et sa normale animée d’origine sont conservées.
Les accents suivent les pentes des vaguelettes qui réfléchissent le soleil
vers la caméra. Leur pulsation vient des normales animées de la texture,
sans oscillateur indépendant ni inversion artificielle du relief.
Une faible variation stable par texel évite des crêtes toutes identiques ;
elle module seulement l’intensité, sans produire des points isolés aléatoires.
Les détails s’atténuent lorsqu’ils deviennent plus petits qu’un pixel écran.
Les accents restent limités au reflet solaire et conservent sa couleur.
Les lampes et la lune gardent leurs
couleurs propres.
PBR 50 %, SSR 20 % et deux portées indépendantes de 64 blocs par défaut conservés.
Minecraft 26.3, Java 25 et dépendances inchangés ; aucune sauvegarde modifiée.
## Vérifications
Tests des profils de terre et scènes GPU comparant PBR OFF/ON sur terre et
feuillage : conservation de la couleur native et présence du relief.
- Suites PBR finales Vulkan/OpenGL réussies, dont profils des huit types de
sol, proximité, intensités, préférences et feuillage.
Journaux : `build/beta150-pbr-vulkan-final.log` et
`build/beta150-pbr-opengl-final.log`.
- Terre : 180 469 pixels contrôlés, saturation relative 0,99877 sur les deux
moteurs ; relief visible sur 145 415 pixels. Captures conservées dans
`build/evidence/beta150-pbr-vulkan-final/` et
`build/evidence/beta150-pbr-opengl-final/`.
Les tests comparent la contribution PBR au rendu natif et capturent aussi
le disque du soleil, avant puis pendant la transition native du ciel.
Le contrôle serveur `./gradlew check build`, exécuté dans une copie isolée
`build/server-validation` avant les derniers ajouts exclusivement client,
compte 229 réussites et 23 échecs sur 252 tests. Les 23 identifiants d’échec
sont identiques à beta.149 ; aucun nouvel identifiant. Le contrôle global
n’est donc pas vert. Journaux : `build/beta150-check-build-isolated.log` et
`build/beta150-server-failures.json`.
Les scènes solaires comparent le rendu PBR au natif, avant et pendant le
coucher de soleil. À 2 000 ticks, la teinte native est blanche ; à 11 500 ticks
sa transition commence légèrement (alpha 0,051) ; à 12 400 ticks l’alpha
natif atteint 0,831 et le disque devient chaud (centre RGB 255/255/135).
Les deux moteurs ont validé cette synchronisation native.
Un lancement sans sélection PBR a également rencontré l’assertion client
Blocodex « The full snapshot must become visible together », avant les scènes
GPU (`build/beta150-water-motion-vulkan.log`). Il ne constitue pas une
validation de la suite client générale.
La suite finale Vulkan des éclats liés aux vaguelettes passe
(`build/beta150-wave-glints-vulkan.log`) : animation native, masquage F5,
distances indépendantes, reflets solaires et lunaires, matériaux transparents,
rechargement des ressources et redimensionnement. Dans la scène solaire,
150 563 pixels sont éclaircis, sans pixel blanc saturé.
La suite OpenGL finale passe également
(`build/beta150-wave-glints-opengl.log`) : 148 180 pixels éclaircis, aucun
pixel blanc saturé. Les captures finales sont conservées dans
`build/evidence/beta150-wave-glints-vulkan/` et
`build/evidence/beta150-wave-glints-opengl/`.
Le ressenti des vaguelettes en mouvement reste à confirmer par le créateur
sur sa configuration ; les tests ne constituent pas une validation esthétique.
## Pack local
Construction et assemblage réussis avec
`./gradlew build assemblePack -x :sanctuary:check`, après le contrôle complet
ci-dessus. L’exclusion ne transforme pas ses échecs connus en réussite.
Export packwiz puis vérification ZIP, version Fabric, Minecraft 26.3,
Loader 0.19.5, JAR unique identique au construit, shader final et mixin solaire.
- Pack : `/Users/koka/Documents/sanctuary/sanctuary-beta/build/Sanctuary-beta.150.mrpack`
- Taille : 10522942 octets.
- SHA-256 pack : `65a4a44948dcdcf0325b5e24c076a03f8832184f25f5c1ff16f69bd3ee641b93`.
- SHA-256 JAR : `4962e6f8cafd6ef3e81e088bf9b0092a264441632cfa095d4fe7394b855f093d`.
- Reçu : `build/beta150-artifacts.json`, également copié à côté du pack.
Aucun canal publié, aucune instance Prism ni sauvegarde personnelle modifiée.
+82
View File
@@ -0,0 +1,82 @@
# RENDER-147 — PBR proche, lune et portée 256 blocs
Branche `codex/pbr-close-range-beta147`, socle beta.146 `cf9a670`.
Minecraft 26.3, Java 25 ; dépendances et formats de sauvegarde inchangés.
## Résultat
- Le prépassage des récepteurs PBR comparait encore les profondeurs natives
avec un epsilon fixe de 0,0000001. En profondeur inversée, cette marge
devenait trop stricte au voisinage de la caméra : de nombreux fragments
alternaient entre le rendu natif et le PBR lors de mouvements minuscules.
- La comparaison utilise maintenant une distance reconstruite avec la marge
bornée de 5 mm déjà employée par les passes couleur. La sélection de la
surface PBR la plus proche et son test de profondeur EQUAL restent stricts.
Aucun décalage du maillage ni fondu supprimant le PBR près de la caméra.
- La lune ne reçoit plus le renforcement spéculaire du soleil (×20 pour
l’eau, ×4 pour les autres matières). Son coefficient lunaire et ses phases
restent appliqués ; le grand reflet solaire est conservé.
- Distance commune PBR/SSR : 16, 32 (défaut), 64, 128 ou 256 blocs.
À 256, le rayon SSR peut aussi rechercher jusqu’à 256 blocs. Nombre de pas
et budgets de maillage inchangés ; les limites du terrain visible/chargé,
des reflets hors écran et du budget de maillage subsistent.
- PBR 80 %, SSR 20 %, mélange des eaux et préférences de beta.146 conservés.
Libellés FR/EN mis à jour.
## Vérifications
Mondes de test jetables, macOS Apple M1. Aucune sauvegarde personnelle utilisée.
- Reproduction avant correction sous Vulkan : à 12 cm du sol de briques,
59 442 / 262 272 pixels changent de plus de 12 niveaux RVB cumulés sous une
rotation de 0,00002 degré. Le test échoue. Journal :
`build/beta147-close-before-vulkan.log`.
- Même scène après correction : 1 / 262 272 pixels à 12 cm ; également testé
à 25 cm, 50 cm et 1 m. Suite PBR Vulkan réussie :
`build/beta147-close-after-vulkan.log`.
- Preuves avant/après dans `build/evidence/close-before-vulkan/` et
`build/evidence/close-after-vulkan/`.
- Suite PBR et préférences OpenGL finale réussie : mêmes scènes proches,
persistance des distances dont 256 blocs, FR/EN, OFF/zéro, intensités,
rechargement, redimensionnement et effets combinés.
Journal : `build/beta147-close-final-opengl.log` ; preuves :
`build/evidence/beta147-close-final-opengl/`.
- Suite SSR Vulkan finale réussie : F5, intersections, portées dont 256,
eau/verre/métal, OFF/zéro, rechargement et redimensionnement.
Journal : `build/beta147-ssr-final-vulkan.log` ; preuves :
`build/evidence/beta147-ssr-final-vulkan/`.
- À PBR 80 % / SSR 20 %, le soleil conserve 22 697 pixels quasi blancs sur
la scène aquatique 854 × 480. La lune seule en compte zéro, tout en modifiant
visiblement 40 808 pixels par rapport au PBR OFF. Capture du bloom lunaire
inspectée : reflet doux, sans plateau blanc.
- Suite SSR OpenGL finale réussie également : zéro pixel quasi blanc pour
la lune, 22 111 pour le soleil et 40 749 pixels de reflet lunaire visibles.
Intersections : 91 / 518 400 pixels changés sous rotation minuscule.
Journal : `build/beta147-ssr-final-opengl.log` ; captures correspondantes
dans `build/evidence/beta147-ssr-final-opengl/`.
- `./gradlew check build` dans un instantané isolé : 252 tests serveur,
229 réussis, 23 échecs, avec exactement les mêmes identifiants que beta.146.
Journal : `build/beta147-check-build-isolated.log` ; comparaison :
`build/beta147-server-failures.json`. La vérification globale reste en échec.
Les derniers ajouts lune/256 concernent exclusivement le rendu client,
ses réglages et ses tests ; ils sont validés par les suites finales ci-dessus.
- Assemblage final réussi : `./gradlew build assemblePack -x :sanctuary:check`,
après les contrôles purs et serveur exécutés dans l’instantané, sans les
répéter. Journal : `build/beta147-build-pack.log`. Cette exclusion ne
transforme pas le contrôle complet en réussite.
## Artefact
[Sanctuary-beta.147.mrpack](../build/Sanctuary-beta.147.mrpack), également copié
à côté de beta.146 dans `sanctuary-beta/build/`. Aucun ancien pack remplacé,
aucune installation Prism ou publication effectuée.
Archive ZIP vérifiée, un seul JAR Sanctuary beta.147, identique au JAR construit,
shaders identiques aux sources finales, options FR/EN 256 présentes,
Minecraft 26.3 / Fabric Loader 0.19.5 conservés. Taille : 10 519 851 octets.
SHA-256 : `b8044243dbe160d5171ea584052cf5732393e4d91352c29c33b727af80c0a5bc`.
Reçu : `build/beta147-artifacts.json`.
+68
View File
@@ -0,0 +1,68 @@
# RENDER-148 — PBR 50 % et reflet solaire diffus
Branche `codex/pbr-soft-sun-beta148`, socle beta.147 `96a36d9`.
Minecraft 26.3, Java 25, dépendances et sauvegardes inchangés.
## Résultat
- PBR à 50 % par défaut, SSR toujours à 20 % et portée commune jusqu’à 256.
- Les configurations anciennes contenant exactement PBR 80 % passent à 50 %.
Un marqueur de migration conserve ensuite tout choix explicite, y compris
un nouveau choix 80 %. Les autres anciennes intensités restent conservées.
- Le reflet solaire de l’eau avait un renforcement ×20 et une compression
exponentielle qui effaçait les détails dans une large zone blanche.
Le renforcement passe à ×6 et le lobe est plus diffus (rugosité minimale
de 0,42 au lieu de 0,34 pour le lobe céleste de l’eau).
- Pour le soleil sur l’eau, fusion par texel entre éclaircissement vers le
blanc et lumière douce fondée sur la couleur native. La pondération emploie
une compression rationnelle, sans atteindre brutalement un plateau blanc.
La texture et ses animations restent natives ; aucun bruit ajouté.
- La lune conserve son intensité atténuée, sans renforcement solaire.
Les lampes et matières solides conservent leur fusion spéculaire précédente.
Le bloom reste réglable et suit la lumière réellement ajoutée.
## Vérifications
Scènes plates jetables, Apple M1, Vulkan et OpenGL. Le test solaire contrôle
une lumière largement visible et limite les pixels quasi blancs à moins de
0,5 % de l’image, au lieu d’imposer une grande tache blanche.
Premier contrôle Vulkan à PBR 50 % / SSR 20 % : 149 908 pixels éclaircis,
zéro pixel quasi blanc sur 854 × 480. Captures vues du dessus et à soleil bas
inspectées : la texture reste visible dans la traînée lumineuse.
Preuves : `build/evidence/beta148-preview/`.
Rendu de la traînée solaire approuvé par le créateur après inspection de la capture.
- Suites SSR complètes Vulkan et OpenGL réussies : F5, intersections, portées,
eau/verre/métal, OFF/zéro, lune, bloom, rechargement et redimensionnement.
Journaux : `build/beta148-ssr-vulkan.log`, `build/beta148-ssr-opengl.log`.
Sous OpenGL, 146 680 pixels éclaircis et zéro pixel quasi blanc dans la scène
solaire. La lune reste visible sans saturation (35 865 pixels modifiés).
Preuves : `build/evidence/beta148-ssr-vulkan/` et
`build/evidence/beta148-ssr-opengl/`.
- Suites PBR/préférences Vulkan et OpenGL réussies : défaut 50 %, migration
de l’ancien 80 %, conservation d’un nouveau choix explicite 80 %, valeurs
personnalisées, FR/EN, proximité, OFF/zéro, intensités et rechargement.
Journaux : `build/beta148-pbr-vulkan.log`, `build/beta148-pbr-opengl.log`.
- `./gradlew check build` dans l’instantané isolé : 252 tests serveur,
229 réussis, 23 échecs. Exactement les mêmes identifiants que beta.147,
aucun nouvel échec. Journal : `build/beta148-check-build-isolated.log` ;
comparaison : `build/beta148-server-failures.json`. Le contrôle global
demeure donc en échec.
- Assemblage final réussi : `./gradlew build assemblePack -x :sanctuary:check`,
sans répéter les contrôles purs et serveur déjà exécutés dans l’instantané.
Journal : `build/beta148-build-pack.log`. L’exclusion ne constitue pas
une réussite du contrôle complet.
## Artefact
[Sanctuary-beta.148.mrpack](../build/Sanctuary-beta.148.mrpack), également copié
à côté des autres versions dans `sanctuary-beta/build/`. Archive ZIP vérifiée,
un seul JAR Sanctuary beta.148 identique au JAR construit, shaders finaux
identiques aux sources, textes FR/EN 50 % et dépendances exactes vérifiés.
Taille : 10 520 050 octets. SHA-256 :
`597cc2a96eabc3cf0ebf8ac59b4f94cf7cabf0c773e1dce13c10736ca6fcba38`.
Reçu : `build/beta148-artifacts.json`.
Aucune publication ni installation Prism effectuée.
+112
View File
@@ -0,0 +1,112 @@
# RENDER-146 — Reflets, portée commune et transitions de l’eau
Branche `codex/reflections-water-beta146`, socle beta.145 `ed2d088`.
Minecraft 26.3, Java 25 et dépendances inchangés. Préparation locale uniquement.
## Contrat
- Les passes PBR et SSR vérifient la profondeur finale du rendu natif pour
masquer les personnages, notamment en F5. La profondeur du paysage capturée
avant les transparences reste celle utilisée pour rechercher le reflet.
- Le PBR utilise le test matériel EQUAL contre la profondeur du récepteur
sélectionné. L’ancienne tolérance de 3,5 cm pouvait accepter des faces
concurrentes près des coins ; elle est supprimée. La comparaison avec la
profondeur native conserve seulement une marge de 5 mm pour les différences
d’ordre de calcul des matrices, sans relâcher la sélection stricte du récepteur.
La position du vertex est déclarée invariante entre les passes.
- PBR à 80 % et SSR à 20 % par défaut, pour toutes les matières, eau comprise.
Deux intensités d’effets distinctes, sans réglage séparé solide/liquide.
Les préférences explicites déjà enregistrées restent conservées.
- Distance PBR/SSR commune : 16, 32 (défaut), 64, 128 blocs. Maillages,
sélection des récepteurs et fondu final emploient ce réglage. Le rayon SSR
conserve sa recherche maximale de 128 blocs dans le paysage visible.
Budgets de maillages inchangés : solides 24 Mio, transparences 8 Mio.
Une forte densité à grande portée peut donc limiter les surfaces disponibles.
- Le reflet du soleil adopte un lobe plus large sur l’eau, avec une irradiance
renforcée : grande empreinte blanche vue du dessus et traînée étendue aux
angles rasants. Les lampes conservent leur lobe local.
Les éclats spéculaires ne sont plus plafonnés au gris moyen. Leur compression
conserve une valeur finie pouvant approcher le blanc. Une contribution douce
des seules passes PBR/SSR alimente le bloom existant, sans faire briller tous
les blocs blancs. Le réglage Bloom et son intensité gardent autorité.
- Eau naturelle OFF par défaut dans une dimension ordinaire, ON pour une
dimension dont le générateur est Sanctuary / ExpansionChunkGenerator.
Le serveur transmet ce contexte à la connexion, au changement de dimension
et à la réapparition, y compris en multijoueur. Le défaut automatique nécessite
ce contexte envoyé par un serveur beta.146 ; sans lui, le client utilise le
défaut ordinaire OFF, toujours réglable. Aucune donnée de monde modifiée.
Les choix ON/OFF sont mémorisés séparément pour ces deux catégories.
Un ancien OFF explicite est conservé dans les deux ; un ancien ON global
adopte les nouveaux défauts par contexte.
- Mélange des profils sur 1×1, 3×3, 5×5, 9×9 (défaut) ou 17×17 blocs, puis
interpolation aux sommets. Océans toujours clairs. La texture demeure native.
Surface et immersion utilisent la même étendue. Les changements du fond
invalident toute la largeur dépendante ; changer le réglage reconstruit les
sections chargées contenant de l’eau.
Le filtre de surface est calculé dans la copie de région native, avec sommes
préfixées par hauteur pour borner le coût des sommets. Aucun accès au monde
vivant depuis le worker, chargement de chunk ou modification de sauvegarde.
Les textes des nouvelles options sont fournis en français et en anglais.
## Vérifications
Machine : Apple M1, macOS, Java 25, Minecraft 26.3. Mondes plats jetables,
graine 122 ; aucune sauvegarde personnelle utilisée.
- Suite SSR/PBR Vulkan avec transparence améliorée : réussie
(`build/beta146-final-settings-vulkan.log`). F5 avec personnage réel en créatif,
portée 16/32/64/128, couleur du paysage, eau/verre/métal, OFF/zéro,
immersion, rechargement de ressources et redimensionnement.
- Suite SSR/PBR OpenGL finale réussie également
(`build/beta146-final-settings-opengl.log`), avec 22 450 pixels quasi blancs
dans la scène solaire et 99 / 518 400 pixels modifiés dans le contrôle
des intersections. Captures dans `build/evidence/final-settings-opengl/`.
- F5 : les 1 900 pixels du torse contrôlés sont strictement identiques entre
SSR OFF et ON, tandis que le reflet reste présent autour du personnage.
- Soleil : 22 111 pixels quasi blancs sur 854 × 480 à PBR 80 % / SSR 20 %,
sans bloom, sur la scène de contrôle Vulkan. Les captures vues du dessus et
à soleil bas montrent une empreinte large et une traînée allongée.
Bloom OFF libère sa cible.
- Mur, sol et escaliers en contact : 86 pixels sur 518 400 changent de plus
de 12 niveaux cumulés lors d’une rotation de 0,00002 degré ; seuil du test
0,1 %. Le cadre exclut l’eau animée, qui ne constitue pas une référence
de stabilité pour les blocs statiques.
- Eau : suites fonctionnelles Vulkan et OpenGL réussies
(`build/beta146-water-vulkan.log`, `build/beta146-water-opengl.log`).
Profils, mélange 5/9/17, changement de contexte transmis par le serveur,
préférences séparées, immersion, fond modifié, océans, eau courante,
waterlogging et rechargement. OpenGL contrôle aussi l’égalité des couleurs
aux frontières des copies de région et avec l’échantillonnage de brume.
- `./gradlew check build` exécuté dans un instantané isolé des sources :
252 tests serveur, 229 réussis et 23 échecs. Les identifiants des échecs
correspondent exactement au reçu archivé beta.145 ; aucun nouvel identifiant.
Il ne s’agit pas d’une nouvelle exécution comparative de beta.145.
Journal : `build/beta146-check-build-isolated.log` ; comparaison :
`build/beta146-server-failures.json`. Les derniers changements après cet
instantané concernent le rendu client, ses réglages et ses tests.
Les preuves Vulkan finales sont dans `build/evidence/final-settings-vulkan/`.
La suite de régression PBR et de préférences finale réussit
(`build/beta146-final-pbr-preferences.log`) : PBR 80 %, SSR 20 %, persistance,
migration des anciennes préférences, FR/EN, OFF/zéro et rechargement.
La commande finale `./gradlew check build assemblePack -x :sanctuary:runGameTest`
réussit (125 tâches), sans répéter la suite serveur isolée déjà exécutée.
Journal : `build/beta146-final-build-pack.log`. Cette exclusion ne transforme
pas les 23 échecs serveur en validation globale réussie.
## Artefact local
Le pack [Sanctuary-beta.146.mrpack](../build/Sanctuary-beta.146.mrpack) est exporté
et copié dans le dossier `sanctuary-beta/build/`, à côté des autres versions.
Intégrité ZIP, version beta.146, Minecraft 26.3 et identité du JAR embarqué
avec le JAR construit contrôlées ; shaders finaux présents et identiques aux sources.
Taille : 10 519 634 octets. SHA-256 :
`9f3f7a840652d401741cbe3c85bbb5626326542179754cb599479b01a6b4c955`.
Reçu : `build/beta146-artifacts.json`.
Aucun benchmark isolé de performance de beta.146 n’est revendiqué : des
contrôles serveur peuvent tourner simultanément. Les limites SSR hors écran,
de maillage à grande portée et de compatibilité avec d’autres GPU subsistent.
Aucune publication ou synchronisation Prism.
+2 -2
View File
@@ -9,8 +9,8 @@ loom_version=1.17.20
fabric_api_version=0.160.5+26.3
# Release counter: beta.001, .002, .003, ... (see docs/versioning.md).
mod_version=beta.145
pack_version=beta.145
mod_version=beta.150
pack_version=beta.150
resource_pack_version=beta.121
maven_group=fr.koka.sanctuary
jei_version=30.32.0-sanctuary.3
@@ -27,12 +27,14 @@ public final class Pbr134ClientChecks implements FabricClientGameTest {
c.runOnClient(m->check(analyses==ProceduralPbr.analyses()&&ProceduralPbr.materialCount()>0,"Source textures are cached, not regenerated every frame"));
unchanged(on,capture(c,null),"Static PBR has no animated noise");
look(c,server,.00002f,40.00002f);frames(c);unchanged(on,capture(c,null),"PBR tiny camera motion");look(c,server,0,40);frames(c);
closeRange(c,server);
camera(c,server,10.5,69,5.5,65);look(c,server,0,40);settle(c);
c.runOnClient(m->VanillaLight.setPbrIntensity(20));frames(c);var low=difference(off,capture(c,"pbr-20"));
check(delta.total>low.total*1.3,"PBR strength affects actual GPU output");
c.runOnClient(m->VanillaLight.setPbrIntensity(100));frames(c);var high=difference(off,capture(c,"pbr-100"));check(high.total>delta.total*1.2,"Strong PBR visibly increases relief");
c.runOnClient(m->VanillaLight.setPbrIntensity(0));c.waitTicks(8);unchanged(off,capture(c,null),"PBR zero restores native image");
c.runOnClient(m->{VanillaLight.setPbrIntensity(0);});c.waitTicks(8);unchanged(off,capture(c,null),"PBR zero restores native image");
c.runOnClient(m->check(!ProceduralPbr.allocated()&&ProceduralPbr.materialCount()==0,"Zero releases targets and material cache"));
c.runOnClient(m->VanillaLight.setPbrIntensity(50));frames(c);
c.runOnClient(m->{VanillaLight.setPbrIntensity(50);});frames(c);
server.runOnServer(s->command(s,"time set 11000"));settle(c);enable(c,false);var eveningOff=capture(c,null);enable(c,true);var eveningOn=capture(c,"pbr-evening");
int directions=0;for(int i=0;i<on.pixels().length;i++){int am=(on.pixels()[i]>>16&255)-(off.pixels()[i]>>16&255),pm=(eveningOn.pixels()[i]>>16&255)-(eveningOff.pixels()[i]>>16&255);if(Math.abs(am-pm)>5)directions++;}
check(directions>500,"Relief follows the moving sun: "+directions);
@@ -48,10 +50,53 @@ public final class Pbr134ClientChecks implements FabricClientGameTest {
c.runOnClient(m->m.getWindow().setWindowed(oldWidth,oldHeight));c.waitFor(m->m.gameRenderer.mainRenderTarget().width==on.width(),200);frames(c);
c.runOnClient(m->{VanillaLight.setPixelShadows(true);VanillaLight.setSsgi(true);VanillaLight.setBloom(true);VanillaLight.setOreEmission(true);VanillaLight.setEdgeHighlights(true);});
c.waitFor(m->PixelShadows.applied()&&PixelShadows.ready()&&ScreenSpaceGI.applied()&&Bloom.applied()&&EdgeHighlights.applied()&&ProceduralPbr.applied(),1200);frames(c);capture(c,"pbr-combined");
matteGround(c,server,Blocks.OAK_LEAVES,"leaves",true);
matteGround(c,server,Blocks.DIRT,"dirt",false);
c.runOnClient(m->VanillaLight.setEnabled(false));c.waitTicks(8);c.runOnClient(m->check(!ProceduralPbr.allocated()&&ProceduralPbr.materialCount()==0,"Global OFF releases PBR"));
c.runOnClient(m->{VanillaLight.setEnabled(true);VanillaLight.setPbr(false);VanillaLight.setSsgi(false);});
System.out.println("PBR134_PASS normals; profiles; texture cache; directional lighting; intensity; OFF/zero; tiny camera; reload; resize; combined; default="+delta+" high="+high+" directional="+directions);
}
private static void matteGround(ClientGameTestContext c,TestServerContext server,net.minecraft.world.level.block.Block block,String name,boolean leaves){
c.runOnClient(m->{VanillaLight.setSsr(false);VanillaLight.setPbrIntensity(50);VanillaLight.setPixelShadows(false);VanillaLight.setSsgi(false);VanillaLight.setBloom(false);VanillaLight.setOreEmission(false);VanillaLight.setEdgeHighlights(false);});
server.runOnServer(s->{if(leaves)command(s,"time set 1000");for(int x=-5;x<=24;x++)for(int z=-5;z<=24;z++)
s.overworld().setBlockAndUpdate(new BlockPos(x,64,z),leaves?block.defaultBlockState().setValue(net.minecraft.world.level.block.LeavesBlock.PERSISTENT,true):block.defaultBlockState());});
camera(c,server,10.5,69,5.5,65);look(c,server,0,40);settle(c);
enable(c,false);var off=capture(c,"pbr150-"+name+"-off");enable(c,true);var on=capture(c,"pbr150-"+name+"-on");
double nativeChroma=0,pbrChroma=0;int samples=0,relief=0;
for(int y=off.height()/3;y<off.height()*9/10;y++)for(int x=off.width()/10;x<off.width()*9/10;x++){
int i=y*off.width()+x,a=off.pixels()[i],b=on.pixels()[i],r=a>>16&255,g=a>>8&255,blue=a&255;
if(leaves?(g<30||g<r*1.1||g<blue*1.1):(r<30||r<g*1.05||g<blue*1.1))continue;
nativeChroma+=chroma(a);pbrChroma+=chroma(b);samples++;
if(Math.abs((b>>16&255)-r)+Math.abs((b>>8&255)-g)+Math.abs((b&255)-blue)>6)relief++;
}
double retained=pbrChroma/nativeChroma;
System.out.println("PBR150_MATTE material="+name+" samples="+samples+" chromaRetained="+retained+" relief="+relief);
check(samples>1000&&retained>.985,name+" preserves native colour without specular veil: "+retained);
check(relief>100,name+" normal relief remains visible");
}
private static double chroma(int pixel){
int r=pixel>>16&255,g=pixel>>8&255,b=pixel&255,max=Math.max(r,Math.max(g,b)),min=Math.min(r,Math.min(g,b));
return (max-min)/(double)Math.max(1,max);
}
private static void closeRange(ClientGameTestContext c,TestServerContext server){
int failures=0;
c.runOnClient(m->VanillaLight.setPbrIntensity(80));
for(double distance:new double[]{.12,.25,.5,1.0}){
double eye=c.computeOnClient(m->(double)m.player.getEyeHeight());
camera(c,server,4.5,65-eye+distance,5.5,65);look(c,server,17,55);settle(c);frames(c);
var before=capture(c,"pbr147-close-"+distance);
look(c,server,17.00002f,55.00002f);frames(c);var after=capture(c,"pbr147-close-moved-"+distance);
int changed=0,count=0;
for(int y=before.height()/10;y<before.height()*9/10;y++)for(int x=before.width()/10;x<before.width()*9/10;x++){
int i=y*before.width()+x,a=before.pixels()[i],b=after.pixels()[i];count++;
if(Math.abs((a>>16&255)-(b>>16&255))+Math.abs((a>>8&255)-(b>>8&255))+Math.abs((a&255)-(b&255))>12)changed++;
}
System.out.println("PBR147_CLOSE distance="+distance+" changed="+changed+" samples="+count);
if(changed>count*.001)failures++;
}
c.runOnClient(m->VanillaLight.setPbrIntensity(50));
check(failures==0,"Close PBR stays stable under subpixel motion: failing distances="+failures);
}
private static void materials(){
int[] flat=new int[16];Arrays.fill(flat,0xFF808080);var profile=PbrMaterials.profile("bricks");
for(int p:PbrMaterials.generate(flat,4,4,profile))check((p>>8&0xFFFF)==0x8080,"Flat source has neutral normal");
@@ -61,23 +106,40 @@ public final class Pbr134ClientChecks implements FabricClientGameTest {
check(PbrMaterials.profile("water").metal()==0&&PbrMaterials.profile("glass").metal()==0,"Water and glass stay dielectric");
int[] glass={0x00FFFFFF,0x00000000,0x00000000,0x00FFFFFF};
for(int p:PbrMaterials.generate(glass,2,2,PbrMaterials.profile("glass")))check((p>>8&0xFFFF)==0x8080,"Transparent glass texels fall back to geometric normal");
for(String soil:new String[]{"dirt","coarse_dirt","rooted_dirt","grass_block","dirt_path","farmland","podzol","mycelium"})
check(PbrMaterials.profile(soil).roughness()>=.98f&&PbrMaterials.profile(soil).metal()==0,"Dry soil has a fully matte profile: "+soil);
check(PbrMaterials.profile("oak_planks").roughness()>PbrMaterials.profile("polished_andesite").roughness(),"Wood remains rougher than polished stone");
}
private static void preferences(){try{
var p=FabricLoader.getInstance().getConfigDir().resolve("sanctuary-shaders.json");Files.writeString(p,"{\"ssgi\":true,\"ssgiIntensity\":35,\"bloom\":false}");forgetPreferences();
check(VanillaLight.pbr()&&VanillaLight.pbrIntensity()==80&&VanillaLight.ssgi()&&!VanillaLight.bloom(),"Missing PBR setting defaults ON while preserving explicit old choices");
check(VanillaLight.pbr()&&VanillaLight.pbrIntensity()==50&&VanillaLight.ssgi()&&!VanillaLight.bloom(),"Missing PBR setting defaults ON while preserving explicit old choices");
Files.writeString(p,"{\"pbrIntensity\":80}");forgetPreferences();
check(VanillaLight.pbrIntensity()==50,"Previous 80 percent baseline migrates to 50 once");
VanillaLight.setPbrIntensity(80);forgetPreferences();check(VanillaLight.pbrIntensity()==80,"New explicit 80 percent choice persists after migration");
for(int n:new int[]{-1,0,50,100,101}){VanillaLight.setPbr(true);VanillaLight.setPbrIntensity(n);forgetPreferences();check(VanillaLight.pbr()&&VanillaLight.pbrIntensity()==Math.clamp(n,0,100),"PBR preference persistence/clamp");}
check(!VanillaLight.ssr()&&VanillaLight.ssrIntensity()==50,"Missing SSR defaults OFF at 50 percent");
check(VanillaLight.pbrDistance()==64&&VanillaLight.ssrDistance()==64,"Independent distances default to 64");
check(!VanillaLight.naturalWater(false)&&VanillaLight.naturalWater(true),"World-specific water defaults");
for(int n:new int[]{16,32,64,128,256}){VanillaLight.setPbrDistance(n);forgetPreferences();check(VanillaLight.pbrDistance()==n&&VanillaLight.ssrDistance()==64,"PBR distance changes independently");}
for(int n:new int[]{16,32,64,128,256}){VanillaLight.setSsrDistance(n);forgetPreferences();check(VanillaLight.ssrDistance()==n&&VanillaLight.pbrDistance()==256,"SSR distance changes independently");}
VanillaLight.setSsrDistance(64);
for(int n:new int[]{0,1,2,4,8}){VanillaLight.setWaterBlendRadius(n);forgetPreferences();check(VanillaLight.waterBlendRadius()==n,"Water blend persistence");}
VanillaLight.setPbrDistance(32);VanillaLight.setWaterBlendRadius(4);
check(!VanillaLight.ssr()&&VanillaLight.ssrIntensity()==20,"Missing SSR defaults OFF at 20 percent");
for(int n:new int[]{-1,0,50,100,101}){VanillaLight.setSsr(true);VanillaLight.setSsrIntensity(n);forgetPreferences();check(VanillaLight.ssr()&&VanillaLight.ssrIntensity()==Math.clamp(n,0,100),"SSR preference persistence/clamp");}
VanillaLight.setSsr(false);VanillaLight.setSsrIntensity(50);forgetPreferences();check(!VanillaLight.ssr(),"SSR OFF persists");
VanillaLight.setSsr(false);VanillaLight.setSsrIntensity(20);forgetPreferences();check(!VanillaLight.ssr(),"SSR OFF persists");
var manager=net.minecraft.client.Minecraft.getInstance().getLanguageManager();var oldLanguage=manager.getSelected();
for(String locale:new String[]{"fr_fr","en_us"}){
manager.setSelected(locale);manager.onResourceManagerReload(net.minecraft.client.Minecraft.getInstance().getResourceManager());
for(String key:new String[]{"ssr","ssr_help","ssr_intensity","ssr_intensity_help","ssr_intensity_value"}){
for(String key:new String[]{"ssr_distance","ssr_distance_help","ssr_distance_value","pbr_distance","pbr_distance_help","pbr_distance_value","water_blend","water_blend_help","water_blend_value","ssr","ssr_help","ssr_intensity","ssr_intensity_help","ssr_intensity_value"}){
String full="sanctuary.shaders."+key;check(!net.minecraft.network.chat.Component.translatable(full,50).getString().equals(full),"SSR FR/EN "+full);
}
}
check(net.minecraft.network.chat.Component.translatable("sanctuary.shaders.ssr").getString().equals("SSR"),"SSR label without experimental qualifier");
manager.setSelected(oldLanguage);manager.onResourceManagerReload(net.minecraft.client.Minecraft.getInstance().getResourceManager());
Files.writeString(p,"{\"naturalWater\":false,\"pbrIntensity\":37}");forgetPreferences();
check(!VanillaLight.naturalWater(false)&&!VanillaLight.naturalWater(true)&&VanillaLight.pbrIntensity()==37,"Legacy water OFF and personal PBR intensity are preserved");
Files.writeString(p,"{\"naturalWater\":true}");forgetPreferences();
check(!VanillaLight.naturalWater(false)&&VanillaLight.naturalWater(true),"Legacy global ON adopts contextual defaults");
VanillaLight.setPbrIntensity(50);
}catch(Exception e){throw new AssertionError(e);}}
private record Delta(int changed,int brighter,int darker,long total){}
@@ -10,7 +10,7 @@ import net.minecraft.world.level.block.Blocks;
final class PixelReflectionsClientChecks {
static void run(ClientGameTestContext c,TestServerContext server){
c.runOnClient(m->{VanillaLight.setEnabled(true);VanillaLight.setSaturation(100);VanillaLight.setPbr(true);VanillaLight.setPbrIntensity(80);
VanillaLight.setNaturalWater(true);VanillaLight.setWaterIntensity(100);VanillaLight.setSsr(false);VanillaLight.setSsrIntensity(100);VanillaLight.setColoredLights(false);VanillaLight.setSsgi(false);
VanillaLight.setNaturalWater(true);VanillaLight.setWaterIntensity(100);VanillaLight.setWaterBlendRadius(0);VanillaLight.setSsr(false);VanillaLight.setSsrIntensity(100);VanillaLight.setColoredLights(false);VanillaLight.setSsgi(false);
VanillaLight.setSunshafts(false);VanillaLight.setLensFlare(false);VanillaLight.setBloom(false);VanillaLight.setOreEmission(false);
VanillaLight.setEdgeHighlights(false);VanillaLight.setPixelShadows(false);});
server.runOnServer(s->{
@@ -32,6 +32,97 @@ final class PixelReflectionsClientChecks {
long changed=changed(off,on);System.out.println("SSR_WATER_DIFF "+changed);
check(changed>100,"SSR changes water receiver pixels: "+changed);
double redSignal=colourSignal(off,on);
server.runOnServer(s->{command(s,"gamemode creative @a");var player=s.getPlayerList().getPlayers().getFirst();player.getAbilities().flying=true;player.onUpdateAbilities();});
c.waitTicks(10);
c.runOnClient(m->m.options.setCameraType(net.minecraft.client.CameraType.THIRD_PERSON_BACK));c.waitTicks(20);
c.runOnClient(m->VanillaLight.setSsr(false));c.waitTicks(8);var f5Off=capture(c,"ssr146-f5-off");
c.runOnClient(m->VanillaLight.setSsr(true));frames(c);var f5On=capture(c,"ssr146-f5-on");
check(changed(f5Off,f5On)>100,"SSR remains visible around third-person player");
int torsoChange=0,torsoPixels=0;
for(int y=f5Off.height()*55/100;y<f5Off.height()*71/100;y++)for(int x=f5Off.width()*485/1000;x<f5Off.width()*515/1000;x++){
int index=y*f5Off.width()+x;torsoPixels++;if(f5Off.pixels()[index]!=f5On.pixels()[index])torsoChange++;
}
check(torsoChange<torsoPixels*.01,"SSR does not draw through the visible F5 torso: "+torsoChange+" / "+torsoPixels);
c.runOnClient(m->m.options.setCameraType(net.minecraft.client.CameraType.FIRST_PERSON));c.waitTicks(20);
server.runOnServer(s->command(s,"gamemode spectator @a"));c.waitTicks(10);
for(int distance:new int[]{16,64,128,256,32}){
c.runOnClient(m->{VanillaLight.setPbrDistance(distance);VanillaLight.setSsrDistance(256);});settle(c);frames(c);capture(c,"ssr146-distance-"+distance);
c.runOnClient(m->check(ProceduralPbr.applied()&&PixelReflections.applied(),"Independent material distances render at PBR "+distance+" / SSR 256"));
}
for(int distance:new int[]{16,64,256}){
c.runOnClient(m->{VanillaLight.setPbrDistance(256);VanillaLight.setSsrDistance(distance);});settle(c);frames(c);
capture(c,"ssr149-independent-"+distance);
c.runOnClient(m->check(ProceduralPbr.applied()&&PixelReflections.applied(),"PBR 256 remains active with independent SSR "+distance));
}
c.runOnClient(m->VanillaLight.setPbrDistance(32));
c.runOnClient(m->VanillaLight.setSsrDistance(32));
c.runOnClient(m->{VanillaLight.setPbrIntensity(50);VanillaLight.setSsrIntensity(20);});
camera(c,server,.5,68,10,70);settle(c);frames(c);
c.runOnClient(m->VanillaLight.setPbr(false));c.waitTicks(8);var solarOff=capture(c,"ssr148-solar-water-off");
c.runOnClient(m->VanillaLight.setPbr(true));frames(c);
var solar=capture(c,"ssr146-solar-water");
int white=0;for(int pixel:solar.pixels())if((pixel>>16&255)>235&&(pixel>>8&255)>235&&(pixel&255)>235)white++;
int brightened=0;for(int i=0;i<solar.pixels().length;i++){
int a=solarOff.pixels()[i],b=solar.pixels()[i];
if((b>>16&255)+(b>>8&255)+(b&255)>(a>>16&255)+(a>>8&255)+(a&255)+24)brightened++;
}
check(brightened>5000,"Soft solar reflection remains broadly visible: "+brightened);
check(white<solar.pixels().length*.005,"Soft solar reflection preserves texture instead of a white plateau: "+white);
System.out.println("PBR148_SOLAR brightened="+brightened+" white="+white);
System.out.println("SSR146_SOLAR_WHITE pixels="+white+" width="+solar.width()+" height="+solar.height());
c.runOnClient(m->VanillaLight.setBloom(true));frames(c);capture(c,"ssr146-solar-water-bloom");
c.runOnClient(m->check(MaterialBloom.contribution()!=null,"Material light reaches bloom"));
c.runOnClient(m->VanillaLight.setBloom(false));frames(c);
c.runOnClient(m->check(MaterialBloom.contribution()==null,"Bloom OFF releases material halo"));
server.runOnServer(s->command(s,"time set 18000"));c.waitTicks(15);
c.runOnClient(m->VanillaLight.setSsr(false));c.waitTicks(8);
var moon=capture(c,"ssr147-moon-water");
int moonWhite=0;for(int pixel:moon.pixels())if((pixel>>16&255)>235&&(pixel>>8&255)>235&&(pixel&255)>235)moonWhite++;
check(moonWhite<Math.max(10,white*.05),"Moon reflection stays much softer than the sun: "+moonWhite+" / "+white);
c.runOnClient(m->VanillaLight.setPbr(false));c.waitTicks(8);var moonOff=capture(c,"ssr147-moon-water-off");
check(changed(moonOff,moon)>100,"Soft moon reflection remains visible");
System.out.println("PBR147_MOON white="+moonWhite+" sunWhite="+white+" changed="+changed(moonOff,moon));
c.runOnClient(m->{VanillaLight.setPbr(true);VanillaLight.setSsr(true);VanillaLight.setBloom(true);});frames(c);capture(c,"ssr147-moon-water-bloom");
c.runOnClient(m->VanillaLight.setBloom(false));
server.runOnServer(s->command(s,"time set 1000"));c.waitTicks(10);
var sunLook=c.computeOnClient(m->{var sun=PixelShadows.sunDirection(m.gameRenderer.gameRenderState().levelRenderState.skyRenderState.sunAngle);return new float[]{(float)Math.toDegrees(Math.atan2(-sun.x,sun.z)),(float)Math.toDegrees(Math.asin(sun.y))};});
look(c,server,sunLook[0],sunLook[1]);frames(c);capture(c,"ssr146-solar-path-low-sun");
c.runOnClient(m->VanillaLight.setBloom(true));frames(c);capture(c,"ssr146-solar-path-low-sun-bloom");
for(int time:new int[]{2000,11500,12400}){
c.runOnClient(m->{VanillaLight.setBloom(false);VanillaLight.setSsr(false);});
server.runOnServer(s->command(s,"time set "+time));c.waitTicks(15);
var solarLook=c.computeOnClient(m->{var sun=PixelShadows.sunDirection(m.gameRenderer.gameRenderState().levelRenderState.skyRenderState.sunAngle);return new float[]{(float)Math.toDegrees(Math.atan2(-sun.x,sun.z)),(float)Math.toDegrees(Math.asin(sun.y))};});
look(c,server,solarLook[0],solarLook[1]);pbrFrames(c);
var warm=capture(c,"ssr150-solar-"+time);
c.runOnClient(m->VanillaLight.setPbr(false));c.waitTicks(8);var nativeWater=capture(c,"ssr150-solar-native-"+time);
long red=0,green=0,blue=0;int samples=0;
for(int y=warm.height()/3;y<warm.height()*9/10;y++)for(int x=warm.width()/3;x<warm.width()*2/3;x++){
int i=y*warm.width()+x,a=nativeWater.pixels()[i],b=warm.pixels()[i];
int dr=(b>>16&255)-(a>>16&255),dg=(b>>8&255)-(a>>8&255),db=(b&255)-(a&255);
if(dr>3){red+=dr;green+=dg;blue+=db;samples++;}
}
System.out.println("PBR150_SOLAR_COLOUR time="+time+" pitch="+solarLook[1]+" samples="+samples+" red="+red+" green="+green+" blue="+blue);
var tint=c.computeOnClient(m->SolarColour.tint(m.gameRenderer.gameRenderState().levelRenderState.skyRenderState));
float nativeFade=c.computeOnClient(m->m.gameRenderer.gameRenderState().levelRenderState.skyRenderState.sunriseAndSunsetColor.w());
System.out.println("PBR150_NATIVE_SUNSET time="+time+" fade="+nativeFade+" tint="+tint);
check(samples>500,"Solar reflection remains visible: "+time);
if(nativeFade>.1)check(red>green*1.1&&red>blue*1.1,"Reflection follows warm native horizon colour: "+time);
if(nativeFade==0)check(tint.equals(new org.joml.Vector3f(1)),"No early tint before native sunset");
c.runOnClient(m->{VanillaLight.setPbr(true);VanillaLight.setSsr(true);VanillaLight.setBloom(true);});frames(c);capture(c,"ssr150-solar-bloom-"+time);
c.runOnClient(m->VanillaLight.setBloom(false));
look(c,server,solarLook[0],-solarLook[1]);frames(c);var sunDisc=capture(c,"ssr150-sun-disc-"+time);
long sr=0,sg=0,sb=0;int sunSamples=0;
for(int y=sunDisc.height()/2-5;y<sunDisc.height()/2+5;y++)for(int x=sunDisc.width()/2-5;x<sunDisc.width()/2+5;x++){
int pixel=sunDisc.pixels()[y*sunDisc.width()+x];sr+=pixel>>16&255;sg+=pixel>>8&255;sb+=pixel&255;sunSamples++;
}
System.out.println("PBR150_SUN_DISC time="+time+" red="+sr/sunSamples+" green="+sg/sunSamples+" blue="+sb/sunSamples);
if(nativeFade>.1)check(sr>sb*1.05,"Sun disc follows native warm tint: "+time);
look(c,server,solarLook[0],solarLook[1]);
}
c.runOnClient(m->{VanillaLight.setBloom(false);VanillaLight.setSsrIntensity(100);});
server.runOnServer(s->command(s,"time set 6000"));c.waitTicks(10);
camera(c,server,.5,68,0,70);look(c,server,0,12);settle(c);
server.runOnServer(s->{for(int x=-12;x<=12;x++)for(int y=65;y<=77-Math.abs(x)/2;y++)s.overworld().setBlockAndUpdate(new BlockPos(x,y,19),Blocks.CONCRETE.blue().defaultBlockState());});
settle(c);c.runOnClient(m->VanillaLight.setSsr(false));c.waitTicks(8);var blueOff=capture(c,"ssr-blue-off");
c.runOnClient(m->VanillaLight.setSsr(true));frames(c);var blueOn=capture(c,"ssr-blue-on");double blueSignal=colourSignal(blueOff,blueOn);
@@ -82,6 +173,13 @@ final class PixelReflectionsClientChecks {
check(changed(metalOff,metalOn)>100,"Solid PBR reflects landscape");
look(c,server,.00002f,12.00002f);frames(c);var tiny=capture(c,"ssr-metal-tiny-motion");
check(stableMetal(metalOn,tiny),"Tiny camera movement keeps material texels stable");look(c,server,0,12);frames(c);
server.runOnServer(s->{
command(s,"fill -7 67 9 7 70 9 iron_block");
for(int x=-6;x<=6;x+=2)command(s,"setblock "+x+" 67 8 polished_andesite_stairs[facing=south]");
});settle(c);frames(c);var intersections=capture(c,"ssr146-intersections");
look(c,server,.00002f,12.00002f);frames(c);var shifted=capture(c,"ssr146-intersections-tiny-motion");
check(stableIntersections(intersections,shifted),"Block intersections remain stable during subpixel motion");
look(c,server,0,12);frames(c);
c.runOnClient(m->{VanillaLight.setPixelShadows(true);VanillaLight.setSsgi(true);VanillaLight.setColoredLights(true);VanillaLight.setBloom(true);VanillaLight.setSunshafts(true);});
frames(c);capture(c,"ssr-combined");
server.runOnServer(s->command(s,"time set 18000"));c.waitTicks(15);frames(c);capture(c,"ssr-moon");
@@ -112,6 +210,16 @@ final class PixelReflectionsClientChecks {
c.runOnClient(m->VanillaLight.setPbr(false));c.waitTicks(8);c.runOnClient(m->check(!PixelReflections.allocated(),"PBR OFF releases reflection resources"));
System.out.println("SSR_PASS water; transparent glass; solids; OFF/zero; motion; reload; resize");
}
private static boolean stableIntersections(Frame a,Frame b){
// The surrounding animated water is not a stability oracle for static blocks.
int changed=0,count=0;
for(int y=a.height()*30/100;y<a.height()*80/100;y++)for(int x=a.width()/4;x<a.width()*3/4;x++){
int i=y*a.width()+x,aa=a.pixels()[i],bb=b.pixels()[i];count++;
if(Math.abs((aa>>16&255)-(bb>>16&255))+Math.abs((aa>>8&255)-(bb>>8&255))+Math.abs((aa&255)-(bb&255))>12)changed++;
}
System.out.println("SSR146_INTERSECTIONS changed="+changed+" samples="+count);
return changed<count*.001;
}
private static boolean stableMetal(Frame a,Frame b){int changes=0,count=0;
for(int y=a.height()*58/100;y<a.height()*68/100;y++)for(int x=a.width()*3/10;x<a.width()*7/10;x++){
int i=y*a.width()+x,aa=a.pixels()[i],bb=b.pixels()[i];count++;
@@ -151,6 +259,7 @@ final class PixelReflectionsClientChecks {
int i=y*a.width()+x,aa=a.pixels()[i],bb=b.pixels()[i];
if(Math.abs((aa>>16&255)-(bb>>16&255))+Math.abs((aa>>8&255)-(bb>>8&255))+Math.abs((aa&255)-(bb&255))>8)n++;
}return n;}
private static void pbrFrames(ClientGameTestContext c){int start=c.computeOnClient(m->ProceduralPbr.renderedFrames());c.waitFor(m->ProceduralPbr.applied()&&ProceduralPbr.renderedFrames()>start+8,1200);}
private static void frames(ClientGameTestContext c){int start=c.computeOnClient(m->PixelReflections.frames());c.waitFor(m->PixelReflections.applied()&&ProceduralPbr.ready()&&PixelReflections.frames()>start+8,1200);}
private static void settle(ClientGameTestContext c){c.waitTicks(45);c.waitFor(m->m.levelRenderer.hasRenderedAllSections()&&ProceduralPbr.ready(),1200);c.waitTicks(10);}
}
@@ -454,7 +454,7 @@ public final class PixelShadows122ClientChecks implements FabricClientGameTest {
var path=FabricLoader.getInstance().getConfigDir().resolve("sanctuary-shaders.json");
Files.deleteIfExists(path);forgetPreferences();
check(VanillaLight.bloom()&&VanillaLight.bloomIntensity()==20&&VanillaLight.pbr()&&VanillaLight.ssgi(),"Fresh defaults: bloom20, PBR and SSGI ON");
check(VanillaLight.pbrIntensity()==80&&VanillaLight.ssgiIntensity()==35,"PBR default 80, SSGI strength retained");
check(VanillaLight.pbrIntensity()==50&&VanillaLight.ssrIntensity()==20&&VanillaLight.ssgiIntensity()==35,"PBR 50 and SSR 20 defaults, SSGI strength retained");
Files.writeString(path,"{\"pbr\":false,\"ssgi\":false,\"bloomIntensity\":73}");forgetPreferences();
check(!VanillaLight.pbr()&&!VanillaLight.ssgi()&&VanillaLight.bloomIntensity()==73,"Explicit personal toggles and intensity survive changed defaults");
Files.writeString(path,"{\"bloom\":false}");forgetPreferences();
@@ -11,7 +11,7 @@ import java.util.*;
final class Water144ClientChecks {
static void run(ClientGameTestContext c,TestServerContext server){
c.runOnClient(m->{
VanillaLight.setEnabled(true);VanillaLight.setNaturalWater(true);VanillaLight.setWaterIntensity(100);
VanillaLight.setEnabled(true);VanillaLight.setNaturalWater(true);VanillaLight.setWaterIntensity(100);VanillaLight.setWaterBlendRadius(0);
VanillaLight.setPbr(false);VanillaLight.setSsgi(false);VanillaLight.setBloom(false);VanillaLight.setOreEmission(false);
VanillaLight.setPixelShadows(false);VanillaLight.setColoredLights(false);VanillaLight.setSunshafts(false);VanillaLight.setLensFlare(false);VanillaLight.setEdgeHighlights(false);
});
@@ -41,6 +41,30 @@ final class Water144ClientChecks {
check(NaturalWater.sample(m.level,88.5,110.1,8.5).equals(NaturalWater.CLEAR),"No bed in bounded search uses clear");
var boundary=NaturalWater.sample(m.level,80,99.1,8.5);check(boundary.tint()>.1&&boundary.tint()<.85,"Section boundary mixes profiles");
});
c.runOnClient(m->check(!NaturalWater.sanctuaryWorld(),"Server identifies ordinary test dimension"));
server.runOnServer(s->net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.send(s.getPlayerList().getPlayers().getFirst(),new fr.koka.sanctuary.water.WaterWorldSettings.Context(true)));
c.waitTicks(5);c.runOnClient(m->{check(NaturalWater.sanctuaryWorld()&&VanillaLight.naturalWater(),"Sanctuary context defaults ON");VanillaLight.setNaturalWater(false);});
server.runOnServer(s->net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.send(s.getPlayerList().getPlayers().getFirst(),new fr.koka.sanctuary.water.WaterWorldSettings.Context(false)));
c.waitTicks(5);c.runOnClient(m->check(VanillaLight.naturalWater(),"Ordinary explicit ON is independent of Sanctuary OFF"));
server.runOnServer(s->net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.send(s.getPlayerList().getPlayers().getFirst(),new fr.koka.sanctuary.water.WaterWorldSettings.Context(true)));
c.waitTicks(5);c.runOnClient(m->{check(!VanillaLight.naturalWater(),"Sanctuary explicit OFF survives context round trip");VanillaLight.setNaturalWater(true);});
server.runOnServer(s->net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.send(s.getPlayerList().getPlayers().getFirst(),new fr.koka.sanctuary.water.WaterWorldSettings.Context(false)));
c.waitTicks(5);
for(int radius:new int[]{2,4,8}){
c.runOnClient(m->VanillaLight.setWaterBlendRadius(radius));settle(c);
c.runOnClient(m->{
var left=NaturalWater.sample(m.level,79.5,99.1,8.5);
var right=NaturalWater.sample(m.level,80.5,99.1,8.5);
check(left.tint()>.1&&right.tint()<.85&&right.tint()>left.tint(),"Wider transition smooths both sides of section seam");
var west=new NaturalWater.Region(m.level,3,5,-1).corner(m.level,new BlockPos(79,99,8),1,0);
var east=new NaturalWater.Region(m.level,4,5,-1).corner(m.level,new BlockPos(80,99,8),0,0);
var expected=NaturalWater.sample(m.level,80,99,8);
check(Math.abs(west.tint()-east.tint())<.0002&&Math.abs(west.alpha()-east.alpha())<.0002,"Adjacent compiled sections share continuous vertex tint and alpha");
check(Math.abs(west.tint()-expected.tint())<.0002&&Math.abs(west.alpha()-expected.alpha())<.0002,"Compiled surface blend matches immersion sampling");
});
capture(c,"blend146-"+(radius*2+1));
}
c.runOnClient(m->VanillaLight.setWaterBlendRadius(0));settle(c);
enable(c,false);var off=capture(c,"surface-off");enable(c,true);var on=capture(c,"surface-on");
check(difference(off,on)>100000,"Visible surface colour and opacity change");
c.runOnClient(m->VanillaLight.setWaterIntensity(0));settle(c);var zero=capture(c,"surface-zero");
@@ -71,6 +71,7 @@ public final class SanctuaryMod implements ModInitializer {
fr.koka.sanctuary.notifications.DiscoveryNotifications.register();
fr.koka.sanctuary.realtime.RealtimeService.register();
fr.koka.sanctuary.weather.WeatherService.register();
fr.koka.sanctuary.water.WaterWorldSettings.register();
fr.koka.sanctuary.plans.PlanService.register();
fr.koka.sanctuary.plans.Statuary.register();
fr.koka.sanctuary.food.FoodSync.register();
@@ -42,8 +42,9 @@ public final class Bloom {
var builder=RenderPipeline.builder().withLocation(id("pipeline/"+name)).withVertexShader("core/screenquad").withFragmentShader(id("core/"+name)).withBindGroupLayout(layout.build());
if(scene)builder.withBindGroupLayout(SCENE);
return RenderPipelines.register(builder.withPrimitiveTopology(PrimitiveTopology.TRIANGLES).withCull(false)
.withColorTargetState(new ColorTargetState(Optional.ofNullable(blend),name.equals("bloom_blur")||name.equals("bloom_downsample")||name.equals("lens_flare_source")?GpuFormat.RGBA16_FLOAT:GpuFormat.RGBA8_UNORM,blend==null?ColorTargetState.WRITE_ALL:ColorTargetState.WRITE_COLOR)).withDepthStencilState(Optional.empty()).build());
.withColorTargetState(new ColorTargetState(Optional.ofNullable(blend),name.equals("bloom_material_add")||name.equals("bloom_blur")||name.equals("bloom_downsample")||name.equals("lens_flare_source")?GpuFormat.RGBA16_FLOAT:GpuFormat.RGBA8_UNORM,blend==null?ColorTargetState.WRITE_ALL:ColorTargetState.WRITE_COLOR)).withDepthStencilState(Optional.empty()).build());
}
private static final RenderPipeline MATERIAL=screen("bloom_material_add",new BlendFunction(BlendFactor.ONE,BlendFactor.ONE,BlendFactor.ZERO,BlendFactor.ONE),false,false);
private static final RenderPipeline SKY=screen("bloom_sky",null,true,false);
private static final RenderPipeline DOWNSAMPLE=screen("bloom_downsample",null,false,false);
private static final RenderPipeline BLUR=screen("bloom_blur",null,false,true);
@@ -121,6 +122,7 @@ public final class Bloom {
}
if(halo){
screen(DOWNSAMPLE,small.getColorTextureView(),emission.getColorTextureView(),false,null);
if(MaterialBloom.contribution()!=null)screen(MATERIAL,small.getColorTextureView(),MaterialBloom.contribution(),false,null);
screen(BLUR,ping.getColorTextureView(),small.getColorTextureView(),false,horizontal);
screen(BLUR,small.getColorTextureView(),ping.getColorTextureView(),false,vertical);
}
@@ -0,0 +1,42 @@
package fr.koka.sanctuary.client.shader;
import com.mojang.blaze3d.pipeline.TextureTarget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.renderpearl.api.GpuFormat;
import com.mojang.renderpearl.api.pipeline.*;
import com.mojang.renderpearl.api.textures.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.resources.Identifier;
import org.joml.Vector4f;
import java.util.Optional;
/** Extract only the positive contribution of each material pass, before other effects. */
final class MaterialBloom {
private static final RenderPipeline EXTRACT=RenderPipelines.register(RenderPipeline.builder()
.withLocation(Identifier.parse("sanctuary:pipeline/material_bloom"))
.withVertexShader("core/screenquad").withFragmentShader(Identifier.parse("sanctuary:core/material_bloom"))
.withBindGroupLayout(BindGroupLayout.builder().withUniform("Before",UniformType.COMBINED_IMAGE_SAMPLER)
.withUniform("After",UniformType.COMBINED_IMAGE_SAMPLER).build())
.withPrimitiveTopology(PrimitiveTopology.TRIANGLES).withCull(false)
.withColorTargetState(new ColorTargetState(Optional.of(new BlendFunction(BlendFactor.ONE,BlendFactor.ONE,BlendFactor.ZERO,BlendFactor.ONE)),GpuFormat.RGBA16_FLOAT,ColorTargetState.WRITE_COLOR))
.withDepthStencilState(Optional.empty()).build());
private static TextureTarget contribution;
private static boolean ready;
private MaterialBloom(){}
static void beginFrame(){ready=false;if(!VanillaLight.bloom()||VanillaLight.bloomIntensity()==0)release();}
static void accumulate(GpuTextureView before){
if(!VanillaLight.bloom()||VanillaLight.bloomIntensity()==0)return;
var main=Minecraft.getInstance().gameRenderer.mainRenderTarget();
int w=Math.max(1,main.width/8),h=Math.max(1,main.height/8);
if(contribution==null||contribution.width!=w||contribution.height!=h){release();contribution=new TextureTarget("Sanctuary material glow",w,h,GpuFormat.RGBA16_FLOAT,null);}
try(var pass=RenderSystem.getDevice().createCommandEncoder().createRenderPass(()->"Sanctuary material glow",contribution.getColorTextureView(),ready?Optional.empty():Optional.of(new Vector4f()))){
pass.setPipeline(RenderSystem.getCompiledPipeline(EXTRACT));
var nearest=RenderSystem.getSamplerCache().getClampToEdge(FilterMode.NEAREST);
pass.setUniform("Before",before,nearest);pass.setUniform("After",main.getColorTextureView(),nearest);pass.draw(3,1,0,0);
}
ready=true;
}
static GpuTextureView contribution(){return ready?contribution.getColorTextureView():null;}
static void release(){if(contribution!=null){contribution.destroyBuffers();contribution=null;}ready=false;}
}
@@ -29,11 +29,18 @@ public final class NaturalWater {
private static volatile Map<Block,Integer> materials=Map.of();
private static volatile float strength;
private static ClientLevel previousLevel;
private static boolean sanctuaryWorld;
private static volatile int blendRadius=4;
public static boolean sanctuaryWorld(){return sanctuaryWorld;}
private static Profile fogFrom=CLEAR,fogTarget=CLEAR;
private static long fogChanged;
private static boolean wasUnderwater;
private NaturalWater(){}
public static void register(){
net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.registerGlobalReceiver(
fr.koka.sanctuary.water.WaterWorldSettings.Context.TYPE,(payload,context)->context.client().execute(()->sanctuaryWorld=payload.sanctuary()));
net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents.DISCONNECT.register((listener,client)->sanctuaryWorld=false);
net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationConnectionEvents.INIT.register((listener,client)->sanctuaryWorld=false);
ResourceLoader.get(PackType.CLIENT_RESOURCES).registerReloadListener(Identifier.parse("sanctuary:water_materials"),
(ResourceManagerReloadListener) manager->{
try(var reader=manager.getResourceOrThrow(Identifier.parse("sanctuary:water_materials.json")).openAsReader()){
@@ -48,7 +55,7 @@ public final class NaturalWater {
});
ClientTickEvents.END_CLIENT_TICK.register(client->{
float next=VanillaLight.active()&&VanillaLight.naturalWater()?VanillaLight.waterIntensity()/100f:0;
if(previousLevel!=client.level||strength!=next){previousLevel=client.level;strength=next;wasUnderwater=false;
if(previousLevel!=client.level||strength!=next||blendRadius!=VanillaLight.waterBlendRadius()){previousLevel=client.level;strength=next;blendRadius=VanillaLight.waterBlendRadius();wasUnderwater=false;
if(client.level!=null)invalidateWaterSections(client);}
if(client.level==null||next==0){wasUnderwater=false;return;}
var camera=client.gameRenderer.mainCamera();
@@ -103,10 +110,19 @@ public final class NaturalWater {
}
private static Profile live(ClientLevel l,int x,int y,int z){
var p=new BlockPos(x,y,z);if(!l.hasChunk(x>>4,z>>4)||ocean(l,p))return CLEAR;
return PROFILES[classify(l::getBlockState,p,materials)];
float tint=0,alpha=0,fog=0;int count=0;
for(int dz=-blendRadius;dz<=blendRadius;dz++)for(int dx=-blendRadius;dx<=blendRadius;dx++){
var q=p.offset(dx,0,dz);
Profile v=!l.hasChunk(q.getX()>>4,q.getZ()>>4)||ocean(l,q)?CLEAR:PROFILES[classify(l::getBlockState,q,materials)];
tint+=v.tint;alpha+=v.alpha;fog+=v.fog;count++;
}
return new Profile(tint/count,alpha/count,fog/count);
}
/** Owned by a single native section compilation, with ocean data captured before worker submission. */
public static final class Region {
private static final int PAD=9,SIDE=34;
private final int radius=blendRadius;
private final float[][][] sums=new float[16][][];
private final int ox,oy,oz;
private final net.minecraft.world.level.biome.BiomeManager biomes;
private byte[] oceanKinds;
@@ -117,30 +133,47 @@ public final class NaturalWater {
ox=(minX+1)*16;oy=(minY+1)*16;oz=(minZ+1)*16;
// Copy quart holders, then keep the native seeded biome zoom on the immutable copy.
// Sampling only quart centres would misclassify the jagged edges of ocean biomes.
var copied=new java.util.ArrayList<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>>(216);
int qx=(ox>>2)-1,qy=(oy>>2)-1,qz=(oz>>2)-1;
for(int y=0;y<6;y++)for(int z=0;z<6;z++)for(int x=0;x<6;x++)
var copied=new java.util.ArrayList<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>>(600);
int qx=(ox>>2)-3,qy=(oy>>2)-1,qz=(oz>>2)-3;
for(int y=0;y<6;y++)for(int z=0;z<10;z++)for(int x=0;x<10;x++)
copied.add(level.hasChunk((qx+x)>>2,(qz+z)>>2)?level.getBiomeManager().getNoiseBiomeAtQuart(qx+x,qy+y,qz+z):null);
biomes=level.getBiomeManager().withDifferentSource((x,y,z)->copied.get(((y-qy)*6+z-qz)*6+x-qx));
biomes=level.getBiomeManager().withDifferentSource((x,y,z)->copied.get(((y-qy)*10+z-qz)*10+x-qx));
}
public boolean ocean(int x,int y,int z){
if(oceanKinds==null)oceanKinds=new byte[18*16*18];
int key=((y-oy)*18+z-oz+1)*18+x-ox+1;
if(oceanKinds==null)oceanKinds=new byte[SIDE*16*SIDE];
int key=((y-oy)*SIDE+z-oz+PAD)*SIDE+x-ox+PAD;
int code=oceanKinds[key];if(code==0){var biome=biomes.getBiome(x,y,z);code=biome!=null&&biome.is(BiomeTags.IS_OCEAN)?2:1;oceanKinds[key]=(byte)code;}
return code==2;
}
private Profile profile(BlockAndTintGetter region,int x,int y,int z){
if(x<ox-1||x>ox+16||y<oy||y>oy+15||z<oz-1||z>oz+16)return CLEAR;
if(x<ox-PAD||x>=ox-PAD+SIDE||y<oy||y>oy+15||z<oz-PAD||z>=oz-PAD+SIDE)return CLEAR;
if(ocean(x,y,z))return CLEAR;
int key=((y-oy)*18+z-oz+1)*18+x-ox+1;
if(profiles==null)profiles=new byte[18*16*18];
int key=((y-oy)*SIDE+z-oz+PAD)*SIDE+x-ox+PAD;
if(profiles==null)profiles=new byte[SIDE*16*SIDE];
int code=profiles[key];if(code==0){code=1+classify(region::getBlockState,new BlockPos(x,y,z),table);profiles[key]=(byte)code;}
return PROFILES[code-1];
}
private Profile blended(BlockAndTintGetter region,int x,int y,int z){
if(radius==0)return profile(region,x,y,z);
int layer=y-oy,stride=SIDE+1;
if(sums[layer]==null){
var sum=new float[3][stride*stride];
for(int iz=0;iz<SIDE;iz++)for(int ix=0;ix<SIDE;ix++){
var p=profile(region,ox-PAD+ix,y,oz-PAD+iz);int at=(iz+1)*stride+ix+1;
float[] values={p.tint,p.alpha,p.fog};
for(int c=0;c<3;c++)sum[c][at]=values[c]+sum[c][at-1]+sum[c][at-stride]-sum[c][at-stride-1];
}
sums[layer]=sum;
}
int left=x-ox+PAD-radius,top=z-oz+PAD-radius,right=left+radius*2+1,bottom=top+radius*2+1;
float[] values=new float[3];float area=(radius*2+1)*(radius*2+1);
for(int c=0;c<3;c++){var a=sums[layer][c];values[c]=(a[bottom*stride+right]-a[top*stride+right]-a[bottom*stride+left]+a[top*stride+left])/area;}
return new Profile(values[0],values[1],values[2]);
}
public Profile corner(BlockAndTintGetter region,BlockPos p,int dx,int dz){
if(ocean(p.getX(),p.getY(),p.getZ()))return CLEAR;
int x=p.getX()+dx-1,y=p.getY(),z=p.getZ()+dz-1;
return profile(region,x,y,z).mix(profile(region,x+1,y,z),.5f).mix(profile(region,x,y,z+1).mix(profile(region,x+1,y,z+1),.5f),.5f);
return blended(region,x,y,z).mix(blended(region,x+1,y,z),.5f).mix(blended(region,x,y,z+1).mix(blended(region,x+1,y,z+1),.5f),.5f);
}
}
public interface RegionAccess { Region sanctuary$waterRegion(); }
@@ -158,7 +191,8 @@ public final class NaturalWater {
public static void dirty(BlockPos pos){
if(strength==0)return;
var renderer=Minecraft.getInstance().levelExtractor;
renderer.setSectionRangeDirty((pos.getX()-1)>>4,pos.getY()>>4,(pos.getZ()-1)>>4,
(pos.getX()+1)>>4,(pos.getY()+DEPTH)>>4,(pos.getZ()+1)>>4);
int margin=blendRadius+1;
renderer.setSectionRangeDirty((pos.getX()-margin)>>4,pos.getY()>>4,(pos.getZ()-margin)>>4,
(pos.getX()+margin)>>4,(pos.getY()+DEPTH)>>4,(pos.getZ()+margin)>>4);
}
}
@@ -32,6 +32,8 @@ final class PbrMaterials implements AutoCloseable {
if(name.equals("iron_block")||name.equals("gold_block")||name.equals("netherite_block")||name.contains("copper")&&!name.contains("ore")&&!name.contains("raw"))
return new Profile(name.contains("oxidized")?.65f:.32f,name.contains("oxidized")?.35f:.85f);
if(name.contains("polished")||name.contains("glazed")||name.equals("diamond_block")||name.equals("emerald_block")||name.equals("ruby_block")||name.equals("sapphire_block"))return new Profile(.42f,0);
// Dry soil keeps its normal relief without a broad white specular coating.
if(java.util.Set.of("dirt","coarse_dirt","rooted_dirt","grass_block","dirt_path","farmland","podzol","mycelium").contains(name))return new Profile(.98f,0);
if(name.contains("wool")||name.contains("leaves"))return new Profile(.98f,0);
if(name.contains("planks")||name.contains("log")||name.contains("wood"))return new Profile(.88f,0);
return new Profile(.82f,0);
@@ -48,7 +48,7 @@ final class PbrTerrain implements AutoCloseable {
long frame=mc.level.getGameTime();var active=new ArrayList<Section>();
for(var render:mc.levelRenderer.visibleSections()){
long key=render.getSectionNode();var pos=render.getRenderOrigin();
if(pos.offset(8,8,8).distToCenterSqr(camera)>48*48)continue;
if(pos.offset(8,8,8).distToCenterSqr(camera)>Math.pow(VanillaLight.materialDistance()+16,2))continue;
var chunk=mc.level.getChunkSource().getChunk(pos.getX()>>4,pos.getZ()>>4,ChunkStatus.FULL,false);
if(chunk==null)continue;
var storage=chunk.getSection(mc.level.getSectionIndex(pos.getY()));
@@ -60,7 +60,7 @@ public final class PixelReflections {
&&mc.gameRenderer.gameRenderState().levelRenderState.cameraRenderState.fogType==FogType.NONE
&&mc.gameRenderer.gameRenderState().levelRenderState.skyRenderState.skybox==net.minecraft.world.level.dimension.DimensionType.Skybox.OVERWORLD;
}
public static void beginFrame(){captured=ready=applied=false;if(!eligible())release();}
public static void beginFrame(){MaterialBloom.beginFrame();captured=ready=applied=false;if(!eligible())release();}
/** Called only with the opaque render pass closed, on both native transparency paths. */
public static void captureOpaque(){
if(!eligible())return;
@@ -90,8 +90,8 @@ public final class PixelReflections {
if(uniform==null)uniform=new MappableRingBuffer(()->"Sanctuary reflection parameters",GpuBuffer.USAGE_UNIFORM|GpuBuffer.USAGE_MAP_WRITE,160);
uniform.rotate();try(var map=uniform.currentBuffer().map(false,true)){
Std140Builder.intoBuffer(map.data()).putMat4f(vp).putMat4f(new Matrix4f(vp).invert())
.putVec4(RenderSystem.getDevice().getDeviceInfo().isZZeroToOne()?1:0,VanillaLight.ssrIntensity()/100f,VanillaLight.pbrIntensity()/100f,32)
.putVec4(128,32,0,0);
.putVec4(RenderSystem.getDevice().getDeviceInfo().isZZeroToOne()?1:0,VanillaLight.ssrIntensity()/100f,VanillaLight.pbrIntensity()/100f,VanillaLight.ssrDistance())
.putVec4(Math.max(128,VanillaLight.ssrDistance()),32,VanillaLight.materialDistance(),0);
}
int max=java.util.stream.Stream.concat(solid.stream(),transparent.stream()).mapToInt(PbrTerrain.Entry::indices).max().orElse(0);
RenderSystem.getSequentialBuffer(PrimitiveTopology.QUADS).requestIndexCount(max);
@@ -111,7 +111,7 @@ public final class PixelReflections {
pass.setUniform("OpaqueDepth",opaqueDepthView,nearest);
pass.setUniform("OpaqueColor",opaqueColorView!=null?opaqueColorView:scene,nearest);
// Never bind the receiver as a sampled texture while it is attached for depth writes.
pass.setUniform("ReceiverDepth",opaqueDepthView,nearest);
pass.setUniform("ReceiverDepth",reflection?Minecraft.getInstance().gameRenderer.mainRenderTarget().getDepthTextureView():opaqueDepthView,nearest);
pass.setUniform("SceneColor",scene,nearest);
pass.setUniform("BlockAtlas",Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS).getTextureView(),nearest);
}
@@ -135,6 +135,7 @@ public final class PixelReflections {
pass.setPipeline(RenderSystem.getCompiledPipeline(REFLECT));bind(pass,scene,true);
draw(pass,solid,solidAtlas);draw(pass,transparent,transparentAtlas);
}
MaterialBloom.accumulate(scene);
applied=true;frames++;
}
public static void release(){
@@ -33,9 +33,9 @@ public final class ProceduralPbr {
private static final RenderPipeline PIPELINE=RenderPipelines.register(RenderPipeline.builder()
.withLocation(Identifier.parse("sanctuary:pipeline/pbr")).withVertexShader(Identifier.parse("sanctuary:core/pbr"))
.withFragmentShader(Identifier.parse("sanctuary:core/pbr")).withBindGroupLayout(BindGroupLayouts.DYNAMIC_TRANSFORMS).withBindGroupLayout(SCENE)
.withVertexBinding(0,PbrTerrain.FORMAT).withPrimitiveTopology(PrimitiveTopology.QUADS).withCull(false)
.withVertexBinding(0,PbrTerrain.FORMAT).withPrimitiveTopology(PrimitiveTopology.QUADS).withCull(true)
.withColorTargetState(new ColorTargetState(Optional.empty(),GpuFormat.RGBA8_UNORM,ColorTargetState.WRITE_COLOR))
.withDepthStencilState(Optional.empty()).build());
.withDepthStencilState(new DepthStencilState(CompareOp.EQUAL,false)).build());
private static final PbrTerrain TERRAIN=new PbrTerrain();
private static final PbrTerrain TRANSPARENT=new PbrTerrain(true);
private static final Matrix4f projection=new Matrix4f();
@@ -61,17 +61,21 @@ public final class ProceduralPbr {
var entries=new ArrayList<PbrTerrain.Entry>(solidEntries);entries.addAll(transparentEntries);
var vp=new Matrix4f(projection).mul(camera.viewRotationMatrix);var fog=camera.fogData;
PixelReflections.prepare(vp,solidEntries,atlas,transparentEntries,transparentAtlas);
if(PixelReflections.depth()==null)return;
var sun=PixelShadows.sunDirection(sky.sunAngle);boolean lunar=sun.y<=.08f;
if(lunar)sun=PixelShadows.sunDirection(sky.moonAngle);
float moon=sky.moonPhase==null?1:(float)(.5+.5*Math.cos(sky.moonPhase.index()*Math.PI/4));
float strength=(lunar?.12f*moon:1)*sky.rainBrightness*Math.clamp((sun.y-.04f)/.16f,0,1);
var sunColour=lunar?new org.joml.Vector3f(1):SolarColour.tint(sky);
boolean shadow=PixelShadows.applied();
scene.rotate();try(var mapped=scene.currentBuffer().map(false,true)){
Std140Builder.intoBuffer(mapped.data()).putMat4f(new Matrix4f(vp).invert())
.putVec4(sun.x,sun.y,sun.z,strength)
.putVec4(VanillaLight.pbrIntensity()/100f,RenderSystem.getDevice().getDeviceInfo().isZZeroToOne()?1:0,shadow?1:0,32)
.putVec4(fog.renderDistanceStart,fog.renderDistanceEnd,fog.environmentalStart,fog.environmentalEnd).putVec4(fog.color.w,ColoredLights.directionalReady()?1:0,0,0)
.putVec4(0,0,0,0).putVec4(0,0,0,0).putVec4(0,0,0,0).putVec4(0,0,0,0);
.putVec4(VanillaLight.pbrIntensity()/100f,RenderSystem.getDevice().getDeviceInfo().isZZeroToOne()?1:0,shadow?1:0,VanillaLight.pbrDistance())
.putVec4(fog.renderDistanceStart,fog.renderDistanceEnd,fog.environmentalStart,fog.environmentalEnd).putVec4(fog.color.w,ColoredLights.directionalReady()?1:0,lunar?0:1,0)
.putVec4(sunColour.x*sunColour.x,sunColour.y*sunColour.y,sunColour.z*sunColour.z,1)
.putVec4((float)(camera.pos.x%256),(float)(camera.pos.y%256),(float)(camera.pos.z%256),0)
.putVec4(0,0,0,0).putVec4(0,0,0,0);
}
var transforms=new ArrayList<GpuBufferSlice>(entries.size());int max=0;
for(var entry:entries){var p=entry.origin();var offset=new Vector3f((float)(p.getX()-camera.pos.x),(float)(p.getY()-camera.pos.y),(float)(p.getZ()-camera.pos.z));
@@ -80,11 +84,11 @@ public final class ProceduralPbr {
var encoder=RenderSystem.getDevice().createCommandEncoder();
encoder.copyTextureToTexture(main.getColorTexture(),source.getColorTexture(),0,0,0,0,0,main.width,main.height);
var nearest=RenderSystem.getSamplerCache().getClampToEdge(FilterMode.NEAREST);
if((atlas!=null||transparentAtlas!=null)&&!entries.isEmpty())try(var pass=encoder.createRenderPass(()->"Sanctuary PBR materials",main.getColorTextureView(),Optional.empty())){
if((atlas!=null||transparentAtlas!=null)&&!entries.isEmpty())try(var pass=encoder.createRenderPass(()->"Sanctuary PBR materials",main.getColorTextureView(),Optional.empty(),PixelReflections.depth(),OptionalDouble.empty())){
pass.setPipeline(RenderSystem.getCompiledPipeline(PIPELINE));pass.setUniform("PbrScene",scene.currentBuffer());
pass.setUniform("PixelShadows",shadow?PixelShadows.materialUniforms():scene.currentBuffer());
pass.setUniform("SunDepth",shadow?PixelShadows.materialDepth():main.getDepthTextureView(),nearest);
pass.setUniform("WorldDepth",PixelReflections.depth()!=null?PixelReflections.depth():main.getDepthTextureView(),nearest);pass.setUniform("SceneColor",source.getColorTextureView(),nearest);
pass.setUniform("WorldDepth",main.getDepthTextureView(),nearest);pass.setUniform("SceneColor",source.getColorTextureView(),nearest);
pass.setUniform("BlockAtlas",mc.getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS).getTextureView(),nearest);
pass.setUniform("MaterialAtlas",(atlas!=null?atlas:transparentAtlas).getTextureView(),nearest);
if(ColoredLights.directionalReady())ColoredLights.bindDirections(pass);
@@ -93,6 +97,7 @@ public final class ProceduralPbr {
for(int i=0;i<entries.size();i++){var entry=entries.get(i);
pass.setUniform("MaterialAtlas",(i<solidEntries.size()?atlas:transparentAtlas).getTextureView(),nearest);pass.setUniform("DynamicTransforms",transforms.get(i));pass.setVertexBuffer(0,entry.vertices().slice());pass.drawIndexed(entry.indices(),1,0,0,0);}
}
MaterialBloom.accumulate(source.getColorTextureView());
applied=true;frames++;
}
static com.mojang.renderpearl.api.textures.GpuTextureView copyScene(){
@@ -100,7 +105,7 @@ public final class ProceduralPbr {
RenderSystem.getDevice().createCommandEncoder().copyTextureToTexture(main.getColorTexture(),source.getColorTexture(),0,0,0,0,0,main.width,main.height);
return source.getColorTextureView();
}
public static void release(){TERRAIN.close();TRANSPARENT.close();PixelReflections.release();if(source!=null){source.destroyBuffers();source=null;}if(scene!=null){scene.close();scene=null;}applied=false;}
public static void release(){MaterialBloom.release();TERRAIN.close();TRANSPARENT.close();PixelReflections.release();if(source!=null){source.destroyBuffers();source=null;}if(scene!=null){scene.close();scene=null;}applied=false;}
static long solidBytes(){return TERRAIN.allocatedBytes();}
static long transparentBytes(){return TRANSPARENT.allocatedBytes();}
static int waterUpdates(){return TRANSPARENT.materials.animationUpdates();}
@@ -17,6 +17,9 @@ public final class ShaderOptionsScreen extends OptionsSubScreen {
list.addBig(OptionInstance.createBoolean("sanctuary.shaders.natural_water",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.natural_water_help")),VanillaLight.naturalWater(),VanillaLight::setNaturalWater));
slider("water_intensity",VanillaLight.waterIntensity(),VanillaLight::setWaterIntensity);
list.addBig(new OptionInstance<Integer>("sanctuary.shaders.water_blend",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.water_blend_help")),(caption,value)->Component.translatable("sanctuary.shaders.water_blend_value",value*2+1,value*2+1),
new OptionInstance.Enum<>(List.of(0,1,2,4,8),Codec.INT),VanillaLight.waterBlendRadius(),VanillaLight::setWaterBlendRadius));
list.addBig(new OptionInstance<Integer>("sanctuary.shaders.saturation",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.saturation_help")),(caption,value)->Component.translatable("sanctuary.shaders.saturation_value",value),
new OptionInstance.IntRange(0,200),VanillaLight.saturation(),VanillaLight::setSaturation));
@@ -26,9 +29,15 @@ public final class ShaderOptionsScreen extends OptionsSubScreen {
list.addBig(OptionInstance.createBoolean("sanctuary.shaders.pbr",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.pbr_help")),VanillaLight.pbr(),VanillaLight::setPbr));
slider("pbr_intensity",VanillaLight.pbrIntensity(),VanillaLight::setPbrIntensity);
list.addBig(new OptionInstance<Integer>("sanctuary.shaders.pbr_distance",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.pbr_distance_help")),(caption,value)->Component.translatable("sanctuary.shaders.pbr_distance_value",value),
new OptionInstance.Enum<>(List.of(16,32,64,128,256),Codec.INT),VanillaLight.pbrDistance(),VanillaLight::setPbrDistance));
list.addBig(OptionInstance.createBoolean("sanctuary.shaders.ssr",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.ssr_help")),VanillaLight.ssr(),VanillaLight::setSsr));
slider("ssr_intensity",VanillaLight.ssrIntensity(),VanillaLight::setSsrIntensity);
list.addBig(new OptionInstance<Integer>("sanctuary.shaders.ssr_distance",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.ssr_distance_help")),(caption,value)->Component.translatable("sanctuary.shaders.ssr_distance_value",value),
new OptionInstance.Enum<>(List.of(16,32,64,128,256),Codec.INT),VanillaLight.ssrDistance(),VanillaLight::setSsrDistance));
list.addBig(OptionInstance.createBoolean("sanctuary.shaders.colored_lights",OptionInstance.cachedConstantTooltip(
Component.translatable("sanctuary.shaders.colored_lights_help")),VanillaLight.coloredLights(),VanillaLight::setColoredLights));
list.addBig(OptionInstance.createBoolean("sanctuary.shaders.warm_torches",OptionInstance.cachedConstantTooltip(
@@ -0,0 +1,15 @@
package fr.koka.sanctuary.client.shader;
import net.minecraft.client.renderer.state.level.SkyRenderState;
import org.joml.Vector3f;
/** Uses the exact colour and fade already extracted for Minecraft's horizon. */
public final class SolarColour {
private SolarColour(){}
public static Vector3f tint(SkyRenderState sky){
var colour=sky.sunriseAndSunsetColor;
if(colour==null)return new Vector3f(1);
float weight=Math.clamp(colour.w(),0,1);
return new Vector3f(1).lerp(new Vector3f(colour.x(),colour.y(),colour.z()),weight);
}
}
@@ -16,7 +16,10 @@ public final class VanillaLight {
private VanillaLight() { }
private static final class Preferences {
boolean enabled=true;
boolean naturalWater=true;
Boolean naturalWater; // Legacy OFF is an explicit opt-out in both world types.
Boolean sanctuaryNaturalWater;
Boolean ordinaryNaturalWater;
int waterBlendRadius=4;
int waterIntensity=100;
int saturation=142;
boolean pixelShadows=true;
@@ -26,9 +29,13 @@ public final class VanillaLight {
boolean lensFlare=true;
int lensFlareIntensity=30;
boolean pbr=true;
int pbrIntensity=80;
int pbrIntensity=50;
int pbrBalanceVersion;
int pbrDistance=64;
int ssrDistance=64;
int reflectionDistanceVersion;
boolean ssr=false;
int ssrIntensity=50;
int ssrIntensity=20;
boolean ssgi=true;
boolean coloredLights=true;
boolean warmTorches=false;
@@ -51,9 +58,21 @@ public final class VanillaLight {
try{if(Files.isRegularFile(path()))preferences=new GsonBuilder().create().fromJson(Files.readString(path()),Preferences.class);}
catch(Exception e){SanctuaryMod.LOGGER.warn("Cannot read Sanctuary shader preference",e);}
if(preferences==null)preferences=new Preferences();
if(Boolean.FALSE.equals(preferences.naturalWater)){
if(preferences.sanctuaryNaturalWater==null)preferences.sanctuaryNaturalWater=false;
if(preferences.ordinaryNaturalWater==null)preferences.ordinaryNaturalWater=false;
}
preferences.naturalWater=null;
preferences.sunshaftIntensity=Math.clamp(preferences.sunshaftIntensity,0,100);
preferences.lensFlareIntensity=Math.clamp(preferences.lensFlareIntensity,0,100);
preferences.ssrIntensity=Math.clamp(preferences.ssrIntensity,0,100);
if(preferences.reflectionDistanceVersion<1&&preferences.pbrDistance==32)preferences.pbrDistance=64;
preferences.reflectionDistanceVersion=1;
preferences.pbrDistance=normalizePbrDistance(preferences.pbrDistance);
preferences.ssrDistance=normalizePbrDistance(preferences.ssrDistance);
// Migrate the previous 80% baseline once; later explicit 80% choices persist.
if(preferences.pbrBalanceVersion<1&&preferences.pbrIntensity==80)preferences.pbrIntensity=50;
preferences.pbrBalanceVersion=1;
preferences.pbrIntensity=Math.clamp(preferences.pbrIntensity,0,100);
preferences.coloredLightIntensity=Math.clamp(preferences.coloredLightIntensity,0,100);
preferences.coloredLightDistance=normalizeColoredLightDistance(preferences.coloredLightDistance);
@@ -63,6 +82,7 @@ public final class VanillaLight {
preferences.oreIntensity=Math.clamp(preferences.oreIntensity,0,100);
preferences.edgeIntensity=Math.clamp(preferences.edgeIntensity,0,100);
preferences.edgeDistance=normalizeShadowDistance(preferences.edgeDistance);
preferences.waterBlendRadius=normalizeWaterBlendRadius(preferences.waterBlendRadius);
preferences.waterIntensity=Math.clamp(preferences.waterIntensity,0,100);
preferences.saturation=Math.clamp(preferences.saturation,0,200);
preferences.shadowPixels=normalizePrecision(preferences.shadowPixels);
@@ -72,9 +92,13 @@ public final class VanillaLight {
}
public static boolean externalEngine(){return EXTERNAL_ENGINE;}
public static boolean active(){return ProgressionClient.active()&&!EXTERNAL_ENGINE&&enabled();}
public static boolean naturalWater(){enabled();return preferences.naturalWater;}
public static boolean naturalWater(){return naturalWater(NaturalWater.sanctuaryWorld());}
static boolean naturalWater(boolean sanctuary){enabled();Boolean value=sanctuary?preferences.sanctuaryNaturalWater:preferences.ordinaryNaturalWater;return value!=null?value:sanctuary;}
public static int waterBlendRadius(){enabled();return preferences.waterBlendRadius;}
public static void setWaterBlendRadius(int value){enabled();preferences.waterBlendRadius=normalizeWaterBlendRadius(value);save();}
static int normalizeWaterBlendRadius(int value){return value<1?0:value<2?1:value<3?2:value<6?4:8;}
public static int waterIntensity(){enabled();return preferences.waterIntensity;}
public static void setNaturalWater(boolean value){enabled();preferences.naturalWater=value;save();}
public static void setNaturalWater(boolean value){enabled();if(NaturalWater.sanctuaryWorld())preferences.sanctuaryNaturalWater=value;else preferences.ordinaryNaturalWater=value;save();}
public static void setWaterIntensity(int value){enabled();preferences.waterIntensity=Math.clamp(value,0,100);save();}
public static int saturation(){enabled();return preferences.saturation;}
public static boolean edgeHighlights(){enabled();return preferences.edgeHighlights;}
@@ -95,6 +119,12 @@ public final class VanillaLight {
public static int ssrIntensity(){enabled();return preferences.ssrIntensity;}
public static void setSsr(boolean value){enabled();preferences.ssr=value;save();}
public static void setSsrIntensity(int value){enabled();preferences.ssrIntensity=Math.clamp(value,0,100);save();}
public static int ssrDistance(){enabled();return preferences.ssrDistance;}
public static void setSsrDistance(int value){enabled();preferences.ssrDistance=normalizePbrDistance(value);save();}
static int materialDistance(){return Math.max(pbrDistance(),ssr()&&ssrIntensity()>0?ssrDistance():0);}
public static int pbrDistance(){enabled();return preferences.pbrDistance;}
public static void setPbrDistance(int value){enabled();preferences.pbrDistance=normalizePbrDistance(value);save();}
static int normalizePbrDistance(int value){return value<24?16:value<48?32:value<96?64:value<192?128:256;}
public static boolean pbr(){enabled();return preferences.pbr;}
public static int pbrIntensity(){enabled();return preferences.pbrIntensity;}
public static void setPbr(boolean value){enabled();preferences.pbr=value;save();}
@@ -0,0 +1,28 @@
package fr.koka.sanctuary.mixin.client;
import com.mojang.renderpearl.api.buffers.GpuBufferSlice;
import fr.koka.sanctuary.client.shader.SolarColour;
import fr.koka.sanctuary.client.shader.VanillaLight;
import net.minecraft.client.renderer.SkyRenderer;
import net.minecraft.client.renderer.state.level.SkyRenderState;
import org.joml.Vector3f;
import org.joml.Vector4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SkyRenderer.class)
abstract class SolarColourMixin {
@Unique private Vector3f sanctuary$sunTint=new Vector3f(1);
@Inject(method="render",at=@At("HEAD"))
private void sanctuary$nativeSunset(GpuBufferSlice fog,SkyRenderState sky,CallbackInfo ci){
sanctuary$sunTint=VanillaLight.active()?SolarColour.tint(sky):new Vector3f(1);
}
@ModifyArg(method="renderSun",at=@At(value="INVOKE",target="Lnet/minecraft/client/renderer/DynamicGpuData;writeTransform(Lorg/joml/Matrix4f;Lorg/joml/Vector4f;)Lcom/mojang/renderpearl/api/buffers/GpuBufferSlice;"),index=1)
private Vector4f sanctuary$tintSun(Vector4f nativeColour){
return new Vector4f(nativeColour.x*sanctuary$sunTint.x,nativeColour.y*sanctuary$sunTint.y,nativeColour.z*sanctuary$sunTint.z,nativeColour.w);
}
}
@@ -0,0 +1,32 @@
package fr.koka.sanctuary.water;
import fr.koka.sanctuary.SanctuaryMod;
import fr.koka.sanctuary.expansion.ExpansionChunkGenerator;
import net.fabricmc.fabric.api.networking.v1.*;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityLevelChangeEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.server.level.ServerPlayer;
/** Read-only dimension context; no persistent world or generation changes. */
public final class WaterWorldSettings {
private WaterWorldSettings() {}
public record Context(boolean sanctuary) implements CustomPacketPayload {
public static final Type<Context> TYPE=new Type<>(SanctuaryMod.id("water_world_v1"));
public static final StreamCodec<RegistryFriendlyByteBuf,Context> CODEC=CustomPacketPayload.codec(
(p,b)->b.writeBoolean(p.sanctuary),b->new Context(b.readBoolean()));
public Type<Context> type(){return TYPE;}
}
public static void register(){
PayloadTypeRegistry.clientboundPlay().register(Context.TYPE,Context.CODEC);
ServerPlayConnectionEvents.JOIN.register((handler,sender,server)->send(handler.player));
ServerEntityLevelChangeEvents.AFTER_PLAYER_CHANGE_LEVEL.register((player,origin,destination)->send(player));
ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer,player,alive)->send(player));
}
private static void send(ServerPlayer player){
if(ServerPlayNetworking.canSend(player,Context.TYPE))
ServerPlayNetworking.send(player,new Context(player.level().getChunkSource().getGenerator() instanceof ExpansionChunkGenerator));
}
}
@@ -1,7 +1,7 @@
{
"sanctuary.shaders.ssr_intensity_value": "Reflection strength: %s%%",
"sanctuary.shaders.ssr_intensity_help": "Amount of landscape reflected by materials. Zero disables SSR.",
"sanctuary.shaders.ssr": "Landscape reflections — experimental",
"sanctuary.shaders.ssr_intensity_help": "Strength of visible landscape reflections on solids and water. Default: 20%.",
"sanctuary.shaders.ssr": "SSR",
"sanctuary.shaders.ssr_help": "Colours material texels with the visible landscape. Requires PBR; off-screen objects cannot be reflected.",
"sanctuary.shaders.ssr_intensity": "Reflection strength",
"sanctuary.graphics.default_vulkan": "Vulkan (default)",
@@ -2302,9 +2302,9 @@
"sanctuary.shaders.ssgi_intensity_value": "SSGI: %s%%",
"sanctuary.shaders.pbr": "PBR · material relief",
"sanctuary.shaders.pbr_help": "Experimental: procedural block normals and roughness, sun, moon and local light highlights. Enable Colored lights for local direction. Range 32 blocks. ON at 80% by default.",
"sanctuary.shaders.pbr_intensity": "PBR strength",
"sanctuary.shaders.pbr_intensity_help": "Material relief and highlights. Zero stops rendering and frees the cache. Original textures remain unchanged.",
"sanctuary.shaders.pbr_intensity_value": "PBR: %s%%",
"sanctuary.shaders.pbr_intensity": "PBR intensity",
"sanctuary.shaders.pbr_intensity_help": "Material relief and highlights, including water. Default: 50%.",
"sanctuary.shaders.pbr_intensity_value": "PBR intensity: %s %%",
"sanctuary.shaders.lens_flare": "Lens flare · soft rectangles",
"sanctuary.shaders.lens_flare_help": "Soft rectangular sun and moon reflections. Obstacles hide the sources. Independent of the bloom halo.",
"sanctuary.shaders.lens_flare_intensity": "Lens flare intensity",
@@ -2326,8 +2326,17 @@
"sanctuary.shaders.warm_torches": "Warm torches",
"sanctuary.shaders.warm_torches_help": "Off: ordinary torches keep the native color temperature. On: orange tint. Other sources retain their own colors.",
"sanctuary.shaders.natural_water": "Natural water",
"sanctuary.shaders.natural_water_help": "Biome colour, clarity from the bed. Clear oceans. Also changes underwater visibility.",
"sanctuary.shaders.natural_water_help": "Bed-dependent tint, transparency and fog. Defaults OFF in ordinary worlds and ON on Sanctuary islands. Preferences are stored separately for each world type.",
"sanctuary.shaders.water_intensity": "Water intensity",
"sanctuary.shaders.water_intensity_help": "At 0%, keeps native rendering. At 100%, applies all three profiles.",
"sanctuary.shaders.water_intensity_value": "Water intensity: %s%%"
"sanctuary.shaders.water_intensity_value": "Water intensity: %s%%",
"sanctuary.shaders.pbr_distance": "PBR distance",
"sanctuary.shaders.pbr_distance_value": "PBR distance: %s blocks",
"sanctuary.shaders.pbr_distance_help": "Independent PBR range: 16, 32, 64, 128 or 256 blocks. Default: 64 blocks. Limited to visible terrain and mesh budget.",
"sanctuary.shaders.water_blend": "Water blending",
"sanctuary.shaders.water_blend_value": "Water blending: %s × %s blocks",
"sanctuary.shaders.water_blend_help": "Transition width between bed-dependent water colours: 1, 3, 5, 9 or 17 blocks. Default: 9 × 9.",
"sanctuary.shaders.ssr_distance": "SSR distance",
"sanctuary.shaders.ssr_distance_value": "SSR distance: %s blocks",
"sanctuary.shaders.ssr_distance_help": "Independent SSR range: 16, 32, 64, 128 or 256 blocks. Default: 64 blocks. Limited to visible terrain and mesh budget."
}
@@ -1,7 +1,7 @@
{
"sanctuary.shaders.ssr_intensity_value": "Intensité des reflets : %s %%",
"sanctuary.shaders.ssr_intensity_help": "Dose de paysage réfléchie par les matériaux. Zéro désactive le SSR.",
"sanctuary.shaders.ssr": "Reflets du paysage — expérimental",
"sanctuary.shaders.ssr_intensity_help": "Intensité des reflets du paysage visible, sur les solides et l’eau. Défaut : 20 %.",
"sanctuary.shaders.ssr": "SSR",
"sanctuary.shaders.ssr_help": "Colore les pixels de matière avec le paysage visible. PBR requis ; les objets hors écran ne sont pas réfléchis.",
"sanctuary.shaders.ssr_intensity": "Intensité des reflets",
"sanctuary.graphics.default_vulkan": "Vulkan (par défaut)",
@@ -2302,9 +2302,9 @@
"sanctuary.shaders.ssgi_intensity_value": "SSGI : %s %%",
"sanctuary.shaders.pbr": "PBR · relief des matériaux",
"sanctuary.shaders.pbr_help": "Expérimental : normales procédurales et rugosité des blocs, reflets du soleil, de la lune et des lumières locales. Activer Lumières colorées pour la direction locale. Portée 32 blocs. Activé par défaut à 80 %.",
"sanctuary.shaders.pbr_intensity": "Intensité du PBR",
"sanctuary.shaders.pbr_intensity_help": "Relief et reflets des matériaux. Zéro coupe le calcul et libère le cache. Ne modifie pas les textures originales.",
"sanctuary.shaders.pbr_intensity_value": "PBR : %s %%",
"sanctuary.shaders.pbr_intensity": "Intensité PBR",
"sanctuary.shaders.pbr_intensity_help": "Relief et éclats des matières, eau comprise. Défaut : 50 %.",
"sanctuary.shaders.pbr_intensity_value": "Intensité PBR : %s %%",
"sanctuary.shaders.lens_flare": "Lens flare · rectangles doux",
"sanctuary.shaders.lens_flare_help": "Reflets rectangulaires du soleil et de la lune, aux bords dégradés. Les obstacles masquent les sources. Indépendant du halo de bloom.",
"sanctuary.shaders.lens_flare_intensity": "Intensité du lens flare",
@@ -2326,8 +2326,17 @@
"sanctuary.shaders.warm_torches": "Torches chaudes",
"sanctuary.shaders.warm_torches_help": "Désactivé : les torches ordinaires conservent la température de couleur native. Activé : teinte orangée. Les autres sources gardent leurs propres couleurs.",
"sanctuary.shaders.natural_water": "Eau naturelle",
"sanctuary.shaders.natural_water_help": "Couleur du biome, clarté selon le fond. Océans clairs. Modifie aussi la visibilité sous l’eau.",
"sanctuary.shaders.natural_water_help": "Teintes, transparence et brume selon le fond. OFF par défaut dans les mondes ordinaires, ON sur les îles Sanctuary. Choix mémorisé séparément pour chaque type de monde.",
"sanctuary.shaders.water_intensity": "Intensité de l’eau",
"sanctuary.shaders.water_intensity_help": "À 0 %, conserve le rendu natif. À 100 %, applique les trois profils.",
"sanctuary.shaders.water_intensity_value": "Intensité de l’eau: %s%%"
"sanctuary.shaders.water_intensity_value": "Intensité de l’eau: %s%%",
"sanctuary.shaders.pbr_distance": "Distance PBR",
"sanctuary.shaders.pbr_distance_value": "Distance PBR: %s blocs",
"sanctuary.shaders.pbr_distance_help": "Portée indépendante du PBR : 16, 32, 64, 128 ou 256 blocs. Défaut : 64 blocs. Limitée au terrain visible et au budget de maillage.",
"sanctuary.shaders.water_blend": "Mélange des eaux",
"sanctuary.shaders.water_blend_value": "Mélange des eaux : %s × %s blocs",
"sanctuary.shaders.water_blend_help": "Étendue de la transition des teintes selon le fond : 1, 3, 5, 9 ou 17 blocs. Défaut : 9 × 9.",
"sanctuary.shaders.ssr_distance": "Distance SSR",
"sanctuary.shaders.ssr_distance_value": "Distance SSR: %s blocs",
"sanctuary.shaders.ssr_distance_help": "Portée indépendante du SSR : 16, 32, 64, 128 ou 256 blocs. Défaut : 64 blocs. Limitée au terrain visible et au budget de maillage."
}
@@ -0,0 +1,6 @@
#version 330
#extension GL_ARB_separate_shader_objects : require
uniform sampler2D InputTexture;
layout(location=0) in vec2 texCoord;
layout(location=0) out vec4 fragColor;
void main(){fragColor=vec4(texture(InputTexture,texCoord).rgb,0);}
@@ -0,0 +1,16 @@
#version 330
#extension GL_ARB_separate_shader_objects : require
uniform sampler2D Before;
uniform sampler2D After;
layout(location=0) in vec2 texCoord;
layout(location=0) out vec4 fragColor;
void main(){
vec2 pixel=1.0/vec2(textureSize(After,0));vec3 glow=vec3(0);
for(int y=0;y<8;y++)for(int x=0;x<8;x++){
vec2 uv=texCoord+(vec2(x,y)-3.5)*pixel;
vec3 a=texture(After,uv).rgb,b=texture(Before,uv).rgb;
// A restrained halo for material light, stronger for near-white solar glints.
glow+=max(a*a-b*b,vec3(0))*(.12+.28*smoothstep(.75,1.0,max(a.r,max(a.g,a.b))));
}
fragColor=vec4(glow/64.0,0);
}
@@ -25,6 +25,8 @@ layout(std140) uniform PbrScene {
vec4 PbrParams;
vec4 PbrFog;
vec4 PbrEnvironment;
vec4 PbrSunColour;
vec4 PbrWaterOrigin;
};
layout(std140) uniform PixelShadows {
mat4 InverseViewProjection;
@@ -89,8 +91,8 @@ vec3 localShine(vec3 n,vec3 v,vec3 l,vec4 material,vec3 albedo){
vec3 halfVector=l+v;float size=dot(halfVector,halfVector);if(size<.00001)return vec3(0);
vec3 h=halfVector*inversesqrt(size);
float nl=clamp(dot(n,l),0.0,1.0),nv=clamp(dot(n,v),.001,1.0),nh=clamp(dot(n,h),0.0,1.0),vh=clamp(dot(v,h),0.0,1.0);
float roughness=max(material.b,.25),alpha=roughness*roughness,a2=alpha*alpha;
float denom=nh*nh*(a2-1.0)+1.0,distribution=a2/max(3.14159265*denom*denom,.00001);
float roughness=max(material.b,.16),alpha=roughness*roughness,a2=alpha*alpha;
float denom=nh*nh*(a2-1.0)+1.0,distribution=a2/max(3.14159265*denom*denom,.00000001);
float k=(roughness+1.0)*(roughness+1.0)/8.0;
float geometry=nv/(nv*(1.0-k)+k)*nl/max(nl*(1.0-k)+k,.00001);
// Explicit integer power stays defined even at round-off limits on OpenGL drivers.
@@ -102,26 +104,48 @@ void main(){
// Derivatives precede divergent discard; UV-space tangents preserve rotated/mirrored block textures.
vec3 dx=dFdx(relativePosition),dy=dFdy(relativePosition);
vec2 tx=dFdx(blockUv),ty=dFdy(blockUv);
vec2 atlasSize=vec2(textureSize(BlockAtlas,0));
float texelFootprint=max(length(tx*atlasSize),length(ty*atlasSize));
float det=tx.x*ty.y-tx.y*ty.x;
vec3 baseNormal=normalize(cross(dx,dy));if(dot(baseNormal,-relativePosition)<0.0)baseNormal=-baseNormal;
vec2 uv=gl_FragCoord.xy/vec2(textureSize(WorldDepth,0));float depth=texelFetch(WorldDepth,ivec2(gl_FragCoord.xy),0).r;
vec4 projected=PbrInverseVP*vec4(uv*2.0-1.0,PbrParams.y>0.5?depth:depth*2.0-1.0,1.0);
vec3 visible=projected.xyz/projected.w;
if(depth<=0.0||abs(length(visible)-length(relativePosition))>0.035||length(relativePosition)>=PbrParams.w||abs(det)<1e-12)discard;
// Exact receiver depth is tested by the GPU; final scene depth also masks entities.
float visibleDepth=texelFetch(WorldDepth,ivec2(gl_FragCoord.xy),0).r;
vec2 screenUv=gl_FragCoord.xy/vec2(textureSize(WorldDepth,0));
vec4 visiblePoint=PbrInverseVP*vec4(screenUv*2.0-1.0,PbrParams.y>.5?visibleDepth:visibleDepth*2.0-1.0,1);
// Native terrain and material matrices have different evaluation order. Use a
// bounded 5 mm tolerance only for native occlusion; receiver selection stays exact.
if((visibleDepth>0.0&&length(visiblePoint.xyz/visiblePoint.w)+.005<length(relativePosition))||length(relativePosition)>=PbrParams.w||abs(det)<1e-12)discard;
// Keep atlas derivatives valid after per-fragment depth/alpha rejection.
float family=floor(maskUv.y*.5);
vec4 texel=textureGrad(BlockAtlas,blockUv,tx,ty);if(family<.5&&texel.a<0.99)discard;
vec3 tangent=normalize((dx*ty.y-dy*tx.y)/det),bitangent=normalize((dy*tx.x-dx*ty.x)/det);
vec4 material=textureLod(MaterialAtlas,vec2(maskUv.x,maskUv.y-family*2.0),0.0);
// RG stores signed height derivatives; B roughness, A metalness, not transparency.
vec2 slope=(material.rg*255.0-128.0)/127.0*PbrParams.x*(family>1.5?.24:2.0);
float intensity=PbrParams.x;
vec2 slope=(material.rg*255.0-128.0)/127.0*intensity*(family>1.5?.24:2.0);
// Slight world-anchored variation avoids identical crests on every water block.
float waterVariation=1.0;
if(family>1.5){
uvec3 cell=uvec3(floor(mod(relativePosition+PbrWaterOrigin.xyz,256.0)*16.0+.001));
uint seed=cell.x*1597334677u^cell.y*3812015801u^cell.z*2798796415u;
seed=(seed^(seed>>16u))*2246822519u;seed^=seed>>13u;
waterVariation=.75+.25*float(seed&65535u)/65535.0;
}
vec3 n=normalize(baseNormal+tangent*slope.x+bitangent*slope.y);
// Reject degenerate/interpolated geometry without replacing the native scene with NaNs.
if(any(isnan(n))||any(isinf(n))||dot(relativePosition,relativePosition)<.000001)discard;
vec3 l=normalize(PbrSun.xyz),v=normalize(-relativePosition);
float nl=clamp(dot(n,l),0.0,1.0);
vec3 albedo=texel.rgb*tint.rgb;albedo*=albedo;
vec3 specular=localShine(n,v,l,material,albedo);
// A broad solar lobe gives water an extended glitter path at grazing angles.
// Local lamps retain the material's original narrow lobe.
vec4 solarMaterial=material;
solarMaterial.b=max(material.b,family>1.5?.42:.24);
vec3 specular=localShine(n,v,l,solarMaterial,albedo);
// PbrEnvironment.z identifies sunlight: moonlight keeps its modest base radiance.
float solarRadiance=mix(1.0,family>1.5?6.0:4.0,PbrEnvironment.z);
// Same native sunset tint as the sun disc, converted to linear light.
vec3 sunColour=PbrSunColour.rgb;
float fog=max(clamp((max(length(relativePosition.xz),abs(relativePosition.y))-PbrFog.x)/max(PbrFog.y-PbrFog.x,.001),0.0,1.0),
clamp((length(relativePosition)-PbrFog.z)/max(PbrFog.w-PbrFog.z,.001),0.0,1.0));
float amount=PbrSun.w*pow(tint.a,8.0)*visibility(relativePosition,baseNormal)*(1.0-fog*PbrEnvironment.x)
@@ -137,8 +161,29 @@ void main(){
float localRelief=family<.5?(max(dot(n,arrival.xyz),0.0)-max(dot(baseNormal,arrival.xyz),0.0))*.7:0.0;
lit=clamp(lit*(1.0+localRelief*localAmount),0.0,1.0);
}
vec3 shine=min((specular*amount+localShine(n,v,arrival.xyz,material,albedo)*localAmount)*PbrParams.x*3.0,vec3(0.5));
lit+=(1.0-lit)*(1.0-exp(-shine));
// Preserve bright solar highlights instead of capping them at a medium grey.
// Fully matte foliage/fibres receive normal relief, not a broad white specular veil.
// Stone/wood (roughness <= .88), polished surfaces, metals and water are unchanged.
float fullyMatte=smoothstep(.9,.98,material.b)*(1.0-material.a);
float shineWeight=family<.5?1.0-fullyMatte:1.0;
vec3 skyShine=min(specular*amount*solarRadiance*intensity*5.0*shineWeight,vec3(8.0));
vec3 lampShine=min(localShine(n,v,arrival.xyz,material,albedo)*localAmount*intensity*5.0*shineWeight,vec3(8.0));
if(family>1.5&&PbrEnvironment.z>.5){
// Soft-light/screen blend per native texel: broad daylight lifts the water
// without replacing its colour and detail with a saturated white cone.
// Glints follow animated wave facets reflecting the sun towards the eye.
// Their pulse comes from the native wave animation, not an unrelated timer.
vec3 halfSum=l+v;
float alignment=pow(max(dot(n,halfSum*inversesqrt(max(dot(halfSum,halfSum),.00001))),0.0),384.0);
float crest=smoothstep(.025,.18,length((material.rg*255.0-128.0)/127.0));
float detail=1.0-smoothstep(.75,2.0,texelFootprint);
float glint=alignment*crest*waterVariation*detail;
vec3 glintShine=skyShine*(1.0+glint*1.2);
vec3 weight=glintShine/(1.0+glintShine);
vec3 highlight=max(lit,mix(sunColour,sqrt(lit)*sunColour,mix(.55,.30,glint)));
lit=mix(lit,highlight,weight);
}else lit+=(1.0-lit)*(1.0-exp(-skyShine*sunColour));
lit+=(1.0-lit)*(1.0-exp(-lampShine));
if(any(isnan(lit))||any(isinf(lit)))discard;
fragColor=vec4(sqrt(clamp(lit,0.0,1.0)),1.0);
}
@@ -1,6 +1,8 @@
#version 330
#extension GL_ARB_separate_shader_objects : require
#include <minecraft:dynamictransforms.glsl>
// Receiver and colour passes must produce bit-identical depth on every backend.
invariant gl_Position;
layout(location=0) in vec3 Position;
layout(location=1) in vec4 Color;
layout(location=2) in vec2 UV0;
@@ -1,6 +1,7 @@
#version 330
#extension GL_ARB_separate_shader_objects : require
uniform sampler2D OpaqueDepth;
layout(std140) uniform ReflectionScene { mat4 ReflectionVP; mat4 ReflectionInverseVP; vec4 ReflectionParams; vec4 ReflectionLimits; };
uniform sampler2D BlockAtlas;
layout(location=0) in vec3 relativePosition;
layout(location=1) in vec2 blockUv;
@@ -8,9 +9,15 @@ layout(location=2) in vec2 maskUv;
layout(location=3) in vec4 tint;
void main(){
vec2 dx=dFdx(blockUv),dy=dFdy(blockUv);
if(length(relativePosition)>=32.0)discard;
if(length(relativePosition)>=ReflectionLimits.z)discard;
// Minecraft's world projection uses reverse depth: zero is the far plane.
float opaque=texelFetch(OpaqueDepth,ivec2(gl_FragCoord.xy),0).r;
if(gl_FragCoord.z+0.0000001<opaque)discard;
// Native and material transforms differ slightly in evaluation order. A fixed
// depth-buffer epsilon becomes too strict near the camera (reverse-Z).
// Compare world distances with the same bounded margin as the colour passes;
// the receiver attachment still selects the nearest material with exact depth.
vec2 uv=gl_FragCoord.xy/vec2(textureSize(OpaqueDepth,0));
vec4 visible=ReflectionInverseVP*vec4(uv*2.0-1.0,ReflectionParams.x>.5?opaque:opaque*2.0-1.0,1);
if(opaque>0.0&&length(visible.xyz/visible.w)+.005<length(relativePosition))discard;
if(maskUv.y<2.0&&textureGrad(BlockAtlas,blockUv,dx,dy).a<.99)discard;
}
@@ -87,13 +87,18 @@ void main(){
vec2 materialUv=vec2(maskUv.x,maskUv.y-family*2.0);
vec3 base=normalize(cross(dx,dy));if(dot(base,-relativePosition)<0.0)base=-base;
if(abs(det)<1e-14||length(relativePosition)>=ReflectionParams.w)discard;
// The receiver depth attachment rejects hidden and secondary surfaces before ray tracing.
// The final native depth includes entities rendered after the landscape capture.
float finalDepth=texelFetch(ReceiverDepth,ivec2(gl_FragCoord.xy),0).r;
vec2 screenUv=gl_FragCoord.xy/vec2(textureSize(ReceiverDepth,0));
if(finalDepth>0.0&&length(reconstruct(screenUv,finalDepth))+.005<length(relativePosition))discard;
float intensity=ReflectionParams.z;
if(intensity<=0.0)discard;
vec4 texel=textureGrad(BlockAtlas,blockUv,tx,ty);if(family<.5&&texel.a<.99)discard;
vec2 center=(floor(materialUv*1280.0)+.5)/1280.0;
vec3 u=(dx*my.y-dy*mx.y)/det,v=(dy*mx.x-dx*my.x)/det;
vec3 point=relativePosition+u*(center.x-materialUv.x)+v*(center.y-materialUv.y);
vec4 material=textureLod(MaterialAtlas,center,0);
vec2 slope=(material.rg*255.0-128.0)/127.0*ReflectionParams.z*(family>1.5?.24:2.0);
vec2 slope=(material.rg*255.0-128.0)/127.0*intensity*(family>1.5?.24:2.0);
vec3 normal=normalize(base+normalize(u)*slope.x+normalize(v)*slope.y);
if(any(isnan(normal))||any(isinf(normal)))discard;
vec4 hit=trace(point,normal,base);if(hit.w<=0.0)discard;
@@ -117,7 +122,7 @@ void main(){
vec3 albedo=textureLod(BlockAtlas,centerBlock,0).rgb*tint.rgb;
vec3 f0=mix(vec3(family>1.5?.02:.04),albedo*albedo,material.a);
vec3 fresnel=f0+(1.0-f0)*(g2*g2*grazing);
float fade=(1.0-smoothstep(24.0,32.0,length(point)))*hit.w;
float fade=(1.0-smoothstep(ReflectionParams.w*.75,ReflectionParams.w,length(point)))*hit.w;
vec3 weight=clamp(fresnel*ReflectionParams.y*(1.0-material.b*material.b)*fade,0.0,.9);
vec3 scene=texelFetch(SceneColor,ivec2(gl_FragCoord.xy),0).rgb;
vec3 result=mix(scene*scene,reflected*reflected,weight);
@@ -263,6 +263,7 @@
"client.InventoryPointerAccess",
"client.OperatorWorldOptionsMixin",
"client.StarSkyMixin",
"client.SolarColourMixin",
"client.ProgressiveFogMixin",
"client.ShaderSaturationMixin",
"client.WeatherEnvironmentMixin",
+1 -1
View File
@@ -1,6 +1,6 @@
name = "Sanctuary"
author = "KOKA99CAB"
version = "beta.145"
version = "beta.150"
pack-format = "packwiz:1.1.0"
[index]