mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 08:11:47 -05:00
start prep terrain for new shaders
This commit is contained in:
parent
d2a8a78f85
commit
368dda80d2
3 changed files with 53 additions and 7 deletions
41
Assets/Materials/Terrain.mat
generated
41
Assets/Materials/Terrain.mat
generated
|
@ -23,6 +23,10 @@ Material:
|
|||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CliffTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
|
@ -45,7 +49,7 @@ Material:
|
|||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 0.01, y: 0.01}
|
||||
m_Scale: {x: 0.0075, y: 0.0075}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MatCap:
|
||||
m_Texture: {fileID: 2800000, guid: 174675c9d2f4de84ba7e6face5995a2e, type: 3}
|
||||
|
@ -63,6 +67,38 @@ Material:
|
|||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Roughness:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Roughness1:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Roughness2:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ShadowMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Shore:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ShoreMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Variation1:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Variation2:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Ambient: 0.2
|
||||
- _BumpScale: 1
|
||||
|
@ -77,6 +113,7 @@ Material:
|
|||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SeaLevel: 0
|
||||
- _Shininess: 0.7
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
|
@ -87,6 +124,8 @@ Material:
|
|||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _Subtract: 0.2
|
||||
- _TerrainHeight: 128
|
||||
- _TerrainWidth: 128
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
|
|
|
@ -4,12 +4,16 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTS2.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OpenTS2.Content
|
||||
{
|
||||
public abstract class TerrainType
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
public virtual float RoadDistanceForRoughness => 40f;
|
||||
public virtual float RoughnessFalloff => 40f;
|
||||
public virtual Shader TerrainShader => Shader.Find("OpenTS2/ClassicTerrain");
|
||||
public abstract ResourceKey Texture { get; }
|
||||
public virtual ResourceKey Texture1 => Texture;
|
||||
public virtual ResourceKey Texture2 => Texture1;
|
||||
|
|
|
@ -29,15 +29,17 @@ namespace OpenTS2.Scenes
|
|||
void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
var terrain = NeighborhoodManager.CurrentNeighborhood.Terrain;
|
||||
var terrainType = terrain.TerrainType;
|
||||
|
||||
_meshFilter = GetComponent<MeshFilter>();
|
||||
var contentProvider = ContentProvider.Get();
|
||||
var meshRenderer = GetComponent<MeshRenderer>();
|
||||
_terrainMaterial = meshRenderer.material;
|
||||
_terrainMaterial.shader = terrainType.TerrainShader;
|
||||
_terrainMaterial.SetVector("_LightVector", Sun.forward);
|
||||
|
||||
var terrain = NeighborhoodManager.CurrentNeighborhood.Terrain;
|
||||
var terrainType = terrain.TerrainType;
|
||||
|
||||
var matCap = contentProvider.GetAsset<TextureAsset>(s_matCapKey);
|
||||
var smooth = contentProvider.GetAsset<ScenegraphTextureAsset>(terrainType.Texture);
|
||||
var variation1 = contentProvider.GetAsset<ScenegraphTextureAsset>(terrainType.Texture1);
|
||||
|
@ -139,8 +141,9 @@ namespace OpenTS2.Scenes
|
|||
// TODO: Optimize, maybe multithread.
|
||||
void MakeRoughness(Mesh terrainMesh)
|
||||
{
|
||||
var maxRoadDistance = 80f;
|
||||
var minRoadDistance = 40f;
|
||||
var terrainType = NeighborhoodManager.CurrentNeighborhood.Terrain.TerrainType;
|
||||
var roadDistanceForRoughness = terrainType.RoadDistanceForRoughness;
|
||||
var roughnessFalloff = terrainType.RoughnessFalloff;
|
||||
var vertices = terrainMesh.vertices;
|
||||
var colors = terrainMesh.colors;
|
||||
var roads = NeighborhoodManager.CurrentNeighborhood.Decorations.RoadDecorations;
|
||||
|
@ -172,7 +175,7 @@ namespace OpenTS2.Scenes
|
|||
color.b = 1f;
|
||||
else
|
||||
{
|
||||
var amount = Mathf.Clamp((closestRoadDistance - minRoadDistance) / maxRoadDistance, 0f, 1f);
|
||||
var amount = Mathf.Clamp((closestRoadDistance - roughnessFalloff) / (roadDistanceForRoughness + roughnessFalloff), 0f, 1f);
|
||||
color.b = amount;
|
||||
}
|
||||
colors[i] = color;
|
||||
|
|
Loading…
Reference in a new issue