Skip to content

Commit

Permalink
Water collider fix (#117)
Browse files Browse the repository at this point in the history
* unity update

* new water shader added for local

* update noise preview button

* Water mesh collider removed

* Post processing changes

* Under water mesh changes
  • Loading branch information
BLaZeKiLL authored May 6, 2024
1 parent 6e80957 commit b81a923
Show file tree
Hide file tree
Showing 20 changed files with 433 additions and 61 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,8 @@ MigrationBackup/

# End of https://www.toptal.com/developers/gitignore/api/unity,rider,visualstudio,visualstudiocode

.DS_Store
.DS_Store

# I am not sure about the liscense of these shaders
Assets/Plugins/WaterShaders/
Assets/Plugins/WaterShaders.meta
17 changes: 17 additions & 0 deletions Assets/Scenes/World.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4507,6 +4507,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 385efbb587b84105b268631c62e8988f, type: 3}
m_Name:
m_EditorClassIdentifier:
_FaceTransform: {fileID: 373691837}
--- !u!4 &652638165
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -6230,6 +6231,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1773566604}
- component: {fileID: 1773566605}
- component: {fileID: 1773566603}
m_Layer: 0
m_Name: PostProcessing
Expand Down Expand Up @@ -6270,6 +6272,21 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1773566605
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1773566602}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2cfb4bc5c534b03b209443e5573ac32, type: 3}
m_Name:
m_EditorClassIdentifier:
_isPersistant: 0
_main: {fileID: 11400000, guid: 4b9cedcad8dd7c44a81de7c9c9be6b54, type: 2}
_underwater: {fileID: 11400000, guid: 62f8d741270724075bf722d16dec5162, type: 2}
--- !u!114 &1780912054
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
64 changes: 64 additions & 0 deletions Assets/Scripts/Managers/PostProcessingManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using CodeBlaze.Vloxy.Demo.Utils;
using CodeBlaze.Vloxy.Engine.Data;
using UnityEngine;
using UnityEngine.Rendering;

namespace CodeBlaze.Vloxy.Demo.Managers {

public enum PostProcessingMode {
MAIN,
UNDERWATER
}

public class PostProcessingManager : SingletonBehaviour<PostProcessingManager> {

[SerializeField] private VolumeProfile _main;
[SerializeField] private VolumeProfile _underwater;

private Volume _volume;

public PostProcessingMode Mode { get; private set; }

private void Start() {
_volume = GetComponent<Volume>();

SetProfileMain();
}

public void UpdateMode(Block block) {
switch (block) {
case Block.WATER:
if (Mode != PostProcessingMode.UNDERWATER) SetProfileUnderwater();
break;
default:
if (Mode != PostProcessingMode.MAIN) SetProfileMain();
break;
}
}

private void SetProfileMain() {
_volume.profile = _main;

var drawDistance = WorldAPI.Current.World.Settings.Chunk.DrawDistance;

RenderSettings.fogMode = FogMode.Linear;
RenderSettings.fogEndDistance = drawDistance * 32 - 16;

Mode = PostProcessingMode.MAIN;
}

private void SetProfileUnderwater() {
_volume.profile = _underwater;

var drawDistance = WorldAPI.Current.World.Settings.Chunk.DrawDistance;

RenderSettings.fogMode = FogMode.Linear;
RenderSettings.fogEndDistance = Mathf.Max(64, drawDistance * 32 - 128);

Mode = PostProcessingMode.UNDERWATER;
}

}

}
3 changes: 3 additions & 0 deletions Assets/Scripts/Managers/PostProcessingManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 20 additions & 13 deletions Assets/Scripts/Player/VloxyInputController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@
namespace CodeBlaze.Vloxy.Demo.Player {

public class VloxyInputController : MonoBehaviour {


[SerializeField] private Transform _FaceTransform;

private VloxyInput.PlayerActions _PlayerMap;

private VloxyCharacterInteractions _CharacterInteractions;
private VloxyCharacterController _CharacterController;
private VloxyCameraController _CameraController;

private void Awake() {
_CharacterInteractions = GetComponent<VloxyCharacterInteractions>();

_CharacterController = GetComponentInChildren<VloxyCharacterController>();
_CameraController = GetComponentInChildren<VloxyCameraController>();
}

private void Update() {
if (Keyboard.current[Key.P].wasPressedThisFrame) {
if (_PlayerMap.enabled) {
Expand All @@ -29,7 +31,12 @@ private void Update() {
_PlayerMap.Enable();
}
}


// TODO : This prints warnings for the first few frames, as the chunk isn't loaded
PostProcessingManager.Current.UpdateMode(
WorldAPI.Current.World.ChunkManager.GetBlock(Vector3Int.FloorToInt(_FaceTransform.position))
);

CharacterInput();
}

Expand All @@ -39,14 +46,14 @@ private void LateUpdate() {

private void OnEnable() {
_PlayerMap = GameManager.Current.InputMaps.Player;

_PlayerMap.Enable();

_PlayerMap.Toggle.performed += ToggleOnPerformed;
_PlayerMap.Quit.performed += QuitOnPerformed;
_PlayerMap.BreakBlock.performed += BreakBlockOnPerformed;
_PlayerMap.PlaceBlock.performed += PlaceBlockOnPerformed;

Cursor.lockState = CursorLockMode.Locked;
}

Expand All @@ -69,24 +76,24 @@ private void QuitOnPerformed(InputAction.CallbackContext obj) {
#if !UNITY_EDITOR
SceneManager.LoadScene(0);
#endif

#if UNITY_EDITOR
// Application.Quit();
// UnityEditor.EditorApplication.isPlaying = false;
#endif
}

private void BreakBlockOnPerformed(InputAction.CallbackContext obj) {
_CharacterInteractions.BreakBlock();
}

private void PlaceBlockOnPerformed(InputAction.CallbackContext obj) {
_CharacterInteractions.PlaceBlock();
}

private void CharacterInput() {
if (!_PlayerMap.enabled) return;

var move = _PlayerMap.Move.ReadValue<Vector2>();

var input = new VloxyCharacterController.Input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: UrpPostProcessingProfile
m_Name: Main
m_EditorClassIdentifier:
components:
- {fileID: 3870444541769218594}
Expand Down
File renamed without changes.
163 changes: 163 additions & 0 deletions Assets/Settings/URP/Underwater.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6692942426037315030
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5485954d14dfb9a4c8ead8edb0ded5b1, type: 3}
m_Name: LiftGammaGain
m_EditorClassIdentifier:
active: 1
lift:
m_OverrideState: 1
m_Value: {x: 0, y: 0.7071836, z: 1, w: 0}
gamma:
m_OverrideState: 1
m_Value: {x: 0, y: 0.82316446, z: 1, w: 0}
gain:
m_OverrideState: 1
m_Value: {x: 0, y: 0.7773938, z: 1, w: 0}
--- !u!114 &-6644755081694344559
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3}
m_Name: Vignette
m_EditorClassIdentifier:
active: 1
color:
m_OverrideState: 1
m_Value: {r: 0, g: 0, b: 0, a: 1}
center:
m_OverrideState: 1
m_Value: {x: 0.5, y: 0.5}
intensity:
m_OverrideState: 1
m_Value: 0.4
smoothness:
m_OverrideState: 1
m_Value: 0.1
rounded:
m_OverrideState: 1
m_Value: 0
--- !u!114 &-942842996603021615
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29fa0085f50d5e54f8144f766051a691, type: 3}
m_Name: FilmGrain
m_EditorClassIdentifier:
active: 1
type:
m_OverrideState: 1
m_Value: 0
intensity:
m_OverrideState: 1
m_Value: 0.1
response:
m_OverrideState: 1
m_Value: 0.8
texture:
m_OverrideState: 1
m_Value: {fileID: 0}
--- !u!114 &-905501839028520348
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3}
m_Name: ColorAdjustments
m_EditorClassIdentifier:
active: 1
postExposure:
m_OverrideState: 0
m_Value: 0
contrast:
m_OverrideState: 0
m_Value: -3.1
colorFilter:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
hueShift:
m_OverrideState: 1
m_Value: 26
saturation:
m_OverrideState: 1
m_Value: 100
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Underwater
m_EditorClassIdentifier:
components:
- {fileID: 3870444541769218594}
- {fileID: -6644755081694344559}
- {fileID: -942842996603021615}
- {fileID: -6692942426037315030}
- {fileID: -905501839028520348}
--- !u!114 &3870444541769218594
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3}
m_Name: Tonemapping
m_EditorClassIdentifier:
active: 1
mode:
m_OverrideState: 1
m_Value: 2
neutralHDRRangeReductionMode:
m_OverrideState: 0
m_Value: 2
acesPreset:
m_OverrideState: 0
m_Value: 3
hueShiftAmount:
m_OverrideState: 0
m_Value: 0
detectPaperWhite:
m_OverrideState: 0
m_Value: 0
paperWhite:
m_OverrideState: 0
m_Value: 300
detectBrightnessLimits:
m_OverrideState: 0
m_Value: 1
minNits:
m_OverrideState: 0
m_Value: 0.005
maxNits:
m_OverrideState: 0
m_Value: 1000
8 changes: 8 additions & 0 deletions Assets/Settings/URP/Underwater.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b81a923

Please sign in to comment.