Skip to content

Commit

Permalink
Deferred renderer no longer used in MaterialPQS since everything is d…
Browse files Browse the repository at this point in the history
…epth-based, city lights just add their material directly instead of with commandBuffers, improving compatiblity with latest scatterer
  • Loading branch information
LGhassen committed Jun 16, 2021
1 parent 816e24c commit 8f4efdd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"VERSION": {
"MAJOR": 1,
"MINOR": 11,
"PATCH": 2,
"PATCH": 3,
"BUILD": 1
},
"KSP_VERSION": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The MIT License (MIT)

Copyright (c) 2013 Ryan Bray
Copyright (c) 2018 Warwick Allison
Copyright (c) 2021 Ghassen Lahmar

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
45 changes: 38 additions & 7 deletions Utils/MaterialPQS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,53 @@ private void PQSLoaded(CelestialBody body, String s)
}
}

private void AddMaterial(Renderer r)
private void AddMaterial(MeshRenderer meshRenderer)
{
DeferredRenderer.Add(r.gameObject, material, isOcean, body);
if (this.sphere.useSharedMaterial)
{
List<Material> materials = new List<Material>(meshRenderer.sharedMaterials);

if (!materials.Exists(mat => mat.shader.name.Contains(material.shader.name)))
{
materials.Add(material);
meshRenderer.sharedMaterials = materials.ToArray();
}
}
else
{
List<Material> materials = new List<Material>(meshRenderer.materials);

if (!materials.Exists(mat => mat.shader.name.Contains(material.shader.name)))
{
materials.Add(material);
meshRenderer.materials = materials.ToArray();
}
}
}

private void RemoveMaterial(Renderer r)
private void RemoveMaterial(MeshRenderer mr)
{
DeferredRenderer.Remove(r.gameObject, material);
if (this.sphere.useSharedMaterial)
{
List<Material> materials = new List<Material>(mr.sharedMaterials);
materials.Remove(materials.Find(mat => mat.shader.name.Contains(material.shader.name)));

mr.sharedMaterials = materials.ToArray();
}
else
{
List<Material> materials = new List<Material>(mr.materials);
materials.Remove(materials.Find(mat => mat.shader.name.Contains(material.shader.name)));
mr.materials = materials.ToArray();
}
}

private void ApplyToQuadMaterials(PQ pq)
{
Renderer[] renderers = pq.GetComponentsInChildren<Renderer>();
foreach (Renderer r in renderers)
MeshRenderer[] renderers = pq.GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer mr in renderers)
{
AddMaterial(r);
AddMaterial(mr);
}
}

Expand Down
2 changes: 1 addition & 1 deletion _BuildManager/Properties/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.11.2.1")] // KSP version with EVE release number appended; see also CKAN version file.
[assembly: AssemblyVersion("1.11.3.1")] // KSP version with EVE release number appended; see also CKAN version file.

0 comments on commit 8f4efdd

Please sign in to comment.