summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-21 15:03:16 +0800
committerchai <215380520@qq.com>2024-05-21 15:03:16 +0800
commit3fb0e391648628dcfaf9550f2a1d68bc53d58c7b (patch)
tree11c77d43ba161a1d9a4cc3aaa004c22d6778fd2f
parent9b520e7182f0bb697881422e7bb543a29c085f95 (diff)
+ decompiled
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/.gitignore399
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/AlphaMotion.cs18
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonImageColor.cs31
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonSfx.cs54
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonTextColor.cs34
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiBar.cs141
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiPixelFix.cs17
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiScaler.cs56
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localization.cs307
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localize.cs9
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/TabHandler.cs102
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGamePad.cs89
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGroupHandler.cs135
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHandler.cs110
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHint.cs40
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UISelectableGroup.cs11
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UITooltip.cs153
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Uirotate.cs11
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/assembly_guiutils.csproj30
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles.Demo/LuxParticles_ExtendedFlycam.cs75
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_AmbientLighting.cs224
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_DirectionalLight.cs42
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_LocalAmbientLighting.cs71
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_lux/assembly_lux.csproj21
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/ExampleWheelController.cs38
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionComponent.cs190
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionModel.cs87
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AntialiasingModel.cs222
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomComponent.cs116
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomModel.cs117
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsComponent.cs237
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsModel.cs141
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationComponent.cs63
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationModel.cs49
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingComponent.cs352
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingCurve.cs64
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingModel.cs319
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldComponent.cs155
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldModel.cs71
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringComponent.cs61
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringModel.cs35
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationComponent.cs177
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationModel.cs97
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogComponent.cs97
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogModel.cs44
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FxaaComponent.cs34
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GetSetAttribute.cs13
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainComponent.cs62
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainModel.cs59
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GraphicsUtils.cs126
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MaterialFactory.cs43
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MinAttribute.cs11
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurComponent.cs426
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurModel.cs55
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingBehaviour.cs406
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponent.cs17
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentBase.cs23
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentCommandBuffer.cs12
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentRenderTexture.cs8
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingContext.cs39
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingModel.cs33
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingProfile.cs34
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/RenderTextureFactory.cs57
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionComponent.cs227
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionModel.cs141
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TaaComponent.cs184
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballAttribute.cs11
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballGroupAttribute.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutComponent.cs38
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutModel.cs49
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteComponent.cs48
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteModel.cs87
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/assembly_postprocessing.csproj28
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/RunTimeCombineAndRelease.cs43
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombine.cs171
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombineMaster.cs6
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/assembly_simplemeshcombine.csproj18
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/.gitignore399
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/AAMode.cs12
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Antialiasing.cs139
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Bloom.cs333
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomAndFlares.cs257
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomOptimized.cs96
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomScreenBlendMode.cs7
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Blur.cs80
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BlurOptimized.cs84
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CameraMotionBlur.cs382
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionCurves.cs180
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionLookup.cs142
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionRamp.cs16
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastEnhance.cs67
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastStretch.cs178
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CreaseShading.cs76
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfField.cs350
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfFieldDeprecated.cs451
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/EdgeDetection.cs96
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Fisheye.cs43
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/GlobalFog.cs92
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Grayscale.cs20
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/HDRBloomMode.cs8
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffectBase.cs45
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffects.cs34
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/LensflareStyle34.cs8
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/MotionBlur.cs52
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndGrain.cs158
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndScratches.cs138
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsBase.cs233
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsHelper.cs172
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Quads.cs102
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenOverlay.cs53
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientObscurance.cs105
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientOcclusion.cs161
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SepiaTone.cs13
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SunShafts.cs134
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TiltShift.cs80
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Tonemapping.cs226
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Triangles.cs95
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TweakMode34.cs7
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Twirl.cs20
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/VignetteAndChromaticAberration.cs110
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Vortex.cs19
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/assembly_sunshafts.csproj18
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/.gitignore399
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/BitMaskAttribute.cs12
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Cover.cs82
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/DictionaryExt.cs12
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/DrawBounds.cs16
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/HideWhenRunning.cs12
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/ListExtra.cs27
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/LookAt.cs35
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Pool.cs30
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Properties/AssemblyInfo.cs5
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/QuaternionExt.cs10
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/StringExtensionMethods.cs18
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/SyncedList.cs129
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Timer.cs51
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/TriggerTracker.cs35
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Utils.cs504
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/Vector2i.cs104
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZInput.cs522
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZLog.cs28
-rw-r--r--Valheim_r202102_v0.141.2/Valheim/assembly_utils/assembly_utils.csproj28
147 files changed, 15001 insertions, 0 deletions
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/.gitignore b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/.gitignore
new file mode 100644
index 0000000..a4da27a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/.gitignore
@@ -0,0 +1,399 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.vs
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/AlphaMotion.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/AlphaMotion.cs
new file mode 100644
index 0000000..02e4d4c
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/AlphaMotion.cs
@@ -0,0 +1,18 @@
+using UnityEngine;
+
+public class AlphaMotion : MonoBehaviour
+{
+ public float m_rotSpeed = 100f;
+
+ public float m_rotAngle = 0.2f;
+
+ private void Start()
+ {
+ }
+
+ private void Update()
+ {
+ float time = Time.time;
+ base.transform.localRotation = Quaternion.Euler(0f, 0f, Mathf.Sin(time * m_rotSpeed) * m_rotAngle);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonImageColor.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonImageColor.cs
new file mode 100644
index 0000000..4591548
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonImageColor.cs
@@ -0,0 +1,31 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class ButtonImageColor : MonoBehaviour
+{
+ public Image m_image;
+
+ private Color m_defaultColor = Color.white;
+
+ public Color m_disabledColor = Color.grey;
+
+ private Button m_button;
+
+ private void Awake()
+ {
+ m_button = GetComponent<Button>();
+ m_defaultColor = m_image.color;
+ }
+
+ private void Update()
+ {
+ if (m_button.IsInteractable())
+ {
+ m_image.color = m_defaultColor;
+ }
+ else
+ {
+ m_image.color = m_disabledColor;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonSfx.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonSfx.cs
new file mode 100644
index 0000000..9a4dbb3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonSfx.cs
@@ -0,0 +1,54 @@
+using UnityEngine;
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+
+public class ButtonSfx : MonoBehaviour, ISelectHandler, IEventSystemHandler
+{
+ public GameObject m_sfxPrefab;
+
+ public GameObject m_selectSfxPrefab;
+
+ private Selectable m_selectable;
+
+ private static int m_lastTriggerFrame;
+
+ private const int m_minDeltaFrames = 2;
+
+ private void Start()
+ {
+ m_selectable = GetComponent<Selectable>();
+ Button button = m_selectable as Button;
+ if ((bool)button)
+ {
+ button.onClick.AddListener(OnClick);
+ return;
+ }
+ Toggle toggle = m_selectable as Toggle;
+ if ((bool)toggle)
+ {
+ toggle.onValueChanged.AddListener(OnChange);
+ }
+ }
+
+ private void OnClick()
+ {
+ if ((bool)m_sfxPrefab && Time.frameCount - m_lastTriggerFrame > 2)
+ {
+ Object.Instantiate(m_sfxPrefab);
+ m_lastTriggerFrame = Time.frameCount;
+ }
+ }
+
+ private void OnChange(bool v)
+ {
+ if ((bool)m_sfxPrefab && Time.frameCount - m_lastTriggerFrame > 2)
+ {
+ Object.Instantiate(m_sfxPrefab);
+ m_lastTriggerFrame = Time.frameCount;
+ }
+ }
+
+ public void OnSelect(BaseEventData eventData)
+ {
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonTextColor.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonTextColor.cs
new file mode 100644
index 0000000..050cb7d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/ButtonTextColor.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class ButtonTextColor : MonoBehaviour
+{
+ private Color m_defaultColor = Color.white;
+
+ public Color m_disabledColor = Color.grey;
+
+ private Button m_button;
+
+ private Text m_text;
+
+ private Sprite m_sprite;
+
+ private void Awake()
+ {
+ m_button = GetComponent<Button>();
+ m_text = GetComponentInChildren<Text>();
+ m_defaultColor = m_text.color;
+ }
+
+ private void Update()
+ {
+ if (m_button.IsInteractable())
+ {
+ m_text.color = m_defaultColor;
+ }
+ else
+ {
+ m_text.color = m_disabledColor;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiBar.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiBar.cs
new file mode 100644
index 0000000..a43f316
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiBar.cs
@@ -0,0 +1,141 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class GuiBar : MonoBehaviour
+{
+ public RectTransform m_bar;
+
+ public bool m_smoothDrain;
+
+ public bool m_smoothFill;
+
+ public float m_smoothSpeed = 1f;
+
+ public float m_changeDelay;
+
+ private float m_value = 1f;
+
+ private float m_maxValue = 1f;
+
+ private float m_width;
+
+ private float m_smoothValue = 1f;
+
+ private float m_delayTimer;
+
+ private bool m_firstSet = true;
+
+ private Image m_barImage;
+
+ private Color m_originalColor;
+
+ private void Awake()
+ {
+ m_width = m_bar.sizeDelta.x;
+ m_barImage = m_bar.GetComponent<Image>();
+ if ((bool)m_barImage)
+ {
+ m_originalColor = m_barImage.color;
+ }
+ }
+
+ private void OnEnable()
+ {
+ m_delayTimer = 0f;
+ m_smoothValue = Mathf.Clamp01(m_value / m_maxValue);
+ }
+
+ public void SetWidth(float width)
+ {
+ if (m_width != width)
+ {
+ m_width = width;
+ m_bar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_width * m_smoothValue);
+ }
+ }
+
+ public void SetValue(float value)
+ {
+ if (m_value == value && !m_firstSet)
+ {
+ return;
+ }
+ if (m_firstSet)
+ {
+ m_firstSet = false;
+ m_value = value;
+ m_smoothValue = Mathf.Clamp01(m_value / m_maxValue);
+ SetBar(m_smoothValue);
+ }
+ else
+ {
+ if ((value < m_value && m_smoothDrain) || (value > m_value && m_smoothFill))
+ {
+ m_delayTimer = m_changeDelay;
+ }
+ m_value = value;
+ }
+ }
+
+ public void SetMaxValue(float value)
+ {
+ if (m_maxValue != value)
+ {
+ float num = m_smoothValue * m_maxValue;
+ m_maxValue = value;
+ m_smoothValue = Mathf.Clamp01(num / m_maxValue);
+ }
+ }
+
+ private void LateUpdate()
+ {
+ m_delayTimer -= Time.deltaTime;
+ if (m_delayTimer <= 0f)
+ {
+ float num = Mathf.Clamp01(m_value / m_maxValue);
+ if (num > m_smoothValue && m_smoothFill)
+ {
+ m_smoothValue = Mathf.Clamp01(Mathf.MoveTowards(m_smoothValue, num, m_smoothSpeed * Time.deltaTime));
+ }
+ else if (num < m_smoothValue && m_smoothDrain)
+ {
+ m_smoothValue = Mathf.Clamp01(Mathf.MoveTowards(m_smoothValue, num, m_smoothSpeed * Time.deltaTime));
+ }
+ else
+ {
+ m_smoothValue = num;
+ }
+ SetBar(m_smoothValue);
+ }
+ }
+
+ private void SetBar(float i)
+ {
+ m_bar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_width * i);
+ }
+
+ public void SetColor(Color color)
+ {
+ if ((bool)m_barImage)
+ {
+ m_barImage.color = color;
+ }
+ }
+
+ public Color GetColor()
+ {
+ if ((bool)m_barImage)
+ {
+ return m_barImage.color;
+ }
+ return Color.white;
+ }
+
+ public void ResetColor()
+ {
+ if ((bool)m_barImage)
+ {
+ m_barImage.color = m_originalColor;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiPixelFix.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiPixelFix.cs
new file mode 100644
index 0000000..0c00a86
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiPixelFix.cs
@@ -0,0 +1,17 @@
+using UnityEngine;
+
+public class GuiPixelFix : MonoBehaviour
+{
+ private void LateUpdate()
+ {
+ RectTransform rectTransform = base.transform as RectTransform;
+ if (!(rectTransform.parent == null))
+ {
+ Rect rect = (rectTransform.parent as RectTransform).rect;
+ Vector2 offsetMax = rectTransform.offsetMax;
+ offsetMax.x = ((rect.width % 2f != 0f) ? 1 : 0);
+ offsetMax.y = ((rect.height % 2f != 0f) ? 1 : 0);
+ rectTransform.offsetMax = offsetMax;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiScaler.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiScaler.cs
new file mode 100644
index 0000000..6d556ab
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/GuiScaler.cs
@@ -0,0 +1,56 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class GuiScaler : MonoBehaviour
+{
+ private static List<GuiScaler> m_scalers = new List<GuiScaler>();
+
+ private static int m_minWidth = 1920;
+
+ private static int m_minHeight = 1080;
+
+ private CanvasScaler m_canvasScaler;
+
+ private static float m_largeGuiScale = 1f;
+
+ private void Awake()
+ {
+ m_canvasScaler = GetComponent<CanvasScaler>();
+ m_scalers.Add(this);
+ m_largeGuiScale = PlayerPrefs.GetFloat("GuiScale", 1f);
+ }
+
+ private void OnDestroy()
+ {
+ m_scalers.Remove(this);
+ }
+
+ private void Update()
+ {
+ UpdateScale();
+ }
+
+ private void UpdateScale()
+ {
+ float screenSizeFactor = GetScreenSizeFactor();
+ m_canvasScaler.scaleFactor = screenSizeFactor;
+ }
+
+ private float GetScreenSizeFactor()
+ {
+ float a = (float)Screen.width / (float)m_minWidth;
+ float b = (float)Screen.height / (float)m_minHeight;
+ return Mathf.Min(a, b) * m_largeGuiScale;
+ }
+
+ public static void LoadGuiScale()
+ {
+ m_largeGuiScale = PlayerPrefs.GetFloat("GuiScale", 1f);
+ }
+
+ public static void SetScale(float scale)
+ {
+ m_largeGuiScale = scale;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localization.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localization.cs
new file mode 100644
index 0000000..243a09c
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localization.cs
@@ -0,0 +1,307 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class Localization
+{
+ private static Localization m_instance;
+
+ private char[] m_endChars = " (){}[]+-!?/\\\\&%,.:-=<>\n".ToCharArray();
+
+ private Dictionary<string, string> m_translations = new Dictionary<string, string>();
+
+ private List<string> m_languages = new List<string>();
+
+ public static Localization instance
+ {
+ get
+ {
+ if (m_instance == null)
+ {
+ Initialize();
+ }
+ return m_instance;
+ }
+ }
+
+ private static void Initialize()
+ {
+ if (m_instance == null)
+ {
+ m_instance = new Localization();
+ }
+ }
+
+ private Localization()
+ {
+ m_languages = LoadLanguages();
+ SetupLanguage("English");
+ string @string = PlayerPrefs.GetString("language", "");
+ if (@string != "")
+ {
+ SetupLanguage(@string);
+ }
+ }
+
+ public void SetLanguage(string language)
+ {
+ PlayerPrefs.SetString("language", language);
+ }
+
+ public string GetSelectedLanguage()
+ {
+ return PlayerPrefs.GetString("language", "English");
+ }
+
+ public string GetNextLanguage(string lang)
+ {
+ for (int i = 0; i < m_languages.Count; i++)
+ {
+ if (m_languages[i] == lang)
+ {
+ if (i + 1 < m_languages.Count)
+ {
+ return m_languages[i + 1];
+ }
+ return m_languages[0];
+ }
+ }
+ return m_languages[0];
+ }
+
+ public string GetPrevLanguage(string lang)
+ {
+ for (int i = 0; i < m_languages.Count; i++)
+ {
+ if (m_languages[i] == lang)
+ {
+ if (i - 1 >= 0)
+ {
+ return m_languages[i - 1];
+ }
+ return m_languages[m_languages.Count - 1];
+ }
+ }
+ return m_languages[0];
+ }
+
+ public void Localize(Transform root)
+ {
+ Text[] componentsInChildren = root.gameObject.GetComponentsInChildren<Text>(includeInactive: true);
+ foreach (Text text in componentsInChildren)
+ {
+ text.text = Localize(text.text);
+ }
+ }
+
+ public string Localize(string text, params string[] words)
+ {
+ string text2 = Localize(text);
+ return InsertWords(text2, words);
+ }
+
+ private string InsertWords(string text, string[] words)
+ {
+ for (int i = 0; i < words.Length; i++)
+ {
+ string newValue = words[i];
+ text = text.Replace("$" + (i + 1), newValue);
+ }
+ return text;
+ }
+
+ public string Localize(string text)
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ int num = 0;
+ string word;
+ int wordStart;
+ int wordEnd;
+ while (FindNextWord(text, num, out word, out wordStart, out wordEnd))
+ {
+ stringBuilder.Append(text.Substring(num, wordStart - num));
+ stringBuilder.Append(Translate(word));
+ num = wordEnd;
+ }
+ stringBuilder.Append(text.Substring(num));
+ return stringBuilder.ToString();
+ }
+
+ private bool FindNextWord(string text, int startIndex, out string word, out int wordStart, out int wordEnd)
+ {
+ if (startIndex >= text.Length - 1)
+ {
+ word = null;
+ wordStart = -1;
+ wordEnd = -1;
+ return false;
+ }
+ wordStart = text.IndexOf('$', startIndex);
+ if (wordStart != -1)
+ {
+ int num = text.IndexOfAny(m_endChars, wordStart);
+ if (num != -1)
+ {
+ word = text.Substring(wordStart + 1, num - wordStart - 1);
+ wordEnd = num;
+ }
+ else
+ {
+ word = text.Substring(wordStart + 1);
+ wordEnd = text.Length;
+ }
+ return true;
+ }
+ word = null;
+ wordEnd = -1;
+ return false;
+ }
+
+ private string Translate(string word)
+ {
+ if (word.StartsWith("KEY_"))
+ {
+ string bindingName = word.Substring(4);
+ return GetBoundKeyString(bindingName);
+ }
+ if (m_translations.TryGetValue(word, out var value))
+ {
+ return value;
+ }
+ return "[" + word + "]";
+ }
+
+ public string GetBoundKeyString(string bindingName)
+ {
+ string boundKeyString = ZInput.instance.GetBoundKeyString(bindingName);
+ if (boundKeyString.Length > 0 && boundKeyString[0] == '$' && m_translations.TryGetValue(boundKeyString.Substring(1), out var value))
+ {
+ return value;
+ }
+ return boundKeyString;
+ }
+
+ private void AddWord(string key, string text)
+ {
+ m_translations.Remove(key);
+ m_translations.Add(key, text);
+ }
+
+ private void Clear()
+ {
+ m_translations.Clear();
+ }
+
+ public bool SetupLanguage(string language)
+ {
+ TextAsset textAsset = Resources.Load("localization", typeof(TextAsset)) as TextAsset;
+ if (textAsset == null)
+ {
+ ZLog.LogWarning("Failed to load language file");
+ return false;
+ }
+ StringReader stringReader = new StringReader(textAsset.text);
+ string[] array = stringReader.ReadLine().Split(',');
+ int num = -1;
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i] == language)
+ {
+ num = i;
+ break;
+ }
+ }
+ if (num == -1)
+ {
+ ZLog.LogWarning("Failed to find language:" + language);
+ return false;
+ }
+ List<List<string>> list = DoQuoteLineSplit(stringReader);
+ ZLog.Log("Lines " + list.Count);
+ foreach (List<string> item in list)
+ {
+ if (item.Count == 0)
+ {
+ continue;
+ }
+ string text = item[0];
+ if (text.StartsWith("//") || text.Length == 0)
+ {
+ continue;
+ }
+ if (item.Count <= num)
+ {
+ ZLog.Log("Missing " + language + " translation for:" + text);
+ continue;
+ }
+ string text2 = item[num];
+ if (string.IsNullOrEmpty(text2) || text2[0] == '\r')
+ {
+ ZLog.Log("Missing translation for " + text);
+ text2 = item[1];
+ }
+ AddWord(text, text2);
+ }
+ ZLog.Log("Loaded localization " + language);
+ return true;
+ }
+
+ private List<List<string>> DoQuoteLineSplit(StringReader reader)
+ {
+ List<List<string>> list = new List<List<string>>();
+ List<string> list2 = new List<string>();
+ StringBuilder stringBuilder = new StringBuilder();
+ bool flag = false;
+ while (true)
+ {
+ int num = reader.Read();
+ switch (num)
+ {
+ case -1:
+ list2.Add(stringBuilder.ToString());
+ list.Add(list2);
+ return list;
+ case 34:
+ flag = !flag;
+ continue;
+ case 44:
+ if (!flag)
+ {
+ list2.Add(stringBuilder.ToString());
+ stringBuilder.Length = 0;
+ continue;
+ }
+ break;
+ }
+ if (num == 10 && !flag)
+ {
+ list2.Add(stringBuilder.ToString());
+ stringBuilder.Length = 0;
+ list.Add(list2);
+ list2 = new List<string>();
+ }
+ else
+ {
+ stringBuilder.Append((char)num);
+ }
+ }
+ }
+
+ public List<string> GetLanguages()
+ {
+ return m_languages;
+ }
+
+ private List<string> LoadLanguages()
+ {
+ string[] array = new StringReader((Resources.Load("localization", typeof(TextAsset)) as TextAsset).text).ReadLine().Split(',');
+ List<string> list = new List<string>();
+ for (int i = 1; i < array.Length; i++)
+ {
+ list.Add(array[i]);
+ }
+ return list;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localize.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localize.cs
new file mode 100644
index 0000000..39ae6c5
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Localize.cs
@@ -0,0 +1,9 @@
+using UnityEngine;
+
+public class Localize : MonoBehaviour
+{
+ private void Awake()
+ {
+ Localization.instance.Localize(base.transform);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/TabHandler.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/TabHandler.cs
new file mode 100644
index 0000000..ae40fc7
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/TabHandler.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Events;
+using UnityEngine.UI;
+
+public class TabHandler : MonoBehaviour
+{
+ [Serializable]
+ public class Tab
+ {
+ public Button m_button;
+
+ public RectTransform m_page;
+
+ public bool m_default;
+
+ public UnityEvent m_onClick;
+ }
+
+ public bool m_gamepadInput;
+
+ public List<Tab> m_tabs = new List<Tab>();
+
+ private int m_selected;
+
+ private void Awake()
+ {
+ int activeTab = 0;
+ for (int i = 0; i < m_tabs.Count; i++)
+ {
+ Tab tab = m_tabs[i];
+ tab.m_button.onClick.AddListener(delegate
+ {
+ OnClick(tab.m_button);
+ });
+ Transform transform = tab.m_button.gameObject.transform.Find("Selected");
+ if ((bool)transform)
+ {
+ transform.GetComponentInChildren<Text>().text = tab.m_button.GetComponentInChildren<Text>().text;
+ }
+ if (tab.m_default)
+ {
+ activeTab = i;
+ }
+ }
+ SetActiveTab(activeTab);
+ }
+
+ private void Update()
+ {
+ if (m_gamepadInput)
+ {
+ if (ZInput.GetButtonDown("JoyTabLeft"))
+ {
+ SetActiveTab(Mathf.Max(0, m_selected - 1));
+ }
+ if (ZInput.GetButtonDown("JoyTabRight"))
+ {
+ SetActiveTab(Mathf.Min(m_tabs.Count - 1, m_selected + 1));
+ }
+ }
+ }
+
+ private void OnClick(Button button)
+ {
+ SetActiveTab(button);
+ }
+
+ private void SetActiveTab(Button button)
+ {
+ for (int i = 0; i < m_tabs.Count; i++)
+ {
+ if (m_tabs[i].m_button == button)
+ {
+ SetActiveTab(i);
+ break;
+ }
+ }
+ }
+
+ public void SetActiveTab(int index)
+ {
+ m_selected = index;
+ for (int i = 0; i < m_tabs.Count; i++)
+ {
+ Tab tab = m_tabs[i];
+ bool flag = i == index;
+ tab.m_page.gameObject.SetActive(flag);
+ tab.m_button.interactable = !flag;
+ Transform transform = tab.m_button.gameObject.transform.Find("Selected");
+ if ((bool)transform)
+ {
+ transform.gameObject.SetActive(flag);
+ }
+ if (flag)
+ {
+ tab.m_onClick.Invoke();
+ }
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGamePad.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGamePad.cs
new file mode 100644
index 0000000..1bab59e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGamePad.cs
@@ -0,0 +1,89 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class UIGamePad : MonoBehaviour
+{
+ public KeyCode m_keyCode;
+
+ public string m_zinputKey;
+
+ public GameObject m_hint;
+
+ private Button m_button;
+
+ private Toggle m_toggle;
+
+ private UIGroupHandler m_group;
+
+ private static int m_lastInteractFrame;
+
+ private void Start()
+ {
+ m_group = GetComponentInParent<UIGroupHandler>();
+ m_button = GetComponent<Button>();
+ m_toggle = GetComponent<Toggle>();
+ if ((bool)m_hint)
+ {
+ m_hint.SetActive(value: false);
+ }
+ }
+
+ private bool IsInteractive()
+ {
+ if (m_button != null && !m_button.IsInteractable())
+ {
+ return false;
+ }
+ if ((bool)m_toggle)
+ {
+ if (!m_toggle.IsInteractable())
+ {
+ return false;
+ }
+ if ((bool)m_toggle.group && !m_toggle.group.allowSwitchOff && m_toggle.isOn)
+ {
+ return false;
+ }
+ }
+ if ((bool)m_group && !m_group.IsActive())
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private void Update()
+ {
+ bool flag = IsInteractive();
+ if ((bool)m_hint)
+ {
+ m_hint.SetActive(flag && ZInput.IsGamepadActive());
+ }
+ if (flag && Time.frameCount - m_lastInteractFrame >= 2 && ButtonPressed())
+ {
+ m_lastInteractFrame = Time.frameCount;
+ ZLog.Log("Button pressed " + base.gameObject.name + " frame:" + Time.frameCount);
+ if (m_button != null)
+ {
+ m_button.OnSubmit(null);
+ }
+ if (m_toggle != null)
+ {
+ m_toggle.OnSubmit(null);
+ }
+ }
+ }
+
+ private bool ButtonPressed()
+ {
+ if (!string.IsNullOrEmpty(m_zinputKey) && ZInput.GetButtonDown(m_zinputKey))
+ {
+ return true;
+ }
+ if (m_keyCode != 0 && Input.GetKeyDown(m_keyCode))
+ {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGroupHandler.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGroupHandler.cs
new file mode 100644
index 0000000..e0d6cde
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIGroupHandler.cs
@@ -0,0 +1,135 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+
+public class UIGroupHandler : MonoBehaviour
+{
+ public GameObject m_defaultElement;
+
+ public GameObject m_enableWhenActiveAndGamepad;
+
+ public int m_groupPriority;
+
+ private CanvasGroup m_canvasGroup;
+
+ private bool m_userActive = true;
+
+ private bool m_active = true;
+
+ private static List<UIGroupHandler> m_groups = new List<UIGroupHandler>();
+
+ private void Awake()
+ {
+ m_groups.Add(this);
+ m_canvasGroup = GetComponent<CanvasGroup>();
+ }
+
+ private void OnDestroy()
+ {
+ m_groups.Remove(this);
+ }
+
+ private void OnEnable()
+ {
+ }
+
+ private void OnDisable()
+ {
+ if (m_active)
+ {
+ m_active = false;
+ ResetActiveElement();
+ }
+ }
+
+ private Selectable FindSelectable(GameObject root)
+ {
+ return root.GetComponentInChildren<Selectable>(includeInactive: false);
+ }
+
+ private bool IsHighestPriority()
+ {
+ if (!m_userActive)
+ {
+ return false;
+ }
+ foreach (UIGroupHandler group in m_groups)
+ {
+ if (!(group == this) && group.gameObject.activeInHierarchy && group.m_groupPriority > m_groupPriority)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void ResetActiveElement()
+ {
+ if ((bool)EventSystem.current && (bool)EventSystem.current.currentSelectedGameObject && EventSystem.current.currentSelectedGameObject.gameObject.GetComponentInParent<UIGroupHandler>() == this)
+ {
+ EventSystem.current.SetSelectedGameObject(null);
+ }
+ }
+
+ private void Update()
+ {
+ bool flag = IsHighestPriority();
+ if (flag != m_active)
+ {
+ ZLog.Log("UI Group status changed " + base.gameObject.name + " = " + flag);
+ ResetActiveElement();
+ }
+ m_active = flag;
+ if ((bool)m_canvasGroup)
+ {
+ m_canvasGroup.interactable = flag;
+ }
+ if ((bool)m_enableWhenActiveAndGamepad)
+ {
+ m_enableWhenActiveAndGamepad.SetActive(m_active && ZInput.IsGamepadActive());
+ }
+ if (m_active && m_defaultElement != null && ZInput.IsGamepadActive() && !HaveSelectedObject())
+ {
+ Selectable selectable = FindSelectable(m_defaultElement);
+ if ((bool)selectable)
+ {
+ ZLog.Log("Activating default element " + m_defaultElement.name);
+ EventSystem.current.SetSelectedGameObject(selectable.gameObject);
+ selectable.OnSelect(null);
+ }
+ }
+ }
+
+ private bool HaveSelectedObject()
+ {
+ if (EventSystem.current.currentSelectedGameObject == null)
+ {
+ return false;
+ }
+ if (!EventSystem.current.currentSelectedGameObject.activeInHierarchy)
+ {
+ return false;
+ }
+ Selectable component = EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>();
+ if ((bool)component && !component.IsInteractable())
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public void SetActive(bool active)
+ {
+ m_userActive = active;
+ if (!m_userActive && (bool)m_enableWhenActiveAndGamepad)
+ {
+ m_enableWhenActiveAndGamepad.SetActive(value: false);
+ }
+ }
+
+ public bool IsActive()
+ {
+ return m_active;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHandler.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHandler.cs
new file mode 100644
index 0000000..7086fca
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHandler.cs
@@ -0,0 +1,110 @@
+using System;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+public class UIInputHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler
+{
+ public Action<UIInputHandler> m_onLeftClick;
+
+ public Action<UIInputHandler> m_onLeftDown;
+
+ public Action<UIInputHandler> m_onLeftUp;
+
+ public Action<UIInputHandler> m_onRightClick;
+
+ public Action<UIInputHandler> m_onRightDown;
+
+ public Action<UIInputHandler> m_onRightUp;
+
+ public Action<UIInputHandler> m_onMiddleClick;
+
+ public Action<UIInputHandler> m_onMiddleDown;
+
+ public Action<UIInputHandler> m_onMiddleUp;
+
+ public Action<UIInputHandler> m_onPointerEnter;
+
+ public Action<UIInputHandler> m_onPointerExit;
+
+ public void OnPointerDown(PointerEventData eventData)
+ {
+ if (eventData.button == PointerEventData.InputButton.Right)
+ {
+ if (m_onRightDown != null)
+ {
+ m_onRightDown(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Left)
+ {
+ if (m_onLeftDown != null)
+ {
+ m_onLeftDown(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleDown != null)
+ {
+ m_onMiddleDown(this);
+ }
+ }
+
+ public void OnPointerUp(PointerEventData eventData)
+ {
+ if (eventData.button == PointerEventData.InputButton.Right)
+ {
+ if (m_onRightUp != null)
+ {
+ m_onRightUp(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Left)
+ {
+ if (m_onLeftUp != null)
+ {
+ m_onLeftUp(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleUp != null)
+ {
+ m_onMiddleUp(this);
+ }
+ }
+
+ public void OnPointerClick(PointerEventData eventData)
+ {
+ if (eventData.button == PointerEventData.InputButton.Right)
+ {
+ if (m_onRightClick != null)
+ {
+ m_onRightClick(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Left)
+ {
+ if (m_onLeftClick != null)
+ {
+ m_onLeftClick(this);
+ }
+ }
+ else if (eventData.button == PointerEventData.InputButton.Middle && m_onMiddleClick != null)
+ {
+ m_onMiddleClick(this);
+ }
+ }
+
+ public void OnPointerEnter(PointerEventData eventData)
+ {
+ if (m_onPointerEnter != null)
+ {
+ m_onPointerEnter(this);
+ }
+ }
+
+ public void OnPointerExit(PointerEventData eventData)
+ {
+ if (m_onPointerExit != null)
+ {
+ m_onPointerExit(this);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHint.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHint.cs
new file mode 100644
index 0000000..6701a54
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UIInputHint.cs
@@ -0,0 +1,40 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class UIInputHint : MonoBehaviour
+{
+ public GameObject m_gamepadHint;
+
+ public GameObject m_mouseKeyboardHint;
+
+ private Button m_button;
+
+ private UIGroupHandler m_group;
+
+ private void Start()
+ {
+ m_group = GetComponentInParent<UIGroupHandler>();
+ m_button = GetComponent<Button>();
+ if ((bool)m_gamepadHint)
+ {
+ m_gamepadHint.SetActive(value: false);
+ }
+ if ((bool)m_mouseKeyboardHint)
+ {
+ m_mouseKeyboardHint.SetActive(value: false);
+ }
+ }
+
+ private void Update()
+ {
+ bool flag = (m_button == null || m_button.IsInteractable()) && (m_group == null || m_group.IsActive());
+ if (m_gamepadHint != null)
+ {
+ m_gamepadHint.SetActive(flag && ZInput.IsGamepadActive());
+ }
+ if (m_mouseKeyboardHint != null)
+ {
+ m_mouseKeyboardHint.SetActive(flag && ZInput.IsMouseActive());
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UISelectableGroup.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UISelectableGroup.cs
new file mode 100644
index 0000000..1aa87c1
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UISelectableGroup.cs
@@ -0,0 +1,11 @@
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+
+public class UISelectableGroup : Selectable
+{
+ public override void OnSelect(BaseEventData eventData)
+ {
+ base.OnSelect(eventData);
+ ZLog.Log("Select a child");
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UITooltip.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UITooltip.cs
new file mode 100644
index 0000000..2e667f9
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/UITooltip.cs
@@ -0,0 +1,153 @@
+using UnityEngine;
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+
+public class UITooltip : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
+{
+ public GameObject m_tooltipPrefab;
+
+ public string m_text = "";
+
+ public string m_topic = "";
+
+ public GameObject m_gamepadFocusObject;
+
+ private static UITooltip m_current;
+
+ private static GameObject m_tooltip;
+
+ private static GameObject m_hovered;
+
+ private const float m_showDelay = 0.5f;
+
+ private float m_showTimer;
+
+ private void LateUpdate()
+ {
+ if (m_current == this && !m_tooltip.activeSelf)
+ {
+ m_showTimer += Time.deltaTime;
+ if (m_showTimer > 0.5f)
+ {
+ m_tooltip.SetActive(value: true);
+ }
+ }
+ if (ZInput.IsGamepadActive() && !ZInput.IsMouseActive())
+ {
+ if (m_gamepadFocusObject != null)
+ {
+ if (m_gamepadFocusObject.activeSelf && m_current != this)
+ {
+ OnHoverStart(m_gamepadFocusObject);
+ }
+ else if (!m_gamepadFocusObject.activeSelf && m_current == this)
+ {
+ HideTooltip();
+ }
+ if (m_current == this && m_tooltip != null)
+ {
+ RectTransform obj = base.gameObject.transform as RectTransform;
+ Vector3[] array = new Vector3[4];
+ obj.GetWorldCorners(array);
+ m_tooltip.transform.position = array[2];
+ Utils.ClampUIToScreen(m_tooltip.transform as RectTransform);
+ }
+ }
+ }
+ else if (m_current == this)
+ {
+ if (m_hovered == null)
+ {
+ HideTooltip();
+ return;
+ }
+ if (!RectTransformUtility.RectangleContainsScreenPoint(m_hovered.transform as RectTransform, Input.mousePosition))
+ {
+ HideTooltip();
+ return;
+ }
+ m_tooltip.transform.position = Input.mousePosition;
+ Utils.ClampUIToScreen(m_tooltip.transform as RectTransform);
+ }
+ }
+
+ private void OnDisable()
+ {
+ if (m_current == this)
+ {
+ HideTooltip();
+ }
+ }
+
+ public void OnPointerEnter(PointerEventData eventData)
+ {
+ OnHoverStart(eventData.pointerEnter);
+ }
+
+ private void OnHoverStart(GameObject go)
+ {
+ if ((bool)m_current)
+ {
+ HideTooltip();
+ }
+ if (m_tooltip == null && (m_text != "" || m_topic != ""))
+ {
+ m_tooltip = Object.Instantiate(m_tooltipPrefab, base.transform.GetComponentInParent<Canvas>().transform);
+ UpdateTextElements();
+ Utils.ClampUIToScreen(m_tooltip.transform as RectTransform);
+ m_hovered = go;
+ m_current = this;
+ m_tooltip.SetActive(value: false);
+ m_showTimer = 0f;
+ }
+ }
+
+ private void UpdateTextElements()
+ {
+ if (m_tooltip != null)
+ {
+ Transform transform = Utils.FindChild(m_tooltip.transform, "Text");
+ if (transform != null)
+ {
+ transform.GetComponent<Text>().text = Localization.instance.Localize(m_text);
+ }
+ Transform transform2 = Utils.FindChild(m_tooltip.transform, "Topic");
+ if (transform2 != null)
+ {
+ transform2.GetComponent<Text>().text = Localization.instance.Localize(m_topic);
+ }
+ }
+ }
+
+ public void OnPointerExit(PointerEventData eventData)
+ {
+ if (m_current == this)
+ {
+ HideTooltip();
+ }
+ }
+
+ public static void HideTooltip()
+ {
+ if ((bool)m_tooltip)
+ {
+ Object.Destroy(m_tooltip);
+ m_current = null;
+ m_tooltip = null;
+ m_hovered = null;
+ }
+ }
+
+ public void Set(string topic, string text)
+ {
+ if (!(topic == m_topic) || !(text == m_text))
+ {
+ m_topic = topic;
+ m_text = text;
+ if (m_current == this && m_tooltip != null)
+ {
+ UpdateTextElements();
+ }
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Uirotate.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Uirotate.cs
new file mode 100644
index 0000000..32e8872
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/Uirotate.cs
@@ -0,0 +1,11 @@
+using UnityEngine;
+
+public class Uirotate : MonoBehaviour
+{
+ public float m_speed = 1f;
+
+ private void Update()
+ {
+ base.transform.Rotate(0f, 0f, Time.deltaTime * m_speed);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/assembly_guiutils.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/assembly_guiutils.csproj
new file mode 100644
index 0000000..237e9bc
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_guiutils/assembly_guiutils.csproj
@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_guiutils</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.UI">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.UI.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.UIModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.UIModule.dll</HintPath>
+ </Reference>
+ <Reference Include="assembly_utils">
+ <HintPath>..\..\Game\valheim_Data\Managed\assembly_utils.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.InputLegacyModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles.Demo/LuxParticles_ExtendedFlycam.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles.Demo/LuxParticles_ExtendedFlycam.cs
new file mode 100644
index 0000000..a5c7242
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles.Demo/LuxParticles_ExtendedFlycam.cs
@@ -0,0 +1,75 @@
+using UnityEngine;
+
+namespace LuxParticles.Demo;
+
+public class LuxParticles_ExtendedFlycam : MonoBehaviour
+{
+ public float cameraSensitivity = 90f;
+
+ public float climbSpeed = 4f;
+
+ public float normalMoveSpeed = 10f;
+
+ public float slowMoveFactor = 0.25f;
+
+ public float fastMoveFactor = 3f;
+
+ private float rotationX;
+
+ private float rotationY;
+
+ private bool isOrtho;
+
+ private Camera cam;
+
+ private void Start()
+ {
+ rotationX = base.transform.eulerAngles.y;
+ cam = GetComponent<Camera>();
+ if (cam != null)
+ {
+ isOrtho = cam.orthographic;
+ }
+ }
+
+ private void Update()
+ {
+ float deltaTime = Time.deltaTime;
+ rotationX += Input.GetAxis("Mouse X") * cameraSensitivity * deltaTime;
+ rotationY += Input.GetAxis("Mouse Y") * cameraSensitivity * deltaTime;
+ rotationY = Mathf.Clamp(rotationY, -90f, 90f);
+ Quaternion b = Quaternion.AngleAxis(rotationX, Vector3.up);
+ b *= Quaternion.AngleAxis(rotationY, Vector3.left);
+ base.transform.localRotation = Quaternion.Slerp(base.transform.localRotation, b, deltaTime * 6f);
+ if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
+ {
+ base.transform.position += base.transform.forward * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Vertical") * deltaTime;
+ base.transform.position += base.transform.right * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Horizontal") * deltaTime;
+ }
+ else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
+ {
+ base.transform.position += base.transform.forward * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Vertical") * deltaTime;
+ base.transform.position += base.transform.right * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Horizontal") * deltaTime;
+ }
+ else
+ {
+ if (isOrtho)
+ {
+ cam.orthographicSize *= 1f - Input.GetAxis("Vertical") * deltaTime;
+ }
+ else
+ {
+ base.transform.position += base.transform.forward * normalMoveSpeed * Input.GetAxis("Vertical") * deltaTime;
+ }
+ base.transform.position += base.transform.right * normalMoveSpeed * Input.GetAxis("Horizontal") * deltaTime;
+ }
+ if (Input.GetKey(KeyCode.Q))
+ {
+ base.transform.position -= base.transform.up * climbSpeed * deltaTime;
+ }
+ if (Input.GetKey(KeyCode.E))
+ {
+ base.transform.position += base.transform.up * climbSpeed * deltaTime;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_AmbientLighting.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_AmbientLighting.cs
new file mode 100644
index 0000000..1319d84
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_AmbientLighting.cs
@@ -0,0 +1,224 @@
+using UnityEngine;
+using UnityEngine.Rendering;
+
+namespace LuxParticles;
+
+[ExecuteInEditMode]
+public class LuxParticles_AmbientLighting : MonoBehaviour
+{
+ public bool UpdatePerFrame = true;
+
+ public bool AlwaysUseSH;
+
+ private SphericalHarmonicsL2 probe;
+
+ private Vector4[] SHLighting = new Vector4[7];
+
+ private int Lux_SHAr;
+
+ private int Lux_SHAg;
+
+ private int Lux_SHAb;
+
+ private int Lux_SHBr;
+
+ private int Lux_SHBg;
+
+ private int Lux_SHBb;
+
+ private int Lux_SHC;
+
+ private int Lux_L_SHAr;
+
+ private int Lux_L_SHAg;
+
+ private int Lux_L_SHAb;
+
+ private int Lux_L_SHBr;
+
+ private int Lux_L_SHBg;
+
+ private int Lux_L_SHBb;
+
+ private int Lux_L_SHC;
+
+ private int Lux_AmbientMode;
+
+ private const float k0 = 0.2820948f;
+
+ private const float k1 = 0.48860252f;
+
+ private const float k2 = 1.0925485f;
+
+ private const float k3 = 0.31539157f;
+
+ private const float k4 = 0.54627424f;
+
+ private static float[] ks = new float[9] { 0.2820948f, -0.48860252f, 0.48860252f, -0.48860252f, 1.0925485f, -1.0925485f, 0.31539157f, -1.0925485f, 0.54627424f };
+
+ private int managedParticleSystems;
+
+ private void OnEnable()
+ {
+ Lux_SHAr = Shader.PropertyToID("_Lux_SHAr");
+ Lux_SHAg = Shader.PropertyToID("_Lux_SHAg");
+ Lux_SHAb = Shader.PropertyToID("_Lux_SHAb");
+ Lux_SHBr = Shader.PropertyToID("_Lux_SHBr");
+ Lux_SHBg = Shader.PropertyToID("_Lux_SHBg");
+ Lux_SHBb = Shader.PropertyToID("_Lux_SHBb");
+ Lux_SHC = Shader.PropertyToID("_Lux_SHC");
+ Lux_L_SHAr = Shader.PropertyToID("_Lux_L_SHAr");
+ Lux_L_SHAg = Shader.PropertyToID("_Lux_L_SHAg");
+ Lux_L_SHAb = Shader.PropertyToID("_Lux_L_SHAb");
+ Lux_L_SHBr = Shader.PropertyToID("_Lux_L_SHBr");
+ Lux_L_SHBg = Shader.PropertyToID("_Lux_L_SHBg");
+ Lux_L_SHBb = Shader.PropertyToID("_Lux_L_SHBb");
+ Lux_L_SHC = Shader.PropertyToID("_Lux_L_SHC");
+ Lux_AmbientMode = Shader.PropertyToID("_Lux_AmbientMode");
+ Invoke("UpdateAmbientLighting", 0f);
+ }
+
+ private void LateUpdate()
+ {
+ if (UpdatePerFrame)
+ {
+ UpdateAmbientLighting();
+ }
+ else if (LuxParticles_LocalAmbientLighting.LocalProbes != null)
+ {
+ if (managedParticleSystems < LuxParticles_LocalAmbientLighting.LocalProbes.Count)
+ {
+ UpdateAmbientLightingForNewParticleSystems();
+ }
+ managedParticleSystems = LuxParticles_LocalAmbientLighting.LocalProbes.Count;
+ }
+ }
+
+ public void UpdateAmbientLighting()
+ {
+ bool flag = false;
+ if (LuxParticles_LocalAmbientLighting.LocalProbes != null && LuxParticles_LocalAmbientLighting.LocalProbes.Count > 0)
+ {
+ flag = true;
+ }
+ if (RenderSettings.ambientMode == AmbientMode.Flat && !flag && !AlwaysUseSH)
+ {
+ Shader.SetGlobalFloat(Lux_AmbientMode, 0f);
+ return;
+ }
+ if (RenderSettings.ambientMode == AmbientMode.Trilight && !flag && !AlwaysUseSH)
+ {
+ Shader.SetGlobalFloat(Lux_AmbientMode, 1f);
+ return;
+ }
+ Shader.SetGlobalFloat(Lux_AmbientMode, 2f);
+ if (RenderSettings.ambientMode == AmbientMode.Skybox)
+ {
+ probe = RenderSettings.ambientProbe;
+ }
+ else
+ {
+ LightProbes.GetInterpolatedProbe(base.transform.position, null, out probe);
+ }
+ PremultiplyCoefficients(probe);
+ GetShaderConstantsFromNormalizedSH(ref probe, IsSkyLighting: true);
+ SetSHLighting();
+ if (LuxParticles_LocalAmbientLighting.LocalProbes == null)
+ {
+ return;
+ }
+ for (int i = 0; i != LuxParticles_LocalAmbientLighting.LocalProbes.Count; i++)
+ {
+ LuxParticles_LocalAmbientLighting luxParticles_LocalAmbientLighting = LuxParticles_LocalAmbientLighting.LocalProbes[i];
+ if (luxParticles_LocalAmbientLighting.IsVisible)
+ {
+ LightProbes.GetInterpolatedProbe(luxParticles_LocalAmbientLighting.trans.position + luxParticles_LocalAmbientLighting.SampleOffset, null, out probe);
+ PremultiplyCoefficients(probe);
+ GetShaderConstantsFromNormalizedSH(ref probe, IsSkyLighting: false);
+ MaterialPropertyBlock block = LuxParticles_LocalAmbientLighting.LocalProbes[i].m_block;
+ block.Clear();
+ block.SetVector(Lux_L_SHAr, SHLighting[0]);
+ block.SetVector(Lux_L_SHAg, SHLighting[1]);
+ block.SetVector(Lux_L_SHAb, SHLighting[2]);
+ block.SetVector(Lux_L_SHBr, SHLighting[3]);
+ block.SetVector(Lux_L_SHBg, SHLighting[4]);
+ block.SetVector(Lux_L_SHBb, SHLighting[5]);
+ block.SetVector(Lux_L_SHC, SHLighting[6]);
+ LuxParticles_LocalAmbientLighting.LocalProbes[i].rend.SetPropertyBlock(block);
+ }
+ }
+ }
+
+ public void UpdateAmbientLightingForNewParticleSystems()
+ {
+ int count = LuxParticles_LocalAmbientLighting.LocalProbes.Count;
+ for (int i = managedParticleSystems; i != count; i++)
+ {
+ LuxParticles_LocalAmbientLighting luxParticles_LocalAmbientLighting = LuxParticles_LocalAmbientLighting.LocalProbes[i];
+ LightProbes.GetInterpolatedProbe(luxParticles_LocalAmbientLighting.trans.position + luxParticles_LocalAmbientLighting.SampleOffset, null, out probe);
+ PremultiplyCoefficients(probe);
+ GetShaderConstantsFromNormalizedSH(ref probe, IsSkyLighting: false);
+ MaterialPropertyBlock block = LuxParticles_LocalAmbientLighting.LocalProbes[i].m_block;
+ block.Clear();
+ block.SetVector(Lux_L_SHAr, SHLighting[0]);
+ block.SetVector(Lux_L_SHAg, SHLighting[1]);
+ block.SetVector(Lux_L_SHAb, SHLighting[2]);
+ block.SetVector(Lux_L_SHBr, SHLighting[3]);
+ block.SetVector(Lux_L_SHBg, SHLighting[4]);
+ block.SetVector(Lux_L_SHBb, SHLighting[5]);
+ block.SetVector(Lux_L_SHC, SHLighting[6]);
+ LuxParticles_LocalAmbientLighting.LocalProbes[i].rend.SetPropertyBlock(block);
+ }
+ }
+
+ private static SphericalHarmonicsL2 PremultiplyCoefficients(SphericalHarmonicsL2 sh)
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 9; j++)
+ {
+ sh[i, j] *= ks[j];
+ }
+ }
+ return sh;
+ }
+
+ private void GetShaderConstantsFromNormalizedSH(ref SphericalHarmonicsL2 ambientProbe, bool IsSkyLighting)
+ {
+ float num = 1f;
+ if (IsSkyLighting)
+ {
+ num = RenderSettings.ambientIntensity;
+ if (QualitySettings.activeColorSpace == ColorSpace.Linear)
+ {
+ num = Mathf.Pow(num, 2.2f);
+ }
+ }
+ for (int i = 0; i < 3; i++)
+ {
+ SHLighting[i].x = ambientProbe[i, 3] * num;
+ SHLighting[i].y = ambientProbe[i, 1] * num;
+ SHLighting[i].z = ambientProbe[i, 2] * num;
+ SHLighting[i].w = (ambientProbe[i, 0] - ambientProbe[i, 6]) * num;
+ SHLighting[i + 3].x = ambientProbe[i, 4] * num;
+ SHLighting[i + 3].y = ambientProbe[i, 5] * num;
+ SHLighting[i + 3].z = ambientProbe[i, 6] * 3f * num;
+ SHLighting[i + 3].w = ambientProbe[i, 7] * num;
+ }
+ SHLighting[6].x = ambientProbe[0, 8] * num;
+ SHLighting[6].y = ambientProbe[1, 8] * num;
+ SHLighting[6].z = ambientProbe[2, 8] * num;
+ SHLighting[6].w = 1f;
+ }
+
+ private void SetSHLighting()
+ {
+ Shader.SetGlobalVector(Lux_SHAr, SHLighting[0]);
+ Shader.SetGlobalVector(Lux_SHAg, SHLighting[1]);
+ Shader.SetGlobalVector(Lux_SHAb, SHLighting[2]);
+ Shader.SetGlobalVector(Lux_SHBr, SHLighting[3]);
+ Shader.SetGlobalVector(Lux_SHBg, SHLighting[4]);
+ Shader.SetGlobalVector(Lux_SHBb, SHLighting[5]);
+ Shader.SetGlobalVector(Lux_SHC, SHLighting[6]);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_DirectionalLight.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_DirectionalLight.cs
new file mode 100644
index 0000000..0da147a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_DirectionalLight.cs
@@ -0,0 +1,42 @@
+using UnityEngine;
+using UnityEngine.Rendering;
+
+namespace LuxParticles;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Light))]
+public class LuxParticles_DirectionalLight : MonoBehaviour
+{
+ private Light m_light;
+
+ private CommandBuffer GetShadowCascades_CB;
+
+ private void OnEnable()
+ {
+ m_light = GetComponent<Light>();
+ if (GetShadowCascades_CB == null)
+ {
+ GetShadowCascades_CB = new CommandBuffer();
+ GetShadowCascades_CB.name = "LuxParticles GetShadowCascades";
+ GetShadowCascades_CB.SetGlobalTexture("_LuxParticles_CascadedShadowMap", BuiltinRenderTextureType.CurrentActive);
+ }
+ m_light.AddCommandBuffer(LightEvent.AfterShadowMap, GetShadowCascades_CB);
+ }
+
+ private void OnDisable()
+ {
+ if ((bool)GetComponent<Light>() && GetShadowCascades_CB != null)
+ {
+ GetComponent<Light>().RemoveCommandBuffer(LightEvent.AfterShadowMap, GetShadowCascades_CB);
+ }
+ }
+
+ private void OnDestroy()
+ {
+ if (GetShadowCascades_CB != null)
+ {
+ GetShadowCascades_CB.Release();
+ GetShadowCascades_CB = null;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_LocalAmbientLighting.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_LocalAmbientLighting.cs
new file mode 100644
index 0000000..3e5f393
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/LuxParticles/LuxParticles_LocalAmbientLighting.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace LuxParticles;
+
+[ExecuteInEditMode]
+public class LuxParticles_LocalAmbientLighting : MonoBehaviour
+{
+ public static List<LuxParticles_LocalAmbientLighting> LocalProbes = new List<LuxParticles_LocalAmbientLighting>();
+
+ public Vector3 SampleOffset = Vector3.zero;
+
+ [NonSerialized]
+ public Transform trans;
+
+ [NonSerialized]
+ public Renderer rend;
+
+ [NonSerialized]
+ public MaterialPropertyBlock m_block;
+
+ [NonSerialized]
+ public bool IsVisible;
+
+ private void OnEnable()
+ {
+ trans = GetComponent<Transform>();
+ rend = GetComponent<Renderer>();
+ m_block = new MaterialPropertyBlock();
+ IsVisible = true;
+ Register();
+ }
+
+ private void Register()
+ {
+ LocalProbes.Add(this);
+ }
+
+ private void OnDisable()
+ {
+ LocalProbes.Remove(this);
+ if (m_block != null)
+ {
+ m_block.Clear();
+ rend.SetPropertyBlock(m_block);
+ m_block = null;
+ }
+ }
+
+ private void OnDestroy()
+ {
+ LocalProbes.Remove(this);
+ if (m_block != null)
+ {
+ m_block.Clear();
+ rend.SetPropertyBlock(m_block);
+ m_block = null;
+ }
+ }
+
+ private void OnBecameVisible()
+ {
+ IsVisible = true;
+ }
+
+ private void OnBecameInvisible()
+ {
+ IsVisible = false;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_lux/assembly_lux.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/assembly_lux.csproj
new file mode 100644
index 0000000..16145c3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_lux/assembly_lux.csproj
@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_lux</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.InputLegacyModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/ExampleWheelController.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/ExampleWheelController.cs
new file mode 100644
index 0000000..a2f05e0
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/ExampleWheelController.cs
@@ -0,0 +1,38 @@
+using UnityEngine;
+
+public class ExampleWheelController : MonoBehaviour
+{
+ private static class Uniforms
+ {
+ internal static readonly int _MotionAmount = Shader.PropertyToID("_MotionAmount");
+ }
+
+ public float acceleration;
+
+ public Renderer motionVectorRenderer;
+
+ private Rigidbody m_Rigidbody;
+
+ private void Start()
+ {
+ m_Rigidbody = GetComponent<Rigidbody>();
+ m_Rigidbody.maxAngularVelocity = 100f;
+ }
+
+ private void Update()
+ {
+ if (Input.GetKey(KeyCode.UpArrow))
+ {
+ m_Rigidbody.AddRelativeTorque(new Vector3(-1f * acceleration, 0f, 0f), ForceMode.Acceleration);
+ }
+ else if (Input.GetKey(KeyCode.DownArrow))
+ {
+ m_Rigidbody.AddRelativeTorque(new Vector3(1f * acceleration, 0f, 0f), ForceMode.Acceleration);
+ }
+ float value = (0f - m_Rigidbody.angularVelocity.x) / 100f;
+ if ((bool)motionVectorRenderer)
+ {
+ motionVectorRenderer.material.SetFloat(Uniforms._MotionAmount, Mathf.Clamp(value, -0.25f, 0.25f));
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionComponent.cs
new file mode 100644
index 0000000..6dbb292
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionComponent.cs
@@ -0,0 +1,190 @@
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class AmbientOcclusionComponent : PostProcessingComponentCommandBuffer<AmbientOcclusionModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _Intensity = Shader.PropertyToID("_Intensity");
+
+ internal static readonly int _IntensityFar = Shader.PropertyToID("_IntensityFar");
+
+ internal static readonly int _FarDistance = Shader.PropertyToID("_FarDistance");
+
+ internal static readonly int _Radius = Shader.PropertyToID("_Radius");
+
+ internal static readonly int _FogParams = Shader.PropertyToID("_FogParams");
+
+ internal static readonly int _Downsample = Shader.PropertyToID("_Downsample");
+
+ internal static readonly int _SampleCount = Shader.PropertyToID("_SampleCount");
+
+ internal static readonly int _OcclusionTexture1 = Shader.PropertyToID("_OcclusionTexture1");
+
+ internal static readonly int _OcclusionTexture2 = Shader.PropertyToID("_OcclusionTexture2");
+
+ internal static readonly int _OcclusionTexture = Shader.PropertyToID("_OcclusionTexture");
+
+ internal static readonly int _MainTex = Shader.PropertyToID("_MainTex");
+
+ internal static readonly int _TempRT = Shader.PropertyToID("_TempRT");
+ }
+
+ private enum OcclusionSource
+ {
+ DepthTexture,
+ DepthNormalsTexture,
+ GBuffer
+ }
+
+ private const string k_BlitShaderString = "Hidden/Post FX/Blit";
+
+ private const string k_ShaderString = "Hidden/Post FX/Ambient Occlusion";
+
+ private readonly RenderTargetIdentifier[] m_MRT = new RenderTargetIdentifier[2]
+ {
+ BuiltinRenderTextureType.GBuffer0,
+ BuiltinRenderTextureType.CameraTarget
+ };
+
+ private OcclusionSource occlusionSource
+ {
+ get
+ {
+ if (context.isGBufferAvailable && !base.model.settings.forceForwardCompatibility)
+ {
+ return OcclusionSource.GBuffer;
+ }
+ if (base.model.settings.highPrecision && (!context.isGBufferAvailable || base.model.settings.forceForwardCompatibility))
+ {
+ return OcclusionSource.DepthTexture;
+ }
+ return OcclusionSource.DepthNormalsTexture;
+ }
+ }
+
+ private bool ambientOnlySupported
+ {
+ get
+ {
+ if (context.isHdr && base.model.settings.ambientOnly && context.isGBufferAvailable)
+ {
+ return !base.model.settings.forceForwardCompatibility;
+ }
+ return false;
+ }
+ }
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.intensity > 0f)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ DepthTextureMode depthTextureMode = DepthTextureMode.None;
+ if (occlusionSource == OcclusionSource.DepthTexture)
+ {
+ depthTextureMode |= DepthTextureMode.Depth;
+ }
+ if (occlusionSource != OcclusionSource.GBuffer)
+ {
+ depthTextureMode |= DepthTextureMode.DepthNormals;
+ }
+ return depthTextureMode;
+ }
+
+ public override string GetName()
+ {
+ return "Ambient Occlusion";
+ }
+
+ public override CameraEvent GetCameraEvent()
+ {
+ if (!ambientOnlySupported || context.profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.AmbientOcclusion))
+ {
+ return CameraEvent.BeforeImageEffectsOpaque;
+ }
+ return CameraEvent.BeforeReflections;
+ }
+
+ public override void PopulateCommandBuffer(CommandBuffer cb)
+ {
+ AmbientOcclusionModel.Settings settings = base.model.settings;
+ Material mat = context.materialFactory.Get("Hidden/Post FX/Blit");
+ Material material = context.materialFactory.Get("Hidden/Post FX/Ambient Occlusion");
+ material.shaderKeywords = null;
+ material.SetFloat(Uniforms._Intensity, settings.intensity);
+ material.SetFloat(Uniforms._IntensityFar, settings.intensityFar);
+ material.SetFloat(Uniforms._FarDistance, settings.farDistance);
+ material.SetFloat(Uniforms._Radius, settings.radius);
+ material.SetFloat(Uniforms._Downsample, settings.downsampling ? 0.5f : 1f);
+ material.SetInt(Uniforms._SampleCount, (int)settings.sampleCount);
+ if (!context.isGBufferAvailable && RenderSettings.fog)
+ {
+ material.SetVector(Uniforms._FogParams, new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance));
+ switch (RenderSettings.fogMode)
+ {
+ case FogMode.Linear:
+ material.EnableKeyword("FOG_LINEAR");
+ break;
+ case FogMode.Exponential:
+ material.EnableKeyword("FOG_EXP");
+ break;
+ case FogMode.ExponentialSquared:
+ material.EnableKeyword("FOG_EXP2");
+ break;
+ }
+ }
+ else
+ {
+ material.EnableKeyword("FOG_OFF");
+ }
+ int width = context.width;
+ int height = context.height;
+ int num = ((!settings.downsampling) ? 1 : 2);
+ int occlusionTexture = Uniforms._OcclusionTexture1;
+ cb.GetTemporaryRT(occlusionTexture, width / num, height / num, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
+ cb.Blit(null, occlusionTexture, material, (int)occlusionSource);
+ int occlusionTexture2 = Uniforms._OcclusionTexture2;
+ cb.GetTemporaryRT(occlusionTexture2, width, height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, occlusionTexture);
+ cb.Blit(occlusionTexture, occlusionTexture2, material, (occlusionSource == OcclusionSource.GBuffer) ? 4 : 3);
+ cb.ReleaseTemporaryRT(occlusionTexture);
+ occlusionTexture = Uniforms._OcclusionTexture;
+ cb.GetTemporaryRT(occlusionTexture, width, height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, occlusionTexture2);
+ cb.Blit(occlusionTexture2, occlusionTexture, material, 5);
+ cb.ReleaseTemporaryRT(occlusionTexture2);
+ if (context.profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.AmbientOcclusion))
+ {
+ cb.SetGlobalTexture(Uniforms._MainTex, occlusionTexture);
+ cb.Blit(occlusionTexture, BuiltinRenderTextureType.CameraTarget, material, 8);
+ context.Interrupt();
+ }
+ else if (ambientOnlySupported)
+ {
+ cb.SetRenderTarget(m_MRT, BuiltinRenderTextureType.CameraTarget);
+ cb.DrawMesh(GraphicsUtils.quad, Matrix4x4.identity, material, 0, 7);
+ }
+ else
+ {
+ RenderTextureFormat format = (context.isHdr ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
+ int tempRT = Uniforms._TempRT;
+ cb.GetTemporaryRT(tempRT, context.width, context.height, 0, FilterMode.Bilinear, format);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, tempRT, mat, 0);
+ cb.SetGlobalTexture(Uniforms._MainTex, tempRT);
+ cb.Blit(tempRT, BuiltinRenderTextureType.CameraTarget, material, 6);
+ cb.ReleaseTemporaryRT(tempRT);
+ }
+ cb.ReleaseTemporaryRT(occlusionTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionModel.cs
new file mode 100644
index 0000000..82593a7
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AmbientOcclusionModel.cs
@@ -0,0 +1,87 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class AmbientOcclusionModel : PostProcessingModel
+{
+ public enum SampleCount
+ {
+ Lowest = 3,
+ Low = 6,
+ Medium = 10,
+ High = 16
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ [Range(0f, 4f)]
+ [Tooltip("Degree of darkness produced by the effect.")]
+ public float intensity;
+
+ [Range(0f, 4f)]
+ [Tooltip("Degree of darkness produced by the effect at far distance.")]
+ public float intensityFar;
+
+ [Tooltip("Radius of sample points, which affects extent of darkened areas.")]
+ public float farDistance;
+
+ [Min(0.0001f)]
+ [Tooltip("Radius of sample points, which affects extent of darkened areas.")]
+ public float radius;
+
+ [Tooltip("Number of sample points, which affects quality and performance.")]
+ public SampleCount sampleCount;
+
+ [Tooltip("Halves the resolution of the effect to increase performance at the cost of visual quality.")]
+ public bool downsampling;
+
+ [Tooltip("Forces compatibility with Forward rendered objects when working with the Deferred rendering path.")]
+ public bool forceForwardCompatibility;
+
+ [Tooltip("Enables the ambient-only mode in that the effect only affects ambient lighting. This mode is only available with the Deferred rendering path and HDR rendering.")]
+ public bool ambientOnly;
+
+ [Tooltip("Toggles the use of a higher precision depth texture with the forward rendering path (may impact performances). Has no effect with the deferred rendering path.")]
+ public bool highPrecision;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.intensity = 1f;
+ result.intensityFar = 2f;
+ result.farDistance = 100f;
+ result.radius = 0.3f;
+ result.sampleCount = SampleCount.Medium;
+ result.downsampling = true;
+ result.forceForwardCompatibility = false;
+ result.ambientOnly = false;
+ result.highPrecision = false;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AntialiasingModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AntialiasingModel.cs
new file mode 100644
index 0000000..d5bda1d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/AntialiasingModel.cs
@@ -0,0 +1,222 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class AntialiasingModel : PostProcessingModel
+{
+ public enum Method
+ {
+ Fxaa,
+ Taa
+ }
+
+ public enum FxaaPreset
+ {
+ ExtremePerformance,
+ Performance,
+ Default,
+ Quality,
+ ExtremeQuality
+ }
+
+ [Serializable]
+ public struct FxaaQualitySettings
+ {
+ [Tooltip("The amount of desired sub-pixel aliasing removal. Effects the sharpeness of the output.")]
+ [Range(0f, 1f)]
+ public float subpixelAliasingRemovalAmount;
+
+ [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
+ [Range(0.063f, 0.333f)]
+ public float edgeDetectionThreshold;
+
+ [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
+ [Range(0f, 0.0833f)]
+ public float minimumRequiredLuminance;
+
+ public static FxaaQualitySettings[] presets = new FxaaQualitySettings[5]
+ {
+ new FxaaQualitySettings
+ {
+ subpixelAliasingRemovalAmount = 0f,
+ edgeDetectionThreshold = 0.333f,
+ minimumRequiredLuminance = 0.0833f
+ },
+ new FxaaQualitySettings
+ {
+ subpixelAliasingRemovalAmount = 0.25f,
+ edgeDetectionThreshold = 0.25f,
+ minimumRequiredLuminance = 0.0833f
+ },
+ new FxaaQualitySettings
+ {
+ subpixelAliasingRemovalAmount = 0.75f,
+ edgeDetectionThreshold = 0.166f,
+ minimumRequiredLuminance = 0.0833f
+ },
+ new FxaaQualitySettings
+ {
+ subpixelAliasingRemovalAmount = 1f,
+ edgeDetectionThreshold = 0.125f,
+ minimumRequiredLuminance = 0.0625f
+ },
+ new FxaaQualitySettings
+ {
+ subpixelAliasingRemovalAmount = 1f,
+ edgeDetectionThreshold = 0.063f,
+ minimumRequiredLuminance = 0.0312f
+ }
+ };
+ }
+
+ [Serializable]
+ public struct FxaaConsoleSettings
+ {
+ [Tooltip("The amount of spread applied to the sampling coordinates while sampling for subpixel information.")]
+ [Range(0.33f, 0.5f)]
+ public float subpixelSpreadAmount;
+
+ [Tooltip("This value dictates how sharp the edges in the image are kept; a higher value implies sharper edges.")]
+ [Range(2f, 8f)]
+ public float edgeSharpnessAmount;
+
+ [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")]
+ [Range(0.125f, 0.25f)]
+ public float edgeDetectionThreshold;
+
+ [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")]
+ [Range(0.04f, 0.06f)]
+ public float minimumRequiredLuminance;
+
+ public static FxaaConsoleSettings[] presets = new FxaaConsoleSettings[5]
+ {
+ new FxaaConsoleSettings
+ {
+ subpixelSpreadAmount = 0.33f,
+ edgeSharpnessAmount = 8f,
+ edgeDetectionThreshold = 0.25f,
+ minimumRequiredLuminance = 0.06f
+ },
+ new FxaaConsoleSettings
+ {
+ subpixelSpreadAmount = 0.33f,
+ edgeSharpnessAmount = 8f,
+ edgeDetectionThreshold = 0.125f,
+ minimumRequiredLuminance = 0.06f
+ },
+ new FxaaConsoleSettings
+ {
+ subpixelSpreadAmount = 0.5f,
+ edgeSharpnessAmount = 8f,
+ edgeDetectionThreshold = 0.125f,
+ minimumRequiredLuminance = 0.05f
+ },
+ new FxaaConsoleSettings
+ {
+ subpixelSpreadAmount = 0.5f,
+ edgeSharpnessAmount = 4f,
+ edgeDetectionThreshold = 0.125f,
+ minimumRequiredLuminance = 0.04f
+ },
+ new FxaaConsoleSettings
+ {
+ subpixelSpreadAmount = 0.5f,
+ edgeSharpnessAmount = 2f,
+ edgeDetectionThreshold = 0.125f,
+ minimumRequiredLuminance = 0.04f
+ }
+ };
+ }
+
+ [Serializable]
+ public struct FxaaSettings
+ {
+ public FxaaPreset preset;
+
+ public static FxaaSettings defaultSettings
+ {
+ get
+ {
+ FxaaSettings result = default(FxaaSettings);
+ result.preset = FxaaPreset.Default;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct TaaSettings
+ {
+ [Tooltip("The diameter (in texels) inside which jitter samples are spread. Smaller values result in crisper but more aliased output, while larger values result in more stable but blurrier output.")]
+ [Range(0.1f, 1f)]
+ public float jitterSpread;
+
+ [Tooltip("Controls the amount of sharpening applied to the color buffer.")]
+ [Range(0f, 3f)]
+ public float sharpen;
+
+ [Tooltip("The blend coefficient for a stationary fragment. Controls the percentage of history sample blended into the final color.")]
+ [Range(0f, 0.99f)]
+ public float stationaryBlending;
+
+ [Tooltip("The blend coefficient for a fragment with significant motion. Controls the percentage of history sample blended into the final color.")]
+ [Range(0f, 0.99f)]
+ public float motionBlending;
+
+ public static TaaSettings defaultSettings
+ {
+ get
+ {
+ TaaSettings result = default(TaaSettings);
+ result.jitterSpread = 0.75f;
+ result.sharpen = 0.3f;
+ result.stationaryBlending = 0.95f;
+ result.motionBlending = 0.85f;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ public Method method;
+
+ public FxaaSettings fxaaSettings;
+
+ public TaaSettings taaSettings;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.method = Method.Fxaa;
+ result.fxaaSettings = FxaaSettings.defaultSettings;
+ result.taaSettings = TaaSettings.defaultSettings;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomComponent.cs
new file mode 100644
index 0000000..83d499e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomComponent.cs
@@ -0,0 +1,116 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class BloomComponent : PostProcessingComponentRenderTexture<BloomModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _AutoExposure = Shader.PropertyToID("_AutoExposure");
+
+ internal static readonly int _Threshold = Shader.PropertyToID("_Threshold");
+
+ internal static readonly int _Curve = Shader.PropertyToID("_Curve");
+
+ internal static readonly int _PrefilterOffs = Shader.PropertyToID("_PrefilterOffs");
+
+ internal static readonly int _SampleScale = Shader.PropertyToID("_SampleScale");
+
+ internal static readonly int _BaseTex = Shader.PropertyToID("_BaseTex");
+
+ internal static readonly int _BloomTex = Shader.PropertyToID("_BloomTex");
+
+ internal static readonly int _Bloom_Settings = Shader.PropertyToID("_Bloom_Settings");
+
+ internal static readonly int _Bloom_DirtTex = Shader.PropertyToID("_Bloom_DirtTex");
+
+ internal static readonly int _Bloom_DirtIntensity = Shader.PropertyToID("_Bloom_DirtIntensity");
+ }
+
+ private const int k_MaxPyramidBlurLevel = 16;
+
+ private readonly RenderTexture[] m_BlurBuffer1 = new RenderTexture[16];
+
+ private readonly RenderTexture[] m_BlurBuffer2 = new RenderTexture[16];
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.bloom.intensity > 0f)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public void Prepare(RenderTexture source, Material uberMaterial, Texture autoExposure)
+ {
+ BloomModel.BloomSettings bloom = base.model.settings.bloom;
+ BloomModel.LensDirtSettings lensDirt = base.model.settings.lensDirt;
+ Material material = context.materialFactory.Get("Hidden/Post FX/Bloom");
+ material.shaderKeywords = null;
+ material.SetTexture(Uniforms._AutoExposure, autoExposure);
+ int width = context.width / 2;
+ int num = context.height / 2;
+ RenderTextureFormat format = (Application.isMobilePlatform ? RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR);
+ float num2 = Mathf.Log(num, 2f) + bloom.radius - 8f;
+ int num3 = (int)num2;
+ int num4 = Mathf.Clamp(num3, 1, 16);
+ float thresholdLinear = bloom.thresholdLinear;
+ material.SetFloat(Uniforms._Threshold, thresholdLinear);
+ float num5 = thresholdLinear * bloom.softKnee + 1E-05f;
+ material.SetVector(value: new Vector3(thresholdLinear - num5, num5 * 2f, 0.25f / num5), nameID: Uniforms._Curve);
+ material.SetFloat(Uniforms._PrefilterOffs, bloom.antiFlicker ? (-0.5f) : 0f);
+ float num6 = 0.5f + num2 - (float)num3;
+ material.SetFloat(Uniforms._SampleScale, num6);
+ if (bloom.antiFlicker)
+ {
+ material.EnableKeyword("ANTI_FLICKER");
+ }
+ RenderTexture renderTexture = context.renderTextureFactory.Get(width, num, 0, format);
+ Graphics.Blit(source, renderTexture, material, 0);
+ RenderTexture renderTexture2 = renderTexture;
+ for (int i = 0; i < num4; i++)
+ {
+ m_BlurBuffer1[i] = context.renderTextureFactory.Get(renderTexture2.width / 2, renderTexture2.height / 2, 0, format);
+ int pass = ((i == 0) ? 1 : 2);
+ Graphics.Blit(renderTexture2, m_BlurBuffer1[i], material, pass);
+ renderTexture2 = m_BlurBuffer1[i];
+ }
+ for (int num7 = num4 - 2; num7 >= 0; num7--)
+ {
+ RenderTexture renderTexture3 = m_BlurBuffer1[num7];
+ material.SetTexture(Uniforms._BaseTex, renderTexture3);
+ m_BlurBuffer2[num7] = context.renderTextureFactory.Get(renderTexture3.width, renderTexture3.height, 0, format);
+ Graphics.Blit(renderTexture2, m_BlurBuffer2[num7], material, 3);
+ renderTexture2 = m_BlurBuffer2[num7];
+ }
+ RenderTexture renderTexture4 = renderTexture2;
+ for (int j = 0; j < 16; j++)
+ {
+ if (m_BlurBuffer1[j] != null)
+ {
+ context.renderTextureFactory.Release(m_BlurBuffer1[j]);
+ }
+ if (m_BlurBuffer2[j] != null && m_BlurBuffer2[j] != renderTexture4)
+ {
+ context.renderTextureFactory.Release(m_BlurBuffer2[j]);
+ }
+ m_BlurBuffer1[j] = null;
+ m_BlurBuffer2[j] = null;
+ }
+ context.renderTextureFactory.Release(renderTexture);
+ uberMaterial.SetTexture(Uniforms._BloomTex, renderTexture4);
+ uberMaterial.SetVector(Uniforms._Bloom_Settings, new Vector2(num6, bloom.intensity));
+ if (lensDirt.intensity > 0f && lensDirt.texture != null)
+ {
+ uberMaterial.SetTexture(Uniforms._Bloom_DirtTex, lensDirt.texture);
+ uberMaterial.SetFloat(Uniforms._Bloom_DirtIntensity, lensDirt.intensity);
+ uberMaterial.EnableKeyword("BLOOM_LENS_DIRT");
+ }
+ else
+ {
+ uberMaterial.EnableKeyword("BLOOM");
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomModel.cs
new file mode 100644
index 0000000..0569d62
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BloomModel.cs
@@ -0,0 +1,117 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class BloomModel : PostProcessingModel
+{
+ [Serializable]
+ public struct BloomSettings
+ {
+ [Min(0f)]
+ [Tooltip("Strength of the bloom filter.")]
+ public float intensity;
+
+ [Min(0f)]
+ [Tooltip("Filters out pixels under this level of brightness.")]
+ public float threshold;
+
+ [Range(0f, 1f)]
+ [Tooltip("Makes transition between under/over-threshold gradual (0 = hard threshold, 1 = soft threshold).")]
+ public float softKnee;
+
+ [Range(1f, 7f)]
+ [Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")]
+ public float radius;
+
+ [Tooltip("Reduces flashing noise with an additional filter.")]
+ public bool antiFlicker;
+
+ public float thresholdLinear
+ {
+ get
+ {
+ return Mathf.GammaToLinearSpace(threshold);
+ }
+ set
+ {
+ threshold = Mathf.LinearToGammaSpace(value);
+ }
+ }
+
+ public static BloomSettings defaultSettings
+ {
+ get
+ {
+ BloomSettings result = default(BloomSettings);
+ result.intensity = 0.5f;
+ result.threshold = 1.1f;
+ result.softKnee = 0.5f;
+ result.radius = 4f;
+ result.antiFlicker = false;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct LensDirtSettings
+ {
+ [Tooltip("Dirtiness texture to add smudges or dust to the lens.")]
+ public Texture texture;
+
+ [Min(0f)]
+ [Tooltip("Amount of lens dirtiness.")]
+ public float intensity;
+
+ public static LensDirtSettings defaultSettings
+ {
+ get
+ {
+ LensDirtSettings result = default(LensDirtSettings);
+ result.texture = null;
+ result.intensity = 3f;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ public BloomSettings bloom;
+
+ public LensDirtSettings lensDirt;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.bloom = BloomSettings.defaultSettings;
+ result.lensDirt = LensDirtSettings.defaultSettings;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsComponent.cs
new file mode 100644
index 0000000..2bc5413
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsComponent.cs
@@ -0,0 +1,237 @@
+using System.Collections.Generic;
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class BuiltinDebugViewsComponent : PostProcessingComponentCommandBuffer<BuiltinDebugViewsModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _DepthScale = Shader.PropertyToID("_DepthScale");
+
+ internal static readonly int _TempRT = Shader.PropertyToID("_TempRT");
+
+ internal static readonly int _Opacity = Shader.PropertyToID("_Opacity");
+
+ internal static readonly int _MainTex = Shader.PropertyToID("_MainTex");
+
+ internal static readonly int _TempRT2 = Shader.PropertyToID("_TempRT2");
+
+ internal static readonly int _Amplitude = Shader.PropertyToID("_Amplitude");
+
+ internal static readonly int _Scale = Shader.PropertyToID("_Scale");
+ }
+
+ private enum Pass
+ {
+ Depth,
+ Normals,
+ MovecOpacity,
+ MovecImaging,
+ MovecArrows
+ }
+
+ private class ArrowArray
+ {
+ public Mesh mesh { get; private set; }
+
+ public int columnCount { get; private set; }
+
+ public int rowCount { get; private set; }
+
+ public void BuildMesh(int columns, int rows)
+ {
+ Vector3[] array = new Vector3[6]
+ {
+ new Vector3(0f, 0f, 0f),
+ new Vector3(0f, 1f, 0f),
+ new Vector3(0f, 1f, 0f),
+ new Vector3(-1f, 1f, 0f),
+ new Vector3(0f, 1f, 0f),
+ new Vector3(1f, 1f, 0f)
+ };
+ int num = 6 * columns * rows;
+ List<Vector3> list = new List<Vector3>(num);
+ List<Vector2> list2 = new List<Vector2>(num);
+ for (int i = 0; i < rows; i++)
+ {
+ for (int j = 0; j < columns; j++)
+ {
+ Vector2 item = new Vector2((0.5f + (float)j) / (float)columns, (0.5f + (float)i) / (float)rows);
+ for (int k = 0; k < 6; k++)
+ {
+ list.Add(array[k]);
+ list2.Add(item);
+ }
+ }
+ }
+ int[] array2 = new int[num];
+ for (int l = 0; l < num; l++)
+ {
+ array2[l] = l;
+ }
+ mesh = new Mesh
+ {
+ hideFlags = HideFlags.DontSave
+ };
+ mesh.SetVertices(list);
+ mesh.SetUVs(0, list2);
+ mesh.SetIndices(array2, MeshTopology.Lines, 0);
+ mesh.UploadMeshData(markNoLongerReadable: true);
+ columnCount = columns;
+ rowCount = rows;
+ }
+
+ public void Release()
+ {
+ GraphicsUtils.Destroy(mesh);
+ mesh = null;
+ }
+ }
+
+ private const string k_ShaderString = "Hidden/Post FX/Builtin Debug Views";
+
+ private ArrowArray m_Arrows;
+
+ public override bool active
+ {
+ get
+ {
+ if (!base.model.IsModeActive(BuiltinDebugViewsModel.Mode.Depth) && !base.model.IsModeActive(BuiltinDebugViewsModel.Mode.Normals))
+ {
+ return base.model.IsModeActive(BuiltinDebugViewsModel.Mode.MotionVectors);
+ }
+ return true;
+ }
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ BuiltinDebugViewsModel.Mode mode = base.model.settings.mode;
+ DepthTextureMode depthTextureMode = DepthTextureMode.None;
+ switch (mode)
+ {
+ case BuiltinDebugViewsModel.Mode.Normals:
+ depthTextureMode |= DepthTextureMode.DepthNormals;
+ break;
+ case BuiltinDebugViewsModel.Mode.MotionVectors:
+ depthTextureMode |= DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
+ break;
+ case BuiltinDebugViewsModel.Mode.Depth:
+ depthTextureMode |= DepthTextureMode.Depth;
+ break;
+ }
+ return depthTextureMode;
+ }
+
+ public override CameraEvent GetCameraEvent()
+ {
+ if (base.model.settings.mode != BuiltinDebugViewsModel.Mode.MotionVectors)
+ {
+ return CameraEvent.BeforeImageEffectsOpaque;
+ }
+ return CameraEvent.BeforeImageEffects;
+ }
+
+ public override string GetName()
+ {
+ return "Builtin Debug Views";
+ }
+
+ public override void PopulateCommandBuffer(CommandBuffer cb)
+ {
+ BuiltinDebugViewsModel.Settings settings = base.model.settings;
+ Material material = context.materialFactory.Get("Hidden/Post FX/Builtin Debug Views");
+ material.shaderKeywords = null;
+ if (context.isGBufferAvailable)
+ {
+ material.EnableKeyword("SOURCE_GBUFFER");
+ }
+ switch (settings.mode)
+ {
+ case BuiltinDebugViewsModel.Mode.Depth:
+ DepthPass(cb);
+ break;
+ case BuiltinDebugViewsModel.Mode.Normals:
+ DepthNormalsPass(cb);
+ break;
+ case BuiltinDebugViewsModel.Mode.MotionVectors:
+ MotionVectorsPass(cb);
+ break;
+ }
+ context.Interrupt();
+ }
+
+ private void DepthPass(CommandBuffer cb)
+ {
+ Material mat = context.materialFactory.Get("Hidden/Post FX/Builtin Debug Views");
+ BuiltinDebugViewsModel.DepthSettings depth = base.model.settings.depth;
+ cb.SetGlobalFloat(Uniforms._DepthScale, 1f / depth.scale);
+ cb.Blit(null, BuiltinRenderTextureType.CameraTarget, mat, 0);
+ }
+
+ private void DepthNormalsPass(CommandBuffer cb)
+ {
+ Material mat = context.materialFactory.Get("Hidden/Post FX/Builtin Debug Views");
+ cb.Blit(null, BuiltinRenderTextureType.CameraTarget, mat, 1);
+ }
+
+ private void MotionVectorsPass(CommandBuffer cb)
+ {
+ Material material = context.materialFactory.Get("Hidden/Post FX/Builtin Debug Views");
+ BuiltinDebugViewsModel.MotionVectorsSettings motionVectors = base.model.settings.motionVectors;
+ int num = Uniforms._TempRT;
+ cb.GetTemporaryRT(num, context.width, context.height, 0, FilterMode.Bilinear);
+ cb.SetGlobalFloat(Uniforms._Opacity, motionVectors.sourceOpacity);
+ cb.SetGlobalTexture(Uniforms._MainTex, BuiltinRenderTextureType.CameraTarget);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, num, material, 2);
+ if (motionVectors.motionImageOpacity > 0f && motionVectors.motionImageAmplitude > 0f)
+ {
+ int tempRT = Uniforms._TempRT2;
+ cb.GetTemporaryRT(tempRT, context.width, context.height, 0, FilterMode.Bilinear);
+ cb.SetGlobalFloat(Uniforms._Opacity, motionVectors.motionImageOpacity);
+ cb.SetGlobalFloat(Uniforms._Amplitude, motionVectors.motionImageAmplitude);
+ cb.SetGlobalTexture(Uniforms._MainTex, num);
+ cb.Blit(num, tempRT, material, 3);
+ cb.ReleaseTemporaryRT(num);
+ num = tempRT;
+ }
+ if (motionVectors.motionVectorsOpacity > 0f && motionVectors.motionVectorsAmplitude > 0f)
+ {
+ PrepareArrows();
+ float num2 = 1f / (float)motionVectors.motionVectorsResolution;
+ float x = num2 * (float)context.height / (float)context.width;
+ cb.SetGlobalVector(Uniforms._Scale, new Vector2(x, num2));
+ cb.SetGlobalFloat(Uniforms._Opacity, motionVectors.motionVectorsOpacity);
+ cb.SetGlobalFloat(Uniforms._Amplitude, motionVectors.motionVectorsAmplitude);
+ cb.DrawMesh(m_Arrows.mesh, Matrix4x4.identity, material, 0, 4);
+ }
+ cb.SetGlobalTexture(Uniforms._MainTex, num);
+ cb.Blit(num, BuiltinRenderTextureType.CameraTarget);
+ cb.ReleaseTemporaryRT(num);
+ }
+
+ private void PrepareArrows()
+ {
+ int motionVectorsResolution = base.model.settings.motionVectors.motionVectorsResolution;
+ int num = motionVectorsResolution * Screen.width / Screen.height;
+ if (m_Arrows == null)
+ {
+ m_Arrows = new ArrowArray();
+ }
+ if (m_Arrows.columnCount != num || m_Arrows.rowCount != motionVectorsResolution)
+ {
+ m_Arrows.Release();
+ m_Arrows.BuildMesh(num, motionVectorsResolution);
+ }
+ }
+
+ public override void OnDisable()
+ {
+ if (m_Arrows != null)
+ {
+ m_Arrows.Release();
+ }
+ m_Arrows = null;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsModel.cs
new file mode 100644
index 0000000..eab95e0
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/BuiltinDebugViewsModel.cs
@@ -0,0 +1,141 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class BuiltinDebugViewsModel : PostProcessingModel
+{
+ [Serializable]
+ public struct DepthSettings
+ {
+ [Range(0f, 1f)]
+ [Tooltip("Scales the camera far plane before displaying the depth map.")]
+ public float scale;
+
+ public static DepthSettings defaultSettings
+ {
+ get
+ {
+ DepthSettings result = default(DepthSettings);
+ result.scale = 1f;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct MotionVectorsSettings
+ {
+ [Range(0f, 1f)]
+ [Tooltip("Opacity of the source render.")]
+ public float sourceOpacity;
+
+ [Range(0f, 1f)]
+ [Tooltip("Opacity of the per-pixel motion vector colors.")]
+ public float motionImageOpacity;
+
+ [Min(0f)]
+ [Tooltip("Because motion vectors are mainly very small vectors, you can use this setting to make them more visible.")]
+ public float motionImageAmplitude;
+
+ [Range(0f, 1f)]
+ [Tooltip("Opacity for the motion vector arrows.")]
+ public float motionVectorsOpacity;
+
+ [Range(8f, 64f)]
+ [Tooltip("The arrow density on screen.")]
+ public int motionVectorsResolution;
+
+ [Min(0f)]
+ [Tooltip("Tweaks the arrows length.")]
+ public float motionVectorsAmplitude;
+
+ public static MotionVectorsSettings defaultSettings
+ {
+ get
+ {
+ MotionVectorsSettings result = default(MotionVectorsSettings);
+ result.sourceOpacity = 1f;
+ result.motionImageOpacity = 0f;
+ result.motionImageAmplitude = 16f;
+ result.motionVectorsOpacity = 1f;
+ result.motionVectorsResolution = 24;
+ result.motionVectorsAmplitude = 64f;
+ return result;
+ }
+ }
+ }
+
+ public enum Mode
+ {
+ None,
+ Depth,
+ Normals,
+ MotionVectors,
+ AmbientOcclusion,
+ EyeAdaptation,
+ FocusPlane,
+ PreGradingLog,
+ LogLut,
+ UserLut
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ public Mode mode;
+
+ public DepthSettings depth;
+
+ public MotionVectorsSettings motionVectors;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.mode = Mode.None;
+ result.depth = DepthSettings.defaultSettings;
+ result.motionVectors = MotionVectorsSettings.defaultSettings;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public bool willInterrupt
+ {
+ get
+ {
+ if (!IsModeActive(Mode.None) && !IsModeActive(Mode.EyeAdaptation) && !IsModeActive(Mode.PreGradingLog) && !IsModeActive(Mode.LogLut))
+ {
+ return !IsModeActive(Mode.UserLut);
+ }
+ return false;
+ }
+ }
+
+ public override void Reset()
+ {
+ settings = Settings.defaultSettings;
+ }
+
+ public bool IsModeActive(Mode mode)
+ {
+ return m_Settings.mode == mode;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationComponent.cs
new file mode 100644
index 0000000..ffe2df8
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationComponent.cs
@@ -0,0 +1,63 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class ChromaticAberrationComponent : PostProcessingComponentRenderTexture<ChromaticAberrationModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _ChromaticAberration_Amount = Shader.PropertyToID("_ChromaticAberration_Amount");
+
+ internal static readonly int _ChromaticAberration_Spectrum = Shader.PropertyToID("_ChromaticAberration_Spectrum");
+ }
+
+ private Texture2D m_SpectrumLut;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.intensity > 0f)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override void OnDisable()
+ {
+ GraphicsUtils.Destroy(m_SpectrumLut);
+ m_SpectrumLut = null;
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ ChromaticAberrationModel.Settings settings = base.model.settings;
+ Texture2D texture2D = settings.spectralTexture;
+ if (texture2D == null)
+ {
+ if (m_SpectrumLut == null)
+ {
+ m_SpectrumLut = new Texture2D(3, 1, TextureFormat.RGB24, mipChain: false)
+ {
+ name = "Chromatic Aberration Spectrum Lookup",
+ filterMode = FilterMode.Bilinear,
+ wrapMode = TextureWrapMode.Clamp,
+ anisoLevel = 0,
+ hideFlags = HideFlags.DontSave
+ };
+ Color[] pixels = new Color[3]
+ {
+ new Color(1f, 0f, 0f),
+ new Color(0f, 1f, 0f),
+ new Color(0f, 0f, 1f)
+ };
+ m_SpectrumLut.SetPixels(pixels);
+ m_SpectrumLut.Apply();
+ }
+ texture2D = m_SpectrumLut;
+ }
+ uberMaterial.EnableKeyword("CHROMATIC_ABERRATION");
+ uberMaterial.SetFloat(Uniforms._ChromaticAberration_Amount, settings.intensity * 0.03f);
+ uberMaterial.SetTexture(Uniforms._ChromaticAberration_Spectrum, texture2D);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationModel.cs
new file mode 100644
index 0000000..a648f9f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ChromaticAberrationModel.cs
@@ -0,0 +1,49 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class ChromaticAberrationModel : PostProcessingModel
+{
+ [Serializable]
+ public struct Settings
+ {
+ [Tooltip("Shift the hue of chromatic aberrations.")]
+ public Texture2D spectralTexture;
+
+ [Range(0f, 1f)]
+ [Tooltip("Amount of tangential distortion.")]
+ public float intensity;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.spectralTexture = null;
+ result.intensity = 0.1f;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingComponent.cs
new file mode 100644
index 0000000..948d9c6
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingComponent.cs
@@ -0,0 +1,352 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class ColorGradingComponent : PostProcessingComponentRenderTexture<ColorGradingModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _LutParams = Shader.PropertyToID("_LutParams");
+
+ internal static readonly int _NeutralTonemapperParams1 = Shader.PropertyToID("_NeutralTonemapperParams1");
+
+ internal static readonly int _NeutralTonemapperParams2 = Shader.PropertyToID("_NeutralTonemapperParams2");
+
+ internal static readonly int _HueShift = Shader.PropertyToID("_HueShift");
+
+ internal static readonly int _Saturation = Shader.PropertyToID("_Saturation");
+
+ internal static readonly int _Contrast = Shader.PropertyToID("_Contrast");
+
+ internal static readonly int _Balance = Shader.PropertyToID("_Balance");
+
+ internal static readonly int _Lift = Shader.PropertyToID("_Lift");
+
+ internal static readonly int _InvGamma = Shader.PropertyToID("_InvGamma");
+
+ internal static readonly int _Gain = Shader.PropertyToID("_Gain");
+
+ internal static readonly int _Slope = Shader.PropertyToID("_Slope");
+
+ internal static readonly int _Power = Shader.PropertyToID("_Power");
+
+ internal static readonly int _Offset = Shader.PropertyToID("_Offset");
+
+ internal static readonly int _ChannelMixerRed = Shader.PropertyToID("_ChannelMixerRed");
+
+ internal static readonly int _ChannelMixerGreen = Shader.PropertyToID("_ChannelMixerGreen");
+
+ internal static readonly int _ChannelMixerBlue = Shader.PropertyToID("_ChannelMixerBlue");
+
+ internal static readonly int _Curves = Shader.PropertyToID("_Curves");
+
+ internal static readonly int _LogLut = Shader.PropertyToID("_LogLut");
+
+ internal static readonly int _LogLut_Params = Shader.PropertyToID("_LogLut_Params");
+
+ internal static readonly int _ExposureEV = Shader.PropertyToID("_ExposureEV");
+ }
+
+ private const int k_InternalLogLutSize = 32;
+
+ private const int k_CurvePrecision = 128;
+
+ private const float k_CurveStep = 1f / 128f;
+
+ private Texture2D m_GradingCurves;
+
+ private Color[] m_pixels = new Color[256];
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ private float StandardIlluminantY(float x)
+ {
+ return 2.87f * x - 3f * x * x - 0.27509508f;
+ }
+
+ private Vector3 CIExyToLMS(float x, float y)
+ {
+ float num = 1f;
+ float num2 = num * x / y;
+ float num3 = num * (1f - x - y) / y;
+ float x2 = 0.7328f * num2 + 0.4296f * num - 0.1624f * num3;
+ float y2 = -0.7036f * num2 + 1.6975f * num + 0.0061f * num3;
+ float z = 0.003f * num2 + 0.0136f * num + 0.9834f * num3;
+ return new Vector3(x2, y2, z);
+ }
+
+ private Vector3 CalculateColorBalance(float temperature, float tint)
+ {
+ float num = temperature / 55f;
+ float num2 = tint / 55f;
+ float x = 0.31271f - num * ((num < 0f) ? 0.1f : 0.05f);
+ float y = StandardIlluminantY(x) + num2 * 0.05f;
+ Vector3 vector = new Vector3(0.949237f, 1.03542f, 1.08728f);
+ Vector3 vector2 = CIExyToLMS(x, y);
+ return new Vector3(vector.x / vector2.x, vector.y / vector2.y, vector.z / vector2.z);
+ }
+
+ private static Color NormalizeColor(Color c)
+ {
+ float num = (c.r + c.g + c.b) / 3f;
+ if (Mathf.Approximately(num, 0f))
+ {
+ return new Color(1f, 1f, 1f, c.a);
+ }
+ Color result = default(Color);
+ result.r = c.r / num;
+ result.g = c.g / num;
+ result.b = c.b / num;
+ result.a = c.a;
+ return result;
+ }
+
+ private static Vector3 ClampVector(Vector3 v, float min, float max)
+ {
+ return new Vector3(Mathf.Clamp(v.x, min, max), Mathf.Clamp(v.y, min, max), Mathf.Clamp(v.z, min, max));
+ }
+
+ public static Vector3 GetLiftValue(Color lift)
+ {
+ Color color = NormalizeColor(lift);
+ float num = (color.r + color.g + color.b) / 3f;
+ float x = (color.r - num) * 0.1f + lift.a;
+ float y = (color.g - num) * 0.1f + lift.a;
+ float z = (color.b - num) * 0.1f + lift.a;
+ return ClampVector(new Vector3(x, y, z), -1f, 1f);
+ }
+
+ public static Vector3 GetGammaValue(Color gamma)
+ {
+ Color color = NormalizeColor(gamma);
+ float num = (color.r + color.g + color.b) / 3f;
+ gamma.a *= ((gamma.a < 0f) ? 0.8f : 5f);
+ float b = Mathf.Pow(2f, (color.r - num) * 0.5f) + gamma.a;
+ float b2 = Mathf.Pow(2f, (color.g - num) * 0.5f) + gamma.a;
+ float b3 = Mathf.Pow(2f, (color.b - num) * 0.5f) + gamma.a;
+ float x = 1f / Mathf.Max(0.01f, b);
+ float y = 1f / Mathf.Max(0.01f, b2);
+ float z = 1f / Mathf.Max(0.01f, b3);
+ return ClampVector(new Vector3(x, y, z), 0f, 5f);
+ }
+
+ public static Vector3 GetGainValue(Color gain)
+ {
+ Color color = NormalizeColor(gain);
+ float num = (color.r + color.g + color.b) / 3f;
+ gain.a *= ((gain.a > 0f) ? 3f : 1f);
+ float x = Mathf.Pow(2f, (color.r - num) * 0.5f) + gain.a;
+ float y = Mathf.Pow(2f, (color.g - num) * 0.5f) + gain.a;
+ float z = Mathf.Pow(2f, (color.b - num) * 0.5f) + gain.a;
+ return ClampVector(new Vector3(x, y, z), 0f, 4f);
+ }
+
+ public static void CalculateLiftGammaGain(Color lift, Color gamma, Color gain, out Vector3 outLift, out Vector3 outGamma, out Vector3 outGain)
+ {
+ outLift = GetLiftValue(lift);
+ outGamma = GetGammaValue(gamma);
+ outGain = GetGainValue(gain);
+ }
+
+ public static Vector3 GetSlopeValue(Color slope)
+ {
+ Color color = NormalizeColor(slope);
+ float num = (color.r + color.g + color.b) / 3f;
+ slope.a *= 0.5f;
+ float x = (color.r - num) * 0.1f + slope.a + 1f;
+ float y = (color.g - num) * 0.1f + slope.a + 1f;
+ float z = (color.b - num) * 0.1f + slope.a + 1f;
+ return ClampVector(new Vector3(x, y, z), 0f, 2f);
+ }
+
+ public static Vector3 GetPowerValue(Color power)
+ {
+ Color color = NormalizeColor(power);
+ float num = (color.r + color.g + color.b) / 3f;
+ power.a *= 0.5f;
+ float b = (color.r - num) * 0.1f + power.a + 1f;
+ float b2 = (color.g - num) * 0.1f + power.a + 1f;
+ float b3 = (color.b - num) * 0.1f + power.a + 1f;
+ float x = 1f / Mathf.Max(0.01f, b);
+ float y = 1f / Mathf.Max(0.01f, b2);
+ float z = 1f / Mathf.Max(0.01f, b3);
+ return ClampVector(new Vector3(x, y, z), 0.5f, 2.5f);
+ }
+
+ public static Vector3 GetOffsetValue(Color offset)
+ {
+ Color color = NormalizeColor(offset);
+ float num = (color.r + color.g + color.b) / 3f;
+ offset.a *= 0.5f;
+ float x = (color.r - num) * 0.05f + offset.a;
+ float y = (color.g - num) * 0.05f + offset.a;
+ float z = (color.b - num) * 0.05f + offset.a;
+ return ClampVector(new Vector3(x, y, z), -0.8f, 0.8f);
+ }
+
+ public static void CalculateSlopePowerOffset(Color slope, Color power, Color offset, out Vector3 outSlope, out Vector3 outPower, out Vector3 outOffset)
+ {
+ outSlope = GetSlopeValue(slope);
+ outPower = GetPowerValue(power);
+ outOffset = GetOffsetValue(offset);
+ }
+
+ private TextureFormat GetCurveFormat()
+ {
+ if (SystemInfo.SupportsTextureFormat(TextureFormat.RGBAHalf))
+ {
+ return TextureFormat.RGBAHalf;
+ }
+ return TextureFormat.RGBA32;
+ }
+
+ private Texture2D GetCurveTexture()
+ {
+ if (m_GradingCurves == null)
+ {
+ m_GradingCurves = new Texture2D(128, 2, GetCurveFormat(), mipChain: false, linear: true)
+ {
+ name = "Internal Curves Texture",
+ hideFlags = HideFlags.DontSave,
+ anisoLevel = 0,
+ wrapMode = TextureWrapMode.Clamp,
+ filterMode = FilterMode.Bilinear
+ };
+ }
+ ColorGradingModel.CurvesSettings curves = base.model.settings.curves;
+ curves.hueVShue.Cache();
+ curves.hueVSsat.Cache();
+ for (int i = 0; i < 128; i++)
+ {
+ float t = (float)i * (1f / 128f);
+ float r = curves.hueVShue.Evaluate(t);
+ float g = curves.hueVSsat.Evaluate(t);
+ float b = curves.satVSsat.Evaluate(t);
+ float a = curves.lumVSsat.Evaluate(t);
+ m_pixels[i] = new Color(r, g, b, a);
+ float a2 = curves.master.Evaluate(t);
+ float r2 = curves.red.Evaluate(t);
+ float g2 = curves.green.Evaluate(t);
+ float b2 = curves.blue.Evaluate(t);
+ m_pixels[i + 128] = new Color(r2, g2, b2, a2);
+ }
+ m_GradingCurves.SetPixels(m_pixels);
+ m_GradingCurves.Apply(updateMipmaps: false, makeNoLongerReadable: false);
+ return m_GradingCurves;
+ }
+
+ private bool IsLogLutValid(RenderTexture lut)
+ {
+ if (lut != null && lut.IsCreated())
+ {
+ return lut.height == 32;
+ }
+ return false;
+ }
+
+ private RenderTextureFormat GetLutFormat()
+ {
+ if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
+ {
+ return RenderTextureFormat.ARGBHalf;
+ }
+ return RenderTextureFormat.ARGB32;
+ }
+
+ private void GenerateLut()
+ {
+ ColorGradingModel.Settings settings = base.model.settings;
+ if (!IsLogLutValid(base.model.bakedLut))
+ {
+ GraphicsUtils.Destroy(base.model.bakedLut);
+ base.model.bakedLut = new RenderTexture(1024, 32, 0, GetLutFormat())
+ {
+ name = "Color Grading Log LUT",
+ hideFlags = HideFlags.DontSave,
+ filterMode = FilterMode.Bilinear,
+ wrapMode = TextureWrapMode.Clamp,
+ anisoLevel = 0
+ };
+ }
+ Material material = context.materialFactory.Get("Hidden/Post FX/Lut Generator");
+ material.SetVector(Uniforms._LutParams, new Vector4(32f, 0.00048828125f, 1f / 64f, 1.032258f));
+ material.shaderKeywords = null;
+ ColorGradingModel.TonemappingSettings tonemapping = settings.tonemapping;
+ switch (tonemapping.tonemapper)
+ {
+ case ColorGradingModel.Tonemapper.Neutral:
+ {
+ material.EnableKeyword("TONEMAPPING_NEUTRAL");
+ float num = tonemapping.neutralBlackIn * 20f + 1f;
+ float num2 = tonemapping.neutralBlackOut * 10f + 1f;
+ float num3 = tonemapping.neutralWhiteIn / 20f;
+ float num4 = 1f - tonemapping.neutralWhiteOut / 20f;
+ float t = num / num2;
+ float t2 = num3 / num4;
+ float y = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, t));
+ float z = Mathf.LerpUnclamped(0.01f, 0.24f, t2);
+ float w = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.2f, t));
+ material.SetVector(Uniforms._NeutralTonemapperParams1, new Vector4(0.2f, y, z, w));
+ material.SetVector(Uniforms._NeutralTonemapperParams2, new Vector4(0.02f, 0.3f, tonemapping.neutralWhiteLevel, tonemapping.neutralWhiteClip / 10f));
+ break;
+ }
+ case ColorGradingModel.Tonemapper.ACES:
+ material.EnableKeyword("TONEMAPPING_FILMIC");
+ break;
+ }
+ material.SetFloat(Uniforms._HueShift, settings.basic.hueShift / 360f);
+ material.SetFloat(Uniforms._Saturation, settings.basic.saturation);
+ material.SetFloat(Uniforms._Contrast, settings.basic.contrast);
+ material.SetVector(Uniforms._Balance, CalculateColorBalance(settings.basic.temperature, settings.basic.tint));
+ CalculateLiftGammaGain(settings.colorWheels.linear.lift, settings.colorWheels.linear.gamma, settings.colorWheels.linear.gain, out var outLift, out var outGamma, out var outGain);
+ material.SetVector(Uniforms._Lift, outLift);
+ material.SetVector(Uniforms._InvGamma, outGamma);
+ material.SetVector(Uniforms._Gain, outGain);
+ CalculateSlopePowerOffset(settings.colorWheels.log.slope, settings.colorWheels.log.power, settings.colorWheels.log.offset, out var outSlope, out var outPower, out var outOffset);
+ material.SetVector(Uniforms._Slope, outSlope);
+ material.SetVector(Uniforms._Power, outPower);
+ material.SetVector(Uniforms._Offset, outOffset);
+ material.SetVector(Uniforms._ChannelMixerRed, settings.channelMixer.red);
+ material.SetVector(Uniforms._ChannelMixerGreen, settings.channelMixer.green);
+ material.SetVector(Uniforms._ChannelMixerBlue, settings.channelMixer.blue);
+ material.SetTexture(Uniforms._Curves, GetCurveTexture());
+ Graphics.Blit(null, base.model.bakedLut, material, 0);
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ if (base.model.isDirty || !IsLogLutValid(base.model.bakedLut))
+ {
+ GenerateLut();
+ base.model.isDirty = false;
+ }
+ uberMaterial.EnableKeyword(context.profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.PreGradingLog) ? "COLOR_GRADING_LOG_VIEW" : "COLOR_GRADING");
+ RenderTexture bakedLut = base.model.bakedLut;
+ uberMaterial.SetTexture(Uniforms._LogLut, bakedLut);
+ uberMaterial.SetVector(Uniforms._LogLut_Params, new Vector3(1f / (float)bakedLut.width, 1f / (float)bakedLut.height, (float)bakedLut.height - 1f));
+ float value = Mathf.Exp(base.model.settings.basic.postExposure * 0.6931472f);
+ uberMaterial.SetFloat(Uniforms._ExposureEV, value);
+ }
+
+ public void OnGUI()
+ {
+ RenderTexture bakedLut = base.model.bakedLut;
+ GUI.DrawTexture(new Rect(context.viewport.x * (float)Screen.width + 8f, 8f, bakedLut.width, bakedLut.height), bakedLut);
+ }
+
+ public override void OnDisable()
+ {
+ GraphicsUtils.Destroy(m_GradingCurves);
+ GraphicsUtils.Destroy(base.model.bakedLut);
+ m_GradingCurves = null;
+ base.model.bakedLut = null;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingCurve.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingCurve.cs
new file mode 100644
index 0000000..49ea13a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingCurve.cs
@@ -0,0 +1,64 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public sealed class ColorGradingCurve
+{
+ public AnimationCurve curve;
+
+ [SerializeField]
+ private bool m_Loop;
+
+ [SerializeField]
+ private float m_ZeroValue;
+
+ [SerializeField]
+ private float m_Range;
+
+ private AnimationCurve m_InternalLoopingCurve;
+
+ public ColorGradingCurve(AnimationCurve curve, float zeroValue, bool loop, Vector2 bounds)
+ {
+ this.curve = curve;
+ m_ZeroValue = zeroValue;
+ m_Loop = loop;
+ m_Range = bounds.magnitude;
+ }
+
+ public void Cache()
+ {
+ if (!m_Loop)
+ {
+ return;
+ }
+ int length = curve.length;
+ if (length >= 2)
+ {
+ if (m_InternalLoopingCurve == null)
+ {
+ m_InternalLoopingCurve = new AnimationCurve();
+ }
+ Keyframe key = curve[length - 1];
+ key.time -= m_Range;
+ Keyframe key2 = curve[0];
+ key2.time += m_Range;
+ m_InternalLoopingCurve.keys = curve.keys;
+ m_InternalLoopingCurve.AddKey(key);
+ m_InternalLoopingCurve.AddKey(key2);
+ }
+ }
+
+ public float Evaluate(float t)
+ {
+ if (curve.length == 0)
+ {
+ return m_ZeroValue;
+ }
+ if (!m_Loop || curve.length == 1)
+ {
+ return curve.Evaluate(t);
+ }
+ return m_InternalLoopingCurve.Evaluate(t);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingModel.cs
new file mode 100644
index 0000000..5d5a45b
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ColorGradingModel.cs
@@ -0,0 +1,319 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class ColorGradingModel : PostProcessingModel
+{
+ public enum Tonemapper
+ {
+ None,
+ ACES,
+ Neutral
+ }
+
+ [Serializable]
+ public struct TonemappingSettings
+ {
+ [Tooltip("Tonemapping algorithm to use at the end of the color grading process. Use \"Neutral\" if you need a customizable tonemapper or \"Filmic\" to give a standard filmic look to your scenes.")]
+ public Tonemapper tonemapper;
+
+ [Range(-0.1f, 0.1f)]
+ public float neutralBlackIn;
+
+ [Range(1f, 20f)]
+ public float neutralWhiteIn;
+
+ [Range(-0.09f, 0.1f)]
+ public float neutralBlackOut;
+
+ [Range(1f, 19f)]
+ public float neutralWhiteOut;
+
+ [Range(0.1f, 20f)]
+ public float neutralWhiteLevel;
+
+ [Range(1f, 10f)]
+ public float neutralWhiteClip;
+
+ public static TonemappingSettings defaultSettings
+ {
+ get
+ {
+ TonemappingSettings result = default(TonemappingSettings);
+ result.tonemapper = Tonemapper.Neutral;
+ result.neutralBlackIn = 0.02f;
+ result.neutralWhiteIn = 10f;
+ result.neutralBlackOut = 0f;
+ result.neutralWhiteOut = 10f;
+ result.neutralWhiteLevel = 5.3f;
+ result.neutralWhiteClip = 10f;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct BasicSettings
+ {
+ [Tooltip("Adjusts the overall exposure of the scene in EV units. This is applied after HDR effect and right before tonemapping so it won't affect previous effects in the chain.")]
+ public float postExposure;
+
+ [Range(-100f, 100f)]
+ [Tooltip("Sets the white balance to a custom color temperature.")]
+ public float temperature;
+
+ [Range(-100f, 100f)]
+ [Tooltip("Sets the white balance to compensate for a green or magenta tint.")]
+ public float tint;
+
+ [Range(-180f, 180f)]
+ [Tooltip("Shift the hue of all colors.")]
+ public float hueShift;
+
+ [Range(0f, 2f)]
+ [Tooltip("Pushes the intensity of all colors.")]
+ public float saturation;
+
+ [Range(0f, 2f)]
+ [Tooltip("Expands or shrinks the overall range of tonal values.")]
+ public float contrast;
+
+ public static BasicSettings defaultSettings
+ {
+ get
+ {
+ BasicSettings result = default(BasicSettings);
+ result.postExposure = 0f;
+ result.temperature = 0f;
+ result.tint = 0f;
+ result.hueShift = 0f;
+ result.saturation = 1f;
+ result.contrast = 1f;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct ChannelMixerSettings
+ {
+ public Vector3 red;
+
+ public Vector3 green;
+
+ public Vector3 blue;
+
+ [HideInInspector]
+ public int currentEditingChannel;
+
+ public static ChannelMixerSettings defaultSettings
+ {
+ get
+ {
+ ChannelMixerSettings result = default(ChannelMixerSettings);
+ result.red = new Vector3(1f, 0f, 0f);
+ result.green = new Vector3(0f, 1f, 0f);
+ result.blue = new Vector3(0f, 0f, 1f);
+ result.currentEditingChannel = 0;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct LogWheelsSettings
+ {
+ [Trackball("GetSlopeValue")]
+ public Color slope;
+
+ [Trackball("GetPowerValue")]
+ public Color power;
+
+ [Trackball("GetOffsetValue")]
+ public Color offset;
+
+ public static LogWheelsSettings defaultSettings
+ {
+ get
+ {
+ LogWheelsSettings result = default(LogWheelsSettings);
+ result.slope = Color.clear;
+ result.power = Color.clear;
+ result.offset = Color.clear;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct LinearWheelsSettings
+ {
+ [Trackball("GetLiftValue")]
+ public Color lift;
+
+ [Trackball("GetGammaValue")]
+ public Color gamma;
+
+ [Trackball("GetGainValue")]
+ public Color gain;
+
+ public static LinearWheelsSettings defaultSettings
+ {
+ get
+ {
+ LinearWheelsSettings result = default(LinearWheelsSettings);
+ result.lift = Color.clear;
+ result.gamma = Color.clear;
+ result.gain = Color.clear;
+ return result;
+ }
+ }
+ }
+
+ public enum ColorWheelMode
+ {
+ Linear,
+ Log
+ }
+
+ [Serializable]
+ public struct ColorWheelsSettings
+ {
+ public ColorWheelMode mode;
+
+ [TrackballGroup]
+ public LogWheelsSettings log;
+
+ [TrackballGroup]
+ public LinearWheelsSettings linear;
+
+ public static ColorWheelsSettings defaultSettings
+ {
+ get
+ {
+ ColorWheelsSettings result = default(ColorWheelsSettings);
+ result.mode = ColorWheelMode.Log;
+ result.log = LogWheelsSettings.defaultSettings;
+ result.linear = LinearWheelsSettings.defaultSettings;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct CurvesSettings
+ {
+ public ColorGradingCurve master;
+
+ public ColorGradingCurve red;
+
+ public ColorGradingCurve green;
+
+ public ColorGradingCurve blue;
+
+ public ColorGradingCurve hueVShue;
+
+ public ColorGradingCurve hueVSsat;
+
+ public ColorGradingCurve satVSsat;
+
+ public ColorGradingCurve lumVSsat;
+
+ [HideInInspector]
+ public int e_CurrentEditingCurve;
+
+ [HideInInspector]
+ public bool e_CurveY;
+
+ [HideInInspector]
+ public bool e_CurveR;
+
+ [HideInInspector]
+ public bool e_CurveG;
+
+ [HideInInspector]
+ public bool e_CurveB;
+
+ public static CurvesSettings defaultSettings
+ {
+ get
+ {
+ CurvesSettings result = default(CurvesSettings);
+ result.master = new ColorGradingCurve(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, loop: false, new Vector2(0f, 1f));
+ result.red = new ColorGradingCurve(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, loop: false, new Vector2(0f, 1f));
+ result.green = new ColorGradingCurve(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, loop: false, new Vector2(0f, 1f));
+ result.blue = new ColorGradingCurve(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, loop: false, new Vector2(0f, 1f));
+ result.hueVShue = new ColorGradingCurve(new AnimationCurve(), 0.5f, loop: true, new Vector2(0f, 1f));
+ result.hueVSsat = new ColorGradingCurve(new AnimationCurve(), 0.5f, loop: true, new Vector2(0f, 1f));
+ result.satVSsat = new ColorGradingCurve(new AnimationCurve(), 0.5f, loop: false, new Vector2(0f, 1f));
+ result.lumVSsat = new ColorGradingCurve(new AnimationCurve(), 0.5f, loop: false, new Vector2(0f, 1f));
+ result.e_CurrentEditingCurve = 0;
+ result.e_CurveY = true;
+ result.e_CurveR = false;
+ result.e_CurveG = false;
+ result.e_CurveB = false;
+ return result;
+ }
+ }
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ public TonemappingSettings tonemapping;
+
+ public BasicSettings basic;
+
+ public ChannelMixerSettings channelMixer;
+
+ public ColorWheelsSettings colorWheels;
+
+ public CurvesSettings curves;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.tonemapping = TonemappingSettings.defaultSettings;
+ result.basic = BasicSettings.defaultSettings;
+ result.channelMixer = ChannelMixerSettings.defaultSettings;
+ result.colorWheels = ColorWheelsSettings.defaultSettings;
+ result.curves = CurvesSettings.defaultSettings;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ OnValidate();
+ }
+ }
+
+ public bool isDirty { get; internal set; }
+
+ public RenderTexture bakedLut { get; internal set; }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ OnValidate();
+ }
+
+ public override void OnValidate()
+ {
+ isDirty = true;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldComponent.cs
new file mode 100644
index 0000000..787f3ff
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldComponent.cs
@@ -0,0 +1,155 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class DepthOfFieldComponent : PostProcessingComponentRenderTexture<DepthOfFieldModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _DepthOfFieldTex = Shader.PropertyToID("_DepthOfFieldTex");
+
+ internal static readonly int _DepthOfFieldCoCTex = Shader.PropertyToID("_DepthOfFieldCoCTex");
+
+ internal static readonly int _Distance = Shader.PropertyToID("_Distance");
+
+ internal static readonly int _LensCoeff = Shader.PropertyToID("_LensCoeff");
+
+ internal static readonly int _MaxCoC = Shader.PropertyToID("_MaxCoC");
+
+ internal static readonly int _RcpMaxCoC = Shader.PropertyToID("_RcpMaxCoC");
+
+ internal static readonly int _RcpAspect = Shader.PropertyToID("_RcpAspect");
+
+ internal static readonly int _MainTex = Shader.PropertyToID("_MainTex");
+
+ internal static readonly int _CoCTex = Shader.PropertyToID("_CoCTex");
+
+ internal static readonly int _TaaParams = Shader.PropertyToID("_TaaParams");
+
+ internal static readonly int _DepthOfFieldParams = Shader.PropertyToID("_DepthOfFieldParams");
+ }
+
+ private const string k_ShaderString = "Hidden/Post FX/Depth Of Field";
+
+ private RenderTexture m_CoCHistory;
+
+ private const float k_FilmHeight = 0.024f;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.Depth;
+ }
+
+ private float CalculateFocalLength()
+ {
+ DepthOfFieldModel.Settings settings = base.model.settings;
+ if (!settings.useCameraFov)
+ {
+ return settings.focalLength / 1000f;
+ }
+ float num = context.camera.fieldOfView * ((float)Math.PI / 180f);
+ return 0.012f / Mathf.Tan(0.5f * num);
+ }
+
+ private float CalculateMaxCoCRadius(int screenHeight)
+ {
+ float num = (float)base.model.settings.kernelSize * 4f + 6f;
+ return Mathf.Min(0.05f, num / (float)screenHeight);
+ }
+
+ private bool CheckHistory(int width, int height)
+ {
+ if (m_CoCHistory != null && m_CoCHistory.IsCreated() && m_CoCHistory.width == width)
+ {
+ return m_CoCHistory.height == height;
+ }
+ return false;
+ }
+
+ private RenderTextureFormat SelectFormat(RenderTextureFormat primary, RenderTextureFormat secondary)
+ {
+ if (SystemInfo.SupportsRenderTextureFormat(primary))
+ {
+ return primary;
+ }
+ if (SystemInfo.SupportsRenderTextureFormat(secondary))
+ {
+ return secondary;
+ }
+ return RenderTextureFormat.Default;
+ }
+
+ public void Prepare(RenderTexture source, Material uberMaterial, bool antialiasCoC, Vector2 taaJitter, float taaBlending)
+ {
+ DepthOfFieldModel.Settings settings = base.model.settings;
+ RenderTextureFormat format = RenderTextureFormat.DefaultHDR;
+ RenderTextureFormat format2 = SelectFormat(RenderTextureFormat.R8, RenderTextureFormat.RHalf);
+ float num = CalculateFocalLength();
+ float num2 = Mathf.Max(settings.focusDistance, num);
+ float num3 = (float)source.width / (float)source.height;
+ float num4 = num * num / (settings.aperture * (num2 - num) * 0.024f * 2f);
+ float num5 = CalculateMaxCoCRadius(source.height);
+ Material material = context.materialFactory.Get("Hidden/Post FX/Depth Of Field");
+ material.SetFloat(Uniforms._Distance, num2);
+ material.SetFloat(Uniforms._LensCoeff, num4);
+ material.SetFloat(Uniforms._MaxCoC, num5);
+ material.SetFloat(Uniforms._RcpMaxCoC, 1f / num5);
+ material.SetFloat(Uniforms._RcpAspect, 1f / num3);
+ RenderTexture renderTexture = context.renderTextureFactory.Get(context.width, context.height, 0, format2, RenderTextureReadWrite.Linear);
+ Graphics.Blit(null, renderTexture, material, 0);
+ if (antialiasCoC)
+ {
+ material.SetTexture(Uniforms._CoCTex, renderTexture);
+ float z = (CheckHistory(context.width, context.height) ? taaBlending : 0f);
+ material.SetVector(Uniforms._TaaParams, new Vector3(taaJitter.x, taaJitter.y, z));
+ RenderTexture temporary = RenderTexture.GetTemporary(context.width, context.height, 0, format2);
+ Graphics.Blit(m_CoCHistory, temporary, material, 1);
+ context.renderTextureFactory.Release(renderTexture);
+ if (m_CoCHistory != null)
+ {
+ RenderTexture.ReleaseTemporary(m_CoCHistory);
+ }
+ renderTexture = (m_CoCHistory = temporary);
+ }
+ RenderTexture renderTexture2 = context.renderTextureFactory.Get(context.width / 2, context.height / 2, 0, format);
+ material.SetTexture(Uniforms._CoCTex, renderTexture);
+ Graphics.Blit(source, renderTexture2, material, 2);
+ RenderTexture renderTexture3 = context.renderTextureFactory.Get(context.width / 2, context.height / 2, 0, format);
+ Graphics.Blit(renderTexture2, renderTexture3, material, (int)(3 + settings.kernelSize));
+ Graphics.Blit(renderTexture3, renderTexture2, material, 7);
+ uberMaterial.SetVector(Uniforms._DepthOfFieldParams, new Vector3(num2, num4, num5));
+ if (context.profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.FocusPlane))
+ {
+ uberMaterial.EnableKeyword("DEPTH_OF_FIELD_COC_VIEW");
+ context.Interrupt();
+ }
+ else
+ {
+ uberMaterial.SetTexture(Uniforms._DepthOfFieldTex, renderTexture2);
+ uberMaterial.SetTexture(Uniforms._DepthOfFieldCoCTex, renderTexture);
+ uberMaterial.EnableKeyword("DEPTH_OF_FIELD");
+ }
+ context.renderTextureFactory.Release(renderTexture3);
+ }
+
+ public override void OnDisable()
+ {
+ if (m_CoCHistory != null)
+ {
+ RenderTexture.ReleaseTemporary(m_CoCHistory);
+ }
+ m_CoCHistory = null;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldModel.cs
new file mode 100644
index 0000000..6ead0de
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DepthOfFieldModel.cs
@@ -0,0 +1,71 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class DepthOfFieldModel : PostProcessingModel
+{
+ public enum KernelSize
+ {
+ Small,
+ Medium,
+ Large,
+ VeryLarge
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ [Min(0.1f)]
+ [Tooltip("Distance to the point of focus.")]
+ public float focusDistance;
+
+ [Range(0.05f, 32f)]
+ [Tooltip("Ratio of aperture (known as f-stop or f-number). The smaller the value is, the shallower the depth of field is.")]
+ public float aperture;
+
+ [Range(1f, 300f)]
+ [Tooltip("Distance between the lens and the film. The larger the value is, the shallower the depth of field is.")]
+ public float focalLength;
+
+ [Tooltip("Calculate the focal length automatically from the field-of-view value set on the camera. Using this setting isn't recommended.")]
+ public bool useCameraFov;
+
+ [Tooltip("Convolution kernel size of the bokeh filter, which determines the maximum radius of bokeh. It also affects the performance (the larger the kernel is, the longer the GPU time is required).")]
+ public KernelSize kernelSize;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.focusDistance = 10f;
+ result.aperture = 5.6f;
+ result.focalLength = 50f;
+ result.useCameraFov = false;
+ result.kernelSize = KernelSize.Medium;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringComponent.cs
new file mode 100644
index 0000000..f5f2395
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringComponent.cs
@@ -0,0 +1,61 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class DitheringComponent : PostProcessingComponentRenderTexture<DitheringModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _DitheringTex = Shader.PropertyToID("_DitheringTex");
+
+ internal static readonly int _DitheringCoords = Shader.PropertyToID("_DitheringCoords");
+ }
+
+ private Texture2D[] noiseTextures;
+
+ private int textureIndex;
+
+ private const int k_TextureCount = 64;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override void OnDisable()
+ {
+ noiseTextures = null;
+ }
+
+ private void LoadNoiseTextures()
+ {
+ noiseTextures = new Texture2D[64];
+ for (int i = 0; i < 64; i++)
+ {
+ noiseTextures[i] = Resources.Load<Texture2D>("Bluenoise64/LDR_LLL1_" + i);
+ }
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ if (++textureIndex >= 64)
+ {
+ textureIndex = 0;
+ }
+ float value = Random.value;
+ float value2 = Random.value;
+ if (noiseTextures == null)
+ {
+ LoadNoiseTextures();
+ }
+ Texture2D texture2D = noiseTextures[textureIndex];
+ uberMaterial.EnableKeyword("DITHERING");
+ uberMaterial.SetTexture(Uniforms._DitheringTex, texture2D);
+ uberMaterial.SetVector(Uniforms._DitheringCoords, new Vector4((float)context.width / (float)texture2D.width, (float)context.height / (float)texture2D.height, value, value2));
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringModel.cs
new file mode 100644
index 0000000..1258f2e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/DitheringModel.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class DitheringModel : PostProcessingModel
+{
+ [Serializable]
+ [StructLayout(LayoutKind.Sequential, Size = 1)]
+ public struct Settings
+ {
+ public static Settings defaultSettings => default(Settings);
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationComponent.cs
new file mode 100644
index 0000000..8e754b0
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationComponent.cs
@@ -0,0 +1,177 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class EyeAdaptationComponent : PostProcessingComponentRenderTexture<EyeAdaptationModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _Params = Shader.PropertyToID("_Params");
+
+ internal static readonly int _Speed = Shader.PropertyToID("_Speed");
+
+ internal static readonly int _ScaleOffsetRes = Shader.PropertyToID("_ScaleOffsetRes");
+
+ internal static readonly int _ExposureCompensation = Shader.PropertyToID("_ExposureCompensation");
+
+ internal static readonly int _AutoExposure = Shader.PropertyToID("_AutoExposure");
+
+ internal static readonly int _DebugWidth = Shader.PropertyToID("_DebugWidth");
+ }
+
+ private ComputeShader m_EyeCompute;
+
+ private ComputeBuffer m_HistogramBuffer;
+
+ private readonly RenderTexture[] m_AutoExposurePool = new RenderTexture[2];
+
+ private int m_AutoExposurePingPing;
+
+ private RenderTexture m_CurrentAutoExposure;
+
+ private RenderTexture m_DebugHistogram;
+
+ private static uint[] s_EmptyHistogramBuffer;
+
+ private bool m_FirstFrame = true;
+
+ private const int k_HistogramBins = 64;
+
+ private const int k_HistogramThreadX = 16;
+
+ private const int k_HistogramThreadY = 16;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && SystemInfo.supportsComputeShaders)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public void ResetHistory()
+ {
+ m_FirstFrame = true;
+ }
+
+ public override void OnEnable()
+ {
+ m_FirstFrame = true;
+ }
+
+ public override void OnDisable()
+ {
+ RenderTexture[] autoExposurePool = m_AutoExposurePool;
+ for (int i = 0; i < autoExposurePool.Length; i++)
+ {
+ GraphicsUtils.Destroy(autoExposurePool[i]);
+ }
+ if (m_HistogramBuffer != null)
+ {
+ m_HistogramBuffer.Release();
+ }
+ m_HistogramBuffer = null;
+ if (m_DebugHistogram != null)
+ {
+ m_DebugHistogram.Release();
+ }
+ m_DebugHistogram = null;
+ }
+
+ private Vector4 GetHistogramScaleOffsetRes()
+ {
+ EyeAdaptationModel.Settings settings = base.model.settings;
+ float num = settings.logMax - settings.logMin;
+ float num2 = 1f / num;
+ float y = (float)(-settings.logMin) * num2;
+ return new Vector4(num2, y, Mathf.Floor((float)context.width / 2f), Mathf.Floor((float)context.height / 2f));
+ }
+
+ public Texture Prepare(RenderTexture source, Material uberMaterial)
+ {
+ EyeAdaptationModel.Settings settings = base.model.settings;
+ if (m_EyeCompute == null)
+ {
+ m_EyeCompute = Resources.Load<ComputeShader>("Shaders/EyeHistogram");
+ }
+ Material material = context.materialFactory.Get("Hidden/Post FX/Eye Adaptation");
+ material.shaderKeywords = null;
+ if (m_HistogramBuffer == null)
+ {
+ m_HistogramBuffer = new ComputeBuffer(64, 4);
+ }
+ if (s_EmptyHistogramBuffer == null)
+ {
+ s_EmptyHistogramBuffer = new uint[64];
+ }
+ Vector4 histogramScaleOffsetRes = GetHistogramScaleOffsetRes();
+ RenderTexture renderTexture = context.renderTextureFactory.Get((int)histogramScaleOffsetRes.z, (int)histogramScaleOffsetRes.w, 0, source.format);
+ Graphics.Blit(source, renderTexture);
+ if (m_AutoExposurePool[0] == null || !m_AutoExposurePool[0].IsCreated())
+ {
+ m_AutoExposurePool[0] = new RenderTexture(1, 1, 0, RenderTextureFormat.RFloat);
+ }
+ if (m_AutoExposurePool[1] == null || !m_AutoExposurePool[1].IsCreated())
+ {
+ m_AutoExposurePool[1] = new RenderTexture(1, 1, 0, RenderTextureFormat.RFloat);
+ }
+ m_HistogramBuffer.SetData(s_EmptyHistogramBuffer);
+ int kernelIndex = m_EyeCompute.FindKernel("KEyeHistogram");
+ m_EyeCompute.SetBuffer(kernelIndex, "_Histogram", m_HistogramBuffer);
+ m_EyeCompute.SetTexture(kernelIndex, "_Source", renderTexture);
+ m_EyeCompute.SetVector("_ScaleOffsetRes", histogramScaleOffsetRes);
+ m_EyeCompute.Dispatch(kernelIndex, Mathf.CeilToInt((float)renderTexture.width / 16f), Mathf.CeilToInt((float)renderTexture.height / 16f), 1);
+ context.renderTextureFactory.Release(renderTexture);
+ settings.highPercent = Mathf.Clamp(settings.highPercent, 1.01f, 99f);
+ settings.lowPercent = Mathf.Clamp(settings.lowPercent, 1f, settings.highPercent - 0.01f);
+ material.SetBuffer("_Histogram", m_HistogramBuffer);
+ material.SetVector(Uniforms._Params, new Vector4(settings.lowPercent * 0.01f, settings.highPercent * 0.01f, Mathf.Exp(settings.minLuminance * 0.6931472f), Mathf.Exp(settings.maxLuminance * 0.6931472f)));
+ material.SetVector(Uniforms._Speed, new Vector2(settings.speedDown, settings.speedUp));
+ material.SetVector(Uniforms._ScaleOffsetRes, histogramScaleOffsetRes);
+ material.SetFloat(Uniforms._ExposureCompensation, settings.keyValue);
+ if (settings.dynamicKeyValue)
+ {
+ material.EnableKeyword("AUTO_KEY_VALUE");
+ }
+ if (m_FirstFrame || !Application.isPlaying)
+ {
+ m_CurrentAutoExposure = m_AutoExposurePool[0];
+ Graphics.Blit(null, m_CurrentAutoExposure, material, 1);
+ Graphics.Blit(m_AutoExposurePool[0], m_AutoExposurePool[1]);
+ }
+ else
+ {
+ int autoExposurePingPing = m_AutoExposurePingPing;
+ RenderTexture source2 = m_AutoExposurePool[++autoExposurePingPing % 2];
+ RenderTexture renderTexture2 = m_AutoExposurePool[++autoExposurePingPing % 2];
+ Graphics.Blit(source2, renderTexture2, material, (int)settings.adaptationType);
+ m_AutoExposurePingPing = ++autoExposurePingPing % 2;
+ m_CurrentAutoExposure = renderTexture2;
+ }
+ if (context.profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.EyeAdaptation))
+ {
+ if (m_DebugHistogram == null || !m_DebugHistogram.IsCreated())
+ {
+ m_DebugHistogram = new RenderTexture(256, 128, 0, RenderTextureFormat.ARGB32)
+ {
+ filterMode = FilterMode.Point,
+ wrapMode = TextureWrapMode.Clamp
+ };
+ }
+ material.SetFloat(Uniforms._DebugWidth, m_DebugHistogram.width);
+ Graphics.Blit(null, m_DebugHistogram, material, 2);
+ }
+ m_FirstFrame = false;
+ return m_CurrentAutoExposure;
+ }
+
+ public void OnGUI()
+ {
+ if (!(m_DebugHistogram == null) && m_DebugHistogram.IsCreated())
+ {
+ GUI.DrawTexture(new Rect(context.viewport.x * (float)Screen.width + 8f, 8f, m_DebugHistogram.width, m_DebugHistogram.height), m_DebugHistogram);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationModel.cs
new file mode 100644
index 0000000..aab9a3d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/EyeAdaptationModel.cs
@@ -0,0 +1,97 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class EyeAdaptationModel : PostProcessingModel
+{
+ public enum EyeAdaptationType
+ {
+ Progressive,
+ Fixed
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ [Range(1f, 99f)]
+ [Tooltip("Filters the dark part of the histogram when computing the average luminance to avoid very dark pixels from contributing to the auto exposure. Unit is in percent.")]
+ public float lowPercent;
+
+ [Range(1f, 99f)]
+ [Tooltip("Filters the bright part of the histogram when computing the average luminance to avoid very dark pixels from contributing to the auto exposure. Unit is in percent.")]
+ public float highPercent;
+
+ [Tooltip("Minimum average luminance to consider for auto exposure (in EV).")]
+ public float minLuminance;
+
+ [Tooltip("Maximum average luminance to consider for auto exposure (in EV).")]
+ public float maxLuminance;
+
+ [Min(0f)]
+ [Tooltip("Exposure bias. Use this to offset the global exposure of the scene.")]
+ public float keyValue;
+
+ [Tooltip("Set this to true to let Unity handle the key value automatically based on average luminance.")]
+ public bool dynamicKeyValue;
+
+ [Tooltip("Use \"Progressive\" if you want the auto exposure to be animated. Use \"Fixed\" otherwise.")]
+ public EyeAdaptationType adaptationType;
+
+ [Min(0f)]
+ [Tooltip("Adaptation speed from a dark to a light environment.")]
+ public float speedUp;
+
+ [Min(0f)]
+ [Tooltip("Adaptation speed from a light to a dark environment.")]
+ public float speedDown;
+
+ [Range(-16f, -1f)]
+ [Tooltip("Lower bound for the brightness range of the generated histogram (in EV). The bigger the spread between min & max, the lower the precision will be.")]
+ public int logMin;
+
+ [Range(1f, 16f)]
+ [Tooltip("Upper bound for the brightness range of the generated histogram (in EV). The bigger the spread between min & max, the lower the precision will be.")]
+ public int logMax;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.lowPercent = 45f;
+ result.highPercent = 95f;
+ result.minLuminance = -5f;
+ result.maxLuminance = 1f;
+ result.keyValue = 0.25f;
+ result.dynamicKeyValue = true;
+ result.adaptationType = EyeAdaptationType.Progressive;
+ result.speedUp = 2f;
+ result.speedDown = 1f;
+ result.logMin = -8;
+ result.logMax = 4;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogComponent.cs
new file mode 100644
index 0000000..229f23d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogComponent.cs
@@ -0,0 +1,97 @@
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class FogComponent : PostProcessingComponentCommandBuffer<FogModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _FogColor = Shader.PropertyToID("_FogColor");
+
+ internal static readonly int _Density = Shader.PropertyToID("_Density");
+
+ internal static readonly int _Start = Shader.PropertyToID("_Start");
+
+ internal static readonly int _End = Shader.PropertyToID("_End");
+
+ internal static readonly int _TempRT = Shader.PropertyToID("_TempRT");
+
+ internal static readonly int _TopLeft = Shader.PropertyToID("_TopLeft");
+
+ internal static readonly int _TopRight = Shader.PropertyToID("_TopRight");
+
+ internal static readonly int _BottomLeft = Shader.PropertyToID("_BottomLeft");
+
+ internal static readonly int _BottomRight = Shader.PropertyToID("_BottomRight");
+
+ internal static readonly int _SunDir = Shader.PropertyToID("_SunDir");
+
+ internal static readonly int _SunFogColor = Shader.PropertyToID("_SunFogColor");
+ }
+
+ private const string k_ShaderString = "Hidden/Post FX/Fog";
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && context.isGBufferAvailable && RenderSettings.fog)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override string GetName()
+ {
+ return "Fog";
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.Depth;
+ }
+
+ public override CameraEvent GetCameraEvent()
+ {
+ return CameraEvent.AfterImageEffectsOpaque;
+ }
+
+ public override void PopulateCommandBuffer(CommandBuffer cb)
+ {
+ FogModel.Settings settings = base.model.settings;
+ Material material = context.materialFactory.Get("Hidden/Post FX/Fog");
+ material.shaderKeywords = null;
+ Color value = (GraphicsUtils.isLinearColorSpace ? RenderSettings.fogColor.linear : RenderSettings.fogColor);
+ material.SetColor(Uniforms._FogColor, value);
+ material.SetFloat(Uniforms._Density, RenderSettings.fogDensity);
+ material.SetFloat(Uniforms._Start, RenderSettings.fogStartDistance);
+ material.SetFloat(Uniforms._End, RenderSettings.fogEndDistance);
+ Vector3 direction = context.camera.ViewportPointToRay(new Vector3(0f, 1f, 0f)).direction;
+ Vector3 direction2 = context.camera.ViewportPointToRay(new Vector3(1f, 1f, 0f)).direction;
+ Vector3 direction3 = context.camera.ViewportPointToRay(new Vector3(0f, 0f, 0f)).direction;
+ Vector3 direction4 = context.camera.ViewportPointToRay(new Vector3(1f, 0f, 0f)).direction;
+ material.SetVector(Uniforms._TopLeft, direction);
+ material.SetVector(Uniforms._TopRight, direction2);
+ material.SetVector(Uniforms._BottomLeft, direction3);
+ material.SetVector(Uniforms._BottomRight, direction4);
+ switch (RenderSettings.fogMode)
+ {
+ case FogMode.Linear:
+ material.EnableKeyword("FOG_LINEAR");
+ break;
+ case FogMode.Exponential:
+ material.EnableKeyword("FOG_EXP");
+ break;
+ case FogMode.ExponentialSquared:
+ material.EnableKeyword("FOG_EXP2");
+ break;
+ }
+ RenderTextureFormat format = (context.isHdr ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
+ cb.GetTemporaryRT(Uniforms._TempRT, context.width, context.height, 24, FilterMode.Bilinear, format);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, Uniforms._TempRT);
+ cb.Blit(Uniforms._TempRT, BuiltinRenderTextureType.CameraTarget, material, settings.excludeSkybox ? 1 : 0);
+ cb.ReleaseTemporaryRT(Uniforms._TempRT);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogModel.cs
new file mode 100644
index 0000000..4a7f4cd
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FogModel.cs
@@ -0,0 +1,44 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class FogModel : PostProcessingModel
+{
+ [Serializable]
+ public struct Settings
+ {
+ [Tooltip("Should the fog affect the skybox?")]
+ public bool excludeSkybox;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.excludeSkybox = true;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FxaaComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FxaaComponent.cs
new file mode 100644
index 0000000..236085b
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/FxaaComponent.cs
@@ -0,0 +1,34 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class FxaaComponent : PostProcessingComponentRenderTexture<AntialiasingModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _QualitySettings = Shader.PropertyToID("_QualitySettings");
+
+ internal static readonly int _ConsoleSettings = Shader.PropertyToID("_ConsoleSettings");
+ }
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.method == AntialiasingModel.Method.Fxaa)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public void Render(RenderTexture source, RenderTexture destination)
+ {
+ AntialiasingModel.FxaaSettings fxaaSettings = base.model.settings.fxaaSettings;
+ Material material = context.materialFactory.Get("Hidden/Post FX/FXAA");
+ AntialiasingModel.FxaaQualitySettings fxaaQualitySettings = AntialiasingModel.FxaaQualitySettings.presets[(int)fxaaSettings.preset];
+ AntialiasingModel.FxaaConsoleSettings fxaaConsoleSettings = AntialiasingModel.FxaaConsoleSettings.presets[(int)fxaaSettings.preset];
+ material.SetVector(Uniforms._QualitySettings, new Vector3(fxaaQualitySettings.subpixelAliasingRemovalAmount, fxaaQualitySettings.edgeDetectionThreshold, fxaaQualitySettings.minimumRequiredLuminance));
+ material.SetVector(Uniforms._ConsoleSettings, new Vector4(fxaaConsoleSettings.subpixelSpreadAmount, fxaaConsoleSettings.edgeSharpnessAmount, fxaaConsoleSettings.edgeDetectionThreshold, fxaaConsoleSettings.minimumRequiredLuminance));
+ Graphics.Blit(source, destination, material, 0);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GetSetAttribute.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GetSetAttribute.cs
new file mode 100644
index 0000000..1b34e7d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GetSetAttribute.cs
@@ -0,0 +1,13 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class GetSetAttribute : PropertyAttribute
+{
+ public readonly string name;
+
+ public bool dirty;
+
+ public GetSetAttribute(string name)
+ {
+ this.name = name;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainComponent.cs
new file mode 100644
index 0000000..cc2be5d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainComponent.cs
@@ -0,0 +1,62 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class GrainComponent : PostProcessingComponentRenderTexture<GrainModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _Grain_Params1 = Shader.PropertyToID("_Grain_Params1");
+
+ internal static readonly int _Grain_Params2 = Shader.PropertyToID("_Grain_Params2");
+
+ internal static readonly int _GrainTex = Shader.PropertyToID("_GrainTex");
+
+ internal static readonly int _Phase = Shader.PropertyToID("_Phase");
+ }
+
+ private RenderTexture m_GrainLookupRT;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.intensity > 0f && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override void OnDisable()
+ {
+ GraphicsUtils.Destroy(m_GrainLookupRT);
+ m_GrainLookupRT = null;
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ GrainModel.Settings settings = base.model.settings;
+ uberMaterial.EnableKeyword("GRAIN");
+ float realtimeSinceStartup = Time.realtimeSinceStartup;
+ float value = Random.value;
+ float value2 = Random.value;
+ if (m_GrainLookupRT == null || !m_GrainLookupRT.IsCreated())
+ {
+ GraphicsUtils.Destroy(m_GrainLookupRT);
+ m_GrainLookupRT = new RenderTexture(192, 192, 0, RenderTextureFormat.ARGBHalf)
+ {
+ filterMode = FilterMode.Bilinear,
+ wrapMode = TextureWrapMode.Repeat,
+ anisoLevel = 0,
+ name = "Grain Lookup Texture"
+ };
+ m_GrainLookupRT.Create();
+ }
+ Material material = context.materialFactory.Get("Hidden/Post FX/Grain Generator");
+ material.SetFloat(Uniforms._Phase, realtimeSinceStartup / 20f);
+ Graphics.Blit(null, m_GrainLookupRT, material, settings.colored ? 1 : 0);
+ uberMaterial.SetTexture(Uniforms._GrainTex, m_GrainLookupRT);
+ uberMaterial.SetVector(Uniforms._Grain_Params1, new Vector2(settings.luminanceContribution, settings.intensity * 20f));
+ uberMaterial.SetVector(Uniforms._Grain_Params2, new Vector4((float)context.width / (float)m_GrainLookupRT.width / settings.size, (float)context.height / (float)m_GrainLookupRT.height / settings.size, value, value2));
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainModel.cs
new file mode 100644
index 0000000..20ca694
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GrainModel.cs
@@ -0,0 +1,59 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class GrainModel : PostProcessingModel
+{
+ [Serializable]
+ public struct Settings
+ {
+ [Tooltip("Enable the use of colored grain.")]
+ public bool colored;
+
+ [Range(0f, 1f)]
+ [Tooltip("Grain strength. Higher means more visible grain.")]
+ public float intensity;
+
+ [Range(0.3f, 3f)]
+ [Tooltip("Grain particle size.")]
+ public float size;
+
+ [Range(0f, 1f)]
+ [Tooltip("Controls the noisiness response curve based on scene luminance. Lower values mean less noise in dark areas.")]
+ public float luminanceContribution;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.colored = true;
+ result.intensity = 0.5f;
+ result.size = 1f;
+ result.luminanceContribution = 0.8f;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GraphicsUtils.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GraphicsUtils.cs
new file mode 100644
index 0000000..d662af3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/GraphicsUtils.cs
@@ -0,0 +1,126 @@
+namespace UnityEngine.PostProcessing;
+
+public static class GraphicsUtils
+{
+ private static Texture2D s_WhiteTexture;
+
+ private static Mesh s_Quad;
+
+ public static bool isLinearColorSpace => QualitySettings.activeColorSpace == ColorSpace.Linear;
+
+ public static bool supportsDX11
+ {
+ get
+ {
+ if (SystemInfo.graphicsShaderLevel >= 50)
+ {
+ return SystemInfo.supportsComputeShaders;
+ }
+ return false;
+ }
+ }
+
+ public static Texture2D whiteTexture
+ {
+ get
+ {
+ if (s_WhiteTexture != null)
+ {
+ return s_WhiteTexture;
+ }
+ s_WhiteTexture = new Texture2D(1, 1, TextureFormat.ARGB32, mipChain: false);
+ s_WhiteTexture.SetPixel(0, 0, new Color(1f, 1f, 1f, 1f));
+ s_WhiteTexture.Apply();
+ return s_WhiteTexture;
+ }
+ }
+
+ public static Mesh quad
+ {
+ get
+ {
+ if (s_Quad != null)
+ {
+ return s_Quad;
+ }
+ Vector3[] vertices = new Vector3[4]
+ {
+ new Vector3(-1f, -1f, 0f),
+ new Vector3(1f, 1f, 0f),
+ new Vector3(1f, -1f, 0f),
+ new Vector3(-1f, 1f, 0f)
+ };
+ Vector2[] uv = new Vector2[4]
+ {
+ new Vector2(0f, 0f),
+ new Vector2(1f, 1f),
+ new Vector2(1f, 0f),
+ new Vector2(0f, 1f)
+ };
+ int[] triangles = new int[6] { 0, 1, 2, 1, 0, 3 };
+ s_Quad = new Mesh
+ {
+ vertices = vertices,
+ uv = uv,
+ triangles = triangles
+ };
+ s_Quad.RecalculateNormals();
+ s_Quad.RecalculateBounds();
+ return s_Quad;
+ }
+ }
+
+ public static void Blit(Material material, int pass)
+ {
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ material.SetPass(pass);
+ GL.Begin(5);
+ GL.TexCoord2(0f, 0f);
+ GL.Vertex3(0f, 0f, 0.1f);
+ GL.TexCoord2(1f, 0f);
+ GL.Vertex3(1f, 0f, 0.1f);
+ GL.TexCoord2(0f, 1f);
+ GL.Vertex3(0f, 1f, 0.1f);
+ GL.TexCoord2(1f, 1f);
+ GL.Vertex3(1f, 1f, 0.1f);
+ GL.End();
+ GL.PopMatrix();
+ }
+
+ public static void ClearAndBlit(Texture source, RenderTexture destination, Material material, int pass, bool clearColor = true, bool clearDepth = false)
+ {
+ RenderTexture active = RenderTexture.active;
+ RenderTexture.active = destination;
+ GL.Clear(clearDepth: false, clearColor, Color.clear);
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ material.SetTexture("_MainTex", source);
+ material.SetPass(pass);
+ GL.Begin(5);
+ GL.TexCoord2(0f, 0f);
+ GL.Vertex3(0f, 0f, 0.1f);
+ GL.TexCoord2(1f, 0f);
+ GL.Vertex3(1f, 0f, 0.1f);
+ GL.TexCoord2(0f, 1f);
+ GL.Vertex3(0f, 1f, 0.1f);
+ GL.TexCoord2(1f, 1f);
+ GL.Vertex3(1f, 1f, 0.1f);
+ GL.End();
+ GL.PopMatrix();
+ RenderTexture.active = active;
+ }
+
+ public static void Destroy(Object obj)
+ {
+ if (obj != null)
+ {
+ Object.Destroy(obj);
+ }
+ }
+
+ public static void Dispose()
+ {
+ Destroy(s_Quad);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MaterialFactory.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MaterialFactory.cs
new file mode 100644
index 0000000..0f046d1
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MaterialFactory.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class MaterialFactory : IDisposable
+{
+ private Dictionary<string, Material> m_Materials;
+
+ public MaterialFactory()
+ {
+ m_Materials = new Dictionary<string, Material>();
+ }
+
+ public Material Get(string shaderName)
+ {
+ if (!m_Materials.TryGetValue(shaderName, out var value))
+ {
+ Shader shader = Shader.Find(shaderName);
+ if (shader == null)
+ {
+ throw new ArgumentException($"Shader not found ({shaderName})");
+ }
+ value = new Material(shader)
+ {
+ name = string.Format("PostFX - {0}", shaderName.Substring(shaderName.LastIndexOf("/") + 1)),
+ hideFlags = HideFlags.DontSave
+ };
+ m_Materials.Add(shaderName, value);
+ }
+ return value;
+ }
+
+ public void Dispose()
+ {
+ Dictionary<string, Material>.Enumerator enumerator = m_Materials.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ GraphicsUtils.Destroy(enumerator.Current.Value);
+ }
+ m_Materials.Clear();
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MinAttribute.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MinAttribute.cs
new file mode 100644
index 0000000..cc991ef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MinAttribute.cs
@@ -0,0 +1,11 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class MinAttribute : PropertyAttribute
+{
+ public readonly float min;
+
+ public MinAttribute(float min)
+ {
+ this.min = min;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurComponent.cs
new file mode 100644
index 0000000..e2586ac
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurComponent.cs
@@ -0,0 +1,426 @@
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class MotionBlurComponent : PostProcessingComponentCommandBuffer<MotionBlurModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _VelocityScale = Shader.PropertyToID("_VelocityScale");
+
+ internal static readonly int _MaxBlurRadius = Shader.PropertyToID("_MaxBlurRadius");
+
+ internal static readonly int _RcpMaxBlurRadius = Shader.PropertyToID("_RcpMaxBlurRadius");
+
+ internal static readonly int _VelocityTex = Shader.PropertyToID("_VelocityTex");
+
+ internal static readonly int _MainTex = Shader.PropertyToID("_MainTex");
+
+ internal static readonly int _Tile2RT = Shader.PropertyToID("_Tile2RT");
+
+ internal static readonly int _Tile4RT = Shader.PropertyToID("_Tile4RT");
+
+ internal static readonly int _Tile8RT = Shader.PropertyToID("_Tile8RT");
+
+ internal static readonly int _TileMaxOffs = Shader.PropertyToID("_TileMaxOffs");
+
+ internal static readonly int _TileMaxLoop = Shader.PropertyToID("_TileMaxLoop");
+
+ internal static readonly int _TileVRT = Shader.PropertyToID("_TileVRT");
+
+ internal static readonly int _NeighborMaxTex = Shader.PropertyToID("_NeighborMaxTex");
+
+ internal static readonly int _LoopCount = Shader.PropertyToID("_LoopCount");
+
+ internal static readonly int _TempRT = Shader.PropertyToID("_TempRT");
+
+ internal static readonly int _History1LumaTex = Shader.PropertyToID("_History1LumaTex");
+
+ internal static readonly int _History2LumaTex = Shader.PropertyToID("_History2LumaTex");
+
+ internal static readonly int _History3LumaTex = Shader.PropertyToID("_History3LumaTex");
+
+ internal static readonly int _History4LumaTex = Shader.PropertyToID("_History4LumaTex");
+
+ internal static readonly int _History1ChromaTex = Shader.PropertyToID("_History1ChromaTex");
+
+ internal static readonly int _History2ChromaTex = Shader.PropertyToID("_History2ChromaTex");
+
+ internal static readonly int _History3ChromaTex = Shader.PropertyToID("_History3ChromaTex");
+
+ internal static readonly int _History4ChromaTex = Shader.PropertyToID("_History4ChromaTex");
+
+ internal static readonly int _History1Weight = Shader.PropertyToID("_History1Weight");
+
+ internal static readonly int _History2Weight = Shader.PropertyToID("_History2Weight");
+
+ internal static readonly int _History3Weight = Shader.PropertyToID("_History3Weight");
+
+ internal static readonly int _History4Weight = Shader.PropertyToID("_History4Weight");
+ }
+
+ private enum Pass
+ {
+ VelocitySetup,
+ TileMax1,
+ TileMax2,
+ TileMaxV,
+ NeighborMax,
+ Reconstruction,
+ FrameCompression,
+ FrameBlendingChroma,
+ FrameBlendingRaw
+ }
+
+ public class ReconstructionFilter
+ {
+ private RenderTextureFormat m_VectorRTFormat = RenderTextureFormat.RGHalf;
+
+ private RenderTextureFormat m_PackedRTFormat = RenderTextureFormat.ARGB2101010;
+
+ public ReconstructionFilter()
+ {
+ CheckTextureFormatSupport();
+ }
+
+ private void CheckTextureFormatSupport()
+ {
+ if (!SystemInfo.SupportsRenderTextureFormat(m_PackedRTFormat))
+ {
+ m_PackedRTFormat = RenderTextureFormat.ARGB32;
+ }
+ }
+
+ public bool IsSupported()
+ {
+ return SystemInfo.supportsMotionVectors;
+ }
+
+ public void ProcessImage(PostProcessingContext context, CommandBuffer cb, ref MotionBlurModel.Settings settings, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material)
+ {
+ int num = (int)(5f * (float)context.height / 100f);
+ int num2 = ((num - 1) / 8 + 1) * 8;
+ float value = settings.shutterAngle / 360f;
+ cb.SetGlobalFloat(Uniforms._VelocityScale, value);
+ cb.SetGlobalFloat(Uniforms._MaxBlurRadius, num);
+ cb.SetGlobalFloat(Uniforms._RcpMaxBlurRadius, 1f / (float)num);
+ int velocityTex = Uniforms._VelocityTex;
+ cb.GetTemporaryRT(velocityTex, context.width, context.height, 0, FilterMode.Point, m_PackedRTFormat, RenderTextureReadWrite.Linear);
+ cb.Blit(null, velocityTex, material, 0);
+ int tile2RT = Uniforms._Tile2RT;
+ cb.GetTemporaryRT(tile2RT, context.width / 2, context.height / 2, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, velocityTex);
+ cb.Blit(velocityTex, tile2RT, material, 1);
+ int tile4RT = Uniforms._Tile4RT;
+ cb.GetTemporaryRT(tile4RT, context.width / 4, context.height / 4, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, tile2RT);
+ cb.Blit(tile2RT, tile4RT, material, 2);
+ cb.ReleaseTemporaryRT(tile2RT);
+ int tile8RT = Uniforms._Tile8RT;
+ cb.GetTemporaryRT(tile8RT, context.width / 8, context.height / 8, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, tile4RT);
+ cb.Blit(tile4RT, tile8RT, material, 2);
+ cb.ReleaseTemporaryRT(tile4RT);
+ Vector2 vector = Vector2.one * ((float)num2 / 8f - 1f) * -0.5f;
+ cb.SetGlobalVector(Uniforms._TileMaxOffs, vector);
+ cb.SetGlobalFloat(Uniforms._TileMaxLoop, (int)((float)num2 / 8f));
+ int tileVRT = Uniforms._TileVRT;
+ cb.GetTemporaryRT(tileVRT, context.width / num2, context.height / num2, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, tile8RT);
+ cb.Blit(tile8RT, tileVRT, material, 3);
+ cb.ReleaseTemporaryRT(tile8RT);
+ int neighborMaxTex = Uniforms._NeighborMaxTex;
+ int width = context.width / num2;
+ int height = context.height / num2;
+ cb.GetTemporaryRT(neighborMaxTex, width, height, 0, FilterMode.Point, m_VectorRTFormat, RenderTextureReadWrite.Linear);
+ cb.SetGlobalTexture(Uniforms._MainTex, tileVRT);
+ cb.Blit(tileVRT, neighborMaxTex, material, 4);
+ cb.ReleaseTemporaryRT(tileVRT);
+ cb.SetGlobalFloat(Uniforms._LoopCount, Mathf.Clamp(settings.sampleCount / 2, 1, 64));
+ cb.SetGlobalTexture(Uniforms._MainTex, source);
+ cb.Blit(source, destination, material, 5);
+ cb.ReleaseTemporaryRT(velocityTex);
+ cb.ReleaseTemporaryRT(neighborMaxTex);
+ }
+ }
+
+ public class FrameBlendingFilter
+ {
+ private struct Frame
+ {
+ public RenderTexture lumaTexture;
+
+ public RenderTexture chromaTexture;
+
+ private float m_Time;
+
+ private RenderTargetIdentifier[] m_MRT;
+
+ public float CalculateWeight(float strength, float currentTime)
+ {
+ if (Mathf.Approximately(m_Time, 0f))
+ {
+ return 0f;
+ }
+ float num = Mathf.Lerp(80f, 16f, strength);
+ return Mathf.Exp((m_Time - currentTime) * num);
+ }
+
+ public void Release()
+ {
+ if (lumaTexture != null)
+ {
+ RenderTexture.ReleaseTemporary(lumaTexture);
+ }
+ if (chromaTexture != null)
+ {
+ RenderTexture.ReleaseTemporary(chromaTexture);
+ }
+ lumaTexture = null;
+ chromaTexture = null;
+ }
+
+ public void MakeRecord(CommandBuffer cb, RenderTargetIdentifier source, int width, int height, Material material)
+ {
+ Release();
+ lumaTexture = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear);
+ chromaTexture = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear);
+ lumaTexture.filterMode = FilterMode.Point;
+ chromaTexture.filterMode = FilterMode.Point;
+ if (m_MRT == null)
+ {
+ m_MRT = new RenderTargetIdentifier[2];
+ }
+ m_MRT[0] = lumaTexture;
+ m_MRT[1] = chromaTexture;
+ cb.SetGlobalTexture(Uniforms._MainTex, source);
+ cb.SetRenderTarget(m_MRT, lumaTexture);
+ cb.DrawMesh(GraphicsUtils.quad, Matrix4x4.identity, material, 0, 6);
+ m_Time = Time.time;
+ }
+
+ public void MakeRecordRaw(CommandBuffer cb, RenderTargetIdentifier source, int width, int height, RenderTextureFormat format)
+ {
+ Release();
+ lumaTexture = RenderTexture.GetTemporary(width, height, 0, format);
+ lumaTexture.filterMode = FilterMode.Point;
+ cb.SetGlobalTexture(Uniforms._MainTex, source);
+ cb.Blit(source, lumaTexture);
+ m_Time = Time.time;
+ }
+ }
+
+ private bool m_UseCompression;
+
+ private RenderTextureFormat m_RawTextureFormat;
+
+ private Frame[] m_FrameList;
+
+ private int m_LastFrameCount;
+
+ public FrameBlendingFilter()
+ {
+ m_UseCompression = CheckSupportCompression();
+ m_RawTextureFormat = GetPreferredRenderTextureFormat();
+ m_FrameList = new Frame[4];
+ }
+
+ public void Dispose()
+ {
+ Frame[] frameList = m_FrameList;
+ foreach (Frame frame in frameList)
+ {
+ frame.Release();
+ }
+ }
+
+ public void PushFrame(CommandBuffer cb, RenderTargetIdentifier source, int width, int height, Material material)
+ {
+ int frameCount = Time.frameCount;
+ if (frameCount != m_LastFrameCount)
+ {
+ int num = frameCount % m_FrameList.Length;
+ if (m_UseCompression)
+ {
+ m_FrameList[num].MakeRecord(cb, source, width, height, material);
+ }
+ else
+ {
+ m_FrameList[num].MakeRecordRaw(cb, source, width, height, m_RawTextureFormat);
+ }
+ m_LastFrameCount = frameCount;
+ }
+ }
+
+ public void BlendFrames(CommandBuffer cb, float strength, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material)
+ {
+ float time = Time.time;
+ Frame frameRelative = GetFrameRelative(-1);
+ Frame frameRelative2 = GetFrameRelative(-2);
+ Frame frameRelative3 = GetFrameRelative(-3);
+ Frame frameRelative4 = GetFrameRelative(-4);
+ cb.SetGlobalTexture(Uniforms._History1LumaTex, frameRelative.lumaTexture);
+ cb.SetGlobalTexture(Uniforms._History2LumaTex, frameRelative2.lumaTexture);
+ cb.SetGlobalTexture(Uniforms._History3LumaTex, frameRelative3.lumaTexture);
+ cb.SetGlobalTexture(Uniforms._History4LumaTex, frameRelative4.lumaTexture);
+ cb.SetGlobalTexture(Uniforms._History1ChromaTex, frameRelative.chromaTexture);
+ cb.SetGlobalTexture(Uniforms._History2ChromaTex, frameRelative2.chromaTexture);
+ cb.SetGlobalTexture(Uniforms._History3ChromaTex, frameRelative3.chromaTexture);
+ cb.SetGlobalTexture(Uniforms._History4ChromaTex, frameRelative4.chromaTexture);
+ cb.SetGlobalFloat(Uniforms._History1Weight, frameRelative.CalculateWeight(strength, time));
+ cb.SetGlobalFloat(Uniforms._History2Weight, frameRelative2.CalculateWeight(strength, time));
+ cb.SetGlobalFloat(Uniforms._History3Weight, frameRelative3.CalculateWeight(strength, time));
+ cb.SetGlobalFloat(Uniforms._History4Weight, frameRelative4.CalculateWeight(strength, time));
+ cb.SetGlobalTexture(Uniforms._MainTex, source);
+ cb.Blit(source, destination, material, m_UseCompression ? 7 : 8);
+ }
+
+ private static bool CheckSupportCompression()
+ {
+ if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.R8))
+ {
+ return SystemInfo.supportedRenderTargetCount > 1;
+ }
+ return false;
+ }
+
+ private static RenderTextureFormat GetPreferredRenderTextureFormat()
+ {
+ RenderTextureFormat[] array = new RenderTextureFormat[3]
+ {
+ RenderTextureFormat.RGB565,
+ RenderTextureFormat.ARGB1555,
+ RenderTextureFormat.ARGB4444
+ };
+ foreach (RenderTextureFormat renderTextureFormat in array)
+ {
+ if (SystemInfo.SupportsRenderTextureFormat(renderTextureFormat))
+ {
+ return renderTextureFormat;
+ }
+ }
+ return RenderTextureFormat.Default;
+ }
+
+ private Frame GetFrameRelative(int offset)
+ {
+ int num = (Time.frameCount + m_FrameList.Length + offset) % m_FrameList.Length;
+ return m_FrameList[num];
+ }
+ }
+
+ private ReconstructionFilter m_ReconstructionFilter;
+
+ private FrameBlendingFilter m_FrameBlendingFilter;
+
+ private bool m_FirstFrame = true;
+
+ public ReconstructionFilter reconstructionFilter
+ {
+ get
+ {
+ if (m_ReconstructionFilter == null)
+ {
+ m_ReconstructionFilter = new ReconstructionFilter();
+ }
+ return m_ReconstructionFilter;
+ }
+ }
+
+ public FrameBlendingFilter frameBlendingFilter
+ {
+ get
+ {
+ if (m_FrameBlendingFilter == null)
+ {
+ m_FrameBlendingFilter = new FrameBlendingFilter();
+ }
+ return m_FrameBlendingFilter;
+ }
+ }
+
+ public override bool active
+ {
+ get
+ {
+ MotionBlurModel.Settings settings = base.model.settings;
+ if (base.model.enabled && ((settings.shutterAngle > 0f && reconstructionFilter.IsSupported()) || settings.frameBlending > 0f) && SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override string GetName()
+ {
+ return "Motion Blur";
+ }
+
+ public void ResetHistory()
+ {
+ if (m_FrameBlendingFilter != null)
+ {
+ m_FrameBlendingFilter.Dispose();
+ }
+ m_FrameBlendingFilter = null;
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
+ }
+
+ public override CameraEvent GetCameraEvent()
+ {
+ return CameraEvent.BeforeImageEffects;
+ }
+
+ public override void OnEnable()
+ {
+ m_FirstFrame = true;
+ }
+
+ public override void PopulateCommandBuffer(CommandBuffer cb)
+ {
+ if (m_FirstFrame)
+ {
+ m_FirstFrame = false;
+ return;
+ }
+ Material material = context.materialFactory.Get("Hidden/Post FX/Motion Blur");
+ Material mat = context.materialFactory.Get("Hidden/Post FX/Blit");
+ MotionBlurModel.Settings settings = base.model.settings;
+ RenderTextureFormat format = (context.isHdr ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
+ int tempRT = Uniforms._TempRT;
+ cb.GetTemporaryRT(tempRT, context.width, context.height, 0, FilterMode.Point, format);
+ if (settings.shutterAngle > 0f && settings.frameBlending > 0f)
+ {
+ reconstructionFilter.ProcessImage(context, cb, ref settings, BuiltinRenderTextureType.CameraTarget, tempRT, material);
+ frameBlendingFilter.BlendFrames(cb, settings.frameBlending, tempRT, BuiltinRenderTextureType.CameraTarget, material);
+ frameBlendingFilter.PushFrame(cb, tempRT, context.width, context.height, material);
+ }
+ else if (settings.shutterAngle > 0f)
+ {
+ cb.SetGlobalTexture(Uniforms._MainTex, BuiltinRenderTextureType.CameraTarget);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, tempRT, mat, 0);
+ reconstructionFilter.ProcessImage(context, cb, ref settings, tempRT, BuiltinRenderTextureType.CameraTarget, material);
+ }
+ else if (settings.frameBlending > 0f)
+ {
+ cb.SetGlobalTexture(Uniforms._MainTex, BuiltinRenderTextureType.CameraTarget);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, tempRT, mat, 0);
+ frameBlendingFilter.BlendFrames(cb, settings.frameBlending, tempRT, BuiltinRenderTextureType.CameraTarget, material);
+ frameBlendingFilter.PushFrame(cb, tempRT, context.width, context.height, material);
+ }
+ cb.ReleaseTemporaryRT(tempRT);
+ }
+
+ public override void OnDisable()
+ {
+ if (m_FrameBlendingFilter != null)
+ {
+ m_FrameBlendingFilter.Dispose();
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurModel.cs
new file mode 100644
index 0000000..5b0a996
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/MotionBlurModel.cs
@@ -0,0 +1,55 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class MotionBlurModel : PostProcessingModel
+{
+ [Serializable]
+ public struct Settings
+ {
+ [Range(0f, 360f)]
+ [Tooltip("The angle of rotary shutter. Larger values give longer exposure.")]
+ public float shutterAngle;
+
+ [Range(4f, 32f)]
+ [Tooltip("The amount of sample points, which affects quality and performances.")]
+ public int sampleCount;
+
+ [Range(0f, 1f)]
+ [Tooltip("The strength of multiple frame blending. The opacity of preceding frames are determined from this coefficient and time differences.")]
+ public float frameBlending;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.shutterAngle = 270f;
+ result.sampleCount = 10;
+ result.frameBlending = 0f;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingBehaviour.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingBehaviour.cs
new file mode 100644
index 0000000..5f9dccd
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingBehaviour.cs
@@ -0,0 +1,406 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+[ImageEffectAllowedInSceneView]
+[RequireComponent(typeof(Camera))]
+[DisallowMultipleComponent]
+[ExecuteInEditMode]
+[AddComponentMenu("Effects/Post-Processing Behaviour", -1)]
+public class PostProcessingBehaviour : MonoBehaviour
+{
+ public PostProcessingProfile profile;
+
+ public Func<Vector2, Matrix4x4> jitteredMatrixFunc;
+
+ private Dictionary<Type, KeyValuePair<CameraEvent, CommandBuffer>> m_CommandBuffers;
+
+ private List<PostProcessingComponentBase> m_Components;
+
+ private Dictionary<PostProcessingComponentBase, bool> m_ComponentStates;
+
+ private MaterialFactory m_MaterialFactory;
+
+ private RenderTextureFactory m_RenderTextureFactory;
+
+ private PostProcessingContext m_Context;
+
+ private Camera m_Camera;
+
+ private PostProcessingProfile m_PreviousProfile;
+
+ private bool m_RenderingInSceneView;
+
+ private BuiltinDebugViewsComponent m_DebugViews;
+
+ private AmbientOcclusionComponent m_AmbientOcclusion;
+
+ private ScreenSpaceReflectionComponent m_ScreenSpaceReflection;
+
+ private FogComponent m_FogComponent;
+
+ private MotionBlurComponent m_MotionBlur;
+
+ private TaaComponent m_Taa;
+
+ private EyeAdaptationComponent m_EyeAdaptation;
+
+ private DepthOfFieldComponent m_DepthOfField;
+
+ private BloomComponent m_Bloom;
+
+ private ChromaticAberrationComponent m_ChromaticAberration;
+
+ private ColorGradingComponent m_ColorGrading;
+
+ private UserLutComponent m_UserLut;
+
+ private GrainComponent m_Grain;
+
+ private VignetteComponent m_Vignette;
+
+ private DitheringComponent m_Dithering;
+
+ private FxaaComponent m_Fxaa;
+
+ private List<PostProcessingComponentBase> m_ComponentsToEnable = new List<PostProcessingComponentBase>();
+
+ private List<PostProcessingComponentBase> m_ComponentsToDisable = new List<PostProcessingComponentBase>();
+
+ private void OnEnable()
+ {
+ m_CommandBuffers = new Dictionary<Type, KeyValuePair<CameraEvent, CommandBuffer>>();
+ m_MaterialFactory = new MaterialFactory();
+ m_RenderTextureFactory = new RenderTextureFactory();
+ m_Context = new PostProcessingContext();
+ m_Components = new List<PostProcessingComponentBase>();
+ m_DebugViews = AddComponent(new BuiltinDebugViewsComponent());
+ m_AmbientOcclusion = AddComponent(new AmbientOcclusionComponent());
+ m_ScreenSpaceReflection = AddComponent(new ScreenSpaceReflectionComponent());
+ m_FogComponent = AddComponent(new FogComponent());
+ m_MotionBlur = AddComponent(new MotionBlurComponent());
+ m_Taa = AddComponent(new TaaComponent());
+ m_EyeAdaptation = AddComponent(new EyeAdaptationComponent());
+ m_DepthOfField = AddComponent(new DepthOfFieldComponent());
+ m_Bloom = AddComponent(new BloomComponent());
+ m_ChromaticAberration = AddComponent(new ChromaticAberrationComponent());
+ m_ColorGrading = AddComponent(new ColorGradingComponent());
+ m_UserLut = AddComponent(new UserLutComponent());
+ m_Grain = AddComponent(new GrainComponent());
+ m_Vignette = AddComponent(new VignetteComponent());
+ m_Dithering = AddComponent(new DitheringComponent());
+ m_Fxaa = AddComponent(new FxaaComponent());
+ m_ComponentStates = new Dictionary<PostProcessingComponentBase, bool>();
+ foreach (PostProcessingComponentBase component in m_Components)
+ {
+ m_ComponentStates.Add(component, value: false);
+ }
+ base.useGUILayout = false;
+ }
+
+ private void OnPreCull()
+ {
+ m_Camera = GetComponent<Camera>();
+ if (profile == null || m_Camera == null)
+ {
+ return;
+ }
+ PostProcessingContext postProcessingContext = m_Context.Reset();
+ postProcessingContext.profile = profile;
+ postProcessingContext.renderTextureFactory = m_RenderTextureFactory;
+ postProcessingContext.materialFactory = m_MaterialFactory;
+ postProcessingContext.camera = m_Camera;
+ m_DebugViews.Init(postProcessingContext, profile.debugViews);
+ m_AmbientOcclusion.Init(postProcessingContext, profile.ambientOcclusion);
+ m_ScreenSpaceReflection.Init(postProcessingContext, profile.screenSpaceReflection);
+ m_FogComponent.Init(postProcessingContext, profile.fog);
+ m_MotionBlur.Init(postProcessingContext, profile.motionBlur);
+ m_Taa.Init(postProcessingContext, profile.antialiasing);
+ m_EyeAdaptation.Init(postProcessingContext, profile.eyeAdaptation);
+ m_DepthOfField.Init(postProcessingContext, profile.depthOfField);
+ m_Bloom.Init(postProcessingContext, profile.bloom);
+ m_ChromaticAberration.Init(postProcessingContext, profile.chromaticAberration);
+ m_ColorGrading.Init(postProcessingContext, profile.colorGrading);
+ m_UserLut.Init(postProcessingContext, profile.userLut);
+ m_Grain.Init(postProcessingContext, profile.grain);
+ m_Vignette.Init(postProcessingContext, profile.vignette);
+ m_Dithering.Init(postProcessingContext, profile.dithering);
+ m_Fxaa.Init(postProcessingContext, profile.antialiasing);
+ if (m_PreviousProfile != profile)
+ {
+ DisableComponents();
+ m_PreviousProfile = profile;
+ }
+ CheckObservers();
+ DepthTextureMode depthTextureMode = postProcessingContext.camera.depthTextureMode;
+ foreach (PostProcessingComponentBase component in m_Components)
+ {
+ if (component.active)
+ {
+ depthTextureMode |= component.GetCameraFlags();
+ }
+ }
+ postProcessingContext.camera.depthTextureMode = depthTextureMode;
+ if (!m_RenderingInSceneView && m_Taa.active && !profile.debugViews.willInterrupt)
+ {
+ m_Taa.SetProjectionMatrix(jitteredMatrixFunc);
+ }
+ }
+
+ private void OnPreRender()
+ {
+ if (!(profile == null))
+ {
+ TryExecuteCommandBuffer(m_DebugViews);
+ TryExecuteCommandBuffer(m_AmbientOcclusion);
+ TryExecuteCommandBuffer(m_ScreenSpaceReflection);
+ TryExecuteCommandBuffer(m_FogComponent);
+ if (!m_RenderingInSceneView)
+ {
+ TryExecuteCommandBuffer(m_MotionBlur);
+ }
+ }
+ }
+
+ private void OnPostRender()
+ {
+ if (!(profile == null) && !(m_Camera == null) && !m_RenderingInSceneView && m_Taa.active && !profile.debugViews.willInterrupt)
+ {
+ m_Context.camera.ResetProjectionMatrix();
+ }
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (profile == null || m_Camera == null)
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ bool flag = false;
+ bool active = m_Fxaa.active;
+ bool flag2 = m_Taa.active && !m_RenderingInSceneView;
+ bool num = m_DepthOfField.active && !m_RenderingInSceneView;
+ Material material = m_MaterialFactory.Get("Hidden/Post FX/Uber Shader");
+ material.shaderKeywords = null;
+ RenderTexture renderTexture = source;
+ if (flag2)
+ {
+ RenderTexture renderTexture2 = m_RenderTextureFactory.Get(renderTexture);
+ m_Taa.Render(renderTexture, renderTexture2);
+ renderTexture = renderTexture2;
+ }
+ Texture texture = GraphicsUtils.whiteTexture;
+ if (m_EyeAdaptation.active)
+ {
+ flag = true;
+ texture = m_EyeAdaptation.Prepare(renderTexture, material);
+ }
+ material.SetTexture("_AutoExposure", texture);
+ if (num)
+ {
+ flag = true;
+ m_DepthOfField.Prepare(renderTexture, material, flag2, m_Taa.jitterVector, m_Taa.model.settings.taaSettings.motionBlending);
+ }
+ if (m_Bloom.active)
+ {
+ flag = true;
+ m_Bloom.Prepare(renderTexture, material, texture);
+ }
+ flag |= TryPrepareUberImageEffect(m_ChromaticAberration, material);
+ flag |= TryPrepareUberImageEffect(m_ColorGrading, material);
+ flag |= TryPrepareUberImageEffect(m_Vignette, material);
+ flag |= TryPrepareUberImageEffect(m_UserLut, material);
+ Material material2 = (active ? m_MaterialFactory.Get("Hidden/Post FX/FXAA") : null);
+ if (active)
+ {
+ material2.shaderKeywords = null;
+ TryPrepareUberImageEffect(m_Grain, material2);
+ TryPrepareUberImageEffect(m_Dithering, material2);
+ if (flag)
+ {
+ RenderTexture renderTexture3 = m_RenderTextureFactory.Get(renderTexture);
+ Graphics.Blit(renderTexture, renderTexture3, material, 0);
+ renderTexture = renderTexture3;
+ }
+ m_Fxaa.Render(renderTexture, destination);
+ }
+ else
+ {
+ flag |= TryPrepareUberImageEffect(m_Grain, material);
+ flag |= TryPrepareUberImageEffect(m_Dithering, material);
+ if (flag)
+ {
+ if (!GraphicsUtils.isLinearColorSpace)
+ {
+ material.EnableKeyword("UNITY_COLORSPACE_GAMMA");
+ }
+ Graphics.Blit(renderTexture, destination, material, 0);
+ }
+ }
+ if (!flag && !active)
+ {
+ Graphics.Blit(renderTexture, destination);
+ }
+ m_RenderTextureFactory.ReleaseAll();
+ }
+
+ private void OnGUI()
+ {
+ if (Event.current.type == EventType.Repaint && !(profile == null) && !(m_Camera == null))
+ {
+ if (m_EyeAdaptation.active && profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.EyeAdaptation))
+ {
+ m_EyeAdaptation.OnGUI();
+ }
+ else if (m_ColorGrading.active && profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.LogLut))
+ {
+ m_ColorGrading.OnGUI();
+ }
+ else if (m_UserLut.active && profile.debugViews.IsModeActive(BuiltinDebugViewsModel.Mode.UserLut))
+ {
+ m_UserLut.OnGUI();
+ }
+ }
+ }
+
+ private void OnDisable()
+ {
+ foreach (KeyValuePair<CameraEvent, CommandBuffer> value in m_CommandBuffers.Values)
+ {
+ m_Camera.RemoveCommandBuffer(value.Key, value.Value);
+ value.Value.Dispose();
+ }
+ m_CommandBuffers.Clear();
+ if (profile != null)
+ {
+ DisableComponents();
+ }
+ m_Components.Clear();
+ m_MaterialFactory.Dispose();
+ m_RenderTextureFactory.Dispose();
+ GraphicsUtils.Dispose();
+ }
+
+ public void ResetTemporalEffects()
+ {
+ m_Taa.ResetHistory();
+ m_MotionBlur.ResetHistory();
+ m_EyeAdaptation.ResetHistory();
+ }
+
+ private void CheckObservers()
+ {
+ foreach (KeyValuePair<PostProcessingComponentBase, bool> componentState in m_ComponentStates)
+ {
+ PostProcessingComponentBase key = componentState.Key;
+ bool flag = key.GetModel().enabled;
+ if (flag != componentState.Value)
+ {
+ if (flag)
+ {
+ m_ComponentsToEnable.Add(key);
+ }
+ else
+ {
+ m_ComponentsToDisable.Add(key);
+ }
+ }
+ }
+ for (int i = 0; i < m_ComponentsToDisable.Count; i++)
+ {
+ PostProcessingComponentBase postProcessingComponentBase = m_ComponentsToDisable[i];
+ m_ComponentStates[postProcessingComponentBase] = false;
+ postProcessingComponentBase.OnDisable();
+ }
+ for (int j = 0; j < m_ComponentsToEnable.Count; j++)
+ {
+ PostProcessingComponentBase postProcessingComponentBase2 = m_ComponentsToEnable[j];
+ m_ComponentStates[postProcessingComponentBase2] = true;
+ postProcessingComponentBase2.OnEnable();
+ }
+ m_ComponentsToDisable.Clear();
+ m_ComponentsToEnable.Clear();
+ }
+
+ private void DisableComponents()
+ {
+ foreach (PostProcessingComponentBase component in m_Components)
+ {
+ PostProcessingModel model = component.GetModel();
+ if (model != null && model.enabled)
+ {
+ component.OnDisable();
+ }
+ }
+ }
+
+ private CommandBuffer AddCommandBuffer<T>(CameraEvent evt, string name) where T : PostProcessingModel
+ {
+ CommandBuffer value = new CommandBuffer
+ {
+ name = name
+ };
+ KeyValuePair<CameraEvent, CommandBuffer> value2 = new KeyValuePair<CameraEvent, CommandBuffer>(evt, value);
+ m_CommandBuffers.Add(typeof(T), value2);
+ m_Camera.AddCommandBuffer(evt, value2.Value);
+ return value2.Value;
+ }
+
+ private void RemoveCommandBuffer<T>() where T : PostProcessingModel
+ {
+ Type typeFromHandle = typeof(T);
+ if (m_CommandBuffers.TryGetValue(typeFromHandle, out var value))
+ {
+ m_Camera.RemoveCommandBuffer(value.Key, value.Value);
+ m_CommandBuffers.Remove(typeFromHandle);
+ value.Value.Dispose();
+ }
+ }
+
+ private CommandBuffer GetCommandBuffer<T>(CameraEvent evt, string name) where T : PostProcessingModel
+ {
+ if (!m_CommandBuffers.TryGetValue(typeof(T), out var value))
+ {
+ return AddCommandBuffer<T>(evt, name);
+ }
+ if (value.Key != evt)
+ {
+ RemoveCommandBuffer<T>();
+ return AddCommandBuffer<T>(evt, name);
+ }
+ return value.Value;
+ }
+
+ private void TryExecuteCommandBuffer<T>(PostProcessingComponentCommandBuffer<T> component) where T : PostProcessingModel
+ {
+ if (component.active)
+ {
+ CommandBuffer commandBuffer = GetCommandBuffer<T>(component.GetCameraEvent(), component.GetName());
+ commandBuffer.Clear();
+ component.PopulateCommandBuffer(commandBuffer);
+ }
+ else
+ {
+ RemoveCommandBuffer<T>();
+ }
+ }
+
+ private bool TryPrepareUberImageEffect<T>(PostProcessingComponentRenderTexture<T> component, Material material) where T : PostProcessingModel
+ {
+ if (!component.active)
+ {
+ return false;
+ }
+ component.Prepare(material);
+ return true;
+ }
+
+ private T AddComponent<T>(T component) where T : PostProcessingComponentBase
+ {
+ m_Components.Add(component);
+ return component;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponent.cs
new file mode 100644
index 0000000..08c2ba7
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponent.cs
@@ -0,0 +1,17 @@
+namespace UnityEngine.PostProcessing;
+
+public abstract class PostProcessingComponent<T> : PostProcessingComponentBase where T : PostProcessingModel
+{
+ public T model { get; internal set; }
+
+ public virtual void Init(PostProcessingContext pcontext, T pmodel)
+ {
+ context = pcontext;
+ model = pmodel;
+ }
+
+ public override PostProcessingModel GetModel()
+ {
+ return model;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentBase.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentBase.cs
new file mode 100644
index 0000000..491f371
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentBase.cs
@@ -0,0 +1,23 @@
+namespace UnityEngine.PostProcessing;
+
+public abstract class PostProcessingComponentBase
+{
+ public PostProcessingContext context;
+
+ public abstract bool active { get; }
+
+ public virtual DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.None;
+ }
+
+ public virtual void OnEnable()
+ {
+ }
+
+ public virtual void OnDisable()
+ {
+ }
+
+ public abstract PostProcessingModel GetModel();
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentCommandBuffer.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentCommandBuffer.cs
new file mode 100644
index 0000000..a8a9408
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentCommandBuffer.cs
@@ -0,0 +1,12 @@
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public abstract class PostProcessingComponentCommandBuffer<T> : PostProcessingComponent<T> where T : PostProcessingModel
+{
+ public abstract CameraEvent GetCameraEvent();
+
+ public abstract string GetName();
+
+ public abstract void PopulateCommandBuffer(CommandBuffer cb);
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentRenderTexture.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentRenderTexture.cs
new file mode 100644
index 0000000..8284bb2
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingComponentRenderTexture.cs
@@ -0,0 +1,8 @@
+namespace UnityEngine.PostProcessing;
+
+public abstract class PostProcessingComponentRenderTexture<T> : PostProcessingComponent<T> where T : PostProcessingModel
+{
+ public virtual void Prepare(Material material)
+ {
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingContext.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingContext.cs
new file mode 100644
index 0000000..ab810a1
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingContext.cs
@@ -0,0 +1,39 @@
+namespace UnityEngine.PostProcessing;
+
+public class PostProcessingContext
+{
+ public PostProcessingProfile profile;
+
+ public Camera camera;
+
+ public MaterialFactory materialFactory;
+
+ public RenderTextureFactory renderTextureFactory;
+
+ public bool interrupted { get; private set; }
+
+ public bool isGBufferAvailable => camera.actualRenderingPath == RenderingPath.DeferredShading;
+
+ public bool isHdr => camera.allowHDR;
+
+ public int width => camera.pixelWidth;
+
+ public int height => camera.pixelHeight;
+
+ public Rect viewport => camera.rect;
+
+ public void Interrupt()
+ {
+ interrupted = true;
+ }
+
+ public PostProcessingContext Reset()
+ {
+ profile = null;
+ camera = null;
+ materialFactory = null;
+ renderTextureFactory = null;
+ interrupted = false;
+ return this;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingModel.cs
new file mode 100644
index 0000000..986b42b
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingModel.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public abstract class PostProcessingModel
+{
+ [SerializeField]
+ [GetSet("enabled")]
+ private bool m_Enabled;
+
+ public bool enabled
+ {
+ get
+ {
+ return m_Enabled;
+ }
+ set
+ {
+ m_Enabled = value;
+ if (value)
+ {
+ OnValidate();
+ }
+ }
+ }
+
+ public abstract void Reset();
+
+ public virtual void OnValidate()
+ {
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingProfile.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingProfile.cs
new file mode 100644
index 0000000..3c847b3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/PostProcessingProfile.cs
@@ -0,0 +1,34 @@
+namespace UnityEngine.PostProcessing;
+
+public class PostProcessingProfile : ScriptableObject
+{
+ public BuiltinDebugViewsModel debugViews = new BuiltinDebugViewsModel();
+
+ public FogModel fog = new FogModel();
+
+ public AntialiasingModel antialiasing = new AntialiasingModel();
+
+ public AmbientOcclusionModel ambientOcclusion = new AmbientOcclusionModel();
+
+ public ScreenSpaceReflectionModel screenSpaceReflection = new ScreenSpaceReflectionModel();
+
+ public DepthOfFieldModel depthOfField = new DepthOfFieldModel();
+
+ public MotionBlurModel motionBlur = new MotionBlurModel();
+
+ public EyeAdaptationModel eyeAdaptation = new EyeAdaptationModel();
+
+ public BloomModel bloom = new BloomModel();
+
+ public ColorGradingModel colorGrading = new ColorGradingModel();
+
+ public UserLutModel userLut = new UserLutModel();
+
+ public ChromaticAberrationModel chromaticAberration = new ChromaticAberrationModel();
+
+ public GrainModel grain = new GrainModel();
+
+ public VignetteModel vignette = new VignetteModel();
+
+ public DitheringModel dithering = new DitheringModel();
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/RenderTextureFactory.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/RenderTextureFactory.cs
new file mode 100644
index 0000000..51d9f15
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/RenderTextureFactory.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class RenderTextureFactory : IDisposable
+{
+ private HashSet<RenderTexture> m_TemporaryRTs;
+
+ public RenderTextureFactory()
+ {
+ m_TemporaryRTs = new HashSet<RenderTexture>();
+ }
+
+ public RenderTexture Get(RenderTexture baseRenderTexture)
+ {
+ return Get(baseRenderTexture.width, baseRenderTexture.height, baseRenderTexture.depth, baseRenderTexture.format, (!baseRenderTexture.sRGB) ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.sRGB, baseRenderTexture.filterMode, baseRenderTexture.wrapMode);
+ }
+
+ public RenderTexture Get(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, RenderTextureReadWrite rw = RenderTextureReadWrite.Default, FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, string name = "FactoryTempTexture")
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, depthBuffer, format, rw);
+ temporary.filterMode = filterMode;
+ temporary.wrapMode = wrapMode;
+ temporary.name = name;
+ m_TemporaryRTs.Add(temporary);
+ return temporary;
+ }
+
+ public void Release(RenderTexture rt)
+ {
+ if (!(rt == null))
+ {
+ if (!m_TemporaryRTs.Contains(rt))
+ {
+ throw new ArgumentException($"Attempting to remove a RenderTexture that was not allocated: {rt}");
+ }
+ m_TemporaryRTs.Remove(rt);
+ RenderTexture.ReleaseTemporary(rt);
+ }
+ }
+
+ public void ReleaseAll()
+ {
+ HashSet<RenderTexture>.Enumerator enumerator = m_TemporaryRTs.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ RenderTexture.ReleaseTemporary(enumerator.Current);
+ }
+ m_TemporaryRTs.Clear();
+ }
+
+ public void Dispose()
+ {
+ ReleaseAll();
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionComponent.cs
new file mode 100644
index 0000000..e94b2ac
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionComponent.cs
@@ -0,0 +1,227 @@
+using System;
+using UnityEngine.Rendering;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class ScreenSpaceReflectionComponent : PostProcessingComponentCommandBuffer<ScreenSpaceReflectionModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _RayStepSize = Shader.PropertyToID("_RayStepSize");
+
+ internal static readonly int _AdditiveReflection = Shader.PropertyToID("_AdditiveReflection");
+
+ internal static readonly int _BilateralUpsampling = Shader.PropertyToID("_BilateralUpsampling");
+
+ internal static readonly int _TreatBackfaceHitAsMiss = Shader.PropertyToID("_TreatBackfaceHitAsMiss");
+
+ internal static readonly int _AllowBackwardsRays = Shader.PropertyToID("_AllowBackwardsRays");
+
+ internal static readonly int _TraceBehindObjects = Shader.PropertyToID("_TraceBehindObjects");
+
+ internal static readonly int _MaxSteps = Shader.PropertyToID("_MaxSteps");
+
+ internal static readonly int _FullResolutionFiltering = Shader.PropertyToID("_FullResolutionFiltering");
+
+ internal static readonly int _HalfResolution = Shader.PropertyToID("_HalfResolution");
+
+ internal static readonly int _HighlightSuppression = Shader.PropertyToID("_HighlightSuppression");
+
+ internal static readonly int _PixelsPerMeterAtOneMeter = Shader.PropertyToID("_PixelsPerMeterAtOneMeter");
+
+ internal static readonly int _ScreenEdgeFading = Shader.PropertyToID("_ScreenEdgeFading");
+
+ internal static readonly int _ReflectionBlur = Shader.PropertyToID("_ReflectionBlur");
+
+ internal static readonly int _MaxRayTraceDistance = Shader.PropertyToID("_MaxRayTraceDistance");
+
+ internal static readonly int _FadeDistance = Shader.PropertyToID("_FadeDistance");
+
+ internal static readonly int _LayerThickness = Shader.PropertyToID("_LayerThickness");
+
+ internal static readonly int _SSRMultiplier = Shader.PropertyToID("_SSRMultiplier");
+
+ internal static readonly int _FresnelFade = Shader.PropertyToID("_FresnelFade");
+
+ internal static readonly int _FresnelFadePower = Shader.PropertyToID("_FresnelFadePower");
+
+ internal static readonly int _ReflectionBufferSize = Shader.PropertyToID("_ReflectionBufferSize");
+
+ internal static readonly int _ScreenSize = Shader.PropertyToID("_ScreenSize");
+
+ internal static readonly int _InvScreenSize = Shader.PropertyToID("_InvScreenSize");
+
+ internal static readonly int _ProjInfo = Shader.PropertyToID("_ProjInfo");
+
+ internal static readonly int _CameraClipInfo = Shader.PropertyToID("_CameraClipInfo");
+
+ internal static readonly int _ProjectToPixelMatrix = Shader.PropertyToID("_ProjectToPixelMatrix");
+
+ internal static readonly int _WorldToCameraMatrix = Shader.PropertyToID("_WorldToCameraMatrix");
+
+ internal static readonly int _CameraToWorldMatrix = Shader.PropertyToID("_CameraToWorldMatrix");
+
+ internal static readonly int _Axis = Shader.PropertyToID("_Axis");
+
+ internal static readonly int _CurrentMipLevel = Shader.PropertyToID("_CurrentMipLevel");
+
+ internal static readonly int _NormalAndRoughnessTexture = Shader.PropertyToID("_NormalAndRoughnessTexture");
+
+ internal static readonly int _HitPointTexture = Shader.PropertyToID("_HitPointTexture");
+
+ internal static readonly int _BlurTexture = Shader.PropertyToID("_BlurTexture");
+
+ internal static readonly int _FilteredReflections = Shader.PropertyToID("_FilteredReflections");
+
+ internal static readonly int _FinalReflectionTexture = Shader.PropertyToID("_FinalReflectionTexture");
+
+ internal static readonly int _TempTexture = Shader.PropertyToID("_TempTexture");
+ }
+
+ private enum PassIndex
+ {
+ RayTraceStep,
+ CompositeFinal,
+ Blur,
+ CompositeSSR,
+ MinMipGeneration,
+ HitPointToReflections,
+ BilateralKeyPack,
+ BlitDepthAsCSZ,
+ PoissonBlur
+ }
+
+ private bool k_HighlightSuppression;
+
+ private bool k_TraceBehindObjects = true;
+
+ private bool k_TreatBackfaceHitAsMiss;
+
+ private bool k_BilateralUpsample = true;
+
+ private readonly int[] m_ReflectionTextures = new int[5];
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && context.isGBufferAvailable)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.Depth;
+ }
+
+ public override void OnEnable()
+ {
+ m_ReflectionTextures[0] = Shader.PropertyToID("_ReflectionTexture0");
+ m_ReflectionTextures[1] = Shader.PropertyToID("_ReflectionTexture1");
+ m_ReflectionTextures[2] = Shader.PropertyToID("_ReflectionTexture2");
+ m_ReflectionTextures[3] = Shader.PropertyToID("_ReflectionTexture3");
+ m_ReflectionTextures[4] = Shader.PropertyToID("_ReflectionTexture4");
+ }
+
+ public override string GetName()
+ {
+ return "Screen Space Reflection";
+ }
+
+ public override CameraEvent GetCameraEvent()
+ {
+ return CameraEvent.AfterFinalPass;
+ }
+
+ public override void PopulateCommandBuffer(CommandBuffer cb)
+ {
+ ScreenSpaceReflectionModel.Settings settings = base.model.settings;
+ Camera camera = context.camera;
+ int num = ((settings.reflection.reflectionQuality == ScreenSpaceReflectionModel.SSRResolution.High) ? 1 : 2);
+ int num2 = context.width / num;
+ int num3 = context.height / num;
+ float num4 = context.width;
+ float num5 = context.height;
+ float num6 = num4 / 2f;
+ float num7 = num5 / 2f;
+ Material material = context.materialFactory.Get("Hidden/Post FX/Screen Space Reflection");
+ material.SetInt(Uniforms._RayStepSize, settings.reflection.stepSize);
+ material.SetInt(Uniforms._AdditiveReflection, (settings.reflection.blendType == ScreenSpaceReflectionModel.SSRReflectionBlendType.Additive) ? 1 : 0);
+ material.SetInt(Uniforms._BilateralUpsampling, k_BilateralUpsample ? 1 : 0);
+ material.SetInt(Uniforms._TreatBackfaceHitAsMiss, k_TreatBackfaceHitAsMiss ? 1 : 0);
+ material.SetInt(Uniforms._AllowBackwardsRays, settings.reflection.reflectBackfaces ? 1 : 0);
+ material.SetInt(Uniforms._TraceBehindObjects, k_TraceBehindObjects ? 1 : 0);
+ material.SetInt(Uniforms._MaxSteps, settings.reflection.iterationCount);
+ material.SetInt(Uniforms._FullResolutionFiltering, 0);
+ material.SetInt(Uniforms._HalfResolution, (settings.reflection.reflectionQuality != 0) ? 1 : 0);
+ material.SetInt(Uniforms._HighlightSuppression, k_HighlightSuppression ? 1 : 0);
+ float value = num4 / (-2f * Mathf.Tan(camera.fieldOfView / 180f * (float)Math.PI * 0.5f));
+ material.SetFloat(Uniforms._PixelsPerMeterAtOneMeter, value);
+ material.SetFloat(Uniforms._ScreenEdgeFading, settings.screenEdgeMask.intensity);
+ material.SetFloat(Uniforms._ReflectionBlur, settings.reflection.reflectionBlur);
+ material.SetFloat(Uniforms._MaxRayTraceDistance, settings.reflection.maxDistance);
+ material.SetFloat(Uniforms._FadeDistance, settings.intensity.fadeDistance);
+ material.SetFloat(Uniforms._LayerThickness, settings.reflection.widthModifier);
+ material.SetFloat(Uniforms._SSRMultiplier, settings.intensity.reflectionMultiplier);
+ material.SetFloat(Uniforms._FresnelFade, settings.intensity.fresnelFade);
+ material.SetFloat(Uniforms._FresnelFadePower, settings.intensity.fresnelFadePower);
+ Matrix4x4 projectionMatrix = camera.projectionMatrix;
+ Vector4 value2 = new Vector4(-2f / (num4 * projectionMatrix[0]), -2f / (num5 * projectionMatrix[5]), (1f - projectionMatrix[2]) / projectionMatrix[0], (1f + projectionMatrix[6]) / projectionMatrix[5]);
+ Vector3 vector = (float.IsPositiveInfinity(camera.farClipPlane) ? new Vector3(camera.nearClipPlane, -1f, 1f) : new Vector3(camera.nearClipPlane * camera.farClipPlane, camera.nearClipPlane - camera.farClipPlane, camera.farClipPlane));
+ material.SetVector(Uniforms._ReflectionBufferSize, new Vector2(num2, num3));
+ material.SetVector(Uniforms._ScreenSize, new Vector2(num4, num5));
+ material.SetVector(Uniforms._InvScreenSize, new Vector2(1f / num4, 1f / num5));
+ material.SetVector(Uniforms._ProjInfo, value2);
+ material.SetVector(Uniforms._CameraClipInfo, vector);
+ Matrix4x4 matrix4x = default(Matrix4x4);
+ matrix4x.SetRow(0, new Vector4(num6, 0f, 0f, num6));
+ matrix4x.SetRow(1, new Vector4(0f, num7, 0f, num7));
+ matrix4x.SetRow(2, new Vector4(0f, 0f, 1f, 0f));
+ matrix4x.SetRow(3, new Vector4(0f, 0f, 0f, 1f));
+ Matrix4x4 value3 = matrix4x * projectionMatrix;
+ material.SetMatrix(Uniforms._ProjectToPixelMatrix, value3);
+ material.SetMatrix(Uniforms._WorldToCameraMatrix, camera.worldToCameraMatrix);
+ material.SetMatrix(Uniforms._CameraToWorldMatrix, camera.worldToCameraMatrix.inverse);
+ RenderTextureFormat format = (context.isHdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
+ int normalAndRoughnessTexture = Uniforms._NormalAndRoughnessTexture;
+ int hitPointTexture = Uniforms._HitPointTexture;
+ int blurTexture = Uniforms._BlurTexture;
+ int filteredReflections = Uniforms._FilteredReflections;
+ int finalReflectionTexture = Uniforms._FinalReflectionTexture;
+ int tempTexture = Uniforms._TempTexture;
+ cb.GetTemporaryRT(normalAndRoughnessTexture, -1, -1, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
+ cb.GetTemporaryRT(hitPointTexture, num2, num3, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
+ for (int i = 0; i < 5; i++)
+ {
+ cb.GetTemporaryRT(m_ReflectionTextures[i], num2 >> i, num3 >> i, 0, FilterMode.Bilinear, format);
+ }
+ cb.GetTemporaryRT(filteredReflections, num2, num3, 0, (!k_BilateralUpsample) ? FilterMode.Bilinear : FilterMode.Point, format);
+ cb.GetTemporaryRT(finalReflectionTexture, num2, num3, 0, FilterMode.Point, format);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, normalAndRoughnessTexture, material, 6);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, hitPointTexture, material, 0);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, filteredReflections, material, 5);
+ cb.Blit(filteredReflections, m_ReflectionTextures[0], material, 8);
+ for (int j = 1; j < 5; j++)
+ {
+ int num8 = m_ReflectionTextures[j - 1];
+ int num9 = j;
+ cb.GetTemporaryRT(blurTexture, num2 >> num9, num3 >> num9, 0, FilterMode.Bilinear, format);
+ cb.SetGlobalVector(Uniforms._Axis, new Vector4(1f, 0f, 0f, 0f));
+ cb.SetGlobalFloat(Uniforms._CurrentMipLevel, (float)j - 1f);
+ cb.Blit(num8, blurTexture, material, 2);
+ cb.SetGlobalVector(Uniforms._Axis, new Vector4(0f, 1f, 0f, 0f));
+ num8 = m_ReflectionTextures[j];
+ cb.Blit(blurTexture, num8, material, 2);
+ cb.ReleaseTemporaryRT(blurTexture);
+ }
+ cb.Blit(m_ReflectionTextures[0], finalReflectionTexture, material, 3);
+ cb.GetTemporaryRT(tempTexture, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Bilinear, format);
+ cb.Blit(BuiltinRenderTextureType.CameraTarget, tempTexture, material, 1);
+ cb.Blit(tempTexture, BuiltinRenderTextureType.CameraTarget);
+ cb.ReleaseTemporaryRT(tempTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionModel.cs
new file mode 100644
index 0000000..2552044
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/ScreenSpaceReflectionModel.cs
@@ -0,0 +1,141 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class ScreenSpaceReflectionModel : PostProcessingModel
+{
+ public enum SSRResolution
+ {
+ High = 0,
+ Low = 2
+ }
+
+ public enum SSRReflectionBlendType
+ {
+ PhysicallyBased,
+ Additive
+ }
+
+ [Serializable]
+ public struct IntensitySettings
+ {
+ [Tooltip("Nonphysical multiplier for the SSR reflections. 1.0 is physically based.")]
+ [Range(0f, 2f)]
+ public float reflectionMultiplier;
+
+ [Tooltip("How far away from the maxDistance to begin fading SSR.")]
+ [Range(0f, 1000f)]
+ public float fadeDistance;
+
+ [Tooltip("Amplify Fresnel fade out. Increase if floor reflections look good close to the surface and bad farther 'under' the floor.")]
+ [Range(0f, 1f)]
+ public float fresnelFade;
+
+ [Tooltip("Higher values correspond to a faster Fresnel fade as the reflection changes from the grazing angle.")]
+ [Range(0.1f, 10f)]
+ public float fresnelFadePower;
+ }
+
+ [Serializable]
+ public struct ReflectionSettings
+ {
+ [Tooltip("How the reflections are blended into the render.")]
+ public SSRReflectionBlendType blendType;
+
+ [Tooltip("Half resolution SSRR is much faster, but less accurate.")]
+ public SSRResolution reflectionQuality;
+
+ [Tooltip("Maximum reflection distance in world units.")]
+ [Range(0.1f, 300f)]
+ public float maxDistance;
+
+ [Tooltip("Max raytracing length.")]
+ [Range(16f, 1024f)]
+ public int iterationCount;
+
+ [Tooltip("Log base 2 of ray tracing coarse step size. Higher traces farther, lower gives better quality silhouettes.")]
+ [Range(1f, 16f)]
+ public int stepSize;
+
+ [Tooltip("Typical thickness of columns, walls, furniture, and other objects that reflection rays might pass behind.")]
+ [Range(0.01f, 10f)]
+ public float widthModifier;
+
+ [Tooltip("Blurriness of reflections.")]
+ [Range(0.1f, 8f)]
+ public float reflectionBlur;
+
+ [Tooltip("Disable for a performance gain in scenes where most glossy objects are horizontal, like floors, water, and tables. Leave on for scenes with glossy vertical objects.")]
+ public bool reflectBackfaces;
+ }
+
+ [Serializable]
+ public struct ScreenEdgeMask
+ {
+ [Tooltip("Higher = fade out SSRR near the edge of the screen so that reflections don't pop under camera motion.")]
+ [Range(0f, 1f)]
+ public float intensity;
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ public ReflectionSettings reflection;
+
+ public IntensitySettings intensity;
+
+ public ScreenEdgeMask screenEdgeMask;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.reflection = new ReflectionSettings
+ {
+ blendType = SSRReflectionBlendType.PhysicallyBased,
+ reflectionQuality = SSRResolution.Low,
+ maxDistance = 100f,
+ iterationCount = 256,
+ stepSize = 3,
+ widthModifier = 0.5f,
+ reflectionBlur = 1f,
+ reflectBackfaces = false
+ };
+ result.intensity = new IntensitySettings
+ {
+ reflectionMultiplier = 1f,
+ fadeDistance = 100f,
+ fresnelFade = 1f,
+ fresnelFadePower = 1f
+ };
+ result.screenEdgeMask = new ScreenEdgeMask
+ {
+ intensity = 0.03f
+ };
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TaaComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TaaComponent.cs
new file mode 100644
index 0000000..d02e1a9
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TaaComponent.cs
@@ -0,0 +1,184 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+public sealed class TaaComponent : PostProcessingComponentRenderTexture<AntialiasingModel>
+{
+ private static class Uniforms
+ {
+ internal static int _Jitter = Shader.PropertyToID("_Jitter");
+
+ internal static int _SharpenParameters = Shader.PropertyToID("_SharpenParameters");
+
+ internal static int _FinalBlendParameters = Shader.PropertyToID("_FinalBlendParameters");
+
+ internal static int _HistoryTex = Shader.PropertyToID("_HistoryTex");
+
+ internal static int _MainTex = Shader.PropertyToID("_MainTex");
+ }
+
+ private const string k_ShaderString = "Hidden/Post FX/Temporal Anti-aliasing";
+
+ private const int k_SampleCount = 8;
+
+ private readonly RenderBuffer[] m_MRT = new RenderBuffer[2];
+
+ private int m_SampleIndex;
+
+ private bool m_ResetHistory = true;
+
+ private RenderTexture m_HistoryTexture;
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled && base.model.settings.method == AntialiasingModel.Method.Taa && SystemInfo.supportsMotionVectors && SystemInfo.supportedRenderTargetCount >= 2)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public Vector2 jitterVector { get; private set; }
+
+ public override DepthTextureMode GetCameraFlags()
+ {
+ return DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
+ }
+
+ public void ResetHistory()
+ {
+ m_ResetHistory = true;
+ }
+
+ public void SetProjectionMatrix(Func<Vector2, Matrix4x4> jitteredFunc)
+ {
+ AntialiasingModel.TaaSettings taaSettings = base.model.settings.taaSettings;
+ Vector2 vector = GenerateRandomOffset();
+ vector *= taaSettings.jitterSpread;
+ context.camera.nonJitteredProjectionMatrix = context.camera.projectionMatrix;
+ if (jitteredFunc != null)
+ {
+ context.camera.projectionMatrix = jitteredFunc(vector);
+ }
+ else
+ {
+ context.camera.projectionMatrix = (context.camera.orthographic ? GetOrthographicProjectionMatrix(vector) : GetPerspectiveProjectionMatrix(vector));
+ }
+ context.camera.useJitteredProjectionMatrixForTransparentRendering = false;
+ vector.x /= context.width;
+ vector.y /= context.height;
+ context.materialFactory.Get("Hidden/Post FX/Temporal Anti-aliasing").SetVector(Uniforms._Jitter, vector);
+ jitterVector = vector;
+ }
+
+ public void Render(RenderTexture source, RenderTexture destination)
+ {
+ Material material = context.materialFactory.Get("Hidden/Post FX/Temporal Anti-aliasing");
+ material.shaderKeywords = null;
+ AntialiasingModel.TaaSettings taaSettings = base.model.settings.taaSettings;
+ if (m_ResetHistory || m_HistoryTexture == null || m_HistoryTexture.width != source.width || m_HistoryTexture.height != source.height)
+ {
+ if ((bool)m_HistoryTexture)
+ {
+ RenderTexture.ReleaseTemporary(m_HistoryTexture);
+ }
+ m_HistoryTexture = RenderTexture.GetTemporary(source.width, source.height, 0, source.format);
+ m_HistoryTexture.name = "TAA History";
+ Graphics.Blit(source, m_HistoryTexture, material, 2);
+ }
+ material.SetVector(Uniforms._SharpenParameters, new Vector4(taaSettings.sharpen, 0f, 0f, 0f));
+ material.SetVector(Uniforms._FinalBlendParameters, new Vector4(taaSettings.stationaryBlending, taaSettings.motionBlending, 6000f, 0f));
+ material.SetTexture(Uniforms._MainTex, source);
+ material.SetTexture(Uniforms._HistoryTex, m_HistoryTexture);
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0, source.format);
+ temporary.name = "TAA History";
+ m_MRT[0] = destination.colorBuffer;
+ m_MRT[1] = temporary.colorBuffer;
+ Graphics.SetRenderTarget(m_MRT, source.depthBuffer);
+ GraphicsUtils.Blit(material, context.camera.orthographic ? 1 : 0);
+ RenderTexture.ReleaseTemporary(m_HistoryTexture);
+ m_HistoryTexture = temporary;
+ m_ResetHistory = false;
+ }
+
+ private float GetHaltonValue(int index, int radix)
+ {
+ float num = 0f;
+ float num2 = 1f / (float)radix;
+ while (index > 0)
+ {
+ num += (float)(index % radix) * num2;
+ index /= radix;
+ num2 /= (float)radix;
+ }
+ return num;
+ }
+
+ private Vector2 GenerateRandomOffset()
+ {
+ Vector2 result = new Vector2(GetHaltonValue(m_SampleIndex & 0x3FF, 2), GetHaltonValue(m_SampleIndex & 0x3FF, 3));
+ if (++m_SampleIndex >= 8)
+ {
+ m_SampleIndex = 0;
+ }
+ return result;
+ }
+
+ private Matrix4x4 GetPerspectiveProjectionMatrix(Vector2 offset)
+ {
+ float num = Mathf.Tan((float)Math.PI / 360f * context.camera.fieldOfView);
+ float num2 = num * context.camera.aspect;
+ offset.x *= num2 / (0.5f * (float)context.width);
+ offset.y *= num / (0.5f * (float)context.height);
+ float num3 = (offset.x - num2) * context.camera.nearClipPlane;
+ float num4 = (offset.x + num2) * context.camera.nearClipPlane;
+ float num5 = (offset.y + num) * context.camera.nearClipPlane;
+ float num6 = (offset.y - num) * context.camera.nearClipPlane;
+ Matrix4x4 result = default(Matrix4x4);
+ result[0, 0] = 2f * context.camera.nearClipPlane / (num4 - num3);
+ result[0, 1] = 0f;
+ result[0, 2] = (num4 + num3) / (num4 - num3);
+ result[0, 3] = 0f;
+ result[1, 0] = 0f;
+ result[1, 1] = 2f * context.camera.nearClipPlane / (num5 - num6);
+ result[1, 2] = (num5 + num6) / (num5 - num6);
+ result[1, 3] = 0f;
+ result[2, 0] = 0f;
+ result[2, 1] = 0f;
+ result[2, 2] = (0f - (context.camera.farClipPlane + context.camera.nearClipPlane)) / (context.camera.farClipPlane - context.camera.nearClipPlane);
+ result[2, 3] = (0f - 2f * context.camera.farClipPlane * context.camera.nearClipPlane) / (context.camera.farClipPlane - context.camera.nearClipPlane);
+ result[3, 0] = 0f;
+ result[3, 1] = 0f;
+ result[3, 2] = -1f;
+ result[3, 3] = 0f;
+ return result;
+ }
+
+ private Matrix4x4 GetOrthographicProjectionMatrix(Vector2 offset)
+ {
+ float orthographicSize = context.camera.orthographicSize;
+ float num = orthographicSize * context.camera.aspect;
+ offset.x *= num / (0.5f * (float)context.width);
+ offset.y *= orthographicSize / (0.5f * (float)context.height);
+ float left = offset.x - num;
+ float right = offset.x + num;
+ float top = offset.y + orthographicSize;
+ float bottom = offset.y - orthographicSize;
+ return Matrix4x4.Ortho(left, right, bottom, top, context.camera.nearClipPlane, context.camera.farClipPlane);
+ }
+
+ public override void OnDisable()
+ {
+ if (m_HistoryTexture != null)
+ {
+ RenderTexture.ReleaseTemporary(m_HistoryTexture);
+ }
+ m_HistoryTexture = null;
+ m_SampleIndex = 0;
+ ResetHistory();
+ context.camera.useJitteredProjectionMatrixForTransparentRendering = true;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballAttribute.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballAttribute.cs
new file mode 100644
index 0000000..0f37d97
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballAttribute.cs
@@ -0,0 +1,11 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class TrackballAttribute : PropertyAttribute
+{
+ public readonly string method;
+
+ public TrackballAttribute(string method)
+ {
+ this.method = method;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballGroupAttribute.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballGroupAttribute.cs
new file mode 100644
index 0000000..c64ea0e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/TrackballGroupAttribute.cs
@@ -0,0 +1,5 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class TrackballGroupAttribute : PropertyAttribute
+{
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutComponent.cs
new file mode 100644
index 0000000..69399bf
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutComponent.cs
@@ -0,0 +1,38 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class UserLutComponent : PostProcessingComponentRenderTexture<UserLutModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _UserLut = Shader.PropertyToID("_UserLut");
+
+ internal static readonly int _UserLut_Params = Shader.PropertyToID("_UserLut_Params");
+ }
+
+ public override bool active
+ {
+ get
+ {
+ UserLutModel.Settings settings = base.model.settings;
+ if (base.model.enabled && settings.lut != null && settings.contribution > 0f && settings.lut.height == (int)Mathf.Sqrt(settings.lut.width))
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ UserLutModel.Settings settings = base.model.settings;
+ uberMaterial.EnableKeyword("USER_LUT");
+ uberMaterial.SetTexture(Uniforms._UserLut, settings.lut);
+ uberMaterial.SetVector(Uniforms._UserLut_Params, new Vector4(1f / (float)settings.lut.width, 1f / (float)settings.lut.height, (float)settings.lut.height - 1f, settings.contribution));
+ }
+
+ public void OnGUI()
+ {
+ UserLutModel.Settings settings = base.model.settings;
+ GUI.DrawTexture(new Rect(context.viewport.x * (float)Screen.width + 8f, 8f, settings.lut.width, settings.lut.height), settings.lut);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutModel.cs
new file mode 100644
index 0000000..8cab02f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/UserLutModel.cs
@@ -0,0 +1,49 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class UserLutModel : PostProcessingModel
+{
+ [Serializable]
+ public struct Settings
+ {
+ [Tooltip("Custom lookup texture (strip format, e.g. 256x16).")]
+ public Texture2D lut;
+
+ [Range(0f, 1f)]
+ [Tooltip("Blending factor.")]
+ public float contribution;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.lut = null;
+ result.contribution = 1f;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteComponent.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteComponent.cs
new file mode 100644
index 0000000..b1c4b8f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteComponent.cs
@@ -0,0 +1,48 @@
+namespace UnityEngine.PostProcessing;
+
+public sealed class VignetteComponent : PostProcessingComponentRenderTexture<VignetteModel>
+{
+ private static class Uniforms
+ {
+ internal static readonly int _Vignette_Color = Shader.PropertyToID("_Vignette_Color");
+
+ internal static readonly int _Vignette_Center = Shader.PropertyToID("_Vignette_Center");
+
+ internal static readonly int _Vignette_Settings = Shader.PropertyToID("_Vignette_Settings");
+
+ internal static readonly int _Vignette_Mask = Shader.PropertyToID("_Vignette_Mask");
+
+ internal static readonly int _Vignette_Opacity = Shader.PropertyToID("_Vignette_Opacity");
+ }
+
+ public override bool active
+ {
+ get
+ {
+ if (base.model.enabled)
+ {
+ return !context.interrupted;
+ }
+ return false;
+ }
+ }
+
+ public override void Prepare(Material uberMaterial)
+ {
+ VignetteModel.Settings settings = base.model.settings;
+ uberMaterial.SetColor(Uniforms._Vignette_Color, settings.color);
+ if (settings.mode == VignetteModel.Mode.Classic)
+ {
+ uberMaterial.SetVector(Uniforms._Vignette_Center, settings.center);
+ uberMaterial.EnableKeyword("VIGNETTE_CLASSIC");
+ float z = (1f - settings.roundness) * 6f + settings.roundness;
+ uberMaterial.SetVector(Uniforms._Vignette_Settings, new Vector4(settings.intensity * 3f, settings.smoothness * 5f, z, settings.rounded ? 1f : 0f));
+ }
+ else if (settings.mode == VignetteModel.Mode.Masked && settings.mask != null && settings.opacity > 0f)
+ {
+ uberMaterial.EnableKeyword("VIGNETTE_MASKED");
+ uberMaterial.SetTexture(Uniforms._Vignette_Mask, settings.mask);
+ uberMaterial.SetFloat(Uniforms._Vignette_Opacity, settings.opacity);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteModel.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteModel.cs
new file mode 100644
index 0000000..963ce2d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/UnityEngine.PostProcessing/VignetteModel.cs
@@ -0,0 +1,87 @@
+using System;
+
+namespace UnityEngine.PostProcessing;
+
+[Serializable]
+public class VignetteModel : PostProcessingModel
+{
+ public enum Mode
+ {
+ Classic,
+ Masked
+ }
+
+ [Serializable]
+ public struct Settings
+ {
+ [Tooltip("Use the \"Classic\" mode for parametric controls. Use the \"Masked\" mode to use your own texture mask.")]
+ public Mode mode;
+
+ [ColorUsage(false)]
+ [Tooltip("Vignette color. Use the alpha channel for transparency.")]
+ public Color color;
+
+ [Tooltip("Sets the vignette center point (screen center is [0.5,0.5]).")]
+ public Vector2 center;
+
+ [Range(0f, 1f)]
+ [Tooltip("Amount of vignetting on screen.")]
+ public float intensity;
+
+ [Range(0.01f, 1f)]
+ [Tooltip("Smoothness of the vignette borders.")]
+ public float smoothness;
+
+ [Range(0f, 1f)]
+ [Tooltip("Lower values will make a square-ish vignette.")]
+ public float roundness;
+
+ [Tooltip("A black and white mask to use as a vignette.")]
+ public Texture mask;
+
+ [Range(0f, 1f)]
+ [Tooltip("Mask opacity.")]
+ public float opacity;
+
+ [Tooltip("Should the vignette be perfectly round or be dependent on the current aspect ratio?")]
+ public bool rounded;
+
+ public static Settings defaultSettings
+ {
+ get
+ {
+ Settings result = default(Settings);
+ result.mode = Mode.Classic;
+ result.color = new Color(0f, 0f, 0f, 1f);
+ result.center = new Vector2(0.5f, 0.5f);
+ result.intensity = 0.45f;
+ result.smoothness = 0.2f;
+ result.roundness = 1f;
+ result.mask = null;
+ result.opacity = 1f;
+ result.rounded = false;
+ return result;
+ }
+ }
+ }
+
+ [SerializeField]
+ private Settings m_Settings = Settings.defaultSettings;
+
+ public Settings settings
+ {
+ get
+ {
+ return m_Settings;
+ }
+ set
+ {
+ m_Settings = value;
+ }
+ }
+
+ public override void Reset()
+ {
+ m_Settings = Settings.defaultSettings;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/assembly_postprocessing.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/assembly_postprocessing.csproj
new file mode 100644
index 0000000..5939417
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_postprocessing/assembly_postprocessing.csproj
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_postprocessing</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.PhysicsModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="UnityEngine.InputLegacyModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.IMGUIModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/RunTimeCombineAndRelease.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/RunTimeCombineAndRelease.cs
new file mode 100644
index 0000000..65f1d0f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/RunTimeCombineAndRelease.cs
@@ -0,0 +1,43 @@
+using UnityEngine;
+
+public class RunTimeCombineAndRelease : MonoBehaviour
+{
+ public SimpleMeshCombine simpleMeshCombine;
+
+ public float combineTime = 0.5f;
+
+ public float releaseTime = 2f;
+
+ public void Awake()
+ {
+ simpleMeshCombine = GetComponent<SimpleMeshCombine>();
+ }
+
+ public void Start()
+ {
+ if (simpleMeshCombine == null)
+ {
+ Debug.Log("Couldn't find SMC, aborting");
+ return;
+ }
+ Invoke("Combine", combineTime);
+ Invoke("Release", releaseTime);
+ }
+
+ public void Combine()
+ {
+ simpleMeshCombine.CombineMeshes();
+ Debug.Log("Combined");
+ }
+
+ public void Release()
+ {
+ simpleMeshCombine.EnableRenderers(e: true);
+ if (!(simpleMeshCombine.combined == null))
+ {
+ Object.Destroy(simpleMeshCombine.combined);
+ simpleMeshCombine.combinedGameOjects = null;
+ Debug.Log("Released");
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombine.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombine.cs
new file mode 100644
index 0000000..a503bf6
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombine.cs
@@ -0,0 +1,171 @@
+using System.Collections;
+using UnityEngine;
+
+[AddComponentMenu("Simple Mesh Combine")]
+public class SimpleMeshCombine : MonoBehaviour
+{
+ public GameObject[] combinedGameOjects;
+
+ public GameObject combined;
+
+ public string meshName = "Combined_Meshes";
+
+ public bool _canGenerateLightmapUV;
+
+ public int vCount;
+
+ public bool generateLightmapUV;
+
+ public float lightmapScale = 1f;
+
+ public GameObject copyTarget;
+
+ public bool destroyOldColliders;
+
+ public bool keepStructure = true;
+
+ public Mesh autoOverwrite;
+
+ public bool setStatic = true;
+
+ public void EnableRenderers(bool e)
+ {
+ for (int i = 0; i < combinedGameOjects.Length && !(combinedGameOjects[i] == null); i++)
+ {
+ Renderer component = combinedGameOjects[i].GetComponent<Renderer>();
+ if (component != null)
+ {
+ component.enabled = e;
+ }
+ }
+ }
+
+ public MeshFilter[] FindEnabledMeshes()
+ {
+ MeshFilter[] array = null;
+ int num = 0;
+ array = base.transform.GetComponentsInChildren<MeshFilter>();
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i].GetComponent<MeshRenderer>() != null && array[i].GetComponent<MeshRenderer>().enabled)
+ {
+ num++;
+ }
+ }
+ MeshFilter[] array2 = new MeshFilter[num];
+ num = 0;
+ for (int j = 0; j < array.Length; j++)
+ {
+ if (array[j].GetComponent<MeshRenderer>() != null && array[j].GetComponent<MeshRenderer>().enabled)
+ {
+ array2[num] = array[j];
+ num++;
+ }
+ }
+ return array2;
+ }
+
+ public void CombineMeshes()
+ {
+ GameObject gameObject = new GameObject();
+ gameObject.name = "_Combined Mesh [" + base.name + "]";
+ gameObject.gameObject.AddComponent<MeshFilter>();
+ gameObject.gameObject.AddComponent<MeshRenderer>();
+ MeshFilter[] array = null;
+ array = FindEnabledMeshes();
+ ArrayList arrayList = new ArrayList();
+ ArrayList arrayList2 = new ArrayList();
+ combinedGameOjects = new GameObject[array.Length];
+ for (int i = 0; i < array.Length; i++)
+ {
+ combinedGameOjects[i] = array[i].gameObject;
+ MeshRenderer component = array[i].GetComponent<MeshRenderer>();
+ array[i].transform.gameObject.GetComponent<Renderer>().enabled = false;
+ if (array[i].sharedMesh == null)
+ {
+ break;
+ }
+ for (int j = 0; j < array[i].sharedMesh.subMeshCount; j++)
+ {
+ if (component == null)
+ {
+ break;
+ }
+ if (j < component.sharedMaterials.Length && j < array[i].sharedMesh.subMeshCount)
+ {
+ int num = Contains(arrayList, component.sharedMaterials[j]);
+ if (num == -1)
+ {
+ arrayList.Add(component.sharedMaterials[j]);
+ num = arrayList.Count - 1;
+ }
+ arrayList2.Add(new ArrayList());
+ CombineInstance combineInstance = default(CombineInstance);
+ combineInstance.transform = component.transform.localToWorldMatrix;
+ combineInstance.mesh = array[i].sharedMesh;
+ combineInstance.subMeshIndex = j;
+ (arrayList2[num] as ArrayList).Add(combineInstance);
+ }
+ }
+ }
+ Mesh[] array2 = new Mesh[arrayList.Count];
+ CombineInstance[] array3 = new CombineInstance[arrayList.Count];
+ for (int k = 0; k < arrayList.Count; k++)
+ {
+ CombineInstance[] combine = (arrayList2[k] as ArrayList).ToArray(typeof(CombineInstance)) as CombineInstance[];
+ array2[k] = new Mesh();
+ array2[k].CombineMeshes(combine, mergeSubMeshes: true, useMatrices: true);
+ array3[k] = default(CombineInstance);
+ array3[k].mesh = array2[k];
+ array3[k].subMeshIndex = 0;
+ }
+ Mesh mesh2 = (gameObject.GetComponent<MeshFilter>().sharedMesh = new Mesh());
+ Mesh mesh3 = mesh2;
+ mesh3.Clear();
+ mesh3.CombineMeshes(array3, mergeSubMeshes: false, useMatrices: false);
+ gameObject.GetComponent<MeshFilter>().sharedMesh = mesh3;
+ Mesh[] array4 = array2;
+ foreach (Mesh obj in array4)
+ {
+ obj.Clear();
+ Object.DestroyImmediate(obj);
+ }
+ MeshRenderer meshRenderer = gameObject.GetComponent<MeshFilter>().GetComponent<MeshRenderer>();
+ if (meshRenderer == null)
+ {
+ meshRenderer = base.gameObject.AddComponent<MeshRenderer>();
+ }
+ Material[] materials = arrayList.ToArray(typeof(Material)) as Material[];
+ meshRenderer.materials = materials;
+ combined = gameObject.gameObject;
+ EnableRenderers(e: false);
+ gameObject.transform.parent = base.transform;
+ gameObject.GetComponent<MeshFilter>().sharedMesh.RecalculateBounds();
+ vCount = gameObject.GetComponent<MeshFilter>().sharedMesh.vertexCount;
+ if (vCount > 65536)
+ {
+ Debug.LogWarning("Vertex Count: " + vCount + "- Vertex Count too high, please divide mesh combine into more groups. Max 65536 for each mesh");
+ _canGenerateLightmapUV = false;
+ }
+ else
+ {
+ _canGenerateLightmapUV = true;
+ }
+ if (setStatic)
+ {
+ combined.isStatic = true;
+ }
+ }
+
+ public int Contains(ArrayList l, Material n)
+ {
+ for (int i = 0; i < l.Count; i++)
+ {
+ if (l[i] as Material == n)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombineMaster.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombineMaster.cs
new file mode 100644
index 0000000..119731e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/SimpleMeshCombineMaster.cs
@@ -0,0 +1,6 @@
+using UnityEngine;
+
+public class SimpleMeshCombineMaster : MonoBehaviour
+{
+ public bool generateLightmapUV;
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/assembly_simplemeshcombine.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/assembly_simplemeshcombine.csproj
new file mode 100644
index 0000000..3a9185e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_simplemeshcombine/assembly_simplemeshcombine.csproj
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_simplemeshcombine</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/.gitignore b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/.gitignore
new file mode 100644
index 0000000..a4da27a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/.gitignore
@@ -0,0 +1,399 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.vs
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/AAMode.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/AAMode.cs
new file mode 100644
index 0000000..5c47b2e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/AAMode.cs
@@ -0,0 +1,12 @@
+namespace UnityStandardAssets.ImageEffects;
+
+public enum AAMode
+{
+ FXAA2,
+ FXAA3Console,
+ FXAA1PresetA,
+ FXAA1PresetB,
+ NFAA,
+ SSAA,
+ DLAA
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Antialiasing.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Antialiasing.cs
new file mode 100644
index 0000000..73794bf
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Antialiasing.cs
@@ -0,0 +1,139 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Other/Antialiasing")]
+public class Antialiasing : PostEffectsBase
+{
+ public AAMode mode = AAMode.FXAA3Console;
+
+ public bool showGeneratedNormals;
+
+ public float offsetScale = 0.2f;
+
+ public float blurRadius = 18f;
+
+ public float edgeThresholdMin = 0.05f;
+
+ public float edgeThreshold = 0.2f;
+
+ public float edgeSharpness = 4f;
+
+ public bool dlaaSharp;
+
+ public Shader ssaaShader;
+
+ private Material ssaa;
+
+ public Shader dlaaShader;
+
+ private Material dlaa;
+
+ public Shader nfaaShader;
+
+ private Material nfaa;
+
+ public Shader shaderFXAAPreset2;
+
+ private Material materialFXAAPreset2;
+
+ public Shader shaderFXAAPreset3;
+
+ private Material materialFXAAPreset3;
+
+ public Shader shaderFXAAII;
+
+ private Material materialFXAAII;
+
+ public Shader shaderFXAAIII;
+
+ private Material materialFXAAIII;
+
+ public Material CurrentAAMaterial()
+ {
+ Material material = null;
+ return mode switch
+ {
+ AAMode.FXAA3Console => materialFXAAIII,
+ AAMode.FXAA2 => materialFXAAII,
+ AAMode.FXAA1PresetA => materialFXAAPreset2,
+ AAMode.FXAA1PresetB => materialFXAAPreset3,
+ AAMode.NFAA => nfaa,
+ AAMode.SSAA => ssaa,
+ AAMode.DLAA => dlaa,
+ _ => null,
+ };
+ }
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ materialFXAAPreset2 = CreateMaterial(shaderFXAAPreset2, materialFXAAPreset2);
+ materialFXAAPreset3 = CreateMaterial(shaderFXAAPreset3, materialFXAAPreset3);
+ materialFXAAII = CreateMaterial(shaderFXAAII, materialFXAAII);
+ materialFXAAIII = CreateMaterial(shaderFXAAIII, materialFXAAIII);
+ nfaa = CreateMaterial(nfaaShader, nfaa);
+ ssaa = CreateMaterial(ssaaShader, ssaa);
+ dlaa = CreateMaterial(dlaaShader, dlaa);
+ if (!ssaaShader.isSupported)
+ {
+ NotSupported();
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ public void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ }
+ else if (mode == AAMode.FXAA3Console && materialFXAAIII != null)
+ {
+ materialFXAAIII.SetFloat("_EdgeThresholdMin", edgeThresholdMin);
+ materialFXAAIII.SetFloat("_EdgeThreshold", edgeThreshold);
+ materialFXAAIII.SetFloat("_EdgeSharpness", edgeSharpness);
+ Graphics.Blit(source, destination, materialFXAAIII);
+ }
+ else if (mode == AAMode.FXAA1PresetB && materialFXAAPreset3 != null)
+ {
+ Graphics.Blit(source, destination, materialFXAAPreset3);
+ }
+ else if (mode == AAMode.FXAA1PresetA && materialFXAAPreset2 != null)
+ {
+ source.anisoLevel = 4;
+ Graphics.Blit(source, destination, materialFXAAPreset2);
+ source.anisoLevel = 0;
+ }
+ else if (mode == AAMode.FXAA2 && materialFXAAII != null)
+ {
+ Graphics.Blit(source, destination, materialFXAAII);
+ }
+ else if (mode == AAMode.SSAA && ssaa != null)
+ {
+ Graphics.Blit(source, destination, ssaa);
+ }
+ else if (mode == AAMode.DLAA && dlaa != null)
+ {
+ source.anisoLevel = 0;
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height);
+ Graphics.Blit(source, temporary, dlaa, 0);
+ Graphics.Blit(temporary, destination, dlaa, (!dlaaSharp) ? 1 : 2);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ else if (mode == AAMode.NFAA && nfaa != null)
+ {
+ source.anisoLevel = 0;
+ nfaa.SetFloat("_OffsetScale", offsetScale);
+ nfaa.SetFloat("_BlurRadius", blurRadius);
+ Graphics.Blit(source, destination, nfaa, showGeneratedNormals ? 1 : 0);
+ }
+ else
+ {
+ Graphics.Blit(source, destination);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Bloom.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Bloom.cs
new file mode 100644
index 0000000..14f6340
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Bloom.cs
@@ -0,0 +1,333 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Bloom and Glow/Bloom")]
+public class Bloom : PostEffectsBase
+{
+ public enum LensFlareStyle
+ {
+ Ghosting,
+ Anamorphic,
+ Combined
+ }
+
+ public enum TweakMode
+ {
+ Basic,
+ Complex
+ }
+
+ public enum HDRBloomMode
+ {
+ Auto,
+ On,
+ Off
+ }
+
+ public enum BloomScreenBlendMode
+ {
+ Screen,
+ Add
+ }
+
+ public enum BloomQuality
+ {
+ Cheap,
+ High
+ }
+
+ public TweakMode tweakMode;
+
+ public BloomScreenBlendMode screenBlendMode = BloomScreenBlendMode.Add;
+
+ public HDRBloomMode hdr;
+
+ private bool doHdr;
+
+ public float sepBlurSpread = 2.5f;
+
+ public BloomQuality quality = BloomQuality.High;
+
+ public float bloomIntensity = 0.5f;
+
+ public float bloomThreshold = 0.5f;
+
+ public Color bloomThresholdColor = Color.white;
+
+ public int bloomBlurIterations = 2;
+
+ public int hollywoodFlareBlurIterations = 2;
+
+ public float flareRotation;
+
+ public LensFlareStyle lensflareMode = LensFlareStyle.Anamorphic;
+
+ public float hollyStretchWidth = 2.5f;
+
+ public float lensflareIntensity;
+
+ public float lensflareThreshold = 0.3f;
+
+ public float lensFlareSaturation = 0.75f;
+
+ public Color flareColorA = new Color(0.4f, 0.4f, 0.8f, 0.75f);
+
+ public Color flareColorB = new Color(0.4f, 0.8f, 0.8f, 0.75f);
+
+ public Color flareColorC = new Color(0.8f, 0.4f, 0.8f, 0.75f);
+
+ public Color flareColorD = new Color(0.8f, 0.4f, 0f, 0.75f);
+
+ public Texture2D lensFlareVignetteMask;
+
+ public Shader lensFlareShader;
+
+ private Material lensFlareMaterial;
+
+ public Shader screenBlendShader;
+
+ private Material screenBlend;
+
+ public Shader blurAndFlaresShader;
+
+ private Material blurAndFlaresMaterial;
+
+ public Shader brightPassFilterShader;
+
+ private Material brightPassFilterMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ screenBlend = CheckShaderAndCreateMaterial(screenBlendShader, screenBlend);
+ lensFlareMaterial = CheckShaderAndCreateMaterial(lensFlareShader, lensFlareMaterial);
+ blurAndFlaresMaterial = CheckShaderAndCreateMaterial(blurAndFlaresShader, blurAndFlaresMaterial);
+ brightPassFilterMaterial = CheckShaderAndCreateMaterial(brightPassFilterShader, brightPassFilterMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ public void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ doHdr = false;
+ if (hdr == HDRBloomMode.Auto)
+ {
+ doHdr = source.format == RenderTextureFormat.ARGBHalf && GetComponent<Camera>().allowHDR;
+ }
+ else
+ {
+ doHdr = hdr == HDRBloomMode.On;
+ }
+ doHdr = doHdr && supportHDRTextures;
+ BloomScreenBlendMode bloomScreenBlendMode = screenBlendMode;
+ if (doHdr)
+ {
+ bloomScreenBlendMode = BloomScreenBlendMode.Add;
+ }
+ RenderTextureFormat format = (doHdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.Default);
+ int width = source.width / 2;
+ int height = source.height / 2;
+ int width2 = source.width / 4;
+ int height2 = source.height / 4;
+ float num = 1f * (float)source.width / (1f * (float)source.height);
+ float num2 = 0.001953125f;
+ RenderTexture temporary = RenderTexture.GetTemporary(width2, height2, 0, format);
+ RenderTexture temporary2 = RenderTexture.GetTemporary(width, height, 0, format);
+ if (quality > BloomQuality.Cheap)
+ {
+ Graphics.Blit(source, temporary2, screenBlend, 2);
+ RenderTexture temporary3 = RenderTexture.GetTemporary(width2, height2, 0, format);
+ Graphics.Blit(temporary2, temporary3, screenBlend, 2);
+ Graphics.Blit(temporary3, temporary, screenBlend, 6);
+ RenderTexture.ReleaseTemporary(temporary3);
+ }
+ else
+ {
+ Graphics.Blit(source, temporary2);
+ Graphics.Blit(temporary2, temporary, screenBlend, 6);
+ }
+ RenderTexture.ReleaseTemporary(temporary2);
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width2, height2, 0, format);
+ BrightFilter(bloomThreshold * bloomThresholdColor, temporary, renderTexture);
+ if (bloomBlurIterations < 1)
+ {
+ bloomBlurIterations = 1;
+ }
+ else if (bloomBlurIterations > 10)
+ {
+ bloomBlurIterations = 10;
+ }
+ for (int i = 0; i < bloomBlurIterations; i++)
+ {
+ float num3 = (1f + (float)i * 0.25f) * sepBlurSpread;
+ RenderTexture temporary4 = RenderTexture.GetTemporary(width2, height2, 0, format);
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(0f, num3 * num2, 0f, 0f));
+ Graphics.Blit(renderTexture, temporary4, blurAndFlaresMaterial, 4);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary4;
+ temporary4 = RenderTexture.GetTemporary(width2, height2, 0, format);
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num3 / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(renderTexture, temporary4, blurAndFlaresMaterial, 4);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary4;
+ if (quality > BloomQuality.Cheap)
+ {
+ if (i == 0)
+ {
+ Graphics.SetRenderTarget(temporary);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(renderTexture, temporary);
+ }
+ else
+ {
+ temporary.MarkRestoreExpected();
+ Graphics.Blit(renderTexture, temporary, screenBlend, 10);
+ }
+ }
+ }
+ if (quality > BloomQuality.Cheap)
+ {
+ Graphics.SetRenderTarget(renderTexture);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(temporary, renderTexture, screenBlend, 6);
+ }
+ if (lensflareIntensity > Mathf.Epsilon)
+ {
+ RenderTexture temporary5 = RenderTexture.GetTemporary(width2, height2, 0, format);
+ if (lensflareMode == LensFlareStyle.Ghosting)
+ {
+ BrightFilter(lensflareThreshold, renderTexture, temporary5);
+ if (quality > BloomQuality.Cheap)
+ {
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(0f, 1.5f / (1f * (float)temporary.height), 0f, 0f));
+ Graphics.SetRenderTarget(temporary);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(temporary5, temporary, blurAndFlaresMaterial, 4);
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(1.5f / (1f * (float)temporary.width), 0f, 0f, 0f));
+ Graphics.SetRenderTarget(temporary5);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(temporary, temporary5, blurAndFlaresMaterial, 4);
+ }
+ Vignette(0.975f, temporary5, temporary5);
+ BlendFlares(temporary5, renderTexture);
+ }
+ else
+ {
+ float num4 = 1f * Mathf.Cos(flareRotation);
+ float num5 = 1f * Mathf.Sin(flareRotation);
+ float num6 = hollyStretchWidth * 1f / num * num2;
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num4, num5, 0f, 0f));
+ blurAndFlaresMaterial.SetVector("_Threshhold", new Vector4(lensflareThreshold, 1f, 0f, 0f));
+ blurAndFlaresMaterial.SetVector("_TintColor", new Vector4(flareColorA.r, flareColorA.g, flareColorA.b, flareColorA.a) * flareColorA.a * lensflareIntensity);
+ blurAndFlaresMaterial.SetFloat("_Saturation", lensFlareSaturation);
+ temporary.DiscardContents();
+ Graphics.Blit(temporary5, temporary, blurAndFlaresMaterial, 2);
+ temporary5.DiscardContents();
+ Graphics.Blit(temporary, temporary5, blurAndFlaresMaterial, 3);
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num4 * num6, num5 * num6, 0f, 0f));
+ blurAndFlaresMaterial.SetFloat("_StretchWidth", hollyStretchWidth);
+ temporary.DiscardContents();
+ Graphics.Blit(temporary5, temporary, blurAndFlaresMaterial, 1);
+ blurAndFlaresMaterial.SetFloat("_StretchWidth", hollyStretchWidth * 2f);
+ temporary5.DiscardContents();
+ Graphics.Blit(temporary, temporary5, blurAndFlaresMaterial, 1);
+ blurAndFlaresMaterial.SetFloat("_StretchWidth", hollyStretchWidth * 4f);
+ temporary.DiscardContents();
+ Graphics.Blit(temporary5, temporary, blurAndFlaresMaterial, 1);
+ for (int j = 0; j < hollywoodFlareBlurIterations; j++)
+ {
+ num6 = hollyStretchWidth * 2f / num * num2;
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num6 * num4, num6 * num5, 0f, 0f));
+ temporary5.DiscardContents();
+ Graphics.Blit(temporary, temporary5, blurAndFlaresMaterial, 4);
+ blurAndFlaresMaterial.SetVector("_Offsets", new Vector4(num6 * num4, num6 * num5, 0f, 0f));
+ temporary.DiscardContents();
+ Graphics.Blit(temporary5, temporary, blurAndFlaresMaterial, 4);
+ }
+ if (lensflareMode == LensFlareStyle.Anamorphic)
+ {
+ AddTo(1f, temporary, renderTexture);
+ }
+ else
+ {
+ Vignette(1f, temporary, temporary5);
+ BlendFlares(temporary5, temporary);
+ AddTo(1f, temporary, renderTexture);
+ }
+ }
+ RenderTexture.ReleaseTemporary(temporary5);
+ }
+ int pass = (int)bloomScreenBlendMode;
+ screenBlend.SetFloat("_Intensity", bloomIntensity);
+ screenBlend.SetTexture("_ColorBuffer", source);
+ if (quality > BloomQuality.Cheap)
+ {
+ RenderTexture temporary6 = RenderTexture.GetTemporary(width, height, 0, format);
+ Graphics.Blit(renderTexture, temporary6);
+ Graphics.Blit(temporary6, destination, screenBlend, pass);
+ RenderTexture.ReleaseTemporary(temporary6);
+ }
+ else
+ {
+ Graphics.Blit(renderTexture, destination, screenBlend, pass);
+ }
+ RenderTexture.ReleaseTemporary(temporary);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+
+ private void AddTo(float intensity_, RenderTexture from, RenderTexture to)
+ {
+ screenBlend.SetFloat("_Intensity", intensity_);
+ to.MarkRestoreExpected();
+ Graphics.Blit(from, to, screenBlend, 9);
+ }
+
+ private void BlendFlares(RenderTexture from, RenderTexture to)
+ {
+ lensFlareMaterial.SetVector("colorA", new Vector4(flareColorA.r, flareColorA.g, flareColorA.b, flareColorA.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorB", new Vector4(flareColorB.r, flareColorB.g, flareColorB.b, flareColorB.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorC", new Vector4(flareColorC.r, flareColorC.g, flareColorC.b, flareColorC.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorD", new Vector4(flareColorD.r, flareColorD.g, flareColorD.b, flareColorD.a) * lensflareIntensity);
+ to.MarkRestoreExpected();
+ Graphics.Blit(from, to, lensFlareMaterial);
+ }
+
+ private void BrightFilter(float thresh, RenderTexture from, RenderTexture to)
+ {
+ brightPassFilterMaterial.SetVector("_Threshhold", new Vector4(thresh, thresh, thresh, thresh));
+ Graphics.Blit(from, to, brightPassFilterMaterial, 0);
+ }
+
+ private void BrightFilter(Color threshColor, RenderTexture from, RenderTexture to)
+ {
+ brightPassFilterMaterial.SetVector("_Threshhold", threshColor);
+ Graphics.Blit(from, to, brightPassFilterMaterial, 1);
+ }
+
+ private void Vignette(float amount, RenderTexture from, RenderTexture to)
+ {
+ if ((bool)lensFlareVignetteMask)
+ {
+ screenBlend.SetTexture("_ColorBuffer", lensFlareVignetteMask);
+ to.MarkRestoreExpected();
+ Graphics.Blit((from == to) ? null : from, to, screenBlend, (from == to) ? 7 : 3);
+ }
+ else if (from != to)
+ {
+ Graphics.SetRenderTarget(to);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(from, to);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomAndFlares.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomAndFlares.cs
new file mode 100644
index 0000000..1c4428c
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomAndFlares.cs
@@ -0,0 +1,257 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Bloom and Glow/BloomAndFlares (3.5, Deprecated)")]
+public class BloomAndFlares : PostEffectsBase
+{
+ public TweakMode34 tweakMode;
+
+ public BloomScreenBlendMode screenBlendMode = BloomScreenBlendMode.Add;
+
+ public HDRBloomMode hdr;
+
+ private bool doHdr;
+
+ public float sepBlurSpread = 1.5f;
+
+ public float useSrcAlphaAsMask = 0.5f;
+
+ public float bloomIntensity = 1f;
+
+ public float bloomThreshold = 0.5f;
+
+ public int bloomBlurIterations = 2;
+
+ public bool lensflares;
+
+ public int hollywoodFlareBlurIterations = 2;
+
+ public LensflareStyle34 lensflareMode = LensflareStyle34.Anamorphic;
+
+ public float hollyStretchWidth = 3.5f;
+
+ public float lensflareIntensity = 1f;
+
+ public float lensflareThreshold = 0.3f;
+
+ public Color flareColorA = new Color(0.4f, 0.4f, 0.8f, 0.75f);
+
+ public Color flareColorB = new Color(0.4f, 0.8f, 0.8f, 0.75f);
+
+ public Color flareColorC = new Color(0.8f, 0.4f, 0.8f, 0.75f);
+
+ public Color flareColorD = new Color(0.8f, 0.4f, 0f, 0.75f);
+
+ public Texture2D lensFlareVignetteMask;
+
+ public Shader lensFlareShader;
+
+ private Material lensFlareMaterial;
+
+ public Shader vignetteShader;
+
+ private Material vignetteMaterial;
+
+ public Shader separableBlurShader;
+
+ private Material separableBlurMaterial;
+
+ public Shader addBrightStuffOneOneShader;
+
+ private Material addBrightStuffBlendOneOneMaterial;
+
+ public Shader screenBlendShader;
+
+ private Material screenBlend;
+
+ public Shader hollywoodFlaresShader;
+
+ private Material hollywoodFlaresMaterial;
+
+ public Shader brightPassFilterShader;
+
+ private Material brightPassFilterMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ screenBlend = CheckShaderAndCreateMaterial(screenBlendShader, screenBlend);
+ lensFlareMaterial = CheckShaderAndCreateMaterial(lensFlareShader, lensFlareMaterial);
+ vignetteMaterial = CheckShaderAndCreateMaterial(vignetteShader, vignetteMaterial);
+ separableBlurMaterial = CheckShaderAndCreateMaterial(separableBlurShader, separableBlurMaterial);
+ addBrightStuffBlendOneOneMaterial = CheckShaderAndCreateMaterial(addBrightStuffOneOneShader, addBrightStuffBlendOneOneMaterial);
+ hollywoodFlaresMaterial = CheckShaderAndCreateMaterial(hollywoodFlaresShader, hollywoodFlaresMaterial);
+ brightPassFilterMaterial = CheckShaderAndCreateMaterial(brightPassFilterShader, brightPassFilterMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ doHdr = false;
+ if (hdr == HDRBloomMode.Auto)
+ {
+ doHdr = source.format == RenderTextureFormat.ARGBHalf && GetComponent<Camera>().allowHDR;
+ }
+ else
+ {
+ doHdr = hdr == HDRBloomMode.On;
+ }
+ doHdr = doHdr && supportHDRTextures;
+ BloomScreenBlendMode pass = screenBlendMode;
+ if (doHdr)
+ {
+ pass = BloomScreenBlendMode.Add;
+ }
+ RenderTextureFormat format = (doHdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.Default);
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width / 2, source.height / 2, 0, format);
+ RenderTexture temporary2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, format);
+ RenderTexture temporary3 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, format);
+ RenderTexture temporary4 = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0, format);
+ float num = 1f * (float)source.width / (1f * (float)source.height);
+ float num2 = 0.001953125f;
+ Graphics.Blit(source, temporary, screenBlend, 2);
+ Graphics.Blit(temporary, temporary2, screenBlend, 2);
+ RenderTexture.ReleaseTemporary(temporary);
+ BrightFilter(bloomThreshold, useSrcAlphaAsMask, temporary2, temporary3);
+ temporary2.DiscardContents();
+ if (bloomBlurIterations < 1)
+ {
+ bloomBlurIterations = 1;
+ }
+ for (int i = 0; i < bloomBlurIterations; i++)
+ {
+ float num3 = (1f + (float)i * 0.5f) * sepBlurSpread;
+ separableBlurMaterial.SetVector("offsets", new Vector4(0f, num3 * num2, 0f, 0f));
+ RenderTexture obj = ((i == 0) ? temporary3 : temporary2);
+ Graphics.Blit(obj, temporary4, separableBlurMaterial);
+ obj.DiscardContents();
+ separableBlurMaterial.SetVector("offsets", new Vector4(num3 / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(temporary4, temporary2, separableBlurMaterial);
+ temporary4.DiscardContents();
+ }
+ if (lensflares)
+ {
+ if (lensflareMode == LensflareStyle34.Ghosting)
+ {
+ BrightFilter(lensflareThreshold, 0f, temporary2, temporary4);
+ temporary2.DiscardContents();
+ Vignette(0.975f, temporary4, temporary3);
+ temporary4.DiscardContents();
+ BlendFlares(temporary3, temporary2);
+ temporary3.DiscardContents();
+ }
+ else
+ {
+ hollywoodFlaresMaterial.SetVector("_threshold", new Vector4(lensflareThreshold, 1f / (1f - lensflareThreshold), 0f, 0f));
+ hollywoodFlaresMaterial.SetVector("tintColor", new Vector4(flareColorA.r, flareColorA.g, flareColorA.b, flareColorA.a) * flareColorA.a * lensflareIntensity);
+ Graphics.Blit(temporary4, temporary3, hollywoodFlaresMaterial, 2);
+ temporary4.DiscardContents();
+ Graphics.Blit(temporary3, temporary4, hollywoodFlaresMaterial, 3);
+ temporary3.DiscardContents();
+ hollywoodFlaresMaterial.SetVector("offsets", new Vector4(sepBlurSpread * 1f / num * num2, 0f, 0f, 0f));
+ hollywoodFlaresMaterial.SetFloat("stretchWidth", hollyStretchWidth);
+ Graphics.Blit(temporary4, temporary3, hollywoodFlaresMaterial, 1);
+ temporary4.DiscardContents();
+ hollywoodFlaresMaterial.SetFloat("stretchWidth", hollyStretchWidth * 2f);
+ Graphics.Blit(temporary3, temporary4, hollywoodFlaresMaterial, 1);
+ temporary3.DiscardContents();
+ hollywoodFlaresMaterial.SetFloat("stretchWidth", hollyStretchWidth * 4f);
+ Graphics.Blit(temporary4, temporary3, hollywoodFlaresMaterial, 1);
+ temporary4.DiscardContents();
+ if (lensflareMode == LensflareStyle34.Anamorphic)
+ {
+ for (int j = 0; j < hollywoodFlareBlurIterations; j++)
+ {
+ separableBlurMaterial.SetVector("offsets", new Vector4(hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(temporary3, temporary4, separableBlurMaterial);
+ temporary3.DiscardContents();
+ separableBlurMaterial.SetVector("offsets", new Vector4(hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(temporary4, temporary3, separableBlurMaterial);
+ temporary4.DiscardContents();
+ }
+ AddTo(1f, temporary3, temporary2);
+ temporary3.DiscardContents();
+ }
+ else
+ {
+ for (int k = 0; k < hollywoodFlareBlurIterations; k++)
+ {
+ separableBlurMaterial.SetVector("offsets", new Vector4(hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(temporary3, temporary4, separableBlurMaterial);
+ temporary3.DiscardContents();
+ separableBlurMaterial.SetVector("offsets", new Vector4(hollyStretchWidth * 2f / num * num2, 0f, 0f, 0f));
+ Graphics.Blit(temporary4, temporary3, separableBlurMaterial);
+ temporary4.DiscardContents();
+ }
+ Vignette(1f, temporary3, temporary4);
+ temporary3.DiscardContents();
+ BlendFlares(temporary4, temporary3);
+ temporary4.DiscardContents();
+ AddTo(1f, temporary3, temporary2);
+ temporary3.DiscardContents();
+ }
+ }
+ }
+ screenBlend.SetFloat("_Intensity", bloomIntensity);
+ screenBlend.SetTexture("_ColorBuffer", source);
+ Graphics.Blit(temporary2, destination, screenBlend, (int)pass);
+ RenderTexture.ReleaseTemporary(temporary2);
+ RenderTexture.ReleaseTemporary(temporary3);
+ RenderTexture.ReleaseTemporary(temporary4);
+ }
+
+ private void AddTo(float intensity_, RenderTexture from, RenderTexture to)
+ {
+ addBrightStuffBlendOneOneMaterial.SetFloat("_Intensity", intensity_);
+ Graphics.Blit(from, to, addBrightStuffBlendOneOneMaterial);
+ }
+
+ private void BlendFlares(RenderTexture from, RenderTexture to)
+ {
+ lensFlareMaterial.SetVector("colorA", new Vector4(flareColorA.r, flareColorA.g, flareColorA.b, flareColorA.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorB", new Vector4(flareColorB.r, flareColorB.g, flareColorB.b, flareColorB.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorC", new Vector4(flareColorC.r, flareColorC.g, flareColorC.b, flareColorC.a) * lensflareIntensity);
+ lensFlareMaterial.SetVector("colorD", new Vector4(flareColorD.r, flareColorD.g, flareColorD.b, flareColorD.a) * lensflareIntensity);
+ Graphics.Blit(from, to, lensFlareMaterial);
+ }
+
+ private void BrightFilter(float thresh, float useAlphaAsMask, RenderTexture from, RenderTexture to)
+ {
+ if (doHdr)
+ {
+ brightPassFilterMaterial.SetVector("threshold", new Vector4(thresh, 1f, 0f, 0f));
+ }
+ else
+ {
+ brightPassFilterMaterial.SetVector("threshold", new Vector4(thresh, 1f / (1f - thresh), 0f, 0f));
+ }
+ brightPassFilterMaterial.SetFloat("useSrcAlphaAsMask", useAlphaAsMask);
+ Graphics.Blit(from, to, brightPassFilterMaterial);
+ }
+
+ private void Vignette(float amount, RenderTexture from, RenderTexture to)
+ {
+ if ((bool)lensFlareVignetteMask)
+ {
+ screenBlend.SetTexture("_ColorBuffer", lensFlareVignetteMask);
+ Graphics.Blit(from, to, screenBlend, 3);
+ }
+ else
+ {
+ vignetteMaterial.SetFloat("vignetteIntensity", amount);
+ Graphics.Blit(from, to, vignetteMaterial);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomOptimized.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomOptimized.cs
new file mode 100644
index 0000000..9b90a75
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomOptimized.cs
@@ -0,0 +1,96 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Bloom and Glow/Bloom (Optimized)")]
+public class BloomOptimized : PostEffectsBase
+{
+ public enum Resolution
+ {
+ Low,
+ High
+ }
+
+ public enum BlurType
+ {
+ Standard,
+ Sgx
+ }
+
+ [Range(0f, 1.5f)]
+ public float threshold = 0.25f;
+
+ [Range(0f, 2.5f)]
+ public float intensity = 0.75f;
+
+ [Range(0.25f, 5.5f)]
+ public float blurSize = 1f;
+
+ private Resolution resolution;
+
+ [Range(1f, 4f)]
+ public int blurIterations = 1;
+
+ public BlurType blurType;
+
+ public Shader fastBloomShader;
+
+ private Material fastBloomMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ fastBloomMaterial = CheckShaderAndCreateMaterial(fastBloomShader, fastBloomMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnDisable()
+ {
+ if ((bool)fastBloomMaterial)
+ {
+ Object.DestroyImmediate(fastBloomMaterial);
+ }
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ int num = ((resolution == Resolution.Low) ? 4 : 2);
+ float num2 = ((resolution == Resolution.Low) ? 0.5f : 1f);
+ fastBloomMaterial.SetVector("_Parameter", new Vector4(blurSize * num2, 0f, threshold, intensity));
+ source.filterMode = FilterMode.Bilinear;
+ int width = source.width / num;
+ int height = source.height / num;
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width, height, 0, source.format);
+ renderTexture.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(source, renderTexture, fastBloomMaterial, 1);
+ int num3 = ((blurType != 0) ? 2 : 0);
+ for (int i = 0; i < blurIterations; i++)
+ {
+ fastBloomMaterial.SetVector("_Parameter", new Vector4(blurSize * num2 + (float)i * 1f, 0f, threshold, intensity));
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
+ temporary.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(renderTexture, temporary, fastBloomMaterial, 2 + num3);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
+ temporary.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(renderTexture, temporary, fastBloomMaterial, 3 + num3);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ }
+ fastBloomMaterial.SetTexture("_Bloom", renderTexture);
+ Graphics.Blit(source, destination, fastBloomMaterial, 0);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomScreenBlendMode.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomScreenBlendMode.cs
new file mode 100644
index 0000000..621cc01
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BloomScreenBlendMode.cs
@@ -0,0 +1,7 @@
+namespace UnityStandardAssets.ImageEffects;
+
+public enum BloomScreenBlendMode
+{
+ Screen,
+ Add
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Blur.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Blur.cs
new file mode 100644
index 0000000..d250a75
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Blur.cs
@@ -0,0 +1,80 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Blur/Blur")]
+public class Blur : MonoBehaviour
+{
+ [Range(0f, 10f)]
+ public int iterations = 3;
+
+ [Range(0f, 1f)]
+ public float blurSpread = 0.6f;
+
+ public Shader blurShader;
+
+ private static Material m_Material;
+
+ protected Material material
+ {
+ get
+ {
+ if (m_Material == null)
+ {
+ m_Material = new Material(blurShader);
+ m_Material.hideFlags = HideFlags.DontSave;
+ }
+ return m_Material;
+ }
+ }
+
+ protected void OnDisable()
+ {
+ if ((bool)m_Material)
+ {
+ Object.DestroyImmediate(m_Material);
+ }
+ }
+
+ protected void Start()
+ {
+ if (!SystemInfo.supportsImageEffects)
+ {
+ base.enabled = false;
+ }
+ else if (!blurShader || !material.shader.isSupported)
+ {
+ base.enabled = false;
+ }
+ }
+
+ public void FourTapCone(RenderTexture source, RenderTexture dest, int iteration)
+ {
+ float num = 0.5f + (float)iteration * blurSpread;
+ Graphics.BlitMultiTap(source, dest, material, new Vector2(0f - num, 0f - num), new Vector2(0f - num, num), new Vector2(num, num), new Vector2(num, 0f - num));
+ }
+
+ private void DownSample4x(RenderTexture source, RenderTexture dest)
+ {
+ float num = 1f;
+ Graphics.BlitMultiTap(source, dest, material, new Vector2(0f - num, 0f - num), new Vector2(0f - num, num), new Vector2(num, num), new Vector2(num, 0f - num));
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ int width = source.width / 4;
+ int height = source.height / 4;
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width, height, 0);
+ DownSample4x(source, renderTexture);
+ for (int i = 0; i < iterations; i++)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0);
+ FourTapCone(renderTexture, temporary, i);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ }
+ Graphics.Blit(renderTexture, destination);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BlurOptimized.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BlurOptimized.cs
new file mode 100644
index 0000000..43c55f5
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/BlurOptimized.cs
@@ -0,0 +1,84 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Blur/Blur (Optimized)")]
+public class BlurOptimized : PostEffectsBase
+{
+ public enum BlurType
+ {
+ StandardGauss,
+ SgxGauss
+ }
+
+ [Range(0f, 2f)]
+ public int downsample = 1;
+
+ [Range(0f, 10f)]
+ public float blurSize = 3f;
+
+ [Range(1f, 4f)]
+ public int blurIterations = 2;
+
+ public BlurType blurType;
+
+ public Shader blurShader;
+
+ private Material blurMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ blurMaterial = CheckShaderAndCreateMaterial(blurShader, blurMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ public void OnDisable()
+ {
+ if ((bool)blurMaterial)
+ {
+ Object.DestroyImmediate(blurMaterial);
+ }
+ }
+
+ public void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ float num = 1f / (1f * (float)(1 << downsample));
+ blurMaterial.SetVector("_Parameter", new Vector4(blurSize * num, (0f - blurSize) * num, 0f, 0f));
+ source.filterMode = FilterMode.Bilinear;
+ int width = source.width >> downsample;
+ int height = source.height >> downsample;
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width, height, 0, source.format);
+ renderTexture.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(source, renderTexture, blurMaterial, 0);
+ int num2 = ((blurType != 0) ? 2 : 0);
+ for (int i = 0; i < blurIterations; i++)
+ {
+ float num3 = (float)i * 1f;
+ blurMaterial.SetVector("_Parameter", new Vector4(blurSize * num + num3, (0f - blurSize) * num - num3, 0f, 0f));
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
+ temporary.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(renderTexture, temporary, blurMaterial, 1 + num2);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
+ temporary.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(renderTexture, temporary, blurMaterial, 2 + num2);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ }
+ Graphics.Blit(renderTexture, destination);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CameraMotionBlur.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CameraMotionBlur.cs
new file mode 100644
index 0000000..7af41d3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CameraMotionBlur.cs
@@ -0,0 +1,382 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Camera/Camera Motion Blur")]
+public class CameraMotionBlur : PostEffectsBase
+{
+ public enum MotionBlurFilter
+ {
+ CameraMotion,
+ LocalBlur,
+ Reconstruction,
+ ReconstructionDX11,
+ ReconstructionDisc
+ }
+
+ private static float MAX_RADIUS = 10f;
+
+ public MotionBlurFilter filterType = MotionBlurFilter.Reconstruction;
+
+ public bool preview;
+
+ public Vector3 previewScale = Vector3.one;
+
+ public float movementScale;
+
+ public float rotationScale = 1f;
+
+ public float maxVelocity = 8f;
+
+ public float minVelocity = 0.1f;
+
+ public float velocityScale = 0.375f;
+
+ public float softZDistance = 0.005f;
+
+ public int velocityDownsample = 1;
+
+ public LayerMask excludeLayers = 0;
+
+ private GameObject tmpCam;
+
+ public Shader shader;
+
+ public Shader dx11MotionBlurShader;
+
+ public Shader replacementClear;
+
+ private Material motionBlurMaterial;
+
+ private Material dx11MotionBlurMaterial;
+
+ public Texture2D noiseTexture;
+
+ public float jitter = 0.05f;
+
+ public bool showVelocity;
+
+ public float showVelocityScale = 1f;
+
+ private Matrix4x4 currentViewProjMat;
+
+ private Matrix4x4[] currentStereoViewProjMat;
+
+ private Matrix4x4 prevViewProjMat;
+
+ private Matrix4x4[] prevStereoViewProjMat;
+
+ private int prevFrameCount;
+
+ private bool wasActive;
+
+ private Vector3 prevFrameForward = Vector3.forward;
+
+ private Vector3 prevFrameUp = Vector3.up;
+
+ private Vector3 prevFramePos = Vector3.zero;
+
+ private Camera _camera;
+
+ private void CalculateViewProjection()
+ {
+ Matrix4x4 worldToCameraMatrix = _camera.worldToCameraMatrix;
+ Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(_camera.projectionMatrix, renderIntoTexture: true);
+ currentViewProjMat = gPUProjectionMatrix * worldToCameraMatrix;
+ if (_camera.stereoEnabled)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ Matrix4x4 stereoViewMatrix = _camera.GetStereoViewMatrix((i != 0) ? Camera.StereoscopicEye.Right : Camera.StereoscopicEye.Left);
+ Matrix4x4 stereoProjectionMatrix = _camera.GetStereoProjectionMatrix((i != 0) ? Camera.StereoscopicEye.Right : Camera.StereoscopicEye.Left);
+ stereoProjectionMatrix = GL.GetGPUProjectionMatrix(stereoProjectionMatrix, renderIntoTexture: true);
+ currentStereoViewProjMat[i] = stereoProjectionMatrix * stereoViewMatrix;
+ }
+ }
+ }
+
+ private new void Start()
+ {
+ CheckResources();
+ if (_camera == null)
+ {
+ _camera = GetComponent<Camera>();
+ }
+ wasActive = base.gameObject.activeInHierarchy;
+ currentStereoViewProjMat = new Matrix4x4[2];
+ prevStereoViewProjMat = new Matrix4x4[2];
+ CalculateViewProjection();
+ Remember();
+ wasActive = false;
+ }
+
+ private void OnEnable()
+ {
+ if (_camera == null)
+ {
+ _camera = GetComponent<Camera>();
+ }
+ _camera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+
+ private void OnDisable()
+ {
+ if (null != motionBlurMaterial)
+ {
+ Object.DestroyImmediate(motionBlurMaterial);
+ motionBlurMaterial = null;
+ }
+ if (null != dx11MotionBlurMaterial)
+ {
+ Object.DestroyImmediate(dx11MotionBlurMaterial);
+ dx11MotionBlurMaterial = null;
+ }
+ if (null != tmpCam)
+ {
+ Object.DestroyImmediate(tmpCam);
+ tmpCam = null;
+ }
+ }
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true, needHdr: true);
+ motionBlurMaterial = CheckShaderAndCreateMaterial(shader, motionBlurMaterial);
+ if (supportDX11 && filterType == MotionBlurFilter.ReconstructionDX11)
+ {
+ dx11MotionBlurMaterial = CheckShaderAndCreateMaterial(dx11MotionBlurShader, dx11MotionBlurMaterial);
+ }
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ if (filterType == MotionBlurFilter.CameraMotion)
+ {
+ StartFrame();
+ }
+ RenderTextureFormat format = (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf) ? RenderTextureFormat.RGHalf : RenderTextureFormat.ARGBHalf);
+ RenderTexture temporary = RenderTexture.GetTemporary(divRoundUp(source.width, velocityDownsample), divRoundUp(source.height, velocityDownsample), 0, format);
+ int num = 1;
+ int num2 = 1;
+ maxVelocity = Mathf.Max(2f, maxVelocity);
+ float num3 = maxVelocity;
+ bool flag = filterType == MotionBlurFilter.ReconstructionDX11 && dx11MotionBlurMaterial == null;
+ if (filterType == MotionBlurFilter.Reconstruction || flag || filterType == MotionBlurFilter.ReconstructionDisc)
+ {
+ maxVelocity = Mathf.Min(maxVelocity, MAX_RADIUS);
+ num = divRoundUp(temporary.width, (int)maxVelocity);
+ num2 = divRoundUp(temporary.height, (int)maxVelocity);
+ num3 = temporary.width / num;
+ }
+ else
+ {
+ num = divRoundUp(temporary.width, (int)maxVelocity);
+ num2 = divRoundUp(temporary.height, (int)maxVelocity);
+ num3 = temporary.width / num;
+ }
+ RenderTexture temporary2 = RenderTexture.GetTemporary(num, num2, 0, format);
+ RenderTexture temporary3 = RenderTexture.GetTemporary(num, num2, 0, format);
+ temporary.filterMode = FilterMode.Point;
+ temporary2.filterMode = FilterMode.Point;
+ temporary3.filterMode = FilterMode.Point;
+ if ((bool)noiseTexture)
+ {
+ noiseTexture.filterMode = FilterMode.Point;
+ }
+ source.wrapMode = TextureWrapMode.Clamp;
+ temporary.wrapMode = TextureWrapMode.Clamp;
+ temporary3.wrapMode = TextureWrapMode.Clamp;
+ temporary2.wrapMode = TextureWrapMode.Clamp;
+ CalculateViewProjection();
+ if (base.gameObject.activeInHierarchy && !wasActive)
+ {
+ Remember();
+ }
+ wasActive = base.gameObject.activeInHierarchy;
+ Matrix4x4 matrix4x = Matrix4x4.Inverse(currentViewProjMat);
+ motionBlurMaterial.SetMatrix("_InvViewProj", matrix4x);
+ motionBlurMaterial.SetMatrix("_PrevViewProj", prevViewProjMat);
+ motionBlurMaterial.SetMatrix("_ToPrevViewProjCombined", prevViewProjMat * matrix4x);
+ if (_camera.stereoEnabled)
+ {
+ Matrix4x4[] array = new Matrix4x4[2]
+ {
+ Matrix4x4.Inverse(currentStereoViewProjMat[0]),
+ Matrix4x4.Inverse(currentStereoViewProjMat[1])
+ };
+ Matrix4x4 value = prevStereoViewProjMat[0] * array[0];
+ motionBlurMaterial.SetMatrix("_StereoToPrevViewProjCombined0", value);
+ motionBlurMaterial.SetMatrix("_StereoToPrevViewProjCombined1", prevStereoViewProjMat[1] * array[1]);
+ }
+ motionBlurMaterial.SetFloat("_MaxVelocity", num3);
+ motionBlurMaterial.SetFloat("_MaxRadiusOrKInPaper", num3);
+ motionBlurMaterial.SetFloat("_MinVelocity", minVelocity);
+ motionBlurMaterial.SetFloat("_VelocityScale", velocityScale);
+ motionBlurMaterial.SetFloat("_Jitter", jitter);
+ motionBlurMaterial.SetTexture("_NoiseTex", noiseTexture);
+ motionBlurMaterial.SetTexture("_VelTex", temporary);
+ motionBlurMaterial.SetTexture("_NeighbourMaxTex", temporary3);
+ motionBlurMaterial.SetTexture("_TileTexDebug", temporary2);
+ if (preview)
+ {
+ Matrix4x4 worldToCameraMatrix = _camera.worldToCameraMatrix;
+ Matrix4x4 identity = Matrix4x4.identity;
+ identity.SetTRS(previewScale * 0.3333f, Quaternion.identity, Vector3.one);
+ Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(_camera.projectionMatrix, renderIntoTexture: true);
+ prevViewProjMat = gPUProjectionMatrix * identity * worldToCameraMatrix;
+ motionBlurMaterial.SetMatrix("_PrevViewProj", prevViewProjMat);
+ motionBlurMaterial.SetMatrix("_ToPrevViewProjCombined", prevViewProjMat * matrix4x);
+ }
+ if (filterType == MotionBlurFilter.CameraMotion)
+ {
+ Vector4 zero = Vector4.zero;
+ float num4 = Vector3.Dot(base.transform.up, Vector3.up);
+ Vector3 rhs = prevFramePos - base.transform.position;
+ float magnitude = rhs.magnitude;
+ float num5 = 1f;
+ num5 = Vector3.Angle(base.transform.up, prevFrameUp) / _camera.fieldOfView * ((float)source.width * 0.75f);
+ zero.x = rotationScale * num5;
+ num5 = Vector3.Angle(base.transform.forward, prevFrameForward) / _camera.fieldOfView * ((float)source.width * 0.75f);
+ zero.y = rotationScale * num4 * num5;
+ num5 = Vector3.Angle(base.transform.forward, prevFrameForward) / _camera.fieldOfView * ((float)source.width * 0.75f);
+ zero.z = rotationScale * (1f - num4) * num5;
+ if (magnitude > Mathf.Epsilon && movementScale > Mathf.Epsilon)
+ {
+ zero.w = movementScale * Vector3.Dot(base.transform.forward, rhs) * ((float)source.width * 0.5f);
+ zero.x += movementScale * Vector3.Dot(base.transform.up, rhs) * ((float)source.width * 0.5f);
+ zero.y += movementScale * Vector3.Dot(base.transform.right, rhs) * ((float)source.width * 0.5f);
+ }
+ if (preview)
+ {
+ motionBlurMaterial.SetVector("_BlurDirectionPacked", new Vector4(previewScale.y, previewScale.x, 0f, previewScale.z) * 0.5f * _camera.fieldOfView);
+ }
+ else
+ {
+ motionBlurMaterial.SetVector("_BlurDirectionPacked", zero);
+ }
+ }
+ else
+ {
+ Graphics.Blit(source, temporary, motionBlurMaterial, 0);
+ Camera camera = null;
+ if (excludeLayers.value != 0)
+ {
+ camera = GetTmpCam();
+ }
+ if ((bool)camera && excludeLayers.value != 0 && (bool)replacementClear && replacementClear.isSupported)
+ {
+ camera.targetTexture = temporary;
+ camera.cullingMask = excludeLayers;
+ camera.RenderWithShader(replacementClear, "");
+ }
+ }
+ if (!preview && Time.frameCount != prevFrameCount)
+ {
+ prevFrameCount = Time.frameCount;
+ Remember();
+ }
+ source.filterMode = FilterMode.Bilinear;
+ if (showVelocity)
+ {
+ motionBlurMaterial.SetFloat("_DisplayVelocityScale", showVelocityScale);
+ Graphics.Blit(temporary, destination, motionBlurMaterial, 1);
+ }
+ else if (filterType == MotionBlurFilter.ReconstructionDX11 && !flag)
+ {
+ dx11MotionBlurMaterial.SetFloat("_MinVelocity", minVelocity);
+ dx11MotionBlurMaterial.SetFloat("_VelocityScale", velocityScale);
+ dx11MotionBlurMaterial.SetFloat("_Jitter", jitter);
+ dx11MotionBlurMaterial.SetTexture("_NoiseTex", noiseTexture);
+ dx11MotionBlurMaterial.SetTexture("_VelTex", temporary);
+ dx11MotionBlurMaterial.SetTexture("_NeighbourMaxTex", temporary3);
+ dx11MotionBlurMaterial.SetFloat("_SoftZDistance", Mathf.Max(0.00025f, softZDistance));
+ dx11MotionBlurMaterial.SetFloat("_MaxRadiusOrKInPaper", num3);
+ Graphics.Blit(temporary, temporary2, dx11MotionBlurMaterial, 0);
+ Graphics.Blit(temporary2, temporary3, dx11MotionBlurMaterial, 1);
+ Graphics.Blit(source, destination, dx11MotionBlurMaterial, 2);
+ }
+ else if (filterType == MotionBlurFilter.Reconstruction || flag)
+ {
+ motionBlurMaterial.SetFloat("_SoftZDistance", Mathf.Max(0.00025f, softZDistance));
+ Graphics.Blit(temporary, temporary2, motionBlurMaterial, 2);
+ Graphics.Blit(temporary2, temporary3, motionBlurMaterial, 3);
+ Graphics.Blit(source, destination, motionBlurMaterial, 4);
+ }
+ else if (filterType == MotionBlurFilter.CameraMotion)
+ {
+ Graphics.Blit(source, destination, motionBlurMaterial, 6);
+ }
+ else if (filterType == MotionBlurFilter.ReconstructionDisc)
+ {
+ motionBlurMaterial.SetFloat("_SoftZDistance", Mathf.Max(0.00025f, softZDistance));
+ Graphics.Blit(temporary, temporary2, motionBlurMaterial, 2);
+ Graphics.Blit(temporary2, temporary3, motionBlurMaterial, 3);
+ Graphics.Blit(source, destination, motionBlurMaterial, 7);
+ }
+ else
+ {
+ Graphics.Blit(source, destination, motionBlurMaterial, 5);
+ }
+ RenderTexture.ReleaseTemporary(temporary);
+ RenderTexture.ReleaseTemporary(temporary2);
+ RenderTexture.ReleaseTemporary(temporary3);
+ }
+
+ private void Remember()
+ {
+ prevViewProjMat = currentViewProjMat;
+ prevFrameForward = base.transform.forward;
+ prevFrameUp = base.transform.up;
+ prevFramePos = base.transform.position;
+ prevStereoViewProjMat[0] = currentStereoViewProjMat[0];
+ prevStereoViewProjMat[1] = currentStereoViewProjMat[1];
+ }
+
+ private Camera GetTmpCam()
+ {
+ if (tmpCam == null)
+ {
+ string text = "_" + _camera.name + "_MotionBlurTmpCam";
+ GameObject gameObject = GameObject.Find(text);
+ if (null == gameObject)
+ {
+ tmpCam = new GameObject(text, typeof(Camera));
+ }
+ else
+ {
+ tmpCam = gameObject;
+ }
+ }
+ tmpCam.hideFlags = HideFlags.DontSave;
+ tmpCam.transform.position = _camera.transform.position;
+ tmpCam.transform.rotation = _camera.transform.rotation;
+ tmpCam.transform.localScale = _camera.transform.localScale;
+ tmpCam.GetComponent<Camera>().CopyFrom(_camera);
+ tmpCam.GetComponent<Camera>().enabled = false;
+ tmpCam.GetComponent<Camera>().depthTextureMode = DepthTextureMode.None;
+ tmpCam.GetComponent<Camera>().clearFlags = CameraClearFlags.Nothing;
+ return tmpCam.GetComponent<Camera>();
+ }
+
+ private void StartFrame()
+ {
+ prevFramePos = Vector3.Slerp(prevFramePos, base.transform.position, 0.75f);
+ }
+
+ private static int divRoundUp(int x, int d)
+ {
+ return (x + d - 1) / d;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionCurves.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionCurves.cs
new file mode 100644
index 0000000..1242f66
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionCurves.cs
@@ -0,0 +1,180 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Color Correction (Curves, Saturation)")]
+public class ColorCorrectionCurves : PostEffectsBase
+{
+ public enum ColorCorrectionMode
+ {
+ Simple,
+ Advanced
+ }
+
+ public AnimationCurve redChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public AnimationCurve greenChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public AnimationCurve blueChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public bool useDepthCorrection;
+
+ public AnimationCurve zCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public AnimationCurve depthRedChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public AnimationCurve depthGreenChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ public AnimationCurve depthBlueChannel = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f));
+
+ private Material ccMaterial;
+
+ private Material ccDepthMaterial;
+
+ private Material selectiveCcMaterial;
+
+ private Texture2D rgbChannelTex;
+
+ private Texture2D rgbDepthChannelTex;
+
+ private Texture2D zCurveTex;
+
+ public float saturation = 1f;
+
+ public bool selectiveCc;
+
+ public Color selectiveFromColor = Color.white;
+
+ public Color selectiveToColor = Color.white;
+
+ public ColorCorrectionMode mode;
+
+ public bool updateTextures = true;
+
+ public Shader colorCorrectionCurvesShader;
+
+ public Shader simpleColorCorrectionCurvesShader;
+
+ public Shader colorCorrectionSelectiveShader;
+
+ private bool updateTexturesOnStartup = true;
+
+ private new void Start()
+ {
+ base.Start();
+ updateTexturesOnStartup = true;
+ }
+
+ private void Awake()
+ {
+ }
+
+ public override bool CheckResources()
+ {
+ CheckSupport(mode == ColorCorrectionMode.Advanced);
+ ccMaterial = CheckShaderAndCreateMaterial(simpleColorCorrectionCurvesShader, ccMaterial);
+ ccDepthMaterial = CheckShaderAndCreateMaterial(colorCorrectionCurvesShader, ccDepthMaterial);
+ selectiveCcMaterial = CheckShaderAndCreateMaterial(colorCorrectionSelectiveShader, selectiveCcMaterial);
+ if (!rgbChannelTex)
+ {
+ rgbChannelTex = new Texture2D(256, 4, TextureFormat.ARGB32, mipChain: false, linear: true);
+ }
+ if (!rgbDepthChannelTex)
+ {
+ rgbDepthChannelTex = new Texture2D(256, 4, TextureFormat.ARGB32, mipChain: false, linear: true);
+ }
+ if (!zCurveTex)
+ {
+ zCurveTex = new Texture2D(256, 1, TextureFormat.ARGB32, mipChain: false, linear: true);
+ }
+ rgbChannelTex.hideFlags = HideFlags.DontSave;
+ rgbDepthChannelTex.hideFlags = HideFlags.DontSave;
+ zCurveTex.hideFlags = HideFlags.DontSave;
+ rgbChannelTex.wrapMode = TextureWrapMode.Clamp;
+ rgbDepthChannelTex.wrapMode = TextureWrapMode.Clamp;
+ zCurveTex.wrapMode = TextureWrapMode.Clamp;
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ public void UpdateParameters()
+ {
+ CheckResources();
+ if (redChannel != null && greenChannel != null && blueChannel != null)
+ {
+ for (float num = 0f; num <= 1f; num += 0.003921569f)
+ {
+ float num2 = Mathf.Clamp(redChannel.Evaluate(num), 0f, 1f);
+ float num3 = Mathf.Clamp(greenChannel.Evaluate(num), 0f, 1f);
+ float num4 = Mathf.Clamp(blueChannel.Evaluate(num), 0f, 1f);
+ rgbChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 0, new Color(num2, num2, num2));
+ rgbChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 1, new Color(num3, num3, num3));
+ rgbChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 2, new Color(num4, num4, num4));
+ float num5 = Mathf.Clamp(zCurve.Evaluate(num), 0f, 1f);
+ zCurveTex.SetPixel((int)Mathf.Floor(num * 255f), 0, new Color(num5, num5, num5));
+ num2 = Mathf.Clamp(depthRedChannel.Evaluate(num), 0f, 1f);
+ num3 = Mathf.Clamp(depthGreenChannel.Evaluate(num), 0f, 1f);
+ num4 = Mathf.Clamp(depthBlueChannel.Evaluate(num), 0f, 1f);
+ rgbDepthChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 0, new Color(num2, num2, num2));
+ rgbDepthChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 1, new Color(num3, num3, num3));
+ rgbDepthChannelTex.SetPixel((int)Mathf.Floor(num * 255f), 2, new Color(num4, num4, num4));
+ }
+ rgbChannelTex.Apply();
+ rgbDepthChannelTex.Apply();
+ zCurveTex.Apply();
+ }
+ }
+
+ private void UpdateTextures()
+ {
+ UpdateParameters();
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ if (updateTexturesOnStartup)
+ {
+ UpdateParameters();
+ updateTexturesOnStartup = false;
+ }
+ if (useDepthCorrection)
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
+ }
+ RenderTexture renderTexture = destination;
+ if (selectiveCc)
+ {
+ renderTexture = RenderTexture.GetTemporary(source.width, source.height);
+ }
+ if (useDepthCorrection)
+ {
+ ccDepthMaterial.SetTexture("_RgbTex", rgbChannelTex);
+ ccDepthMaterial.SetTexture("_ZCurve", zCurveTex);
+ ccDepthMaterial.SetTexture("_RgbDepthTex", rgbDepthChannelTex);
+ ccDepthMaterial.SetFloat("_Saturation", saturation);
+ Graphics.Blit(source, renderTexture, ccDepthMaterial);
+ }
+ else
+ {
+ ccMaterial.SetTexture("_RgbTex", rgbChannelTex);
+ ccMaterial.SetFloat("_Saturation", saturation);
+ Graphics.Blit(source, renderTexture, ccMaterial);
+ }
+ if (selectiveCc)
+ {
+ selectiveCcMaterial.SetColor("selColor", selectiveFromColor);
+ selectiveCcMaterial.SetColor("targetColor", selectiveToColor);
+ Graphics.Blit(renderTexture, destination, selectiveCcMaterial);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionLookup.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionLookup.cs
new file mode 100644
index 0000000..07ce1e3
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionLookup.cs
@@ -0,0 +1,142 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Color Correction (3D Lookup Texture)")]
+public class ColorCorrectionLookup : PostEffectsBase
+{
+ public Shader shader;
+
+ private Material material;
+
+ public Texture3D converted3DLut;
+
+ public string basedOnTempTex = "";
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ material = CheckShaderAndCreateMaterial(shader, material);
+ if (!isSupported || !SystemInfo.supports3DTextures)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnDisable()
+ {
+ if ((bool)material)
+ {
+ Object.DestroyImmediate(material);
+ material = null;
+ }
+ }
+
+ private void OnDestroy()
+ {
+ if ((bool)converted3DLut)
+ {
+ Object.DestroyImmediate(converted3DLut);
+ }
+ converted3DLut = null;
+ }
+
+ public void SetIdentityLut()
+ {
+ int num = 16;
+ Color[] array = new Color[num * num * num];
+ float num2 = 1f / (1f * (float)num - 1f);
+ for (int i = 0; i < num; i++)
+ {
+ for (int j = 0; j < num; j++)
+ {
+ for (int k = 0; k < num; k++)
+ {
+ array[i + j * num + k * num * num] = new Color((float)i * 1f * num2, (float)j * 1f * num2, (float)k * 1f * num2, 1f);
+ }
+ }
+ }
+ if ((bool)converted3DLut)
+ {
+ Object.DestroyImmediate(converted3DLut);
+ }
+ converted3DLut = new Texture3D(num, num, num, TextureFormat.ARGB32, mipChain: false);
+ converted3DLut.SetPixels(array);
+ converted3DLut.Apply();
+ basedOnTempTex = "";
+ }
+
+ public bool ValidDimensions(Texture2D tex2d)
+ {
+ if (!tex2d)
+ {
+ return false;
+ }
+ if (tex2d.height != Mathf.FloorToInt(Mathf.Sqrt(tex2d.width)))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public void Convert(Texture2D temp2DTex, string path)
+ {
+ if ((bool)temp2DTex)
+ {
+ int num = temp2DTex.width * temp2DTex.height;
+ num = temp2DTex.height;
+ if (!ValidDimensions(temp2DTex))
+ {
+ Debug.LogWarning("The given 2D texture " + temp2DTex.name + " cannot be used as a 3D LUT.");
+ basedOnTempTex = "";
+ return;
+ }
+ Color[] pixels = temp2DTex.GetPixels();
+ Color[] array = new Color[pixels.Length];
+ for (int i = 0; i < num; i++)
+ {
+ for (int j = 0; j < num; j++)
+ {
+ for (int k = 0; k < num; k++)
+ {
+ int num2 = num - j - 1;
+ array[i + j * num + k * num * num] = pixels[k * num + i + num2 * num * num];
+ }
+ }
+ }
+ if ((bool)converted3DLut)
+ {
+ Object.DestroyImmediate(converted3DLut);
+ }
+ converted3DLut = new Texture3D(num, num, num, TextureFormat.ARGB32, mipChain: false);
+ converted3DLut.SetPixels(array);
+ converted3DLut.Apply();
+ basedOnTempTex = path;
+ }
+ else
+ {
+ Debug.LogError("Couldn't color correct with 3D LUT texture. Image Effect will be disabled.");
+ }
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources() || !SystemInfo.supports3DTextures)
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ if (converted3DLut == null)
+ {
+ SetIdentityLut();
+ }
+ int width = converted3DLut.width;
+ converted3DLut.wrapMode = TextureWrapMode.Clamp;
+ material.SetFloat("_Scale", (float)(width - 1) / (1f * (float)width));
+ material.SetFloat("_Offset", 1f / (2f * (float)width));
+ material.SetTexture("_ClutTex", converted3DLut);
+ Graphics.Blit(source, destination, material, (QualitySettings.activeColorSpace == ColorSpace.Linear) ? 1 : 0);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionRamp.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionRamp.cs
new file mode 100644
index 0000000..82caf1f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ColorCorrectionRamp.cs
@@ -0,0 +1,16 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Color Correction (Ramp)")]
+public class ColorCorrectionRamp : ImageEffectBase
+{
+ public Texture textureRamp;
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ base.material.SetTexture("_RampTex", textureRamp);
+ Graphics.Blit(source, destination, base.material);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastEnhance.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastEnhance.cs
new file mode 100644
index 0000000..8001766
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastEnhance.cs
@@ -0,0 +1,67 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Color Adjustments/Contrast Enhance (Unsharp Mask)")]
+public class ContrastEnhance : PostEffectsBase
+{
+ [Range(0f, 1f)]
+ public float intensity = 0.5f;
+
+ [Range(0f, 0.999f)]
+ public float threshold;
+
+ private Material separableBlurMaterial;
+
+ private Material contrastCompositeMaterial;
+
+ [Range(0f, 1f)]
+ public float blurSpread = 1f;
+
+ public Shader separableBlurShader;
+
+ public Shader contrastCompositeShader;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ contrastCompositeMaterial = CheckShaderAndCreateMaterial(contrastCompositeShader, contrastCompositeMaterial);
+ separableBlurMaterial = CheckShaderAndCreateMaterial(separableBlurShader, separableBlurMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ int width = source.width;
+ int height = source.height;
+ RenderTexture temporary = RenderTexture.GetTemporary(width / 2, height / 2, 0);
+ Graphics.Blit(source, temporary);
+ RenderTexture temporary2 = RenderTexture.GetTemporary(width / 4, height / 4, 0);
+ Graphics.Blit(temporary, temporary2);
+ RenderTexture.ReleaseTemporary(temporary);
+ separableBlurMaterial.SetVector("offsets", new Vector4(0f, blurSpread * 1f / (float)temporary2.height, 0f, 0f));
+ RenderTexture temporary3 = RenderTexture.GetTemporary(width / 4, height / 4, 0);
+ Graphics.Blit(temporary2, temporary3, separableBlurMaterial);
+ RenderTexture.ReleaseTemporary(temporary2);
+ separableBlurMaterial.SetVector("offsets", new Vector4(blurSpread * 1f / (float)temporary2.width, 0f, 0f, 0f));
+ temporary2 = RenderTexture.GetTemporary(width / 4, height / 4, 0);
+ Graphics.Blit(temporary3, temporary2, separableBlurMaterial);
+ RenderTexture.ReleaseTemporary(temporary3);
+ contrastCompositeMaterial.SetTexture("_MainTexBlurred", temporary2);
+ contrastCompositeMaterial.SetFloat("intensity", intensity);
+ contrastCompositeMaterial.SetFloat("threshold", threshold);
+ Graphics.Blit(source, destination, contrastCompositeMaterial);
+ RenderTexture.ReleaseTemporary(temporary2);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastStretch.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastStretch.cs
new file mode 100644
index 0000000..a843a7d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ContrastStretch.cs
@@ -0,0 +1,178 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Contrast Stretch")]
+public class ContrastStretch : MonoBehaviour
+{
+ [Range(0.0001f, 1f)]
+ public float adaptationSpeed = 0.02f;
+
+ [Range(0f, 1f)]
+ public float limitMinimum = 0.2f;
+
+ [Range(0f, 1f)]
+ public float limitMaximum = 0.6f;
+
+ private RenderTexture[] adaptRenderTex = new RenderTexture[2];
+
+ private int curAdaptIndex;
+
+ public Shader shaderLum;
+
+ private Material m_materialLum;
+
+ public Shader shaderReduce;
+
+ private Material m_materialReduce;
+
+ public Shader shaderAdapt;
+
+ private Material m_materialAdapt;
+
+ public Shader shaderApply;
+
+ private Material m_materialApply;
+
+ protected Material materialLum
+ {
+ get
+ {
+ if (m_materialLum == null)
+ {
+ m_materialLum = new Material(shaderLum);
+ m_materialLum.hideFlags = HideFlags.HideAndDontSave;
+ }
+ return m_materialLum;
+ }
+ }
+
+ protected Material materialReduce
+ {
+ get
+ {
+ if (m_materialReduce == null)
+ {
+ m_materialReduce = new Material(shaderReduce);
+ m_materialReduce.hideFlags = HideFlags.HideAndDontSave;
+ }
+ return m_materialReduce;
+ }
+ }
+
+ protected Material materialAdapt
+ {
+ get
+ {
+ if (m_materialAdapt == null)
+ {
+ m_materialAdapt = new Material(shaderAdapt);
+ m_materialAdapt.hideFlags = HideFlags.HideAndDontSave;
+ }
+ return m_materialAdapt;
+ }
+ }
+
+ protected Material materialApply
+ {
+ get
+ {
+ if (m_materialApply == null)
+ {
+ m_materialApply = new Material(shaderApply);
+ m_materialApply.hideFlags = HideFlags.HideAndDontSave;
+ }
+ return m_materialApply;
+ }
+ }
+
+ private void Start()
+ {
+ if (!SystemInfo.supportsImageEffects)
+ {
+ base.enabled = false;
+ }
+ else if (!shaderAdapt.isSupported || !shaderApply.isSupported || !shaderLum.isSupported || !shaderReduce.isSupported)
+ {
+ base.enabled = false;
+ }
+ }
+
+ private void OnEnable()
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ if (!adaptRenderTex[i])
+ {
+ adaptRenderTex[i] = new RenderTexture(1, 1, 0);
+ adaptRenderTex[i].hideFlags = HideFlags.HideAndDontSave;
+ }
+ }
+ }
+
+ private void OnDisable()
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ Object.DestroyImmediate(adaptRenderTex[i]);
+ adaptRenderTex[i] = null;
+ }
+ if ((bool)m_materialLum)
+ {
+ Object.DestroyImmediate(m_materialLum);
+ }
+ if ((bool)m_materialReduce)
+ {
+ Object.DestroyImmediate(m_materialReduce);
+ }
+ if ((bool)m_materialAdapt)
+ {
+ Object.DestroyImmediate(m_materialAdapt);
+ }
+ if ((bool)m_materialApply)
+ {
+ Object.DestroyImmediate(m_materialApply);
+ }
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ RenderTexture renderTexture = RenderTexture.GetTemporary(source.width / 1, source.height / 1);
+ Graphics.Blit(source, renderTexture, materialLum);
+ while (renderTexture.width > 1 || renderTexture.height > 1)
+ {
+ int num = renderTexture.width / 2;
+ if (num < 1)
+ {
+ num = 1;
+ }
+ int num2 = renderTexture.height / 2;
+ if (num2 < 1)
+ {
+ num2 = 1;
+ }
+ RenderTexture temporary = RenderTexture.GetTemporary(num, num2);
+ Graphics.Blit(renderTexture, temporary, materialReduce);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ }
+ CalculateAdaptation(renderTexture);
+ materialApply.SetTexture("_AdaptTex", adaptRenderTex[curAdaptIndex]);
+ Graphics.Blit(source, destination, materialApply);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+
+ private void CalculateAdaptation(Texture curTexture)
+ {
+ int num = curAdaptIndex;
+ curAdaptIndex = (curAdaptIndex + 1) % 2;
+ float value = 1f - Mathf.Pow(1f - adaptationSpeed, 30f * Time.deltaTime);
+ value = Mathf.Clamp(value, 0.01f, 1f);
+ materialAdapt.SetTexture("_CurTex", curTexture);
+ materialAdapt.SetVector("_AdaptParams", new Vector4(value, limitMinimum, limitMaximum, 0f));
+ Graphics.SetRenderTarget(adaptRenderTex[curAdaptIndex]);
+ GL.Clear(clearDepth: false, clearColor: true, Color.black);
+ Graphics.Blit(adaptRenderTex[num], adaptRenderTex[curAdaptIndex], materialAdapt);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CreaseShading.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CreaseShading.cs
new file mode 100644
index 0000000..237e56d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/CreaseShading.cs
@@ -0,0 +1,76 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Edge Detection/Crease Shading")]
+public class CreaseShading : PostEffectsBase
+{
+ public float intensity = 0.5f;
+
+ public int softness = 1;
+
+ public float spread = 1f;
+
+ public Shader blurShader;
+
+ private Material blurMaterial;
+
+ public Shader depthFetchShader;
+
+ private Material depthFetchMaterial;
+
+ public Shader creaseApplyShader;
+
+ private Material creaseApplyMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ blurMaterial = CheckShaderAndCreateMaterial(blurShader, blurMaterial);
+ depthFetchMaterial = CheckShaderAndCreateMaterial(depthFetchShader, depthFetchMaterial);
+ creaseApplyMaterial = CheckShaderAndCreateMaterial(creaseApplyShader, creaseApplyMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ int width = source.width;
+ int height = source.height;
+ float num = 1f * (float)width / (1f * (float)height);
+ float num2 = 0.001953125f;
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0);
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width / 2, height / 2, 0);
+ Graphics.Blit(source, temporary, depthFetchMaterial);
+ Graphics.Blit(temporary, renderTexture);
+ for (int i = 0; i < softness; i++)
+ {
+ RenderTexture temporary2 = RenderTexture.GetTemporary(width / 2, height / 2, 0);
+ blurMaterial.SetVector("offsets", new Vector4(0f, spread * num2, 0f, 0f));
+ Graphics.Blit(renderTexture, temporary2, blurMaterial);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary2;
+ temporary2 = RenderTexture.GetTemporary(width / 2, height / 2, 0);
+ blurMaterial.SetVector("offsets", new Vector4(spread * num2 / num, 0f, 0f, 0f));
+ Graphics.Blit(renderTexture, temporary2, blurMaterial);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary2;
+ }
+ creaseApplyMaterial.SetTexture("_HrDepthTex", temporary);
+ creaseApplyMaterial.SetTexture("_LrDepthTex", renderTexture);
+ creaseApplyMaterial.SetFloat("intensity", intensity);
+ Graphics.Blit(source, destination, creaseApplyMaterial);
+ RenderTexture.ReleaseTemporary(temporary);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfField.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfField.cs
new file mode 100644
index 0000000..8b9d11a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfField.cs
@@ -0,0 +1,350 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Camera/Depth of Field (Lens Blur, Scatter, DX11)")]
+public class DepthOfField : PostEffectsBase
+{
+ public enum BlurType
+ {
+ DiscBlur,
+ DX11
+ }
+
+ public enum BlurSampleCount
+ {
+ Low,
+ Medium,
+ High
+ }
+
+ public bool visualizeFocus;
+
+ public float focalLength = 10f;
+
+ public float focalSize = 0.05f;
+
+ public float aperture = 0.5f;
+
+ public Transform focalTransform;
+
+ public float maxBlurSize = 2f;
+
+ public bool highResolution;
+
+ public BlurType blurType;
+
+ public BlurSampleCount blurSampleCount = BlurSampleCount.High;
+
+ public bool nearBlur;
+
+ public float foregroundOverlap = 1f;
+
+ public Shader dofHdrShader;
+
+ private Material dofHdrMaterial;
+
+ public Shader dx11BokehShader;
+
+ private Material dx11bokehMaterial;
+
+ public float dx11BokehThreshold = 0.5f;
+
+ public float dx11SpawnHeuristic = 0.0875f;
+
+ public Texture2D dx11BokehTexture;
+
+ public float dx11BokehScale = 1.2f;
+
+ public float dx11BokehIntensity = 2.5f;
+
+ private float focalDistance01 = 10f;
+
+ private ComputeBuffer cbDrawArgs;
+
+ private ComputeBuffer cbPoints;
+
+ private float internalBlurWidth = 1f;
+
+ private Camera cachedCamera;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ dofHdrMaterial = CheckShaderAndCreateMaterial(dofHdrShader, dofHdrMaterial);
+ if (supportDX11 && blurType == BlurType.DX11)
+ {
+ dx11bokehMaterial = CheckShaderAndCreateMaterial(dx11BokehShader, dx11bokehMaterial);
+ CreateComputeResources();
+ }
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnEnable()
+ {
+ cachedCamera = GetComponent<Camera>();
+ cachedCamera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+
+ private void OnDisable()
+ {
+ ReleaseComputeResources();
+ if ((bool)dofHdrMaterial)
+ {
+ Object.DestroyImmediate(dofHdrMaterial);
+ }
+ dofHdrMaterial = null;
+ if ((bool)dx11bokehMaterial)
+ {
+ Object.DestroyImmediate(dx11bokehMaterial);
+ }
+ dx11bokehMaterial = null;
+ }
+
+ private void ReleaseComputeResources()
+ {
+ if (cbDrawArgs != null)
+ {
+ cbDrawArgs.Release();
+ }
+ cbDrawArgs = null;
+ if (cbPoints != null)
+ {
+ cbPoints.Release();
+ }
+ cbPoints = null;
+ }
+
+ private void CreateComputeResources()
+ {
+ if (cbDrawArgs == null)
+ {
+ cbDrawArgs = new ComputeBuffer(1, 16, ComputeBufferType.DrawIndirect);
+ int[] data = new int[4] { 0, 1, 0, 0 };
+ cbDrawArgs.SetData(data);
+ }
+ if (cbPoints == null)
+ {
+ cbPoints = new ComputeBuffer(90000, 28, ComputeBufferType.Append);
+ }
+ }
+
+ private float FocalDistance01(float worldDist)
+ {
+ return cachedCamera.WorldToViewportPoint((worldDist - cachedCamera.nearClipPlane) * cachedCamera.transform.forward + cachedCamera.transform.position).z / (cachedCamera.farClipPlane - cachedCamera.nearClipPlane);
+ }
+
+ private void WriteCoc(RenderTexture fromTo, bool fgDilate)
+ {
+ dofHdrMaterial.SetTexture("_FgOverlap", null);
+ if (nearBlur && fgDilate)
+ {
+ int width = fromTo.width / 2;
+ int height = fromTo.height / 2;
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
+ Graphics.Blit(fromTo, temporary, dofHdrMaterial, 4);
+ float num = internalBlurWidth * foregroundOverlap;
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, num, 0f, num));
+ RenderTexture temporary2 = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
+ Graphics.Blit(temporary, temporary2, dofHdrMaterial, 2);
+ RenderTexture.ReleaseTemporary(temporary);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(num, 0f, 0f, num));
+ temporary = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
+ Graphics.Blit(temporary2, temporary, dofHdrMaterial, 2);
+ RenderTexture.ReleaseTemporary(temporary2);
+ dofHdrMaterial.SetTexture("_FgOverlap", temporary);
+ fromTo.MarkRestoreExpected();
+ Graphics.Blit(fromTo, fromTo, dofHdrMaterial, 13);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ else
+ {
+ fromTo.MarkRestoreExpected();
+ Graphics.Blit(fromTo, fromTo, dofHdrMaterial, 0);
+ }
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ float num = (float)source.width / 1024f;
+ if (aperture < 0f)
+ {
+ aperture = 0f;
+ }
+ if (maxBlurSize < 0.1f)
+ {
+ maxBlurSize = 0.1f;
+ }
+ focalSize = Mathf.Clamp(focalSize, 0f, 2f);
+ internalBlurWidth = Mathf.Max(maxBlurSize, 0f) * num;
+ focalDistance01 = (focalTransform ? (cachedCamera.WorldToViewportPoint(focalTransform.position).z / cachedCamera.farClipPlane) : FocalDistance01(focalLength));
+ dofHdrMaterial.SetVector("_CurveParams", new Vector4(1f, focalSize, 1f / (1f - aperture) - 1f, focalDistance01));
+ RenderTexture renderTexture = null;
+ RenderTexture renderTexture2 = null;
+ RenderTexture renderTexture3 = null;
+ RenderTexture renderTexture4 = null;
+ float num2 = internalBlurWidth * foregroundOverlap;
+ if (visualizeFocus)
+ {
+ WriteCoc(source, fgDilate: true);
+ Graphics.Blit(source, destination, dofHdrMaterial, 16);
+ }
+ else if (blurType == BlurType.DX11 && (bool)dx11bokehMaterial)
+ {
+ if (highResolution)
+ {
+ internalBlurWidth = ((internalBlurWidth < 0.1f) ? 0.1f : internalBlurWidth);
+ num2 = internalBlurWidth * foregroundOverlap;
+ renderTexture = RenderTexture.GetTemporary(source.width, source.height, 0, source.format);
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0, source.format);
+ WriteCoc(source, fgDilate: false);
+ renderTexture3 = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ renderTexture4 = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ Graphics.Blit(source, renderTexture3, dofHdrMaterial, 15);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, 1.5f, 0f, 1.5f));
+ Graphics.Blit(renderTexture3, renderTexture4, dofHdrMaterial, 19);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(1.5f, 0f, 0f, 1.5f));
+ Graphics.Blit(renderTexture4, renderTexture3, dofHdrMaterial, 19);
+ if (nearBlur)
+ {
+ Graphics.Blit(source, renderTexture4, dofHdrMaterial, 4);
+ }
+ dx11bokehMaterial.SetTexture("_BlurredColor", renderTexture3);
+ dx11bokehMaterial.SetFloat("_SpawnHeuristic", dx11SpawnHeuristic);
+ dx11bokehMaterial.SetVector("_BokehParams", new Vector4(dx11BokehScale, dx11BokehIntensity, Mathf.Clamp(dx11BokehThreshold, 0.005f, 4f), internalBlurWidth));
+ dx11bokehMaterial.SetTexture("_FgCocMask", nearBlur ? renderTexture4 : null);
+ Graphics.SetRandomWriteTarget(1, cbPoints);
+ Graphics.Blit(source, renderTexture, dx11bokehMaterial, 0);
+ Graphics.ClearRandomWriteTargets();
+ if (nearBlur)
+ {
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, num2, 0f, num2));
+ Graphics.Blit(renderTexture4, renderTexture3, dofHdrMaterial, 2);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(num2, 0f, 0f, num2));
+ Graphics.Blit(renderTexture3, renderTexture4, dofHdrMaterial, 2);
+ Graphics.Blit(renderTexture4, renderTexture, dofHdrMaterial, 3);
+ }
+ Graphics.Blit(renderTexture, temporary, dofHdrMaterial, 20);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(internalBlurWidth, 0f, 0f, internalBlurWidth));
+ Graphics.Blit(renderTexture, source, dofHdrMaterial, 5);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, internalBlurWidth, 0f, internalBlurWidth));
+ Graphics.Blit(source, temporary, dofHdrMaterial, 21);
+ Graphics.SetRenderTarget(temporary);
+ ComputeBuffer.CopyCount(cbPoints, cbDrawArgs, 0);
+ dx11bokehMaterial.SetBuffer("pointBuffer", cbPoints);
+ dx11bokehMaterial.SetTexture("_MainTex", dx11BokehTexture);
+ dx11bokehMaterial.SetVector("_Screen", new Vector3(1f / (1f * (float)source.width), 1f / (1f * (float)source.height), internalBlurWidth));
+ dx11bokehMaterial.SetPass(2);
+ Graphics.DrawProceduralIndirectNow(MeshTopology.Points, cbDrawArgs);
+ Graphics.Blit(temporary, destination);
+ RenderTexture.ReleaseTemporary(temporary);
+ RenderTexture.ReleaseTemporary(renderTexture3);
+ RenderTexture.ReleaseTemporary(renderTexture4);
+ }
+ else
+ {
+ renderTexture = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ renderTexture2 = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ num2 = internalBlurWidth * foregroundOverlap;
+ WriteCoc(source, fgDilate: false);
+ source.filterMode = FilterMode.Bilinear;
+ Graphics.Blit(source, renderTexture, dofHdrMaterial, 6);
+ renderTexture3 = RenderTexture.GetTemporary(renderTexture.width >> 1, renderTexture.height >> 1, 0, renderTexture.format);
+ renderTexture4 = RenderTexture.GetTemporary(renderTexture.width >> 1, renderTexture.height >> 1, 0, renderTexture.format);
+ Graphics.Blit(renderTexture, renderTexture3, dofHdrMaterial, 15);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, 1.5f, 0f, 1.5f));
+ Graphics.Blit(renderTexture3, renderTexture4, dofHdrMaterial, 19);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(1.5f, 0f, 0f, 1.5f));
+ Graphics.Blit(renderTexture4, renderTexture3, dofHdrMaterial, 19);
+ RenderTexture renderTexture5 = null;
+ if (nearBlur)
+ {
+ renderTexture5 = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ Graphics.Blit(source, renderTexture5, dofHdrMaterial, 4);
+ }
+ dx11bokehMaterial.SetTexture("_BlurredColor", renderTexture3);
+ dx11bokehMaterial.SetFloat("_SpawnHeuristic", dx11SpawnHeuristic);
+ dx11bokehMaterial.SetVector("_BokehParams", new Vector4(dx11BokehScale, dx11BokehIntensity, Mathf.Clamp(dx11BokehThreshold, 0.005f, 4f), internalBlurWidth));
+ dx11bokehMaterial.SetTexture("_FgCocMask", renderTexture5);
+ Graphics.SetRandomWriteTarget(1, cbPoints);
+ Graphics.Blit(renderTexture, renderTexture2, dx11bokehMaterial, 0);
+ Graphics.ClearRandomWriteTargets();
+ RenderTexture.ReleaseTemporary(renderTexture3);
+ RenderTexture.ReleaseTemporary(renderTexture4);
+ if (nearBlur)
+ {
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, num2, 0f, num2));
+ Graphics.Blit(renderTexture5, renderTexture, dofHdrMaterial, 2);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(num2, 0f, 0f, num2));
+ Graphics.Blit(renderTexture, renderTexture5, dofHdrMaterial, 2);
+ Graphics.Blit(renderTexture5, renderTexture2, dofHdrMaterial, 3);
+ }
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(internalBlurWidth, 0f, 0f, internalBlurWidth));
+ Graphics.Blit(renderTexture2, renderTexture, dofHdrMaterial, 5);
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, internalBlurWidth, 0f, internalBlurWidth));
+ Graphics.Blit(renderTexture, renderTexture2, dofHdrMaterial, 5);
+ Graphics.SetRenderTarget(renderTexture2);
+ ComputeBuffer.CopyCount(cbPoints, cbDrawArgs, 0);
+ dx11bokehMaterial.SetBuffer("pointBuffer", cbPoints);
+ dx11bokehMaterial.SetTexture("_MainTex", dx11BokehTexture);
+ dx11bokehMaterial.SetVector("_Screen", new Vector3(1f / (1f * (float)renderTexture2.width), 1f / (1f * (float)renderTexture2.height), internalBlurWidth));
+ dx11bokehMaterial.SetPass(1);
+ Graphics.DrawProceduralIndirectNow(MeshTopology.Points, cbDrawArgs);
+ dofHdrMaterial.SetTexture("_LowRez", renderTexture2);
+ dofHdrMaterial.SetTexture("_FgOverlap", renderTexture5);
+ dofHdrMaterial.SetVector("_Offsets", 1f * (float)source.width / (1f * (float)renderTexture2.width) * internalBlurWidth * Vector4.one);
+ Graphics.Blit(source, destination, dofHdrMaterial, 9);
+ if ((bool)renderTexture5)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture5);
+ }
+ }
+ }
+ else
+ {
+ source.filterMode = FilterMode.Bilinear;
+ if (highResolution)
+ {
+ internalBlurWidth *= 2f;
+ }
+ WriteCoc(source, fgDilate: true);
+ renderTexture = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ renderTexture2 = RenderTexture.GetTemporary(source.width >> 1, source.height >> 1, 0, source.format);
+ int pass = ((blurSampleCount == BlurSampleCount.High || blurSampleCount == BlurSampleCount.Medium) ? 17 : 11);
+ if (highResolution)
+ {
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, internalBlurWidth, 0.025f, internalBlurWidth));
+ Graphics.Blit(source, destination, dofHdrMaterial, pass);
+ }
+ else
+ {
+ dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, internalBlurWidth, 0.1f, internalBlurWidth));
+ Graphics.Blit(source, renderTexture, dofHdrMaterial, 6);
+ Graphics.Blit(renderTexture, renderTexture2, dofHdrMaterial, pass);
+ dofHdrMaterial.SetTexture("_LowRez", renderTexture2);
+ dofHdrMaterial.SetTexture("_FgOverlap", null);
+ dofHdrMaterial.SetVector("_Offsets", Vector4.one * (1f * (float)source.width / (1f * (float)renderTexture2.width)) * internalBlurWidth);
+ Graphics.Blit(source, destination, dofHdrMaterial, (blurSampleCount == BlurSampleCount.High) ? 18 : 12);
+ }
+ }
+ if ((bool)renderTexture)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+ if ((bool)renderTexture2)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture2);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfFieldDeprecated.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfFieldDeprecated.cs
new file mode 100644
index 0000000..9c2dc42
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/DepthOfFieldDeprecated.cs
@@ -0,0 +1,451 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Camera/Depth of Field (deprecated)")]
+public class DepthOfFieldDeprecated : PostEffectsBase
+{
+ public enum Dof34QualitySetting
+ {
+ OnlyBackground = 1,
+ BackgroundAndForeground
+ }
+
+ public enum DofResolution
+ {
+ High = 2,
+ Medium,
+ Low
+ }
+
+ public enum DofBlurriness
+ {
+ Low = 1,
+ High = 2,
+ VeryHigh = 4
+ }
+
+ public enum BokehDestination
+ {
+ Background = 1,
+ Foreground,
+ BackgroundAndForeground
+ }
+
+ private static int SMOOTH_DOWNSAMPLE_PASS = 6;
+
+ private static float BOKEH_EXTRA_BLUR = 2f;
+
+ public Dof34QualitySetting quality = Dof34QualitySetting.OnlyBackground;
+
+ public DofResolution resolution = DofResolution.Low;
+
+ public bool simpleTweakMode = true;
+
+ public float focalPoint = 1f;
+
+ public float smoothness = 0.5f;
+
+ public float focalZDistance;
+
+ public float focalZStartCurve = 1f;
+
+ public float focalZEndCurve = 1f;
+
+ private float focalStartCurve = 2f;
+
+ private float focalEndCurve = 2f;
+
+ private float focalDistance01 = 0.1f;
+
+ public Transform objectFocus;
+
+ public float focalSize;
+
+ public DofBlurriness bluriness = DofBlurriness.High;
+
+ public float maxBlurSpread = 1.75f;
+
+ public float foregroundBlurExtrude = 1.15f;
+
+ public Shader dofBlurShader;
+
+ private Material dofBlurMaterial;
+
+ public Shader dofShader;
+
+ private Material dofMaterial;
+
+ public bool visualize;
+
+ public BokehDestination bokehDestination = BokehDestination.Background;
+
+ private float widthOverHeight = 1.25f;
+
+ private float oneOverBaseSize = 0.001953125f;
+
+ public bool bokeh;
+
+ public bool bokehSupport = true;
+
+ public Shader bokehShader;
+
+ public Texture2D bokehTexture;
+
+ public float bokehScale = 2.4f;
+
+ public float bokehIntensity = 0.15f;
+
+ public float bokehThresholdContrast = 0.1f;
+
+ public float bokehThresholdLuminance = 0.55f;
+
+ public int bokehDownsample = 1;
+
+ private Material bokehMaterial;
+
+ private Camera _camera;
+
+ private RenderTexture foregroundTexture;
+
+ private RenderTexture mediumRezWorkTexture;
+
+ private RenderTexture finalDefocus;
+
+ private RenderTexture lowRezWorkTexture;
+
+ private RenderTexture bokehSource;
+
+ private RenderTexture bokehSource2;
+
+ private void CreateMaterials()
+ {
+ dofBlurMaterial = CheckShaderAndCreateMaterial(dofBlurShader, dofBlurMaterial);
+ dofMaterial = CheckShaderAndCreateMaterial(dofShader, dofMaterial);
+ bokehSupport = bokehShader.isSupported;
+ if (bokeh && bokehSupport && (bool)bokehShader)
+ {
+ bokehMaterial = CheckShaderAndCreateMaterial(bokehShader, bokehMaterial);
+ }
+ }
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ dofBlurMaterial = CheckShaderAndCreateMaterial(dofBlurShader, dofBlurMaterial);
+ dofMaterial = CheckShaderAndCreateMaterial(dofShader, dofMaterial);
+ bokehSupport = bokehShader.isSupported;
+ if (bokeh && bokehSupport && (bool)bokehShader)
+ {
+ bokehMaterial = CheckShaderAndCreateMaterial(bokehShader, bokehMaterial);
+ }
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnDisable()
+ {
+ Quads.Cleanup();
+ }
+
+ private void OnEnable()
+ {
+ _camera = GetComponent<Camera>();
+ _camera.depthTextureMode |= DepthTextureMode.Depth;
+ }
+
+ private float FocalDistance01(float worldDist)
+ {
+ return _camera.WorldToViewportPoint((worldDist - _camera.nearClipPlane) * _camera.transform.forward + _camera.transform.position).z / (_camera.farClipPlane - _camera.nearClipPlane);
+ }
+
+ private int GetDividerBasedOnQuality()
+ {
+ int result = 1;
+ if (resolution == DofResolution.Medium)
+ {
+ result = 2;
+ }
+ else if (resolution == DofResolution.Low)
+ {
+ result = 2;
+ }
+ return result;
+ }
+
+ private int GetLowResolutionDividerBasedOnQuality(int baseDivider)
+ {
+ int num = baseDivider;
+ if (resolution == DofResolution.High)
+ {
+ num *= 2;
+ }
+ if (resolution == DofResolution.Low)
+ {
+ num *= 2;
+ }
+ return num;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ if (smoothness < 0.1f)
+ {
+ smoothness = 0.1f;
+ }
+ bokeh = bokeh && bokehSupport;
+ float num = (bokeh ? BOKEH_EXTRA_BLUR : 1f);
+ bool flag = quality > Dof34QualitySetting.OnlyBackground;
+ float num2 = focalSize / (_camera.farClipPlane - _camera.nearClipPlane);
+ if (simpleTweakMode)
+ {
+ focalDistance01 = (objectFocus ? (_camera.WorldToViewportPoint(objectFocus.position).z / _camera.farClipPlane) : FocalDistance01(focalPoint));
+ focalStartCurve = focalDistance01 * smoothness;
+ focalEndCurve = focalStartCurve;
+ flag = flag && focalPoint > _camera.nearClipPlane + Mathf.Epsilon;
+ }
+ else
+ {
+ if ((bool)objectFocus)
+ {
+ Vector3 vector = _camera.WorldToViewportPoint(objectFocus.position);
+ vector.z /= _camera.farClipPlane;
+ focalDistance01 = vector.z;
+ }
+ else
+ {
+ focalDistance01 = FocalDistance01(focalZDistance);
+ }
+ focalStartCurve = focalZStartCurve;
+ focalEndCurve = focalZEndCurve;
+ flag = flag && focalPoint > _camera.nearClipPlane + Mathf.Epsilon;
+ }
+ widthOverHeight = 1f * (float)source.width / (1f * (float)source.height);
+ oneOverBaseSize = 0.001953125f;
+ dofMaterial.SetFloat("_ForegroundBlurExtrude", foregroundBlurExtrude);
+ dofMaterial.SetVector("_CurveParams", new Vector4(simpleTweakMode ? (1f / focalStartCurve) : focalStartCurve, simpleTweakMode ? (1f / focalEndCurve) : focalEndCurve, num2 * 0.5f, focalDistance01));
+ dofMaterial.SetVector("_InvRenderTargetSize", new Vector4(1f / (1f * (float)source.width), 1f / (1f * (float)source.height), 0f, 0f));
+ int dividerBasedOnQuality = GetDividerBasedOnQuality();
+ int lowResolutionDividerBasedOnQuality = GetLowResolutionDividerBasedOnQuality(dividerBasedOnQuality);
+ AllocateTextures(flag, source, dividerBasedOnQuality, lowResolutionDividerBasedOnQuality);
+ Graphics.Blit(source, source, dofMaterial, 3);
+ Downsample(source, mediumRezWorkTexture);
+ Blur(mediumRezWorkTexture, mediumRezWorkTexture, DofBlurriness.Low, 4, maxBlurSpread);
+ if (bokeh && (BokehDestination.Foreground & bokehDestination) != 0)
+ {
+ dofMaterial.SetVector("_Threshhold", new Vector4(bokehThresholdContrast, bokehThresholdLuminance, 0.95f, 0f));
+ Graphics.Blit(mediumRezWorkTexture, bokehSource2, dofMaterial, 11);
+ Graphics.Blit(mediumRezWorkTexture, lowRezWorkTexture);
+ Blur(lowRezWorkTexture, lowRezWorkTexture, bluriness, 0, maxBlurSpread * num);
+ }
+ else
+ {
+ Downsample(mediumRezWorkTexture, lowRezWorkTexture);
+ Blur(lowRezWorkTexture, lowRezWorkTexture, bluriness, 0, maxBlurSpread);
+ }
+ dofBlurMaterial.SetTexture("_TapLow", lowRezWorkTexture);
+ dofBlurMaterial.SetTexture("_TapMedium", mediumRezWorkTexture);
+ Graphics.Blit(null, finalDefocus, dofBlurMaterial, 3);
+ if (bokeh && (BokehDestination.Foreground & bokehDestination) != 0)
+ {
+ AddBokeh(bokehSource2, bokehSource, finalDefocus);
+ }
+ dofMaterial.SetTexture("_TapLowBackground", finalDefocus);
+ dofMaterial.SetTexture("_TapMedium", mediumRezWorkTexture);
+ Graphics.Blit(source, flag ? foregroundTexture : destination, dofMaterial, visualize ? 2 : 0);
+ if (flag)
+ {
+ Graphics.Blit(foregroundTexture, source, dofMaterial, 5);
+ Downsample(source, mediumRezWorkTexture);
+ BlurFg(mediumRezWorkTexture, mediumRezWorkTexture, DofBlurriness.Low, 2, maxBlurSpread);
+ if (bokeh && (BokehDestination.Foreground & bokehDestination) != 0)
+ {
+ dofMaterial.SetVector("_Threshhold", new Vector4(bokehThresholdContrast * 0.5f, bokehThresholdLuminance, 0f, 0f));
+ Graphics.Blit(mediumRezWorkTexture, bokehSource2, dofMaterial, 11);
+ Graphics.Blit(mediumRezWorkTexture, lowRezWorkTexture);
+ BlurFg(lowRezWorkTexture, lowRezWorkTexture, bluriness, 1, maxBlurSpread * num);
+ }
+ else
+ {
+ BlurFg(mediumRezWorkTexture, lowRezWorkTexture, bluriness, 1, maxBlurSpread);
+ }
+ Graphics.Blit(lowRezWorkTexture, finalDefocus);
+ dofMaterial.SetTexture("_TapLowForeground", finalDefocus);
+ Graphics.Blit(source, destination, dofMaterial, visualize ? 1 : 4);
+ if (bokeh && (BokehDestination.Foreground & bokehDestination) != 0)
+ {
+ AddBokeh(bokehSource2, bokehSource, destination);
+ }
+ }
+ ReleaseTextures();
+ }
+
+ private void Blur(RenderTexture from, RenderTexture to, DofBlurriness iterations, int blurPass, float spread)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(to.width, to.height);
+ if (iterations > DofBlurriness.Low)
+ {
+ BlurHex(from, to, blurPass, spread, temporary);
+ if (iterations > DofBlurriness.High)
+ {
+ dofBlurMaterial.SetVector("offsets", new Vector4(0f, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(to, temporary, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, 0f, 0f, 0f));
+ Graphics.Blit(temporary, to, dofBlurMaterial, blurPass);
+ }
+ }
+ else
+ {
+ dofBlurMaterial.SetVector("offsets", new Vector4(0f, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(from, temporary, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, 0f, 0f, 0f));
+ Graphics.Blit(temporary, to, dofBlurMaterial, blurPass);
+ }
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+
+ private void BlurFg(RenderTexture from, RenderTexture to, DofBlurriness iterations, int blurPass, float spread)
+ {
+ dofBlurMaterial.SetTexture("_TapHigh", from);
+ RenderTexture temporary = RenderTexture.GetTemporary(to.width, to.height);
+ if (iterations > DofBlurriness.Low)
+ {
+ BlurHex(from, to, blurPass, spread, temporary);
+ if (iterations > DofBlurriness.High)
+ {
+ dofBlurMaterial.SetVector("offsets", new Vector4(0f, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(to, temporary, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, 0f, 0f, 0f));
+ Graphics.Blit(temporary, to, dofBlurMaterial, blurPass);
+ }
+ }
+ else
+ {
+ dofBlurMaterial.SetVector("offsets", new Vector4(0f, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(from, temporary, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, 0f, 0f, 0f));
+ Graphics.Blit(temporary, to, dofBlurMaterial, blurPass);
+ }
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+
+ private void BlurHex(RenderTexture from, RenderTexture to, int blurPass, float spread, RenderTexture tmp)
+ {
+ dofBlurMaterial.SetVector("offsets", new Vector4(0f, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(from, tmp, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, 0f, 0f, 0f));
+ Graphics.Blit(tmp, to, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, spread * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(to, tmp, dofBlurMaterial, blurPass);
+ dofBlurMaterial.SetVector("offsets", new Vector4(spread / widthOverHeight * oneOverBaseSize, (0f - spread) * oneOverBaseSize, 0f, 0f));
+ Graphics.Blit(tmp, to, dofBlurMaterial, blurPass);
+ }
+
+ private void Downsample(RenderTexture from, RenderTexture to)
+ {
+ dofMaterial.SetVector("_InvRenderTargetSize", new Vector4(1f / (1f * (float)to.width), 1f / (1f * (float)to.height), 0f, 0f));
+ Graphics.Blit(from, to, dofMaterial, SMOOTH_DOWNSAMPLE_PASS);
+ }
+
+ private void AddBokeh(RenderTexture bokehInfo, RenderTexture tempTex, RenderTexture finalTarget)
+ {
+ if (!bokehMaterial)
+ {
+ return;
+ }
+ Mesh[] meshes = Quads.GetMeshes(tempTex.width, tempTex.height);
+ RenderTexture.active = tempTex;
+ GL.Clear(clearDepth: false, clearColor: true, new Color(0f, 0f, 0f, 0f));
+ GL.PushMatrix();
+ GL.LoadIdentity();
+ bokehInfo.filterMode = FilterMode.Point;
+ float num = (float)bokehInfo.width * 1f / ((float)bokehInfo.height * 1f);
+ float num2 = 2f / (1f * (float)bokehInfo.width);
+ num2 += bokehScale * maxBlurSpread * BOKEH_EXTRA_BLUR * oneOverBaseSize;
+ bokehMaterial.SetTexture("_Source", bokehInfo);
+ bokehMaterial.SetTexture("_MainTex", bokehTexture);
+ bokehMaterial.SetVector("_ArScale", new Vector4(num2, num2 * num, 0.5f, 0.5f * num));
+ bokehMaterial.SetFloat("_Intensity", bokehIntensity);
+ bokehMaterial.SetPass(0);
+ Mesh[] array = meshes;
+ foreach (Mesh mesh in array)
+ {
+ if ((bool)mesh)
+ {
+ Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
+ }
+ }
+ GL.PopMatrix();
+ Graphics.Blit(tempTex, finalTarget, dofMaterial, 8);
+ bokehInfo.filterMode = FilterMode.Bilinear;
+ }
+
+ private void ReleaseTextures()
+ {
+ if ((bool)foregroundTexture)
+ {
+ RenderTexture.ReleaseTemporary(foregroundTexture);
+ }
+ if ((bool)finalDefocus)
+ {
+ RenderTexture.ReleaseTemporary(finalDefocus);
+ }
+ if ((bool)mediumRezWorkTexture)
+ {
+ RenderTexture.ReleaseTemporary(mediumRezWorkTexture);
+ }
+ if ((bool)lowRezWorkTexture)
+ {
+ RenderTexture.ReleaseTemporary(lowRezWorkTexture);
+ }
+ if ((bool)bokehSource)
+ {
+ RenderTexture.ReleaseTemporary(bokehSource);
+ }
+ if ((bool)bokehSource2)
+ {
+ RenderTexture.ReleaseTemporary(bokehSource2);
+ }
+ }
+
+ private void AllocateTextures(bool blurForeground, RenderTexture source, int divider, int lowTexDivider)
+ {
+ foregroundTexture = null;
+ if (blurForeground)
+ {
+ foregroundTexture = RenderTexture.GetTemporary(source.width, source.height, 0);
+ }
+ mediumRezWorkTexture = RenderTexture.GetTemporary(source.width / divider, source.height / divider, 0);
+ finalDefocus = RenderTexture.GetTemporary(source.width / divider, source.height / divider, 0);
+ lowRezWorkTexture = RenderTexture.GetTemporary(source.width / lowTexDivider, source.height / lowTexDivider, 0);
+ bokehSource = null;
+ bokehSource2 = null;
+ if (bokeh)
+ {
+ bokehSource = RenderTexture.GetTemporary(source.width / (lowTexDivider * bokehDownsample), source.height / (lowTexDivider * bokehDownsample), 0, RenderTextureFormat.ARGBHalf);
+ bokehSource2 = RenderTexture.GetTemporary(source.width / (lowTexDivider * bokehDownsample), source.height / (lowTexDivider * bokehDownsample), 0, RenderTextureFormat.ARGBHalf);
+ bokehSource.filterMode = FilterMode.Bilinear;
+ bokehSource2.filterMode = FilterMode.Bilinear;
+ RenderTexture.active = bokehSource2;
+ GL.Clear(clearDepth: false, clearColor: true, new Color(0f, 0f, 0f, 0f));
+ }
+ source.filterMode = FilterMode.Bilinear;
+ finalDefocus.filterMode = FilterMode.Bilinear;
+ mediumRezWorkTexture.filterMode = FilterMode.Bilinear;
+ lowRezWorkTexture.filterMode = FilterMode.Bilinear;
+ if ((bool)foregroundTexture)
+ {
+ foregroundTexture.filterMode = FilterMode.Bilinear;
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/EdgeDetection.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/EdgeDetection.cs
new file mode 100644
index 0000000..13e9140
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/EdgeDetection.cs
@@ -0,0 +1,96 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Edge Detection/Edge Detection")]
+public class EdgeDetection : PostEffectsBase
+{
+ public enum EdgeDetectMode
+ {
+ TriangleDepthNormals,
+ RobertsCrossDepthNormals,
+ SobelDepth,
+ SobelDepthThin,
+ TriangleLuminance
+ }
+
+ public EdgeDetectMode mode = EdgeDetectMode.SobelDepthThin;
+
+ public float sensitivityDepth = 1f;
+
+ public float sensitivityNormals = 1f;
+
+ public float lumThreshold = 0.2f;
+
+ public float edgeExp = 1f;
+
+ public float sampleDist = 1f;
+
+ public float edgesOnly;
+
+ public Color edgesOnlyBgColor = Color.white;
+
+ public Shader edgeDetectShader;
+
+ private Material edgeDetectMaterial;
+
+ private EdgeDetectMode oldMode = EdgeDetectMode.SobelDepthThin;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ edgeDetectMaterial = CheckShaderAndCreateMaterial(edgeDetectShader, edgeDetectMaterial);
+ if (mode != oldMode)
+ {
+ SetCameraFlag();
+ }
+ oldMode = mode;
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private new void Start()
+ {
+ oldMode = mode;
+ }
+
+ private void SetCameraFlag()
+ {
+ if (mode == EdgeDetectMode.SobelDepth || mode == EdgeDetectMode.SobelDepthThin)
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
+ }
+ else if (mode == EdgeDetectMode.TriangleDepthNormals || mode == EdgeDetectMode.RobertsCrossDepthNormals)
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.DepthNormals;
+ }
+ }
+
+ private void OnEnable()
+ {
+ SetCameraFlag();
+ }
+
+ [ImageEffectOpaque]
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ Vector2 vector = new Vector2(sensitivityDepth, sensitivityNormals);
+ edgeDetectMaterial.SetVector("_Sensitivity", new Vector4(vector.x, vector.y, 1f, vector.y));
+ edgeDetectMaterial.SetFloat("_BgFade", edgesOnly);
+ edgeDetectMaterial.SetFloat("_SampleDistance", sampleDist);
+ edgeDetectMaterial.SetVector("_BgColor", edgesOnlyBgColor);
+ edgeDetectMaterial.SetFloat("_Exponent", edgeExp);
+ edgeDetectMaterial.SetFloat("_Threshold", lumThreshold);
+ Graphics.Blit(source, destination, edgeDetectMaterial, (int)mode);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Fisheye.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Fisheye.cs
new file mode 100644
index 0000000..77c1663
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Fisheye.cs
@@ -0,0 +1,43 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Displacement/Fisheye")]
+public class Fisheye : PostEffectsBase
+{
+ [Range(0f, 1.5f)]
+ public float strengthX = 0.05f;
+
+ [Range(0f, 1.5f)]
+ public float strengthY = 0.05f;
+
+ public Shader fishEyeShader;
+
+ private Material fisheyeMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ fisheyeMaterial = CheckShaderAndCreateMaterial(fishEyeShader, fisheyeMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ float num = 5f / 32f;
+ float num2 = (float)source.width * 1f / ((float)source.height * 1f);
+ fisheyeMaterial.SetVector("intensity", new Vector4(strengthX * num2 * num, strengthY * num, strengthX * num2 * num, strengthY * num));
+ Graphics.Blit(source, destination, fisheyeMaterial);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/GlobalFog.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/GlobalFog.cs
new file mode 100644
index 0000000..72743ac
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/GlobalFog.cs
@@ -0,0 +1,92 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Rendering/Global Fog")]
+internal class GlobalFog : PostEffectsBase
+{
+ [Tooltip("Apply distance-based fog?")]
+ public bool distanceFog = true;
+
+ [Tooltip("Exclude far plane pixels from distance-based fog? (Skybox or clear color)")]
+ public bool excludeFarPixels = true;
+
+ [Tooltip("Distance fog is based on radial distance from camera when checked")]
+ public bool useRadialDistance;
+
+ [Tooltip("Apply height-based fog?")]
+ public bool heightFog = true;
+
+ [Tooltip("Fog top Y coordinate")]
+ public float height = 1f;
+
+ [Range(0.001f, 10f)]
+ public float heightDensity = 2f;
+
+ [Tooltip("Push fog away from the camera by this amount")]
+ public float startDistance;
+
+ public Shader fogShader;
+
+ private Material fogMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ fogMaterial = CheckShaderAndCreateMaterial(fogShader, fogMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ [ImageEffectOpaque]
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources() || (!distanceFog && !heightFog))
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ Camera component = GetComponent<Camera>();
+ Transform obj = component.transform;
+ Vector3[] array = new Vector3[4];
+ component.CalculateFrustumCorners(new Rect(0f, 0f, 1f, 1f), component.farClipPlane, component.stereoActiveEye, array);
+ Vector3 vector = obj.TransformVector(array[0]);
+ Vector3 vector2 = obj.TransformVector(array[1]);
+ Vector3 vector3 = obj.TransformVector(array[2]);
+ Vector3 vector4 = obj.TransformVector(array[3]);
+ Matrix4x4 identity = Matrix4x4.identity;
+ identity.SetRow(0, vector);
+ identity.SetRow(1, vector4);
+ identity.SetRow(2, vector2);
+ identity.SetRow(3, vector3);
+ Vector3 position = obj.position;
+ float num = position.y - height;
+ float z = ((num <= 0f) ? 1f : 0f);
+ float y = (excludeFarPixels ? 1f : 2f);
+ fogMaterial.SetMatrix("_FrustumCornersWS", identity);
+ fogMaterial.SetVector("_CameraWS", position);
+ fogMaterial.SetVector("_HeightParams", new Vector4(height, num, z, heightDensity * 0.5f));
+ fogMaterial.SetVector("_DistanceParams", new Vector4(0f - Mathf.Max(startDistance, 0f), y, 0f, 0f));
+ FogMode fogMode = RenderSettings.fogMode;
+ float fogDensity = RenderSettings.fogDensity;
+ float fogStartDistance = RenderSettings.fogStartDistance;
+ float fogEndDistance = RenderSettings.fogEndDistance;
+ bool flag = fogMode == FogMode.Linear;
+ float num2 = (flag ? (fogEndDistance - fogStartDistance) : 0f);
+ float num3 = ((Mathf.Abs(num2) > 0.0001f) ? (1f / num2) : 0f);
+ Vector4 value = default(Vector4);
+ value.x = fogDensity * 1.2011224f;
+ value.y = fogDensity * 1.442695f;
+ value.z = (flag ? (0f - num3) : 0f);
+ value.w = (flag ? (fogEndDistance * num3) : 0f);
+ fogMaterial.SetVector("_SceneFogParams", value);
+ fogMaterial.SetVector("_SceneFogMode", new Vector4((float)fogMode, useRadialDistance ? 1 : 0, 0f, 0f));
+ int num4 = 0;
+ Graphics.Blit(pass: (!distanceFog || !heightFog) ? (distanceFog ? 1 : 2) : 0, source: source, dest: destination, mat: fogMaterial);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Grayscale.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Grayscale.cs
new file mode 100644
index 0000000..289eddc
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Grayscale.cs
@@ -0,0 +1,20 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Grayscale")]
+public class Grayscale : ImageEffectBase
+{
+ public Texture textureRamp;
+
+ [Range(-1f, 1f)]
+ public float rampOffset;
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ base.material.SetTexture("_RampTex", textureRamp);
+ base.material.SetFloat("_RampOffset", rampOffset);
+ Graphics.Blit(source, destination, base.material);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/HDRBloomMode.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/HDRBloomMode.cs
new file mode 100644
index 0000000..b26d1e5
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/HDRBloomMode.cs
@@ -0,0 +1,8 @@
+namespace UnityStandardAssets.ImageEffects;
+
+public enum HDRBloomMode
+{
+ Auto,
+ On,
+ Off
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffectBase.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffectBase.cs
new file mode 100644
index 0000000..19b4215
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffectBase.cs
@@ -0,0 +1,45 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("")]
+public class ImageEffectBase : MonoBehaviour
+{
+ public Shader shader;
+
+ private Material m_Material;
+
+ protected Material material
+ {
+ get
+ {
+ if (m_Material == null)
+ {
+ m_Material = new Material(shader);
+ m_Material.hideFlags = HideFlags.HideAndDontSave;
+ }
+ return m_Material;
+ }
+ }
+
+ protected virtual void Start()
+ {
+ if (!SystemInfo.supportsImageEffects)
+ {
+ base.enabled = false;
+ }
+ else if (!shader || !shader.isSupported)
+ {
+ base.enabled = false;
+ }
+ }
+
+ protected virtual void OnDisable()
+ {
+ if ((bool)m_Material)
+ {
+ Object.DestroyImmediate(m_Material);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffects.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffects.cs
new file mode 100644
index 0000000..43121e4
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ImageEffects.cs
@@ -0,0 +1,34 @@
+using System;
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[AddComponentMenu("")]
+public class ImageEffects
+{
+ public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
+ {
+ if (source.texelSize.y < 0f)
+ {
+ center.y = 1f - center.y;
+ angle = 0f - angle;
+ }
+ Matrix4x4 value = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, angle), Vector3.one);
+ material.SetMatrix("_RotationMatrix", value);
+ material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
+ material.SetFloat("_Angle", angle * ((float)Math.PI / 180f));
+ Graphics.Blit(source, destination, material);
+ }
+
+ [Obsolete("Use Graphics.Blit(source,dest) instead")]
+ public static void Blit(RenderTexture source, RenderTexture dest)
+ {
+ Graphics.Blit(source, dest);
+ }
+
+ [Obsolete("Use Graphics.Blit(source, destination, material) instead")]
+ public static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture dest)
+ {
+ Graphics.Blit(source, dest, material);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/LensflareStyle34.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/LensflareStyle34.cs
new file mode 100644
index 0000000..a324696
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/LensflareStyle34.cs
@@ -0,0 +1,8 @@
+namespace UnityStandardAssets.ImageEffects;
+
+public enum LensflareStyle34
+{
+ Ghosting,
+ Anamorphic,
+ Combined
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/MotionBlur.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/MotionBlur.cs
new file mode 100644
index 0000000..4f34fc8
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/MotionBlur.cs
@@ -0,0 +1,52 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Blur/Motion Blur (Color Accumulation)")]
+[RequireComponent(typeof(Camera))]
+public class MotionBlur : ImageEffectBase
+{
+ [Range(0f, 0.92f)]
+ public float blurAmount = 0.8f;
+
+ public bool extraBlur;
+
+ private RenderTexture accumTexture;
+
+ protected override void Start()
+ {
+ base.Start();
+ }
+
+ protected override void OnDisable()
+ {
+ base.OnDisable();
+ Object.DestroyImmediate(accumTexture);
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (accumTexture == null || accumTexture.width != source.width || accumTexture.height != source.height)
+ {
+ Object.DestroyImmediate(accumTexture);
+ accumTexture = new RenderTexture(source.width, source.height, 0);
+ accumTexture.hideFlags = HideFlags.HideAndDontSave;
+ Graphics.Blit(source, accumTexture);
+ }
+ if (extraBlur)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width / 4, source.height / 4, 0);
+ accumTexture.MarkRestoreExpected();
+ Graphics.Blit(accumTexture, temporary);
+ Graphics.Blit(temporary, accumTexture);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ blurAmount = Mathf.Clamp(blurAmount, 0f, 0.92f);
+ base.material.SetTexture("_MainTex", accumTexture);
+ base.material.SetFloat("_AccumOrig", 1f - blurAmount);
+ accumTexture.MarkRestoreExpected();
+ Graphics.Blit(source, accumTexture, base.material);
+ Graphics.Blit(accumTexture, destination);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndGrain.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndGrain.cs
new file mode 100644
index 0000000..a15b96d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndGrain.cs
@@ -0,0 +1,158 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Noise/Noise And Grain (Filmic)")]
+public class NoiseAndGrain : PostEffectsBase
+{
+ public float intensityMultiplier = 0.25f;
+
+ public float generalIntensity = 0.5f;
+
+ public float blackIntensity = 1f;
+
+ public float whiteIntensity = 1f;
+
+ public float midGrey = 0.2f;
+
+ public bool dx11Grain;
+
+ public float softness;
+
+ public bool monochrome;
+
+ public Vector3 intensities = new Vector3(1f, 1f, 1f);
+
+ public Vector3 tiling = new Vector3(64f, 64f, 64f);
+
+ public float monochromeTiling = 64f;
+
+ public FilterMode filterMode = FilterMode.Bilinear;
+
+ public Texture2D noiseTexture;
+
+ public Shader noiseShader;
+
+ private Material noiseMaterial;
+
+ public Shader dx11NoiseShader;
+
+ private Material dx11NoiseMaterial;
+
+ private static float TILE_AMOUNT = 64f;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ noiseMaterial = CheckShaderAndCreateMaterial(noiseShader, noiseMaterial);
+ if (dx11Grain && supportDX11)
+ {
+ dx11NoiseMaterial = CheckShaderAndCreateMaterial(dx11NoiseShader, dx11NoiseMaterial);
+ }
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources() || null == noiseTexture)
+ {
+ Graphics.Blit(source, destination);
+ if (null == noiseTexture)
+ {
+ Debug.LogWarning("Noise & Grain effect failing as noise texture is not assigned. please assign.", base.transform);
+ }
+ return;
+ }
+ softness = Mathf.Clamp(softness, 0f, 0.99f);
+ if (dx11Grain && supportDX11)
+ {
+ dx11NoiseMaterial.SetFloat("_DX11NoiseTime", Time.frameCount);
+ dx11NoiseMaterial.SetTexture("_NoiseTex", noiseTexture);
+ dx11NoiseMaterial.SetVector("_NoisePerChannel", monochrome ? Vector3.one : intensities);
+ dx11NoiseMaterial.SetVector("_MidGrey", new Vector3(midGrey, 1f / (1f - midGrey), -1f / midGrey));
+ dx11NoiseMaterial.SetVector("_NoiseAmount", new Vector3(generalIntensity, blackIntensity, whiteIntensity) * intensityMultiplier);
+ if (softness > Mathf.Epsilon)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary((int)((float)source.width * (1f - softness)), (int)((float)source.height * (1f - softness)));
+ DrawNoiseQuadGrid(source, temporary, dx11NoiseMaterial, noiseTexture, monochrome ? 3 : 2);
+ dx11NoiseMaterial.SetTexture("_NoiseTex", temporary);
+ Graphics.Blit(source, destination, dx11NoiseMaterial, 4);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ else
+ {
+ DrawNoiseQuadGrid(source, destination, dx11NoiseMaterial, noiseTexture, monochrome ? 1 : 0);
+ }
+ return;
+ }
+ if ((bool)noiseTexture)
+ {
+ noiseTexture.wrapMode = TextureWrapMode.Repeat;
+ noiseTexture.filterMode = filterMode;
+ }
+ noiseMaterial.SetTexture("_NoiseTex", noiseTexture);
+ noiseMaterial.SetVector("_NoisePerChannel", monochrome ? Vector3.one : intensities);
+ noiseMaterial.SetVector("_NoiseTilingPerChannel", monochrome ? (Vector3.one * monochromeTiling) : tiling);
+ noiseMaterial.SetVector("_MidGrey", new Vector3(midGrey, 1f / (1f - midGrey), -1f / midGrey));
+ noiseMaterial.SetVector("_NoiseAmount", new Vector3(generalIntensity, blackIntensity, whiteIntensity) * intensityMultiplier);
+ if (softness > Mathf.Epsilon)
+ {
+ RenderTexture temporary2 = RenderTexture.GetTemporary((int)((float)source.width * (1f - softness)), (int)((float)source.height * (1f - softness)));
+ DrawNoiseQuadGrid(source, temporary2, noiseMaterial, noiseTexture, 2);
+ noiseMaterial.SetTexture("_NoiseTex", temporary2);
+ Graphics.Blit(source, destination, noiseMaterial, 1);
+ RenderTexture.ReleaseTemporary(temporary2);
+ }
+ else
+ {
+ DrawNoiseQuadGrid(source, destination, noiseMaterial, noiseTexture, 0);
+ }
+ }
+
+ private static void DrawNoiseQuadGrid(RenderTexture source, RenderTexture dest, Material fxMaterial, Texture2D noise, int passNr)
+ {
+ RenderTexture.active = dest;
+ float num = (float)noise.width * 1f;
+ float num2 = 1f * (float)source.width / TILE_AMOUNT;
+ fxMaterial.SetTexture("_MainTex", source);
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ float num3 = 1f * (float)source.width / (1f * (float)source.height);
+ float num4 = 1f / num2;
+ float num5 = num4 * num3;
+ float num6 = num / ((float)noise.width * 1f);
+ fxMaterial.SetPass(passNr);
+ GL.Begin(7);
+ for (float num7 = 0f; num7 < 1f; num7 += num4)
+ {
+ for (float num8 = 0f; num8 < 1f; num8 += num5)
+ {
+ float num9 = Random.Range(0f, 1f);
+ float num10 = Random.Range(0f, 1f);
+ num9 = Mathf.Floor(num9 * num) / num;
+ num10 = Mathf.Floor(num10 * num) / num;
+ float num11 = 1f / num;
+ GL.MultiTexCoord2(0, num9, num10);
+ GL.MultiTexCoord2(1, 0f, 0f);
+ GL.Vertex3(num7, num8, 0.1f);
+ GL.MultiTexCoord2(0, num9 + num6 * num11, num10);
+ GL.MultiTexCoord2(1, 1f, 0f);
+ GL.Vertex3(num7 + num4, num8, 0.1f);
+ GL.MultiTexCoord2(0, num9 + num6 * num11, num10 + num6 * num11);
+ GL.MultiTexCoord2(1, 1f, 1f);
+ GL.Vertex3(num7 + num4, num8 + num5, 0.1f);
+ GL.MultiTexCoord2(0, num9, num10 + num6 * num11);
+ GL.MultiTexCoord2(1, 0f, 1f);
+ GL.Vertex3(num7, num8 + num5, 0.1f);
+ }
+ }
+ GL.End();
+ GL.PopMatrix();
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndScratches.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndScratches.cs
new file mode 100644
index 0000000..256a981
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/NoiseAndScratches.cs
@@ -0,0 +1,138 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Noise/Noise and Scratches")]
+public class NoiseAndScratches : MonoBehaviour
+{
+ public bool monochrome = true;
+
+ private bool rgbFallback;
+
+ [Range(0f, 5f)]
+ public float grainIntensityMin = 0.1f;
+
+ [Range(0f, 5f)]
+ public float grainIntensityMax = 0.2f;
+
+ [Range(0.1f, 50f)]
+ public float grainSize = 2f;
+
+ [Range(0f, 5f)]
+ public float scratchIntensityMin = 0.05f;
+
+ [Range(0f, 5f)]
+ public float scratchIntensityMax = 0.25f;
+
+ [Range(1f, 30f)]
+ public float scratchFPS = 10f;
+
+ [Range(0f, 1f)]
+ public float scratchJitter = 0.01f;
+
+ public Texture grainTexture;
+
+ public Texture scratchTexture;
+
+ public Shader shaderRGB;
+
+ public Shader shaderYUV;
+
+ private Material m_MaterialRGB;
+
+ private Material m_MaterialYUV;
+
+ private float scratchTimeLeft;
+
+ private float scratchX;
+
+ private float scratchY;
+
+ protected Material material
+ {
+ get
+ {
+ if (m_MaterialRGB == null)
+ {
+ m_MaterialRGB = new Material(shaderRGB);
+ m_MaterialRGB.hideFlags = HideFlags.HideAndDontSave;
+ }
+ if (m_MaterialYUV == null && !rgbFallback)
+ {
+ m_MaterialYUV = new Material(shaderYUV);
+ m_MaterialYUV.hideFlags = HideFlags.HideAndDontSave;
+ }
+ if (rgbFallback || monochrome)
+ {
+ return m_MaterialRGB;
+ }
+ return m_MaterialYUV;
+ }
+ }
+
+ protected void Start()
+ {
+ if (!SystemInfo.supportsImageEffects)
+ {
+ base.enabled = false;
+ }
+ else if (shaderRGB == null || shaderYUV == null)
+ {
+ Debug.Log("Noise shaders are not set up! Disabling noise effect.");
+ base.enabled = false;
+ }
+ else if (!shaderRGB.isSupported)
+ {
+ base.enabled = false;
+ }
+ else if (!shaderYUV.isSupported)
+ {
+ rgbFallback = true;
+ }
+ }
+
+ protected void OnDisable()
+ {
+ if ((bool)m_MaterialRGB)
+ {
+ Object.DestroyImmediate(m_MaterialRGB);
+ }
+ if ((bool)m_MaterialYUV)
+ {
+ Object.DestroyImmediate(m_MaterialYUV);
+ }
+ }
+
+ private void SanitizeParameters()
+ {
+ grainIntensityMin = Mathf.Clamp(grainIntensityMin, 0f, 5f);
+ grainIntensityMax = Mathf.Clamp(grainIntensityMax, 0f, 5f);
+ scratchIntensityMin = Mathf.Clamp(scratchIntensityMin, 0f, 5f);
+ scratchIntensityMax = Mathf.Clamp(scratchIntensityMax, 0f, 5f);
+ scratchFPS = Mathf.Clamp(scratchFPS, 1f, 30f);
+ scratchJitter = Mathf.Clamp(scratchJitter, 0f, 1f);
+ grainSize = Mathf.Clamp(grainSize, 0.1f, 50f);
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ SanitizeParameters();
+ if (scratchTimeLeft <= 0f)
+ {
+ scratchTimeLeft = Random.value * 2f / scratchFPS;
+ scratchX = Random.value;
+ scratchY = Random.value;
+ }
+ scratchTimeLeft -= Time.deltaTime;
+ Material material = this.material;
+ material.SetTexture("_GrainTex", grainTexture);
+ material.SetTexture("_ScratchTex", scratchTexture);
+ float num = 1f / grainSize;
+ material.SetVector("_GrainOffsetScale", new Vector4(Random.value, Random.value, (float)Screen.width / (float)grainTexture.width * num, (float)Screen.height / (float)grainTexture.height * num));
+ material.SetVector("_ScratchOffsetScale", new Vector4(scratchX + Random.value * scratchJitter, scratchY + Random.value * scratchJitter, (float)Screen.width / (float)scratchTexture.width, (float)Screen.height / (float)scratchTexture.height));
+ material.SetVector("_Intensity", new Vector4(Random.Range(grainIntensityMin, grainIntensityMax), Random.Range(scratchIntensityMin, scratchIntensityMax), 0f, 0f));
+ Graphics.Blit(source, destination, material);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsBase.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsBase.cs
new file mode 100644
index 0000000..1296bab
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsBase.cs
@@ -0,0 +1,233 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+public class PostEffectsBase : MonoBehaviour
+{
+ protected bool supportHDRTextures = true;
+
+ protected bool supportDX11;
+
+ protected bool isSupported = true;
+
+ private List<Material> createdMaterials = new List<Material>();
+
+ protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
+ {
+ if (!s)
+ {
+ Debug.Log("Missing shader in " + ToString());
+ base.enabled = false;
+ return null;
+ }
+ if (s.isSupported && (bool)m2Create && m2Create.shader == s)
+ {
+ return m2Create;
+ }
+ if (!s.isSupported)
+ {
+ NotSupported();
+ Debug.Log("The shader " + s.ToString() + " on effect " + ToString() + " is not supported on this platform!");
+ return null;
+ }
+ m2Create = new Material(s);
+ createdMaterials.Add(m2Create);
+ m2Create.hideFlags = HideFlags.DontSave;
+ return m2Create;
+ }
+
+ protected Material CreateMaterial(Shader s, Material m2Create)
+ {
+ if (!s)
+ {
+ Debug.Log("Missing shader in " + ToString());
+ return null;
+ }
+ if ((bool)m2Create && m2Create.shader == s && s.isSupported)
+ {
+ return m2Create;
+ }
+ if (!s.isSupported)
+ {
+ return null;
+ }
+ m2Create = new Material(s);
+ createdMaterials.Add(m2Create);
+ m2Create.hideFlags = HideFlags.DontSave;
+ return m2Create;
+ }
+
+ private void OnEnable()
+ {
+ isSupported = true;
+ }
+
+ private void OnDestroy()
+ {
+ RemoveCreatedMaterials();
+ }
+
+ private void RemoveCreatedMaterials()
+ {
+ while (createdMaterials.Count > 0)
+ {
+ Material obj = createdMaterials[0];
+ createdMaterials.RemoveAt(0);
+ Object.Destroy(obj);
+ }
+ }
+
+ protected bool CheckSupport()
+ {
+ return CheckSupport(needDepth: false);
+ }
+
+ public virtual bool CheckResources()
+ {
+ Debug.LogWarning("CheckResources () for " + ToString() + " should be overwritten.");
+ return isSupported;
+ }
+
+ protected void Start()
+ {
+ CheckResources();
+ }
+
+ protected bool CheckSupport(bool needDepth)
+ {
+ isSupported = true;
+ supportHDRTextures = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf);
+ supportDX11 = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders;
+ if (!SystemInfo.supportsImageEffects)
+ {
+ NotSupported();
+ return false;
+ }
+ if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
+ {
+ NotSupported();
+ return false;
+ }
+ if (needDepth)
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
+ }
+ return true;
+ }
+
+ protected bool CheckSupport(bool needDepth, bool needHdr)
+ {
+ if (!CheckSupport(needDepth))
+ {
+ return false;
+ }
+ if (needHdr && !supportHDRTextures)
+ {
+ NotSupported();
+ return false;
+ }
+ return true;
+ }
+
+ public bool Dx11Support()
+ {
+ return supportDX11;
+ }
+
+ protected void ReportAutoDisable()
+ {
+ Debug.LogWarning("The image effect " + ToString() + " has been disabled as it's not supported on the current platform.");
+ }
+
+ private bool CheckShader(Shader s)
+ {
+ Debug.Log("The shader " + s.ToString() + " on effect " + ToString() + " is not part of the Unity 3.2+ effects suite anymore. For best performance and quality, please ensure you are using the latest Standard Assets Image Effects (Pro only) package.");
+ if (!s.isSupported)
+ {
+ NotSupported();
+ return false;
+ }
+ return false;
+ }
+
+ protected void NotSupported()
+ {
+ base.enabled = false;
+ isSupported = false;
+ }
+
+ protected void DrawBorder(RenderTexture dest, Material material)
+ {
+ RenderTexture.active = dest;
+ bool flag = true;
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ for (int i = 0; i < material.passCount; i++)
+ {
+ material.SetPass(i);
+ float y;
+ float y2;
+ if (flag)
+ {
+ y = 1f;
+ y2 = 0f;
+ }
+ else
+ {
+ y = 0f;
+ y2 = 1f;
+ }
+ float x = 0f + 1f / ((float)dest.width * 1f);
+ float y3 = 0f;
+ float y4 = 1f;
+ GL.Begin(7);
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ float x2 = 1f - 1f / ((float)dest.width * 1f);
+ x = 1f;
+ y3 = 0f;
+ y4 = 1f;
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(x2, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(x2, y4, 0.1f);
+ x = 1f;
+ y3 = 0f;
+ y4 = 0f + 1f / ((float)dest.height * 1f);
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ x = 1f;
+ y3 = 1f - 1f / ((float)dest.height * 1f);
+ y4 = 1f;
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ GL.End();
+ }
+ GL.PopMatrix();
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsHelper.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsHelper.cs
new file mode 100644
index 0000000..0558551
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/PostEffectsHelper.cs
@@ -0,0 +1,172 @@
+using System;
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+internal class PostEffectsHelper : MonoBehaviour
+{
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ Debug.Log("OnRenderImage in Helper called ...");
+ }
+
+ private static void DrawLowLevelPlaneAlignedWithCamera(float dist, RenderTexture source, RenderTexture dest, Material material, Camera cameraForProjectionMatrix)
+ {
+ RenderTexture.active = dest;
+ material.SetTexture("_MainTex", source);
+ bool flag = true;
+ GL.PushMatrix();
+ GL.LoadIdentity();
+ GL.LoadProjectionMatrix(cameraForProjectionMatrix.projectionMatrix);
+ float f = cameraForProjectionMatrix.fieldOfView * 0.5f * ((float)Math.PI / 180f);
+ float num = Mathf.Cos(f) / Mathf.Sin(f);
+ float aspect = cameraForProjectionMatrix.aspect;
+ float num2 = aspect / (0f - num);
+ float num3 = aspect / num;
+ float num4 = 1f / (0f - num);
+ float num5 = 1f / num;
+ float num6 = 1f;
+ num2 *= dist * num6;
+ num3 *= dist * num6;
+ num4 *= dist * num6;
+ num5 *= dist * num6;
+ float z = 0f - dist;
+ for (int i = 0; i < material.passCount; i++)
+ {
+ material.SetPass(i);
+ GL.Begin(7);
+ float y;
+ float y2;
+ if (flag)
+ {
+ y = 1f;
+ y2 = 0f;
+ }
+ else
+ {
+ y = 0f;
+ y2 = 1f;
+ }
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(num2, num4, z);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(num3, num4, z);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(num3, num5, z);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(num2, num5, z);
+ GL.End();
+ }
+ GL.PopMatrix();
+ }
+
+ private static void DrawBorder(RenderTexture dest, Material material)
+ {
+ RenderTexture.active = dest;
+ bool flag = true;
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ for (int i = 0; i < material.passCount; i++)
+ {
+ material.SetPass(i);
+ float y;
+ float y2;
+ if (flag)
+ {
+ y = 1f;
+ y2 = 0f;
+ }
+ else
+ {
+ y = 0f;
+ y2 = 1f;
+ }
+ float x = 0f + 1f / ((float)dest.width * 1f);
+ float y3 = 0f;
+ float y4 = 1f;
+ GL.Begin(7);
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ float x2 = 1f - 1f / ((float)dest.width * 1f);
+ x = 1f;
+ y3 = 0f;
+ y4 = 1f;
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(x2, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(x2, y4, 0.1f);
+ x = 1f;
+ y3 = 0f;
+ y4 = 0f + 1f / ((float)dest.height * 1f);
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ x = 1f;
+ y3 = 1f - 1f / ((float)dest.height * 1f);
+ y4 = 1f;
+ GL.TexCoord2(0f, y);
+ GL.Vertex3(0f, y3, 0.1f);
+ GL.TexCoord2(1f, y);
+ GL.Vertex3(x, y3, 0.1f);
+ GL.TexCoord2(1f, y2);
+ GL.Vertex3(x, y4, 0.1f);
+ GL.TexCoord2(0f, y2);
+ GL.Vertex3(0f, y4, 0.1f);
+ GL.End();
+ }
+ GL.PopMatrix();
+ }
+
+ private static void DrawLowLevelQuad(float x1, float x2, float y1, float y2, RenderTexture source, RenderTexture dest, Material material)
+ {
+ RenderTexture.active = dest;
+ material.SetTexture("_MainTex", source);
+ bool flag = true;
+ GL.PushMatrix();
+ GL.LoadOrtho();
+ for (int i = 0; i < material.passCount; i++)
+ {
+ material.SetPass(i);
+ GL.Begin(7);
+ float y3;
+ float y4;
+ if (flag)
+ {
+ y3 = 1f;
+ y4 = 0f;
+ }
+ else
+ {
+ y3 = 0f;
+ y4 = 1f;
+ }
+ GL.TexCoord2(0f, y3);
+ GL.Vertex3(x1, y1, 0.1f);
+ GL.TexCoord2(1f, y3);
+ GL.Vertex3(x2, y1, 0.1f);
+ GL.TexCoord2(1f, y4);
+ GL.Vertex3(x2, y2, 0.1f);
+ GL.TexCoord2(0f, y4);
+ GL.Vertex3(x1, y2, 0.1f);
+ GL.End();
+ }
+ GL.PopMatrix();
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Quads.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Quads.cs
new file mode 100644
index 0000000..f8b01d9
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Quads.cs
@@ -0,0 +1,102 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+internal class Quads
+{
+ private static Mesh[] meshes;
+
+ private static int currentQuads;
+
+ private static bool HasMeshes()
+ {
+ if (meshes == null)
+ {
+ return false;
+ }
+ Mesh[] array = meshes;
+ foreach (Mesh mesh in array)
+ {
+ if (null == mesh)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static void Cleanup()
+ {
+ if (meshes == null)
+ {
+ return;
+ }
+ for (int i = 0; i < meshes.Length; i++)
+ {
+ if (null != meshes[i])
+ {
+ Object.DestroyImmediate(meshes[i]);
+ meshes[i] = null;
+ }
+ }
+ meshes = null;
+ }
+
+ public static Mesh[] GetMeshes(int totalWidth, int totalHeight)
+ {
+ if (HasMeshes() && currentQuads == totalWidth * totalHeight)
+ {
+ return meshes;
+ }
+ int num = 10833;
+ int num2 = (currentQuads = totalWidth * totalHeight);
+ meshes = new Mesh[Mathf.CeilToInt(1f * (float)num2 / (1f * (float)num))];
+ int num3 = 0;
+ int num4 = 0;
+ for (num3 = 0; num3 < num2; num3 += num)
+ {
+ int triCount = Mathf.FloorToInt(Mathf.Clamp(num2 - num3, 0, num));
+ meshes[num4] = GetMesh(triCount, num3, totalWidth, totalHeight);
+ num4++;
+ }
+ return meshes;
+ }
+
+ private static Mesh GetMesh(int triCount, int triOffset, int totalWidth, int totalHeight)
+ {
+ Mesh mesh = new Mesh();
+ mesh.hideFlags = HideFlags.DontSave;
+ Vector3[] array = new Vector3[triCount * 4];
+ Vector2[] array2 = new Vector2[triCount * 4];
+ Vector2[] array3 = new Vector2[triCount * 4];
+ int[] array4 = new int[triCount * 6];
+ for (int i = 0; i < triCount; i++)
+ {
+ int num = i * 4;
+ int num2 = i * 6;
+ int num3 = triOffset + i;
+ float num4 = Mathf.Floor(num3 % totalWidth) / (float)totalWidth;
+ float num5 = Mathf.Floor(num3 / totalWidth) / (float)totalHeight;
+ array[num + 3] = (array[num + 2] = (array[num + 1] = (array[num] = new Vector3(num4 * 2f - 1f, num5 * 2f - 1f, 1f))));
+ array2[num] = new Vector2(0f, 0f);
+ array2[num + 1] = new Vector2(1f, 0f);
+ array2[num + 2] = new Vector2(0f, 1f);
+ array2[num + 3] = new Vector2(1f, 1f);
+ array3[num] = new Vector2(num4, num5);
+ array3[num + 1] = new Vector2(num4, num5);
+ array3[num + 2] = new Vector2(num4, num5);
+ array3[num + 3] = new Vector2(num4, num5);
+ array4[num2] = num;
+ array4[num2 + 1] = num + 1;
+ array4[num2 + 2] = num + 2;
+ array4[num2 + 3] = num + 1;
+ array4[num2 + 4] = num + 2;
+ array4[num2 + 5] = num + 3;
+ }
+ mesh.vertices = array;
+ mesh.triangles = array4;
+ mesh.uv = array2;
+ mesh.uv2 = array3;
+ return mesh;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenOverlay.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenOverlay.cs
new file mode 100644
index 0000000..5136a5e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenOverlay.cs
@@ -0,0 +1,53 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Other/Screen Overlay")]
+public class ScreenOverlay : PostEffectsBase
+{
+ public enum OverlayBlendMode
+ {
+ Additive,
+ ScreenBlend,
+ Multiply,
+ Overlay,
+ AlphaBlend
+ }
+
+ public OverlayBlendMode blendMode = OverlayBlendMode.Overlay;
+
+ public float intensity = 1f;
+
+ public Texture2D texture;
+
+ public Shader overlayShader;
+
+ private Material overlayMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ overlayMaterial = CheckShaderAndCreateMaterial(overlayShader, overlayMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ Vector4 value = new Vector4(1f, 0f, 0f, 1f);
+ overlayMaterial.SetVector("_UV_Transform", value);
+ overlayMaterial.SetFloat("_Intensity", intensity);
+ overlayMaterial.SetTexture("_Overlay", texture);
+ Graphics.Blit(source, destination, overlayMaterial, (int)blendMode);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientObscurance.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientObscurance.cs
new file mode 100644
index 0000000..b59c32e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientObscurance.cs
@@ -0,0 +1,105 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Rendering/Screen Space Ambient Obscurance")]
+internal class ScreenSpaceAmbientObscurance : PostEffectsBase
+{
+ [Range(0f, 3f)]
+ public float intensity = 0.5f;
+
+ [Range(0.1f, 3f)]
+ public float radius = 0.2f;
+
+ [Range(0f, 3f)]
+ public int blurIterations = 1;
+
+ [Range(0f, 5f)]
+ public float blurFilterDistance = 1.25f;
+
+ [Range(0f, 1f)]
+ public int downsample;
+
+ public Texture2D rand;
+
+ public Shader aoShader;
+
+ private Material aoMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: true);
+ aoMaterial = CheckShaderAndCreateMaterial(aoShader, aoMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnDisable()
+ {
+ if ((bool)aoMaterial)
+ {
+ Object.DestroyImmediate(aoMaterial);
+ }
+ aoMaterial = null;
+ }
+
+ [ImageEffectOpaque]
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ Camera component = GetComponent<Camera>();
+ Matrix4x4 projectionMatrix = component.projectionMatrix;
+ Matrix4x4 inverse = projectionMatrix.inverse;
+ Vector4 value = new Vector4(-2f / projectionMatrix[0, 0], -2f / projectionMatrix[1, 1], (1f - projectionMatrix[0, 2]) / projectionMatrix[0, 0], (1f + projectionMatrix[1, 2]) / projectionMatrix[1, 1]);
+ if (component.stereoEnabled)
+ {
+ Matrix4x4 stereoProjectionMatrix = component.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
+ Matrix4x4 stereoProjectionMatrix2 = component.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
+ Vector4 value2 = new Vector4(-2f / stereoProjectionMatrix[0, 0], -2f / stereoProjectionMatrix[1, 1], (1f - stereoProjectionMatrix[0, 2]) / stereoProjectionMatrix[0, 0], (1f + stereoProjectionMatrix[1, 2]) / stereoProjectionMatrix[1, 1]);
+ Vector4 value3 = new Vector4(-2f / stereoProjectionMatrix2[0, 0], -2f / stereoProjectionMatrix2[1, 1], (1f - stereoProjectionMatrix2[0, 2]) / stereoProjectionMatrix2[0, 0], (1f + stereoProjectionMatrix2[1, 2]) / stereoProjectionMatrix2[1, 1]);
+ aoMaterial.SetVector("_ProjInfoLeft", value2);
+ aoMaterial.SetVector("_ProjInfoRight", value3);
+ }
+ aoMaterial.SetVector("_ProjInfo", value);
+ aoMaterial.SetMatrix("_ProjectionInv", inverse);
+ aoMaterial.SetTexture("_Rand", rand);
+ aoMaterial.SetFloat("_Radius", radius);
+ aoMaterial.SetFloat("_Radius2", radius * radius);
+ aoMaterial.SetFloat("_Intensity", intensity);
+ aoMaterial.SetFloat("_BlurFilterDistance", blurFilterDistance);
+ int width = source.width;
+ int height = source.height;
+ RenderTexture renderTexture = RenderTexture.GetTemporary(width >> downsample, height >> downsample);
+ Graphics.Blit(source, renderTexture, aoMaterial, 0);
+ if (downsample > 0)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height);
+ Graphics.Blit(renderTexture, temporary, aoMaterial, 4);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ renderTexture = temporary;
+ }
+ for (int i = 0; i < blurIterations; i++)
+ {
+ aoMaterial.SetVector("_Axis", new Vector2(1f, 0f));
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height);
+ Graphics.Blit(renderTexture, temporary, aoMaterial, 1);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ aoMaterial.SetVector("_Axis", new Vector2(0f, 1f));
+ renderTexture = RenderTexture.GetTemporary(width, height);
+ Graphics.Blit(temporary, renderTexture, aoMaterial, 1);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ aoMaterial.SetTexture("_AOTex", renderTexture);
+ Graphics.Blit(source, destination, aoMaterial, 2);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientOcclusion.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientOcclusion.cs
new file mode 100644
index 0000000..108bd0e
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/ScreenSpaceAmbientOcclusion.cs
@@ -0,0 +1,161 @@
+using System;
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Rendering/Screen Space Ambient Occlusion")]
+public class ScreenSpaceAmbientOcclusion : MonoBehaviour
+{
+ public enum SSAOSamples
+ {
+ Low,
+ Medium,
+ High
+ }
+
+ [Range(0.05f, 1f)]
+ public float m_Radius = 0.4f;
+
+ public SSAOSamples m_SampleCount = SSAOSamples.Medium;
+
+ [Range(0.5f, 4f)]
+ public float m_OcclusionIntensity = 1.5f;
+
+ [Range(0f, 4f)]
+ public int m_Blur = 2;
+
+ [Range(1f, 6f)]
+ public int m_Downsampling = 2;
+
+ [Range(0.2f, 2f)]
+ public float m_OcclusionAttenuation = 1f;
+
+ [Range(1E-05f, 0.5f)]
+ public float m_MinZ = 0.01f;
+
+ public Shader m_SSAOShader;
+
+ private Material m_SSAOMaterial;
+
+ public Texture2D m_RandomTexture;
+
+ private bool m_Supported;
+
+ private static Material CreateMaterial(Shader shader)
+ {
+ if (!shader)
+ {
+ return null;
+ }
+ return new Material(shader)
+ {
+ hideFlags = HideFlags.HideAndDontSave
+ };
+ }
+
+ private static void DestroyMaterial(Material mat)
+ {
+ if ((bool)mat)
+ {
+ UnityEngine.Object.DestroyImmediate(mat);
+ mat = null;
+ }
+ }
+
+ private void OnDisable()
+ {
+ DestroyMaterial(m_SSAOMaterial);
+ }
+
+ private void Start()
+ {
+ if (!SystemInfo.supportsImageEffects || !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
+ {
+ m_Supported = false;
+ base.enabled = false;
+ return;
+ }
+ CreateMaterials();
+ if (!m_SSAOMaterial || m_SSAOMaterial.passCount != 5)
+ {
+ m_Supported = false;
+ base.enabled = false;
+ }
+ else
+ {
+ m_Supported = true;
+ }
+ }
+
+ private void OnEnable()
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.DepthNormals;
+ }
+
+ private void CreateMaterials()
+ {
+ if (!m_SSAOMaterial && m_SSAOShader.isSupported)
+ {
+ m_SSAOMaterial = CreateMaterial(m_SSAOShader);
+ m_SSAOMaterial.SetTexture("_RandomTexture", m_RandomTexture);
+ }
+ }
+
+ [ImageEffectOpaque]
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!m_Supported || !m_SSAOShader.isSupported)
+ {
+ base.enabled = false;
+ return;
+ }
+ CreateMaterials();
+ m_Downsampling = Mathf.Clamp(m_Downsampling, 1, 6);
+ m_Radius = Mathf.Clamp(m_Radius, 0.05f, 1f);
+ m_MinZ = Mathf.Clamp(m_MinZ, 1E-05f, 0.5f);
+ m_OcclusionIntensity = Mathf.Clamp(m_OcclusionIntensity, 0.5f, 4f);
+ m_OcclusionAttenuation = Mathf.Clamp(m_OcclusionAttenuation, 0.2f, 2f);
+ m_Blur = Mathf.Clamp(m_Blur, 0, 4);
+ RenderTexture renderTexture = RenderTexture.GetTemporary(source.width / m_Downsampling, source.height / m_Downsampling, 0);
+ float fieldOfView = GetComponent<Camera>().fieldOfView;
+ float farClipPlane = GetComponent<Camera>().farClipPlane;
+ float num = Mathf.Tan(fieldOfView * ((float)Math.PI / 180f) * 0.5f) * farClipPlane;
+ float x = num * GetComponent<Camera>().aspect;
+ m_SSAOMaterial.SetVector("_FarCorner", new Vector3(x, num, farClipPlane));
+ int num2;
+ int num3;
+ if ((bool)m_RandomTexture)
+ {
+ num2 = m_RandomTexture.width;
+ num3 = m_RandomTexture.height;
+ }
+ else
+ {
+ num2 = 1;
+ num3 = 1;
+ }
+ m_SSAOMaterial.SetVector("_NoiseScale", new Vector3((float)renderTexture.width / (float)num2, (float)renderTexture.height / (float)num3, 0f));
+ m_SSAOMaterial.SetVector("_Params", new Vector4(m_Radius, m_MinZ, 1f / m_OcclusionAttenuation, m_OcclusionIntensity));
+ bool num4 = m_Blur > 0;
+ Graphics.Blit(num4 ? null : source, renderTexture, m_SSAOMaterial, (int)m_SampleCount);
+ if (num4)
+ {
+ RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0);
+ m_SSAOMaterial.SetVector("_TexelOffsetScale", new Vector4((float)m_Blur / (float)source.width, 0f, 0f, 0f));
+ m_SSAOMaterial.SetTexture("_SSAO", renderTexture);
+ Graphics.Blit(null, temporary, m_SSAOMaterial, 3);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ RenderTexture temporary2 = RenderTexture.GetTemporary(source.width, source.height, 0);
+ m_SSAOMaterial.SetVector("_TexelOffsetScale", new Vector4(0f, (float)m_Blur / (float)source.height, 0f, 0f));
+ m_SSAOMaterial.SetTexture("_SSAO", temporary);
+ Graphics.Blit(source, temporary2, m_SSAOMaterial, 3);
+ RenderTexture.ReleaseTemporary(temporary);
+ renderTexture = temporary2;
+ }
+ m_SSAOMaterial.SetTexture("_SSAO", renderTexture);
+ Graphics.Blit(source, destination, m_SSAOMaterial, 4);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SepiaTone.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SepiaTone.cs
new file mode 100644
index 0000000..ff006e5
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SepiaTone.cs
@@ -0,0 +1,13 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Color Adjustments/Sepia Tone")]
+public class SepiaTone : ImageEffectBase
+{
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ Graphics.Blit(source, destination, base.material);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SunShafts.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SunShafts.cs
new file mode 100644
index 0000000..b4a8006
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/SunShafts.cs
@@ -0,0 +1,134 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Rendering/Sun Shafts")]
+public class SunShafts : PostEffectsBase
+{
+ public enum SunShaftsResolution
+ {
+ Low,
+ Normal,
+ High
+ }
+
+ public enum ShaftsScreenBlendMode
+ {
+ Screen,
+ Add
+ }
+
+ public SunShaftsResolution resolution = SunShaftsResolution.Normal;
+
+ public ShaftsScreenBlendMode screenBlendMode;
+
+ public Transform sunTransform;
+
+ public int radialBlurIterations = 2;
+
+ public Color sunColor = Color.white;
+
+ public Color sunThreshold = new Color(0.87f, 0.74f, 0.65f);
+
+ public float sunShaftBlurRadius = 2.5f;
+
+ public float sunShaftIntensity = 1.15f;
+
+ public float maxRadius = 0.75f;
+
+ public bool useDepthTexture = true;
+
+ public Shader sunShaftsShader;
+
+ private Material sunShaftsMaterial;
+
+ public Shader simpleClearShader;
+
+ private Material simpleClearMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(useDepthTexture);
+ sunShaftsMaterial = CheckShaderAndCreateMaterial(sunShaftsShader, sunShaftsMaterial);
+ simpleClearMaterial = CheckShaderAndCreateMaterial(simpleClearShader, simpleClearMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ if (useDepthTexture)
+ {
+ GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
+ }
+ int num = 4;
+ if (resolution == SunShaftsResolution.Normal)
+ {
+ num = 2;
+ }
+ else if (resolution == SunShaftsResolution.High)
+ {
+ num = 1;
+ }
+ Vector3 vector = Vector3.one * 0.5f;
+ vector = ((!sunTransform) ? new Vector3(0.5f, 0.5f, 0f) : GetComponent<Camera>().WorldToViewportPoint(sunTransform.position));
+ int width = source.width / num;
+ int height = source.height / num;
+ RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0);
+ sunShaftsMaterial.SetVector("_BlurRadius4", new Vector4(1f, 1f, 0f, 0f) * sunShaftBlurRadius);
+ sunShaftsMaterial.SetVector("_SunPosition", new Vector4(vector.x, vector.y, vector.z, maxRadius));
+ sunShaftsMaterial.SetVector("_SunThreshold", sunThreshold);
+ if (!useDepthTexture)
+ {
+ RenderTextureFormat format = (GetComponent<Camera>().allowHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
+ RenderTexture renderTexture = (RenderTexture.active = RenderTexture.GetTemporary(source.width, source.height, 0, format));
+ GL.ClearWithSkybox(clearDepth: false, GetComponent<Camera>());
+ sunShaftsMaterial.SetTexture("_Skybox", renderTexture);
+ Graphics.Blit(source, temporary, sunShaftsMaterial, 3);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+ else
+ {
+ Graphics.Blit(source, temporary, sunShaftsMaterial, 2);
+ }
+ DrawBorder(temporary, simpleClearMaterial);
+ radialBlurIterations = Mathf.Clamp(radialBlurIterations, 1, 4);
+ float num2 = sunShaftBlurRadius * 0.0013020834f;
+ sunShaftsMaterial.SetVector("_BlurRadius4", new Vector4(num2, num2, 0f, 0f));
+ sunShaftsMaterial.SetVector("_SunPosition", new Vector4(vector.x, vector.y, vector.z, maxRadius));
+ for (int i = 0; i < radialBlurIterations; i++)
+ {
+ RenderTexture temporary3 = RenderTexture.GetTemporary(width, height, 0);
+ Graphics.Blit(temporary, temporary3, sunShaftsMaterial, 1);
+ RenderTexture.ReleaseTemporary(temporary);
+ num2 = sunShaftBlurRadius * (((float)i * 2f + 1f) * 6f) / 768f;
+ sunShaftsMaterial.SetVector("_BlurRadius4", new Vector4(num2, num2, 0f, 0f));
+ temporary = RenderTexture.GetTemporary(width, height, 0);
+ Graphics.Blit(temporary3, temporary, sunShaftsMaterial, 1);
+ RenderTexture.ReleaseTemporary(temporary3);
+ num2 = sunShaftBlurRadius * (((float)i * 2f + 2f) * 6f) / 768f;
+ sunShaftsMaterial.SetVector("_BlurRadius4", new Vector4(num2, num2, 0f, 0f));
+ }
+ if (vector.z >= 0f)
+ {
+ sunShaftsMaterial.SetVector("_SunColor", new Vector4(sunColor.r, sunColor.g, sunColor.b, sunColor.a) * sunShaftIntensity);
+ }
+ else
+ {
+ sunShaftsMaterial.SetVector("_SunColor", Vector4.zero);
+ }
+ sunShaftsMaterial.SetTexture("_ColorBuffer", temporary);
+ Graphics.Blit(source, destination, sunShaftsMaterial, (screenBlendMode != 0) ? 4 : 0);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TiltShift.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TiltShift.cs
new file mode 100644
index 0000000..9258c81
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TiltShift.cs
@@ -0,0 +1,80 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Camera/Tilt Shift (Lens Blur)")]
+internal class TiltShift : PostEffectsBase
+{
+ public enum TiltShiftMode
+ {
+ TiltShiftMode,
+ IrisMode
+ }
+
+ public enum TiltShiftQuality
+ {
+ Preview,
+ Low,
+ Normal,
+ High
+ }
+
+ public TiltShiftMode mode;
+
+ public TiltShiftQuality quality = TiltShiftQuality.Normal;
+
+ [Range(0f, 15f)]
+ public float blurArea = 1f;
+
+ [Range(0f, 25f)]
+ public float maxBlurSize = 5f;
+
+ [Range(0f, 1f)]
+ public int downsample;
+
+ public Shader tiltShiftShader;
+
+ private Material tiltShiftMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ tiltShiftMaterial = CheckShaderAndCreateMaterial(tiltShiftShader, tiltShiftMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ tiltShiftMaterial.SetFloat("_BlurSize", (maxBlurSize < 0f) ? 0f : maxBlurSize);
+ tiltShiftMaterial.SetFloat("_BlurArea", blurArea);
+ source.filterMode = FilterMode.Bilinear;
+ RenderTexture renderTexture = destination;
+ if ((float)downsample > 0f)
+ {
+ renderTexture = RenderTexture.GetTemporary(source.width >> downsample, source.height >> downsample, 0, source.format);
+ renderTexture.filterMode = FilterMode.Bilinear;
+ }
+ int num = (int)quality;
+ num *= 2;
+ Graphics.Blit(source, renderTexture, tiltShiftMaterial, (mode == TiltShiftMode.TiltShiftMode) ? num : (num + 1));
+ if (downsample > 0)
+ {
+ tiltShiftMaterial.SetTexture("_Blurred", renderTexture);
+ Graphics.Blit(source, destination, tiltShiftMaterial, 8);
+ }
+ if (renderTexture != destination)
+ {
+ RenderTexture.ReleaseTemporary(renderTexture);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Tonemapping.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Tonemapping.cs
new file mode 100644
index 0000000..bd41109
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Tonemapping.cs
@@ -0,0 +1,226 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Color Adjustments/Tonemapping")]
+public class Tonemapping : PostEffectsBase
+{
+ public enum TonemapperType
+ {
+ SimpleReinhard,
+ UserCurve,
+ Hable,
+ Photographic,
+ OptimizedHejiDawson,
+ AdaptiveReinhard,
+ AdaptiveReinhardAutoWhite
+ }
+
+ public enum AdaptiveTexSize
+ {
+ Square16 = 0x10,
+ Square32 = 0x20,
+ Square64 = 0x40,
+ Square128 = 0x80,
+ Square256 = 0x100,
+ Square512 = 0x200,
+ Square1024 = 0x400
+ }
+
+ public TonemapperType type = TonemapperType.Photographic;
+
+ public AdaptiveTexSize adaptiveTextureSize = AdaptiveTexSize.Square256;
+
+ public AnimationCurve remapCurve;
+
+ private Texture2D curveTex;
+
+ public float exposureAdjustment = 1.5f;
+
+ public float middleGrey = 0.4f;
+
+ public float white = 2f;
+
+ public float adaptionSpeed = 1.5f;
+
+ public Shader tonemapper;
+
+ public bool validRenderTextureFormat = true;
+
+ private Material tonemapMaterial;
+
+ private RenderTexture rt;
+
+ private RenderTextureFormat rtFormat = RenderTextureFormat.ARGBHalf;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false, needHdr: true);
+ tonemapMaterial = CheckShaderAndCreateMaterial(tonemapper, tonemapMaterial);
+ if (!curveTex && type == TonemapperType.UserCurve)
+ {
+ curveTex = new Texture2D(256, 1, TextureFormat.ARGB32, mipChain: false, linear: true);
+ curveTex.filterMode = FilterMode.Bilinear;
+ curveTex.wrapMode = TextureWrapMode.Clamp;
+ curveTex.hideFlags = HideFlags.DontSave;
+ }
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ public float UpdateCurve()
+ {
+ float num = 1f;
+ if (remapCurve.keys.Length < 1)
+ {
+ remapCurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(2f, 1f));
+ }
+ if (remapCurve != null)
+ {
+ if (remapCurve.length > 0)
+ {
+ num = remapCurve[remapCurve.length - 1].time;
+ }
+ for (float num2 = 0f; num2 <= 1f; num2 += 0.003921569f)
+ {
+ float num3 = remapCurve.Evaluate(num2 * 1f * num);
+ curveTex.SetPixel((int)Mathf.Floor(num2 * 255f), 0, new Color(num3, num3, num3));
+ }
+ curveTex.Apply();
+ }
+ return 1f / num;
+ }
+
+ private void OnDisable()
+ {
+ if ((bool)rt)
+ {
+ Object.DestroyImmediate(rt);
+ rt = null;
+ }
+ if ((bool)tonemapMaterial)
+ {
+ Object.DestroyImmediate(tonemapMaterial);
+ tonemapMaterial = null;
+ }
+ if ((bool)curveTex)
+ {
+ Object.DestroyImmediate(curveTex);
+ curveTex = null;
+ }
+ }
+
+ private bool CreateInternalRenderTexture()
+ {
+ if ((bool)rt)
+ {
+ return false;
+ }
+ rtFormat = (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf) ? RenderTextureFormat.RGHalf : RenderTextureFormat.ARGBHalf);
+ rt = new RenderTexture(1, 1, 0, rtFormat);
+ rt.hideFlags = HideFlags.DontSave;
+ return true;
+ }
+
+ [ImageEffectTransformsToLDR]
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ exposureAdjustment = ((exposureAdjustment < 0.001f) ? 0.001f : exposureAdjustment);
+ if (type == TonemapperType.UserCurve)
+ {
+ float value = UpdateCurve();
+ tonemapMaterial.SetFloat("_RangeScale", value);
+ tonemapMaterial.SetTexture("_Curve", curveTex);
+ Graphics.Blit(source, destination, tonemapMaterial, 4);
+ return;
+ }
+ if (type == TonemapperType.SimpleReinhard)
+ {
+ tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
+ Graphics.Blit(source, destination, tonemapMaterial, 6);
+ return;
+ }
+ if (type == TonemapperType.Hable)
+ {
+ tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
+ Graphics.Blit(source, destination, tonemapMaterial, 5);
+ return;
+ }
+ if (type == TonemapperType.Photographic)
+ {
+ tonemapMaterial.SetFloat("_ExposureAdjustment", exposureAdjustment);
+ Graphics.Blit(source, destination, tonemapMaterial, 8);
+ return;
+ }
+ if (type == TonemapperType.OptimizedHejiDawson)
+ {
+ tonemapMaterial.SetFloat("_ExposureAdjustment", 0.5f * exposureAdjustment);
+ Graphics.Blit(source, destination, tonemapMaterial, 7);
+ return;
+ }
+ bool flag = CreateInternalRenderTexture();
+ RenderTexture temporary = RenderTexture.GetTemporary((int)adaptiveTextureSize, (int)adaptiveTextureSize, 0, rtFormat);
+ Graphics.Blit(source, temporary);
+ int num = (int)Mathf.Log((float)temporary.width * 1f, 2f);
+ int num2 = 2;
+ RenderTexture[] array = new RenderTexture[num];
+ for (int i = 0; i < num; i++)
+ {
+ array[i] = RenderTexture.GetTemporary(temporary.width / num2, temporary.width / num2, 0, rtFormat);
+ num2 *= 2;
+ }
+ RenderTexture source2 = array[num - 1];
+ Graphics.Blit(temporary, array[0], tonemapMaterial, 1);
+ if (type == TonemapperType.AdaptiveReinhardAutoWhite)
+ {
+ for (int j = 0; j < num - 1; j++)
+ {
+ Graphics.Blit(array[j], array[j + 1], tonemapMaterial, 9);
+ source2 = array[j + 1];
+ }
+ }
+ else if (type == TonemapperType.AdaptiveReinhard)
+ {
+ for (int k = 0; k < num - 1; k++)
+ {
+ Graphics.Blit(array[k], array[k + 1]);
+ source2 = array[k + 1];
+ }
+ }
+ adaptionSpeed = ((adaptionSpeed < 0.001f) ? 0.001f : adaptionSpeed);
+ tonemapMaterial.SetFloat("_AdaptionSpeed", adaptionSpeed);
+ rt.MarkRestoreExpected();
+ Graphics.Blit(source2, rt, tonemapMaterial, flag ? 3 : 2);
+ middleGrey = ((middleGrey < 0.001f) ? 0.001f : middleGrey);
+ tonemapMaterial.SetVector("_HdrParams", new Vector4(middleGrey, middleGrey, middleGrey, white * white));
+ tonemapMaterial.SetTexture("_SmallTex", rt);
+ if (type == TonemapperType.AdaptiveReinhard)
+ {
+ Graphics.Blit(source, destination, tonemapMaterial, 0);
+ }
+ else if (type == TonemapperType.AdaptiveReinhardAutoWhite)
+ {
+ Graphics.Blit(source, destination, tonemapMaterial, 10);
+ }
+ else
+ {
+ Debug.LogError("No valid adaptive tonemapper type found!");
+ Graphics.Blit(source, destination);
+ }
+ for (int l = 0; l < num; l++)
+ {
+ RenderTexture.ReleaseTemporary(array[l]);
+ }
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Triangles.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Triangles.cs
new file mode 100644
index 0000000..3a79391
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Triangles.cs
@@ -0,0 +1,95 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+internal class Triangles
+{
+ private static Mesh[] meshes;
+
+ private static int currentTris;
+
+ private static bool HasMeshes()
+ {
+ if (meshes == null)
+ {
+ return false;
+ }
+ for (int i = 0; i < meshes.Length; i++)
+ {
+ if (null == meshes[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static void Cleanup()
+ {
+ if (meshes == null)
+ {
+ return;
+ }
+ for (int i = 0; i < meshes.Length; i++)
+ {
+ if (null != meshes[i])
+ {
+ Object.DestroyImmediate(meshes[i]);
+ meshes[i] = null;
+ }
+ }
+ meshes = null;
+ }
+
+ private static Mesh[] GetMeshes(int totalWidth, int totalHeight)
+ {
+ if (HasMeshes() && currentTris == totalWidth * totalHeight)
+ {
+ return meshes;
+ }
+ int num = 21666;
+ int num2 = (currentTris = totalWidth * totalHeight);
+ meshes = new Mesh[Mathf.CeilToInt(1f * (float)num2 / (1f * (float)num))];
+ int num3 = 0;
+ int num4 = 0;
+ for (num3 = 0; num3 < num2; num3 += num)
+ {
+ int triCount = Mathf.FloorToInt(Mathf.Clamp(num2 - num3, 0, num));
+ meshes[num4] = GetMesh(triCount, num3, totalWidth, totalHeight);
+ num4++;
+ }
+ return meshes;
+ }
+
+ private static Mesh GetMesh(int triCount, int triOffset, int totalWidth, int totalHeight)
+ {
+ Mesh mesh = new Mesh();
+ mesh.hideFlags = HideFlags.DontSave;
+ Vector3[] array = new Vector3[triCount * 3];
+ Vector2[] array2 = new Vector2[triCount * 3];
+ Vector2[] array3 = new Vector2[triCount * 3];
+ int[] array4 = new int[triCount * 3];
+ for (int i = 0; i < triCount; i++)
+ {
+ int num = i * 3;
+ int num2 = triOffset + i;
+ float num3 = Mathf.Floor(num2 % totalWidth) / (float)totalWidth;
+ float num4 = Mathf.Floor(num2 / totalWidth) / (float)totalHeight;
+ array[num + 2] = (array[num + 1] = (array[num] = new Vector3(num3 * 2f - 1f, num4 * 2f - 1f, 1f)));
+ array2[num] = new Vector2(0f, 0f);
+ array2[num + 1] = new Vector2(1f, 0f);
+ array2[num + 2] = new Vector2(0f, 1f);
+ array3[num] = new Vector2(num3, num4);
+ array3[num + 1] = new Vector2(num3, num4);
+ array3[num + 2] = new Vector2(num3, num4);
+ array4[num] = num;
+ array4[num + 1] = num + 1;
+ array4[num + 2] = num + 2;
+ }
+ mesh.vertices = array;
+ mesh.triangles = array4;
+ mesh.uv = array2;
+ mesh.uv2 = array3;
+ return mesh;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TweakMode34.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TweakMode34.cs
new file mode 100644
index 0000000..6d04716
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/TweakMode34.cs
@@ -0,0 +1,7 @@
+namespace UnityStandardAssets.ImageEffects;
+
+public enum TweakMode34
+{
+ Basic,
+ Complex
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Twirl.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Twirl.cs
new file mode 100644
index 0000000..2e660ec
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Twirl.cs
@@ -0,0 +1,20 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Displacement/Twirl")]
+public class Twirl : ImageEffectBase
+{
+ public Vector2 radius = new Vector2(0.3f, 0.3f);
+
+ [Range(0f, 360f)]
+ public float angle = 50f;
+
+ public Vector2 center = new Vector2(0.5f, 0.5f);
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ ImageEffects.RenderDistortion(base.material, source, destination, angle, center, radius);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/VignetteAndChromaticAberration.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/VignetteAndChromaticAberration.cs
new file mode 100644
index 0000000..df2e56c
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/VignetteAndChromaticAberration.cs
@@ -0,0 +1,110 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[RequireComponent(typeof(Camera))]
+[AddComponentMenu("Image Effects/Camera/Vignette and Chromatic Aberration")]
+public class VignetteAndChromaticAberration : PostEffectsBase
+{
+ public enum AberrationMode
+ {
+ Simple,
+ Advanced
+ }
+
+ public AberrationMode mode;
+
+ public float intensity = 0.036f;
+
+ public float chromaticAberration = 0.2f;
+
+ public float axialAberration = 0.5f;
+
+ public float blur;
+
+ public float blurSpread = 0.75f;
+
+ public float luminanceDependency = 0.25f;
+
+ public float blurDistance = 2.5f;
+
+ public Shader vignetteShader;
+
+ public Shader separableBlurShader;
+
+ public Shader chromAberrationShader;
+
+ private Material m_VignetteMaterial;
+
+ private Material m_SeparableBlurMaterial;
+
+ private Material m_ChromAberrationMaterial;
+
+ public override bool CheckResources()
+ {
+ CheckSupport(needDepth: false);
+ m_VignetteMaterial = CheckShaderAndCreateMaterial(vignetteShader, m_VignetteMaterial);
+ m_SeparableBlurMaterial = CheckShaderAndCreateMaterial(separableBlurShader, m_SeparableBlurMaterial);
+ m_ChromAberrationMaterial = CheckShaderAndCreateMaterial(chromAberrationShader, m_ChromAberrationMaterial);
+ if (!isSupported)
+ {
+ ReportAutoDisable();
+ }
+ return isSupported;
+ }
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ if (!CheckResources())
+ {
+ Graphics.Blit(source, destination);
+ return;
+ }
+ int width = source.width;
+ int height = source.height;
+ bool flag = Mathf.Abs(blur) > 0f || Mathf.Abs(intensity) > 0f;
+ float num = 1f * (float)width / (1f * (float)height);
+ RenderTexture renderTexture = null;
+ RenderTexture renderTexture2 = null;
+ if (flag)
+ {
+ renderTexture = RenderTexture.GetTemporary(width, height, 0, source.format);
+ if (Mathf.Abs(blur) > 0f)
+ {
+ renderTexture2 = RenderTexture.GetTemporary(width / 2, height / 2, 0, source.format);
+ Graphics.Blit(source, renderTexture2, m_ChromAberrationMaterial, 0);
+ for (int i = 0; i < 2; i++)
+ {
+ m_SeparableBlurMaterial.SetVector("offsets", new Vector4(0f, blurSpread * 0.001953125f, 0f, 0f));
+ RenderTexture temporary = RenderTexture.GetTemporary(width / 2, height / 2, 0, source.format);
+ Graphics.Blit(renderTexture2, temporary, m_SeparableBlurMaterial);
+ RenderTexture.ReleaseTemporary(renderTexture2);
+ m_SeparableBlurMaterial.SetVector("offsets", new Vector4(blurSpread * 0.001953125f / num, 0f, 0f, 0f));
+ renderTexture2 = RenderTexture.GetTemporary(width / 2, height / 2, 0, source.format);
+ Graphics.Blit(temporary, renderTexture2, m_SeparableBlurMaterial);
+ RenderTexture.ReleaseTemporary(temporary);
+ }
+ }
+ m_VignetteMaterial.SetFloat("_Intensity", 1f / (1f - intensity) - 1f);
+ m_VignetteMaterial.SetFloat("_Blur", 1f / (1f - blur) - 1f);
+ m_VignetteMaterial.SetTexture("_VignetteTex", renderTexture2);
+ Graphics.Blit(source, renderTexture, m_VignetteMaterial, 0);
+ }
+ m_ChromAberrationMaterial.SetFloat("_ChromaticAberration", chromaticAberration);
+ m_ChromAberrationMaterial.SetFloat("_AxialAberration", axialAberration);
+ m_ChromAberrationMaterial.SetVector("_BlurDistance", new Vector2(0f - blurDistance, blurDistance));
+ m_ChromAberrationMaterial.SetFloat("_Luminance", 1f / Mathf.Max(Mathf.Epsilon, luminanceDependency));
+ if (flag)
+ {
+ renderTexture.wrapMode = TextureWrapMode.Clamp;
+ }
+ else
+ {
+ source.wrapMode = TextureWrapMode.Clamp;
+ }
+ Graphics.Blit(flag ? renderTexture : source, destination, m_ChromAberrationMaterial, (mode != AberrationMode.Advanced) ? 1 : 2);
+ RenderTexture.ReleaseTemporary(renderTexture);
+ RenderTexture.ReleaseTemporary(renderTexture2);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Vortex.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Vortex.cs
new file mode 100644
index 0000000..17ac440
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/UnityStandardAssets.ImageEffects/Vortex.cs
@@ -0,0 +1,19 @@
+using UnityEngine;
+
+namespace UnityStandardAssets.ImageEffects;
+
+[ExecuteInEditMode]
+[AddComponentMenu("Image Effects/Displacement/Vortex")]
+public class Vortex : ImageEffectBase
+{
+ public Vector2 radius = new Vector2(0.4f, 0.4f);
+
+ public float angle = 50f;
+
+ public Vector2 center = new Vector2(0.5f, 0.5f);
+
+ private void OnRenderImage(RenderTexture source, RenderTexture destination)
+ {
+ ImageEffects.RenderDistortion(base.material, source, destination, angle, center, radius);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/assembly_sunshafts.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/assembly_sunshafts.csproj
new file mode 100644
index 0000000..5b6a839
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_sunshafts/assembly_sunshafts.csproj
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_sunshafts</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/.gitignore b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/.gitignore
new file mode 100644
index 0000000..a4da27a
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/.gitignore
@@ -0,0 +1,399 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+.vs
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/BitMaskAttribute.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/BitMaskAttribute.cs
new file mode 100644
index 0000000..fce668b
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/BitMaskAttribute.cs
@@ -0,0 +1,12 @@
+using System;
+using UnityEngine;
+
+public class BitMaskAttribute : PropertyAttribute
+{
+ public Type propType;
+
+ public BitMaskAttribute(Type aType)
+ {
+ propType = aType;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Cover.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Cover.cs
new file mode 100644
index 0000000..73e7288
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Cover.cs
@@ -0,0 +1,82 @@
+using UnityEngine;
+
+public class Cover
+{
+ private const float m_coverRayDistance = 30f;
+
+ private static int m_coverRayMask = 0;
+
+ private static Vector3[] m_coverRays = null;
+
+ private static RaycastHit[] m_raycastHits = new RaycastHit[128];
+
+ public static void GetCoverForPoint(Vector3 startPos, out float coverPercentage, out bool underRoof)
+ {
+ Setup();
+ float num = 0.5f;
+ float num2 = 0f;
+ underRoof = IsUnderRoof(startPos);
+ Vector3[] coverRays = m_coverRays;
+ foreach (Vector3 vector in coverRays)
+ {
+ if (Physics.Raycast(startPos + vector * num, vector, out var _, 30f - num, m_coverRayMask))
+ {
+ num2 += 1f;
+ }
+ }
+ coverPercentage = num2 / (float)m_coverRays.Length;
+ }
+
+ public static bool IsUnderRoof(Vector3 startPos)
+ {
+ Setup();
+ int num = Physics.SphereCastNonAlloc(startPos, 0.1f, Vector3.up, m_raycastHits, 100f, m_coverRayMask);
+ for (int i = 0; i < num; i++)
+ {
+ RaycastHit raycastHit = m_raycastHits[i];
+ if (!raycastHit.collider.gameObject.CompareTag("leaky"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void Setup()
+ {
+ if (m_coverRays == null)
+ {
+ m_coverRayMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "terrain", "vehicle");
+ CreateCoverRays();
+ }
+ }
+
+ private static void CreateCoverRays()
+ {
+ m_coverRays = new Vector3[17]
+ {
+ new Vector3(0f, 1f, 0f),
+ new Vector3(1f, 0f, 0f),
+ new Vector3(-1f, 0f, 0f),
+ new Vector3(0f, 0f, 1f),
+ new Vector3(0f, 0f, -1f),
+ new Vector3(-1f, 0f, -1f),
+ new Vector3(1f, 0f, -1f),
+ new Vector3(-1f, 0f, 1f),
+ new Vector3(1f, 0f, 1f),
+ new Vector3(-1f, 1f, 0f),
+ new Vector3(1f, 1f, 0f),
+ new Vector3(0f, 1f, 1f),
+ new Vector3(0f, 1f, -1f),
+ new Vector3(-1f, 1f, -1f),
+ new Vector3(1f, 1f, -1f),
+ new Vector3(-1f, 1f, 1f),
+ new Vector3(1f, 1f, 1f)
+ };
+ Vector3[] coverRays = m_coverRays;
+ foreach (Vector3 vector in coverRays)
+ {
+ vector.Normalize();
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DictionaryExt.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DictionaryExt.cs
new file mode 100644
index 0000000..91db22f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DictionaryExt.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+public static class DictionaryExt
+{
+ public static void Copy<TKey, TValue>(this Dictionary<TKey, TValue> target, Dictionary<TKey, TValue> other)
+ {
+ foreach (KeyValuePair<TKey, TValue> item in other)
+ {
+ target.Add(item.Key, item.Value);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DrawBounds.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DrawBounds.cs
new file mode 100644
index 0000000..a30a2da
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/DrawBounds.cs
@@ -0,0 +1,16 @@
+using UnityEngine;
+
+public class DrawBounds : MonoBehaviour
+{
+ private void OnDrawGizmosSelected()
+ {
+ Gizmos.color = Color.magenta;
+ MeshFilter[] componentsInChildren = GetComponentsInChildren<MeshFilter>();
+ foreach (MeshFilter obj in componentsInChildren)
+ {
+ Gizmos.matrix = obj.transform.localToWorldMatrix;
+ Mesh sharedMesh = obj.sharedMesh;
+ Gizmos.DrawWireCube(sharedMesh.bounds.center, sharedMesh.bounds.size);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/HideWhenRunning.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/HideWhenRunning.cs
new file mode 100644
index 0000000..7046876
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/HideWhenRunning.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+public class HideWhenRunning : MonoBehaviour
+{
+ private void Awake()
+ {
+ if (Application.isPlaying)
+ {
+ base.gameObject.SetActive(value: false);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ListExtra.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ListExtra.cs
new file mode 100644
index 0000000..d74fb9d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ListExtra.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using System.Linq;
+
+public static class ListExtra
+{
+ public static void Resize<T>(this List<T> list, int sz, T c)
+ {
+ int count = list.Count;
+ if (sz < count)
+ {
+ list.RemoveRange(sz, count - sz);
+ }
+ else if (sz > count)
+ {
+ if (sz > list.Capacity)
+ {
+ list.Capacity = sz;
+ }
+ list.AddRange(Enumerable.Repeat(c, sz - count));
+ }
+ }
+
+ public static void Resize<T>(this List<T> list, int sz) where T : new()
+ {
+ list.Resize(sz, new T());
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/LookAt.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/LookAt.cs
new file mode 100644
index 0000000..7e4a065
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/LookAt.cs
@@ -0,0 +1,35 @@
+using UnityEngine;
+
+public class LookAt : MonoBehaviour
+{
+ private Vector3 m_lookAtTarget = Vector3.zero;
+
+ private float m_weight;
+
+ private float m_targetWeight;
+
+ private Animator m_animator;
+
+ private void Awake()
+ {
+ m_animator = GetComponent<Animator>();
+ }
+
+ private void OnAnimatorIK(int layerIndex)
+ {
+ m_weight = Mathf.MoveTowards(m_weight, m_targetWeight, Time.deltaTime);
+ m_animator.SetLookAtPosition(m_lookAtTarget);
+ m_animator.SetLookAtWeight(m_weight, 0.5f, 1f, 0f);
+ }
+
+ public void SetLoockAtTarget(Vector3 target)
+ {
+ m_lookAtTarget = target;
+ m_targetWeight = 1f;
+ }
+
+ public void ResetTarget()
+ {
+ m_targetWeight = 0f;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Pool.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Pool.cs
new file mode 100644
index 0000000..9d99e7f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Pool.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+
+public class Pool<T> where T : new()
+{
+ private static Stack<T> _available = new Stack<T>();
+
+ public static T Create()
+ {
+ lock (_available)
+ {
+ if (_available.Count > 0)
+ {
+ return _available.Pop();
+ }
+ return new T();
+ }
+ }
+
+ public static void Release(T obj)
+ {
+ if (obj == null)
+ {
+ return;
+ }
+ lock (_available)
+ {
+ _available.Push(obj);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Properties/AssemblyInfo.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bbd7eef
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("0.0.0.0")]
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/QuaternionExt.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/QuaternionExt.cs
new file mode 100644
index 0000000..f6ecdee
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/QuaternionExt.cs
@@ -0,0 +1,10 @@
+using UnityEngine;
+
+public static class QuaternionExt
+{
+ public static Quaternion GetNormalized(this Quaternion q)
+ {
+ float num = 1f / Mathf.Sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w);
+ return new Quaternion(q.x * num, q.y * num, q.z * num, q.w * num);
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/StringExtensionMethods.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/StringExtensionMethods.cs
new file mode 100644
index 0000000..9bd7e45
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/StringExtensionMethods.cs
@@ -0,0 +1,18 @@
+public static class StringExtensionMethods
+{
+ public static int GetStableHashCode(this string str)
+ {
+ int num = 5381;
+ int num2 = num;
+ for (int i = 0; i < str.Length && str[i] != 0; i += 2)
+ {
+ num = ((num << 5) + num) ^ str[i];
+ if (i == str.Length - 1 || str[i + 1] == '\0')
+ {
+ break;
+ }
+ num2 = ((num2 << 5) + num2) ^ str[i + 1];
+ }
+ return num + num2 * 1566083941;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/SyncedList.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/SyncedList.cs
new file mode 100644
index 0000000..0dfb10b
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/SyncedList.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+
+public class SyncedList
+{
+ private const float m_loadInterval = 10f;
+
+ private float m_lastLoadCheckTime;
+
+ private List<string> m_comments = new List<string>();
+
+ private List<string> m_list = new List<string>();
+
+ private string m_fileName;
+
+ private DateTime m_lastLoadDate = DateTime.MinValue;
+
+ public SyncedList(string fileName, string defaultFileComment)
+ {
+ m_fileName = fileName;
+ if (!File.Exists(m_fileName))
+ {
+ m_comments.Add("// " + defaultFileComment);
+ Save();
+ }
+ else
+ {
+ Load();
+ }
+ }
+
+ public List<string> GetList()
+ {
+ CheckLoad();
+ return m_list;
+ }
+
+ public int Count()
+ {
+ CheckLoad();
+ return m_list.Count;
+ }
+
+ public bool Contains(string s)
+ {
+ CheckLoad();
+ return m_list.Contains(s);
+ }
+
+ public void Add(string s)
+ {
+ Load();
+ if (!m_list.Contains(s))
+ {
+ m_list.Add(s);
+ Save();
+ }
+ }
+
+ public void Remove(string s)
+ {
+ Load();
+ if (m_list.Remove(s))
+ {
+ Save();
+ }
+ }
+
+ private void Save()
+ {
+ using (StreamWriter streamWriter = new StreamWriter(m_fileName))
+ {
+ foreach (string comment in m_comments)
+ {
+ streamWriter.WriteLine(comment);
+ }
+ foreach (string item in m_list)
+ {
+ streamWriter.WriteLine(item);
+ }
+ }
+ m_lastLoadDate = File.GetLastWriteTime(m_fileName);
+ }
+
+ private void CheckLoad()
+ {
+ if (Time.realtimeSinceStartup - m_lastLoadCheckTime > 10f)
+ {
+ Load();
+ m_lastLoadCheckTime = Time.realtimeSinceStartup;
+ }
+ }
+
+ private void Load()
+ {
+ try
+ {
+ DateTime lastWriteTime = File.GetLastWriteTime(m_fileName);
+ if (lastWriteTime <= m_lastLoadDate)
+ {
+ return;
+ }
+ m_lastLoadDate = lastWriteTime;
+ m_comments.Clear();
+ m_list.Clear();
+ using StreamReader streamReader = new StreamReader(m_fileName);
+ string text;
+ while ((text = streamReader.ReadLine()) != null)
+ {
+ if (text.Length > 0)
+ {
+ if (text.StartsWith("//"))
+ {
+ m_comments.Add(text);
+ }
+ else
+ {
+ m_list.Add(text);
+ }
+ }
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Timer.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Timer.cs
new file mode 100644
index 0000000..3f2fdec
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Timer.cs
@@ -0,0 +1,51 @@
+using System;
+using UnityEngine;
+
+[Serializable]
+public class Timer
+{
+ public float m_interval;
+
+ private float m_startTime = -1f;
+
+ private bool m_started;
+
+ public Timer(float interval)
+ {
+ m_interval = interval;
+ }
+
+ public Timer()
+ {
+ }
+
+ public void SetInerval(float i)
+ {
+ m_interval = i;
+ }
+
+ public void Start()
+ {
+ m_startTime = Time.time;
+ m_started = true;
+ }
+
+ public void Stop()
+ {
+ m_started = false;
+ }
+
+ public bool IsStarted()
+ {
+ return m_started;
+ }
+
+ public bool IsDue()
+ {
+ if (m_started)
+ {
+ return Time.time >= m_startTime + m_interval;
+ }
+ return false;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/TriggerTracker.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/TriggerTracker.cs
new file mode 100644
index 0000000..d6a2fb0
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/TriggerTracker.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TriggerTracker : MonoBehaviour
+{
+ public Action m_changed;
+
+ private List<Collider> m_colliders = new List<Collider>();
+
+ private void OnTriggerEnter(Collider other)
+ {
+ if (!m_colliders.Contains(other))
+ {
+ m_colliders.Add(other);
+ }
+ m_changed();
+ }
+
+ private void OnTriggerExit(Collider other)
+ {
+ m_colliders.Remove(other);
+ m_changed();
+ }
+
+ public bool IsColliding()
+ {
+ return m_colliders.Count > 0;
+ }
+
+ public List<Collider> GetColliders()
+ {
+ return m_colliders;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Utils.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Utils.cs
new file mode 100644
index 0000000..969742d
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Utils.cs
@@ -0,0 +1,504 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.NetworkInformation;
+using UnityEngine;
+
+public static class Utils
+{
+ private static Plane[] mainPlanes;
+
+ private static int lastPlaneFrame = -1;
+
+ private static int lastFrameCheck = 0;
+
+ private static Camera lastMainCamera = null;
+
+ public static bool InsideMainCamera(Bounds bounds)
+ {
+ Plane[] mainCameraFrustumPlanes = GetMainCameraFrustumPlanes();
+ if (mainCameraFrustumPlanes == null)
+ {
+ return false;
+ }
+ return GeometryUtility.TestPlanesAABB(mainCameraFrustumPlanes, bounds);
+ }
+
+ public static bool InsideMainCamera(BoundingSphere bounds)
+ {
+ Plane[] mainCameraFrustumPlanes = GetMainCameraFrustumPlanes();
+ if (mainCameraFrustumPlanes == null)
+ {
+ return false;
+ }
+ for (int i = 0; i < mainCameraFrustumPlanes.Length; i++)
+ {
+ if (mainCameraFrustumPlanes[i].GetDistanceToPoint(bounds.position) < 0f - bounds.radius)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static Plane[] GetMainCameraFrustumPlanes()
+ {
+ Camera mainCamera = GetMainCamera();
+ if ((bool)mainCamera)
+ {
+ if (Time.frameCount != lastPlaneFrame)
+ {
+ mainPlanes = GeometryUtility.CalculateFrustumPlanes(mainCamera);
+ lastPlaneFrame = Time.frameCount;
+ }
+ return mainPlanes;
+ }
+ return null;
+ }
+
+ public static Camera GetMainCamera()
+ {
+ int frameCount = Time.frameCount;
+ if (lastFrameCheck == frameCount)
+ {
+ return lastMainCamera;
+ }
+ lastMainCamera = Camera.main;
+ lastFrameCheck = frameCount;
+ return lastMainCamera;
+ }
+
+ public static Color Vec3ToColor(Vector3 c)
+ {
+ return new Color(c.x, c.y, c.z);
+ }
+
+ public static Vector3 ColorToVec3(Color c)
+ {
+ return new Vector3(c.r, c.g, c.b);
+ }
+
+ public static float LerpStep(float l, float h, float v)
+ {
+ return Mathf.Clamp01((v - l) / (h - l));
+ }
+
+ public static float SmoothStep(float p_Min, float p_Max, float p_X)
+ {
+ float num = Mathf.Clamp01((p_X - p_Min) / (p_Max - p_Min));
+ return num * num * (3f - 2f * num);
+ }
+
+ public static double LerpStep(double l, double h, double v)
+ {
+ return Clamp01((v - l) / (h - l));
+ }
+
+ public static double Clamp01(double v)
+ {
+ if (v > 1.0)
+ {
+ return 1.0;
+ }
+ if (v < 0.0)
+ {
+ return 0.0;
+ }
+ return v;
+ }
+
+ public static float Fbm(Vector3 p, int octaves, float lacunarity, float gain)
+ {
+ return Fbm(new Vector2(p.x, p.z), octaves, lacunarity, gain);
+ }
+
+ public static float FbmMaxValue(int octaves, float gain)
+ {
+ float num = 0f;
+ float num2 = 1f;
+ for (int i = 0; i < octaves; i++)
+ {
+ num += num2;
+ num2 *= gain;
+ }
+ return num;
+ }
+
+ public static float Fbm(Vector2 p, int octaves, float lacunarity, float gain)
+ {
+ float num = 0f;
+ float num2 = 1f;
+ Vector2 vector = p;
+ for (int i = 0; i < octaves; i++)
+ {
+ num += num2 * Mathf.PerlinNoise(vector.x, vector.y);
+ num2 *= gain;
+ vector *= lacunarity;
+ }
+ return num;
+ }
+
+ public static Quaternion SmoothDamp(Quaternion rot, Quaternion target, ref Quaternion deriv, float smoothTime, float maxSpeed, float deltaTime)
+ {
+ float num = ((Quaternion.Dot(rot, target) > 0f) ? 1f : (-1f));
+ target.x *= num;
+ target.y *= num;
+ target.z *= num;
+ target.w *= num;
+ Vector4 normalized = new Vector4(Mathf.SmoothDamp(rot.x, target.x, ref deriv.x, smoothTime, maxSpeed, deltaTime), Mathf.SmoothDamp(rot.y, target.y, ref deriv.y, smoothTime, maxSpeed, deltaTime), Mathf.SmoothDamp(rot.z, target.z, ref deriv.z, smoothTime, maxSpeed, deltaTime), Mathf.SmoothDamp(rot.w, target.w, ref deriv.w, smoothTime, maxSpeed, deltaTime)).normalized;
+ float num2 = 1f / Time.deltaTime;
+ deriv.x = (normalized.x - rot.x) * num2;
+ deriv.y = (normalized.y - rot.y) * num2;
+ deriv.z = (normalized.z - rot.z) * num2;
+ deriv.w = (normalized.w - rot.w) * num2;
+ return new Quaternion(normalized.x, normalized.y, normalized.z, normalized.w);
+ }
+
+ public static long GenerateUID()
+ {
+ IPGlobalProperties iPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
+ string obj = ((iPGlobalProperties != null && iPGlobalProperties.HostName != null) ? iPGlobalProperties.HostName : "unkown");
+ string text = ((iPGlobalProperties != null && iPGlobalProperties.DomainName != null) ? iPGlobalProperties.DomainName : "domain");
+ return (long)(obj + ":" + text).GetHashCode() + (long)UnityEngine.Random.Range(1, int.MaxValue);
+ }
+
+ public static bool TestPointInViewFrustum(Camera camera, Vector3 worldPos)
+ {
+ Vector3 vector = camera.WorldToViewportPoint(worldPos);
+ if (vector.x >= 0f && vector.x <= 1f && vector.y >= 0f)
+ {
+ return vector.y <= 1f;
+ }
+ return false;
+ }
+
+ public static Vector3 ParseVector3(string rString)
+ {
+ string[] array = rString.Substring(1, rString.Length - 2).Split(',');
+ float x = float.Parse(array[0]);
+ float y = float.Parse(array[1]);
+ float z = float.Parse(array[2]);
+ return new Vector3(x, y, z);
+ }
+
+ public static int GetMinPow2(int val)
+ {
+ if (val <= 1)
+ {
+ return 1;
+ }
+ if (val <= 2)
+ {
+ return 2;
+ }
+ if (val <= 4)
+ {
+ return 4;
+ }
+ if (val <= 8)
+ {
+ return 8;
+ }
+ if (val <= 16)
+ {
+ return 16;
+ }
+ if (val <= 32)
+ {
+ return 32;
+ }
+ if (val <= 64)
+ {
+ return 64;
+ }
+ if (val <= 128)
+ {
+ return 128;
+ }
+ if (val <= 256)
+ {
+ return 256;
+ }
+ if (val <= 512)
+ {
+ return 512;
+ }
+ if (val <= 1024)
+ {
+ return 1024;
+ }
+ if (val <= 2048)
+ {
+ return 2048;
+ }
+ if (val <= 4096)
+ {
+ return 4096;
+ }
+ return 1;
+ }
+
+ public static void NormalizeQuaternion(ref Quaternion q)
+ {
+ float num = 0f;
+ for (int i = 0; i < 4; i++)
+ {
+ num += q[i] * q[i];
+ }
+ float num2 = 1f / Mathf.Sqrt(num);
+ for (int j = 0; j < 4; j++)
+ {
+ q[j] *= num2;
+ }
+ }
+
+ public static Vector3 Project(Vector3 v, Vector3 onTo)
+ {
+ float num = Vector3.Dot(onTo, v);
+ return onTo * num;
+ }
+
+ public static float Length(float x, float y)
+ {
+ return Mathf.Sqrt(x * x + y * y);
+ }
+
+ public static float DistanceSqr(Vector3 v0, Vector3 v1)
+ {
+ float num = v1.x - v0.x;
+ float num2 = v1.y - v0.y;
+ float num3 = v1.z - v0.z;
+ return num * num + num2 * num2 + num3 * num3;
+ }
+
+ public static float DistanceXZ(Vector3 v0, Vector3 v1)
+ {
+ float num = v1.x - v0.x;
+ float num2 = v1.z - v0.z;
+ return Mathf.Sqrt(num * num + num2 * num2);
+ }
+
+ public static float LengthXZ(Vector3 v)
+ {
+ return Mathf.Sqrt(v.x * v.x + v.z * v.z);
+ }
+
+ public static Vector3 DirectionXZ(Vector3 dir)
+ {
+ dir.y = 0f;
+ dir.Normalize();
+ return dir;
+ }
+
+ public static Vector3 Bezier2(Vector3 Start, Vector3 Control, Vector3 End, float delta)
+ {
+ return (1f - delta) * (1f - delta) * Start + 2f * delta * (1f - delta) * Control + delta * delta * End;
+ }
+
+ public static float FixDegAngle(float p_Angle)
+ {
+ while (p_Angle >= 360f)
+ {
+ p_Angle -= 360f;
+ }
+ while (p_Angle < 0f)
+ {
+ p_Angle += 360f;
+ }
+ return p_Angle;
+ }
+
+ public static float DegDistance(float p_a, float p_b)
+ {
+ if (p_a == p_b)
+ {
+ return 0f;
+ }
+ p_a = FixDegAngle(p_a);
+ p_b = FixDegAngle(p_b);
+ float num = Mathf.Abs(p_b - p_a);
+ if (num > 180f)
+ {
+ num = Mathf.Abs(num - 360f);
+ }
+ return num;
+ }
+
+ public static float GetYawDeltaAngle(Quaternion q1, Quaternion q2)
+ {
+ float y = q1.eulerAngles.y;
+ float y2 = q2.eulerAngles.y;
+ return Mathf.DeltaAngle(y, y2);
+ }
+
+ public static float YawFromDirection(Vector3 dir)
+ {
+ float num = Mathf.Atan2(dir.x, dir.z);
+ return FixDegAngle(57.29578f * num);
+ }
+
+ public static float DegDirection(float p_a, float p_b)
+ {
+ if (p_a == p_b)
+ {
+ return 0f;
+ }
+ p_a = FixDegAngle(p_a);
+ p_b = FixDegAngle(p_b);
+ float num = p_a - p_b;
+ float num2 = ((num > 0f) ? 1f : (-1f));
+ if (Mathf.Abs(num) > 180f)
+ {
+ num2 *= -1f;
+ }
+ return num2;
+ }
+
+ public static void RotateBodyTo(Rigidbody body, Quaternion rot, float alpha)
+ {
+ }
+
+ public static string DownloadString(string downloadUrl, int timeoutMS = 5000)
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(downloadUrl);
+ httpWebRequest.Timeout = timeoutMS;
+ httpWebRequest.ReadWriteTimeout = timeoutMS;
+ try
+ {
+ return new StreamReader(((HttpWebResponse)httpWebRequest.GetResponse()).GetResponseStream()).ReadToEnd();
+ }
+ catch (Exception ex)
+ {
+ ZLog.Log("Exception while waiting for respons from " + downloadUrl + " -> " + ex.ToString());
+ return "";
+ }
+ }
+
+ public static bool IsEnabledInheirarcy(GameObject go, GameObject root)
+ {
+ do
+ {
+ if (!go.activeSelf)
+ {
+ return false;
+ }
+ if (go == root)
+ {
+ return true;
+ }
+ go = go.transform.parent.gameObject;
+ }
+ while (go != null);
+ return true;
+ }
+
+ public static bool IsParent(Transform go, Transform parent)
+ {
+ do
+ {
+ if (go == parent)
+ {
+ return true;
+ }
+ go = go.parent;
+ }
+ while (go != null);
+ return false;
+ }
+
+ public static Transform FindChild(Transform aParent, string aName)
+ {
+ foreach (Transform item in aParent)
+ {
+ if (item.name == aName)
+ {
+ return item;
+ }
+ Transform transform2 = FindChild(item, aName);
+ if (transform2 != null)
+ {
+ return transform2;
+ }
+ }
+ return null;
+ }
+
+ public static void AddToLodgroup(LODGroup lg, GameObject toAdd)
+ {
+ List<Renderer> list = new List<Renderer>(lg.GetLODs()[0].renderers);
+ Renderer[] componentsInChildren = toAdd.GetComponentsInChildren<Renderer>();
+ list.AddRange(componentsInChildren);
+ lg.GetLODs()[0].renderers = list.ToArray();
+ }
+
+ public static void RemoveFromLodgroup(LODGroup lg, GameObject toRemove)
+ {
+ List<Renderer> list = new List<Renderer>(lg.GetLODs()[0].renderers);
+ Renderer[] componentsInChildren = toRemove.GetComponentsInChildren<Renderer>();
+ foreach (Renderer item in componentsInChildren)
+ {
+ list.Remove(item);
+ }
+ lg.GetLODs()[0].renderers = list.ToArray();
+ }
+
+ public static void DrawGizmoCircle(Vector3 center, float radius, int steps)
+ {
+ float num = (float)Math.PI * 2f / (float)steps;
+ Vector3 vector = center + new Vector3(Mathf.Cos(0f) * radius, 0f, Mathf.Sin(0f) * radius);
+ Vector3 vector2 = vector;
+ for (float num2 = num; num2 <= (float)Math.PI * 2f; num2 += num)
+ {
+ Vector3 vector3 = center + new Vector3(Mathf.Cos(num2) * radius, 0f, Mathf.Sin(num2) * radius);
+ Gizmos.DrawLine(vector3, vector2);
+ vector2 = vector3;
+ }
+ Gizmos.DrawLine(vector2, vector);
+ }
+
+ public static void ClampUIToScreen(RectTransform transform)
+ {
+ Vector3[] array = new Vector3[4];
+ transform.GetWorldCorners(array);
+ if (!(GetMainCamera() == null))
+ {
+ float num = 0f;
+ float num2 = 0f;
+ if (array[2].x > (float)Screen.width)
+ {
+ num -= array[2].x - (float)Screen.width;
+ }
+ if (array[0].x < 0f)
+ {
+ num -= array[0].x;
+ }
+ if (array[2].y > (float)Screen.height)
+ {
+ num2 -= array[2].y - (float)Screen.height;
+ }
+ if (array[0].y < 0f)
+ {
+ num2 -= array[0].y;
+ }
+ Vector3 position = transform.position;
+ position.x += num;
+ position.y += num2;
+ transform.position = position;
+ }
+ }
+
+ public static void Pull(Rigidbody body, Vector3 target, float targetDistance, float speed, float force, float smoothDistance)
+ {
+ Vector3 vector = target - body.position;
+ float magnitude = vector.magnitude;
+ if (!(magnitude < targetDistance))
+ {
+ Vector3 normalized = vector.normalized;
+ float num = Mathf.Clamp01((magnitude - targetDistance) / smoothDistance);
+ Vector3 vector2 = Vector3.Project(body.velocity, normalized.normalized);
+ Vector3 vector3 = normalized.normalized * speed - vector2;
+ body.AddForce(vector3 * num * force, ForceMode.VelocityChange);
+ }
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Vector2i.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Vector2i.cs
new file mode 100644
index 0000000..3a10e66
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/Vector2i.cs
@@ -0,0 +1,104 @@
+using UnityEngine;
+
+public struct Vector2i
+{
+ public static Vector2i zero = new Vector2i(0, 0);
+
+ public int x;
+
+ public int y;
+
+ public Vector2i(Vector2 v)
+ {
+ x = (int)v.x;
+ y = (int)v.y;
+ }
+
+ public Vector2i(Vector3 v)
+ {
+ x = (int)v.x;
+ y = (int)v.y;
+ }
+
+ public Vector2i(Vector2i v)
+ {
+ x = v.x;
+ y = v.y;
+ }
+
+ public Vector2i(int _x, int _y)
+ {
+ x = _x;
+ y = _y;
+ }
+
+ public static Vector2i operator +(Vector2i v0, Vector2i v1)
+ {
+ return new Vector2i(v0.x + v1.x, v0.y + v1.y);
+ }
+
+ public static Vector2i operator -(Vector2i v0, Vector2i v1)
+ {
+ return new Vector2i(v0.x - v1.x, v0.y - v1.y);
+ }
+
+ public static bool operator ==(Vector2i v0, Vector2i v1)
+ {
+ if (v0.x == v1.x)
+ {
+ return v0.y == v1.y;
+ }
+ return false;
+ }
+
+ public static bool operator !=(Vector2i v0, Vector2i v1)
+ {
+ if (v0.x == v1.x)
+ {
+ return v0.y != v1.y;
+ }
+ return true;
+ }
+
+ public int Magnitude()
+ {
+ return Mathf.Abs(x) + Mathf.Abs(y);
+ }
+
+ public static int Distance(Vector2i a, Vector2i b)
+ {
+ return (a - b).Magnitude();
+ }
+
+ public Vector2 ToVector2()
+ {
+ return new Vector2(x, y);
+ }
+
+ public override string ToString()
+ {
+ return x + "," + y;
+ }
+
+ public override int GetHashCode()
+ {
+ return x.GetHashCode() ^ y.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+ if (obj is Vector2i vector2i)
+ {
+ if (vector2i.x == x)
+ {
+ return vector2i.y == y;
+ }
+ return false;
+ }
+ return false;
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZInput.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZInput.cs
new file mode 100644
index 0000000..116b43f
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZInput.cs
@@ -0,0 +1,522 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class ZInput
+{
+ public class ButtonDef
+ {
+ public string m_name;
+
+ public bool m_gamepad;
+
+ public bool m_save = true;
+
+ public KeyCode m_key;
+
+ public string m_axis;
+
+ public bool m_inverted;
+
+ public bool m_pressed;
+
+ public bool m_wasPressed;
+
+ public bool m_down;
+
+ public bool m_up;
+
+ public bool m_pressedFixed;
+
+ public bool m_wasPressedFixed;
+
+ public bool m_downFixed;
+
+ public bool m_upFixed;
+
+ public float m_pressedTimer;
+
+ public float m_repeatDelay;
+
+ public float m_repeatInterval;
+ }
+
+ private static ZInput m_instance;
+
+ private const float m_stickDeadZone = 0.2f;
+
+ private const float m_gamepadInactiveTimeout = 60f;
+
+ private bool m_gamepadActive;
+
+ private bool m_mouseActive = true;
+
+ private bool m_gamepadEnabled;
+
+ private Dictionary<string, ButtonDef> m_buttons = new Dictionary<string, ButtonDef>();
+
+ private static ButtonDef m_binding;
+
+ public static ZInput instance => m_instance;
+
+ public static void Initialize()
+ {
+ if (m_instance == null)
+ {
+ m_instance = new ZInput();
+ }
+ }
+
+ private ZInput()
+ {
+ Reset();
+ Load();
+ }
+
+ public static void Update(float dt)
+ {
+ if (m_instance != null)
+ {
+ m_instance.InternalUpdate(dt);
+ }
+ }
+
+ public static void FixedUpdate(float dt)
+ {
+ if (m_instance != null)
+ {
+ m_instance.InternalUpdateFixed(dt);
+ }
+ }
+
+ private void InternalUpdate(float dt)
+ {
+ CheckMouseInput();
+ foreach (ButtonDef value in m_buttons.Values)
+ {
+ if (!m_gamepadEnabled && value.m_gamepad)
+ {
+ continue;
+ }
+ value.m_wasPressed = value.m_pressed;
+ if (!string.IsNullOrEmpty(value.m_axis))
+ {
+ float num = (value.m_inverted ? (0f - Input.GetAxis(value.m_axis)) : Input.GetAxis(value.m_axis));
+ value.m_pressed = num > 0.4f;
+ }
+ else
+ {
+ value.m_pressed = Input.GetKey(value.m_key);
+ }
+ value.m_down = value.m_pressed && !value.m_wasPressed;
+ value.m_up = !value.m_pressed && value.m_wasPressed;
+ if (value.m_repeatDelay > 0f)
+ {
+ if (value.m_pressed)
+ {
+ value.m_pressedTimer += dt;
+ if (value.m_pressedTimer > value.m_repeatDelay)
+ {
+ value.m_down = true;
+ value.m_downFixed = true;
+ value.m_pressedTimer -= value.m_repeatInterval;
+ }
+ }
+ else
+ {
+ value.m_pressedTimer = 0f;
+ }
+ }
+ if (value.m_gamepad && value.m_down)
+ {
+ OnGamepadInput();
+ }
+ }
+ }
+
+ private void CheckMouseInput()
+ {
+ if (Input.GetAxis("Mouse X") != 0f || Input.GetAxis("Mouse Y") != 0f)
+ {
+ OnMouseInput();
+ }
+ }
+
+ private void OnMouseInput()
+ {
+ m_gamepadActive = false;
+ m_mouseActive = true;
+ }
+
+ private void OnGamepadInput()
+ {
+ m_gamepadActive = true;
+ m_mouseActive = false;
+ }
+
+ private void InternalUpdateFixed(float dt)
+ {
+ foreach (ButtonDef value in m_buttons.Values)
+ {
+ value.m_wasPressedFixed = value.m_pressedFixed;
+ value.m_pressedFixed = value.m_pressed;
+ value.m_downFixed = value.m_pressedFixed && !value.m_wasPressedFixed;
+ value.m_upFixed = !value.m_pressedFixed && value.m_wasPressedFixed;
+ }
+ }
+
+ public void Reset()
+ {
+ m_buttons.Clear();
+ float repeatDelay = 0.3f;
+ float repeatInterval = 0.1f;
+ AddButton("Attack", KeyCode.Mouse0);
+ AddButton("SecondAttack", KeyCode.Mouse2);
+ AddButton("Block", KeyCode.Mouse1);
+ AddButton("Use", KeyCode.E);
+ AddButton("Hide", KeyCode.R);
+ AddButton("Jump", KeyCode.Space);
+ AddButton("Crouch", KeyCode.LeftControl);
+ AddButton("Run", KeyCode.LeftShift);
+ AddButton("ToggleWalk", KeyCode.C);
+ AddButton("AutoRun", KeyCode.Q);
+ AddButton("Sit", KeyCode.X);
+ AddButton("GPower", KeyCode.F);
+ AddButton("AltPlace", KeyCode.LeftShift);
+ AddButton("Forward", KeyCode.W, repeatDelay, repeatInterval);
+ AddButton("Left", KeyCode.A, repeatDelay, repeatInterval);
+ AddButton("Backward", KeyCode.S, repeatDelay, repeatInterval);
+ AddButton("Right", KeyCode.D, repeatDelay, repeatInterval);
+ AddButton("Inventory", KeyCode.Tab);
+ AddButton("Map", KeyCode.M);
+ AddButton("MapZoomOut", KeyCode.Comma);
+ AddButton("MapZoomIn", KeyCode.Period);
+ AddButton("BuildPrev", KeyCode.Q);
+ AddButton("BuildNext", KeyCode.E);
+ AddButton("BuildMenu", KeyCode.Mouse1);
+ AddButton("Remove", KeyCode.Mouse2);
+ AddButton("JoyUse", KeyCode.JoystickButton0);
+ AddButton("JoyHide", KeyCode.JoystickButton9);
+ AddButton("JoyJump", KeyCode.JoystickButton1);
+ AddButton("JoySit", KeyCode.JoystickButton2);
+ AddButton("JoyGPower", "JoyAxis 7", inverted: true);
+ AddButton("JoyInventory", KeyCode.JoystickButton3);
+ AddButton("JoyRun", KeyCode.JoystickButton4);
+ AddButton("JoyCrouch", KeyCode.JoystickButton8);
+ AddButton("JoyMap", KeyCode.JoystickButton6);
+ AddButton("JoyMenu", KeyCode.JoystickButton7);
+ AddButton("JoyBlock", "JoyAxis 3", inverted: true);
+ AddButton("JoyAttack", "JoyAxis 3");
+ AddButton("JoySecondAttack", KeyCode.JoystickButton5);
+ AddButton("JoyAltPlace", KeyCode.JoystickButton4);
+ AddButton("JoyRotate", "JoyAxis 3", inverted: true);
+ AddButton("JoyPlace", "JoyAxis 10");
+ AddButton("JoyRemove", KeyCode.JoystickButton5);
+ AddButton("JoyTabLeft", KeyCode.JoystickButton4);
+ AddButton("JoyTabRight", KeyCode.JoystickButton5);
+ AddButton("JoyLStickLeft", "JoyAxis 1", inverted: true, repeatDelay, repeatInterval);
+ AddButton("JoyLStickRight", "JoyAxis 1", inverted: false, repeatDelay, repeatInterval);
+ AddButton("JoyLStickUp", "JoyAxis 2", inverted: true, repeatDelay, repeatInterval);
+ AddButton("JoyLStickDown", "JoyAxis 2", inverted: false, repeatDelay, repeatInterval);
+ AddButton("JoyButtonA", KeyCode.JoystickButton0);
+ AddButton("JoyButtonB", KeyCode.JoystickButton1);
+ AddButton("JoyButtonX", KeyCode.JoystickButton2);
+ AddButton("JoyButtonY", KeyCode.JoystickButton3);
+ AddButton("JoyDPadLeft", "JoyAxis 6", inverted: true, repeatDelay, repeatInterval);
+ AddButton("JoyDPadRight", "JoyAxis 6", inverted: false, repeatDelay, repeatInterval);
+ AddButton("JoyDPadUp", "JoyAxis 7", inverted: false, repeatDelay, repeatInterval);
+ AddButton("JoyDPadDown", "JoyAxis 7", inverted: true, repeatDelay, repeatInterval);
+ AddButton("JoyLTrigger", "JoyAxis 3", inverted: true);
+ AddButton("JoyRTrigger", "JoyAxis 3");
+ AddButton("JoyLStick", KeyCode.JoystickButton8);
+ AddButton("JoyRStick", KeyCode.JoystickButton9);
+ }
+
+ public static bool IsGamepadEnabled()
+ {
+ return m_instance.m_gamepadEnabled;
+ }
+
+ public static void SetGamepadEnabled(bool enabled)
+ {
+ m_instance.m_gamepadEnabled = enabled;
+ }
+
+ public static bool IsGamepadActive()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return false;
+ }
+ return m_instance.m_gamepadActive;
+ }
+
+ public static bool IsMouseActive()
+ {
+ return m_instance.m_mouseActive;
+ }
+
+ public void Save()
+ {
+ PlayerPrefs.SetInt("gamepad_enabled", m_gamepadEnabled ? 1 : 0);
+ foreach (ButtonDef value in m_buttons.Values)
+ {
+ if (value.m_save)
+ {
+ PlayerPrefs.SetInt("key_" + value.m_name, (int)value.m_key);
+ }
+ }
+ }
+
+ public void Load()
+ {
+ Reset();
+ m_gamepadEnabled = PlayerPrefs.GetInt("gamepad_enabled", 1) == 1;
+ foreach (ButtonDef value in m_buttons.Values)
+ {
+ if (value.m_save)
+ {
+ KeyCode @int = (KeyCode)PlayerPrefs.GetInt("key_" + value.m_name, (int)value.m_key);
+ value.m_key = @int;
+ }
+ }
+ }
+
+ public ButtonDef AddButton(string name, KeyCode key, float repeatDelay = 0f, float repeatInterval = 0f)
+ {
+ ButtonDef buttonDef = new ButtonDef();
+ buttonDef.m_name = name;
+ buttonDef.m_key = key;
+ buttonDef.m_gamepad = name.StartsWith("Joy");
+ buttonDef.m_save = !buttonDef.m_gamepad;
+ buttonDef.m_repeatDelay = repeatDelay;
+ buttonDef.m_repeatInterval = repeatInterval;
+ m_buttons.Add(name, buttonDef);
+ return buttonDef;
+ }
+
+ public ButtonDef AddButton(string name, string axis, bool inverted = false, float repeatDelay = 0f, float repeatInterval = 0f)
+ {
+ ButtonDef buttonDef = new ButtonDef();
+ buttonDef.m_name = name;
+ buttonDef.m_axis = axis;
+ buttonDef.m_inverted = inverted;
+ buttonDef.m_gamepad = name.StartsWith("Joy");
+ buttonDef.m_save = !buttonDef.m_gamepad;
+ buttonDef.m_repeatDelay = repeatDelay;
+ buttonDef.m_repeatInterval = repeatInterval;
+ m_buttons.Add(name, buttonDef);
+ return buttonDef;
+ }
+
+ public void Setbutton(string name, KeyCode key)
+ {
+ m_buttons[name].m_key = key;
+ }
+
+ public string GetBoundKeyString(string name)
+ {
+ if (m_buttons.TryGetValue(name, out var value))
+ {
+ return value.m_key switch
+ {
+ KeyCode.Comma => ",",
+ KeyCode.Period => ".",
+ KeyCode.Mouse0 => "$button_mouse0",
+ KeyCode.Mouse1 => "$button_mouse1",
+ KeyCode.Mouse2 => "$button_mouse2",
+ KeyCode.Space => "$button_space",
+ KeyCode.LeftShift => "$button_lshift",
+ KeyCode.RightShift => "$button_rshift",
+ KeyCode.LeftAlt => "$button_lalt",
+ KeyCode.RightAlt => "$button_ralt",
+ KeyCode.LeftControl => "$button_lctrl",
+ KeyCode.RightControl => "$button_rctrl",
+ KeyCode.Return => "$button_return",
+ _ => value.m_key.ToString(),
+ };
+ }
+ return "MISSING KEY BINDING \"" + name + "\"";
+ }
+
+ public static void ResetButtonStatus(string name)
+ {
+ if (m_instance.m_buttons.TryGetValue(name, out var value))
+ {
+ value.m_down = false;
+ value.m_up = false;
+ value.m_downFixed = false;
+ value.m_upFixed = false;
+ }
+ }
+
+ public static bool GetButtonDown(string name)
+ {
+ if (m_instance.m_buttons.TryGetValue(name, out var value))
+ {
+ if (!instance.m_gamepadEnabled && value.m_gamepad)
+ {
+ return false;
+ }
+ if (Time.inFixedTimeStep)
+ {
+ return value.m_downFixed;
+ }
+ return value.m_down;
+ }
+ return false;
+ }
+
+ public static bool GetButtonUp(string name)
+ {
+ if (m_instance.m_buttons.TryGetValue(name, out var value))
+ {
+ if (!instance.m_gamepadEnabled && value.m_gamepad)
+ {
+ return false;
+ }
+ if (Time.inFixedTimeStep)
+ {
+ return value.m_upFixed;
+ }
+ return value.m_up;
+ }
+ return false;
+ }
+
+ public static bool GetButton(string name)
+ {
+ if (m_instance.m_buttons.TryGetValue(name, out var value))
+ {
+ if (!instance.m_gamepadEnabled && value.m_gamepad)
+ {
+ return false;
+ }
+ return value.m_pressed;
+ }
+ return false;
+ }
+
+ private KeyCode GetPressedKey()
+ {
+ foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
+ {
+ if (Input.GetKey(value))
+ {
+ return value;
+ }
+ }
+ return KeyCode.None;
+ }
+
+ public void StartBindKey(string name)
+ {
+ if (m_buttons.TryGetValue(name, out var value))
+ {
+ m_binding = value;
+ }
+ }
+
+ public bool EndBindKey()
+ {
+ if (m_binding == null)
+ {
+ return true;
+ }
+ KeyCode pressedKey = GetPressedKey();
+ if (pressedKey != 0)
+ {
+ m_binding.m_key = pressedKey;
+ return true;
+ }
+ return false;
+ }
+
+ private static float ApplyDeadzone(float v, bool soften)
+ {
+ float num = Mathf.Sign(v);
+ v = Mathf.Abs(v);
+ v = Mathf.Clamp01(v - 0.2f);
+ v *= 1.25f;
+ if (soften)
+ {
+ v *= v;
+ }
+ v *= num;
+ return v;
+ }
+
+ public static float GetJoyLeftStickX()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ float num = ApplyDeadzone(Input.GetAxis("JoyAxis 1"), soften: false);
+ if (num != 0f)
+ {
+ m_instance.OnGamepadInput();
+ }
+ return num;
+ }
+
+ public static float GetJoyLeftStickY()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ float num = ApplyDeadzone(Input.GetAxis("JoyAxis 2"), soften: false);
+ if (num != 0f)
+ {
+ m_instance.OnGamepadInput();
+ }
+ return num;
+ }
+
+ public static float GetJoyRightStickX()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ float num = ApplyDeadzone(Input.GetAxis("JoyAxis 4"), soften: true);
+ if (num != 0f)
+ {
+ m_instance.OnGamepadInput();
+ }
+ return num;
+ }
+
+ public static float GetJoyRightStickY()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ float num = ApplyDeadzone(Input.GetAxis("JoyAxis 5"), soften: true);
+ if (num != 0f)
+ {
+ m_instance.OnGamepadInput();
+ }
+ return num;
+ }
+
+ public static float GetJoyLTrigger()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ return Input.GetAxis("JoyAxis 3");
+ }
+
+ public static float GetJoyRTrigger()
+ {
+ if (!m_instance.m_gamepadEnabled)
+ {
+ return 0f;
+ }
+ return Input.GetAxis("JoyAxis 6");
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZLog.cs b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZLog.cs
new file mode 100644
index 0000000..5a0b187
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/ZLog.cs
@@ -0,0 +1,28 @@
+using System;
+using UnityEngine;
+
+public class ZLog
+{
+ public static void Log(object o)
+ {
+ Debug.Log(string.Concat(DateTime.Now.ToString(), ": ", o, "\n"));
+ }
+
+ public static void DevLog(object o)
+ {
+ if (Debug.isDebugBuild)
+ {
+ Debug.Log(string.Concat(DateTime.Now.ToString(), ": ", o, "\n"));
+ }
+ }
+
+ public static void LogError(object o)
+ {
+ Debug.LogError(string.Concat(DateTime.Now.ToString(), ": ", o, "\n"));
+ }
+
+ public static void LogWarning(object o)
+ {
+ Debug.LogWarning(string.Concat(DateTime.Now.ToString(), ": ", o, "\n"));
+ }
+}
diff --git a/Valheim_r202102_v0.141.2/Valheim/assembly_utils/assembly_utils.csproj b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/assembly_utils.csproj
new file mode 100644
index 0000000..aca9a06
--- /dev/null
+++ b/Valheim_r202102_v0.141.2/Valheim/assembly_utils/assembly_utils.csproj
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>assembly_utils</AssemblyName>
+ <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
+ <TargetFramework>net40</TargetFramework>
+ </PropertyGroup>
+ <PropertyGroup>
+ <LangVersion>11.0</LangVersion>
+ <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup />
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="UnityEngine.CoreModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.PhysicsModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
+ </Reference>
+ <Reference Include="UnityEngine.AnimationModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="UnityEngine.InputLegacyModule">
+ <HintPath>..\..\Game\valheim_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project> \ No newline at end of file