Fixed heightmap shader seam

This commit is contained in:
Nick J. Connors 2022-01-04 02:22:09 -05:00
parent 8334c67206
commit e3015b51e9
6 changed files with 13 additions and 9 deletions

Binary file not shown.

View File

@ -1,9 +1,9 @@
ManifestFileVersion: 0 ManifestFileVersion: 0
CRC: 3840241390 CRC: 3597037522
Hashes: Hashes:
AssetFileHash: AssetFileHash:
serializedVersion: 2 serializedVersion: 2
Hash: 1c2c90716d1ed7c9cbf5f785e41eace6 Hash: 33678ea445c06b269454371064cc3a5c
TypeTreeHash: TypeTreeHash:
serializedVersion: 2 serializedVersion: 2
Hash: 6370d3f9de9eca57f523bce048404a46 Hash: 6370d3f9de9eca57f523bce048404a46
@ -12,6 +12,7 @@ ClassTypes:
- Class: 48 - Class: 48
Script: {instanceID: 0} Script: {instanceID: 0}
Assets: Assets:
- Assets/SphereTextureWrapper.shader - Assets/Shaders/SphereTextureWrapper.shader
- Assets/UnlitTransparent.shader - Assets/Shaders/Ring.shader
- Assets/Shaders/UnlitTransparent.shader
Dependencies: [] Dependencies: []

View File

@ -97,8 +97,8 @@ namespace NewHorizons.Body
float latitude = (Mathf.Rad2Deg * Mathf.Acos(v.z / Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z))); float latitude = (Mathf.Rad2Deg * Mathf.Acos(v.z / Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z)));
float longitude = 180f; float longitude = 180f;
if(v.x > 0) longitude = Mathf.Rad2Deg * Mathf.Atan(v.y / v.x) + 90f; if(v.x > 0) longitude = Mathf.Rad2Deg * Mathf.Atan(v.y / v.x);
if(v.x < 0) longitude = Mathf.Rad2Deg * (Mathf.Atan(v.y / v.x) + Mathf.PI) + 90f; if(v.x < 0) longitude = Mathf.Rad2Deg * (Mathf.Atan(v.y / v.x) + Mathf.PI);
float sampleX = heightMap.width * longitude / 360f; float sampleX = heightMap.width * longitude / 360f;
float sampleY = heightMap.height * latitude / 180f; float sampleY = heightMap.height * latitude / 180f;

View File

@ -42,7 +42,7 @@ namespace NewHorizons.Builder.Body
cubeSphere.AddComponent<MeshFilter>(); cubeSphere.AddComponent<MeshFilter>();
cubeSphere.GetComponent<MeshFilter>().mesh = mesh; cubeSphere.GetComponent<MeshFilter>().mesh = mesh;
if(PlanetShader == null) PlanetShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/SphereTextureWrapper.shader"); if(PlanetShader == null) PlanetShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
var cubeSphereMR = cubeSphere.AddComponent<MeshRenderer>(); var cubeSphereMR = cubeSphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(PlanetShader); cubeSphereMR.material = new Material(PlanetShader);

View File

@ -13,6 +13,7 @@ namespace NewHorizons.Builder.Body
static class RingBuilder static class RingBuilder
{ {
public static Shader RingShader; public static Shader RingShader;
public static Shader UnlitShader;
public static void Make(GameObject body, RingModule ring, IModAssets assets) public static void Make(GameObject body, RingModule ring, IModAssets assets)
{ {
@ -39,9 +40,10 @@ namespace NewHorizons.Builder.Body
var ringMR = ringGO.AddComponent<MeshRenderer>(); var ringMR = ringGO.AddComponent<MeshRenderer>();
var texture = ringTexture; var texture = ringTexture;
if (RingShader == null) RingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/UnlitTransparent.shader"); if (RingShader == null) RingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
if (UnlitShader == null) UnlitShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
var mat = new Material(RingShader); var mat = new Material(ring.Unlit ? UnlitShader : RingShader);
mat.mainTexture = texture; mat.mainTexture = texture;
mat.renderQueue = 2895; mat.renderQueue = 2895;
ringMR.material = mat; ringMR.material = mat;

View File

@ -13,5 +13,6 @@ namespace NewHorizons.External
public float Inclination { get; set; } public float Inclination { get; set; }
public float LongitudeOfAscendingNode { get; set; } public float LongitudeOfAscendingNode { get; set; }
public string Texture { get; set; } public string Texture { get; set; }
public bool Unlit { get; set; } = true;
} }
} }