fix box origin, limit water level to always be below camera
This commit is contained in:
parent
acd67fc68d
commit
ddd16ffda1
4 changed files with 16 additions and 9 deletions
|
@ -72,6 +72,7 @@ Material:
|
|||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Grid: 0
|
||||
- _HeightOffset: -0.7
|
||||
- _HorizonTint: 0.1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
|
|
Binary file not shown.
|
@ -186,7 +186,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: a37fd8d654d5c2840a0ab3a5ad65a5ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
spawnHeight: 0
|
||||
spawnHeight: 0.6
|
||||
useAdditionalValues: 0
|
||||
syncValues: []
|
||||
propPrivacy: 1
|
||||
|
@ -221,7 +221,7 @@ SphereCollider:
|
|||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.05
|
||||
m_Center: {x: 0.7, y: 0.05, z: -0.8}
|
||||
m_Center: {x: 0.75, y: 0, z: -0.75}
|
||||
--- !u!1 &1702728164
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -248,7 +248,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1702728164}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.7, y: 0.05, z: -0.8}
|
||||
m_LocalPosition: {x: 0.75, y: 0, z: -0.75}
|
||||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 733733049}
|
||||
|
@ -412,6 +412,11 @@ PrefabInstance:
|
|||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -430,12 +435,12 @@ PrefabInstance:
|
|||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071068
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.7071068
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
|
@ -450,7 +455,7 @@ PrefabInstance:
|
|||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: -90
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 5009e49fafd33ed0e980b53b1f9e954d,
|
||||
type: 3}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
_StarSizeRandom ("Star size randomness", Range(0, 1)) = 0.5
|
||||
_StarTint ("Star tint", Range(0, 1)) = 0.4
|
||||
[Header(Water)]
|
||||
_HeightOffset ("Height offset", Range(-10, 10)) = -0.5
|
||||
_WaterCol ("Water color", Color) = (0.03, 0.08, 0.12, 1.0)
|
||||
_WaveStrength ("Wave scale", Range(0, 1)) = 1
|
||||
[NoScaleOffset]
|
||||
|
@ -78,6 +79,7 @@
|
|||
|
||||
sampler2D _WaterSurface;
|
||||
float3 _WaterCol;
|
||||
float _HeightOffset;
|
||||
float _WaveStrength;
|
||||
|
||||
float _Grid;
|
||||
|
@ -170,15 +172,15 @@
|
|||
float3 sun_dir = float3(sin(_SunAngle), 0, cos(_SunAngle));
|
||||
|
||||
float water_mod = 0;
|
||||
// float water_reflection = 0;
|
||||
|
||||
float3 dir = normalize(i.hit_pos - i.cam_pos);
|
||||
float theta = atan2(dir.x, dir.z); // latitude
|
||||
float phi = asin(dir.y); // longitude
|
||||
|
||||
if (phi < 0) {
|
||||
float3 object_pos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||
float3 object_pos = mul(unity_ObjectToWorld, float4(0, _HeightOffset, 0, 1));
|
||||
float3 camera_local_pos = i.cam_pos - object_pos;
|
||||
camera_local_pos.y = max(camera_local_pos.y, 0.01); // don't allow looking under water surface; it renders backwards.
|
||||
float3 surface_pos = float3 (
|
||||
camera_local_pos.x - camera_local_pos.y / (dir.y / dir.x),
|
||||
0,
|
||||
|
@ -189,7 +191,6 @@
|
|||
dir = reflect(dir, water_normal);
|
||||
phi = asin(dir.y);
|
||||
water_mod = dot(dir, water_normal);
|
||||
// water_reflection = 1;
|
||||
}
|
||||
|
||||
float3 col = sky(dir, theta, phi, sun_dir);
|
||||
|
|
Loading…
Reference in a new issue