Skip to content

Commit 24a90af

Browse files
committed
* add auto-enable of DX11 fix when DX11 is detected
* update API warning to 'support' DX11; disable warning for DX11/GLCore * clean up some debug spam
1 parent bc9e08a commit 24a90af

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed
Binary file not shown.

Plugin/SSTUTools/KSPShaderTools/Addon/ReflectionManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class ReflectionManager : MonoBehaviour
4949
public bool renderScaled = true;
5050
public bool renderAtmo = true;
5151
public bool renderScenery = true;
52-
public bool alternateRender = false;
5352

5453
public bool reflectionsEnabled = true;
5554

@@ -107,9 +106,9 @@ public void Awake()
107106
return;
108107
}
109108
ConfigNode node = nodes[0];
110-
MonoBehaviour.print("SSTUReflectionManager - Loading reflection configuration: \n" + node.ToString());
109+
MonoBehaviour.print("TU-Reflection Manager - Loading reflection configuration: \n" + node.ToString());
110+
MonoBehaviour.print("TU-Reflection Manager - Alternate Render Enabled (DX9/DX11 Fix): " + TexturesUnlimitedLoader.alternateRender);
111111
reflectionsEnabled = node.GetBoolValue("enabled", false);
112-
alternateRender = node.GetBoolValue("directXFix", false);
113112
envMapSize = node.GetIntValue("resolution", envMapSize);
114113
mapUpdateSpacing = node.GetIntValue("interval", mapUpdateSpacing);
115114
eveInstalled = node.GetBoolValue("eveInstalled", false);
@@ -186,7 +185,6 @@ public void debugGuiDisable()
186185

187186
public void OnDestroy()
188187
{
189-
MonoBehaviour.print("SSTUReflectionManager OnDestroy()");
190188
if (instance == this) { instance = null; }
191189
if (gui != null)
192190
{
@@ -208,14 +206,12 @@ public void OnDestroy()
208206

209207
private void init()
210208
{
211-
MonoBehaviour.print("SSTUReflectionManager init()");
212209
if (cameraObject == null)
213210
{
214211
cameraObject = new GameObject("TRReflectionCamera");
215212
reflectionCamera = cameraObject.AddComponent<Camera>();
216213
eveCameraFix = cameraObject.AddComponent<CameraAlphaFix>();
217214
reflectionCamera.enabled = false;
218-
MonoBehaviour.print("SSTUReflectionManager created camera: "+reflectionCamera);
219215
}
220216
if (skyboxShader == null)
221217
{
@@ -272,7 +268,7 @@ public void updateReflections()
272268
if (probeData.updateTime >= mapUpdateSpacing)
273269
{
274270
reflectionCamera.gameObject.SetActive(true);
275-
if (alternateRender)
271+
if (TexturesUnlimitedLoader.alternateRender)
276272
{
277273
renderFaceAlt(probeData.renderedCube, probeData.updateFace, vessel.transform.position, probeData.updatePass);
278274
}

Plugin/SSTUTools/KSPShaderTools/Addon/TexturesUnlimitedLoader.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class TexturesUnlimitedLoader : MonoBehaviour
6464
public static int recolorGUISectionHeight = 540;
6565
public static int recolorGUITotalHeight = 100;
6666

67+
public static bool alternateRender = false;
68+
6769
#endregion ENDREGION - Config Values loaded from disk
6870

6971
public static TexturesUnlimitedLoader INSTANCE;
@@ -87,8 +89,28 @@ public void Start()
8789

8890
//check the graphics API, popup warning if using unsupported gfx (dx9/11/12/legacy-openGL)
8991
UnityEngine.Rendering.GraphicsDeviceType graphicsAPI = SystemInfo.graphicsDeviceType;
90-
if (graphicsAPI != UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore)
92+
if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore)
93+
{
94+
//noop, everything is fine
95+
}
96+
else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D11)
97+
{
98+
//works, but needs alternate render
99+
alternateRender = true;
100+
}
101+
else if (graphicsAPI == UnityEngine.Rendering.GraphicsDeviceType.Direct3D9)
102+
{
103+
//has issues -- display warning, and needs alternate render
104+
alternateRender = true;
105+
if (apiCheckGUI == null)
106+
{
107+
apiCheckGUI = this.gameObject.AddComponent<GraphicsAPIGUI>();
108+
apiCheckGUI.openGUI();
109+
}
110+
}
111+
else
91112
{
113+
//unknown API -- display warning
92114
if (apiCheckGUI == null)
93115
{
94116
apiCheckGUI = this.gameObject.AddComponent<GraphicsAPIGUI>();

Plugin/SSTUTools/KSPShaderTools/GUI/GraphicsAPIGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private void drawWindow(int id)
4040
GUILayout.BeginVertical();
4141
GUILayout.Label("The Graphics API Detected: "+ SystemInfo.graphicsDeviceType);
4242
GUILayout.Label("Is unsupported by Textures Unlimited, and some graphics may not render correctly.");
43-
GUILayout.Label("For best results, use the -force-glcore command line option to start KSP using the OpenGL Core graphics API");
43+
GUILayout.Label("For best results, use the -force-d3d11 or -force-glcore command line option to start KSP using either DirectX11 or the OpenGL Core graphics API");
4444
GUILayout.FlexibleSpace();//push button to bottom of window
4545
if (GUILayout.Button("Acknowledge & Close"))
4646
{

Plugin/SSTUTools/KSPShaderTools/GUI/ReflectionDebugGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private void updateWindow(int id)
4040
manager.renderAtmo = addButtonRowToggle("Render Atmo", atmo);
4141
manager.renderScaled = addButtonRowToggle("Render Scaled", scaled);
4242
manager.renderScenery = addButtonRowToggle("Render Scenery", scenery);
43-
manager.alternateRender = addButtonRowToggle("Alternate Render", manager.alternateRender);
43+
TexturesUnlimitedLoader.alternateRender = addButtonRowToggle("Alternate Render", TexturesUnlimitedLoader.alternateRender);
4444
manager.eveInstalled = addButtonRowToggle("Eve Fix", manager.eveInstalled);
4545

4646
if (GUILayout.Button("Toggle Debug Sphere"))

0 commit comments

Comments
 (0)