diff --git a/G-Effects/Configuration.cs b/G-Effects/Configuration.cs index 3abf844..b29381c 100644 --- a/G-Effects/Configuration.cs +++ b/G-Effects/Configuration.cs @@ -24,11 +24,16 @@ public class Configuration public float gLocStartCoeff = 1.1f; //How much more should our poor kerbal suffer after complete loss of vision to have a G-LOC public float gDeathCoeff = 20.0f; //How much more should a kerbal suffer to die of a sustained over-g public bool gDeathEnabled = false; //Will the critical conditions and g-deaths take place or not + public bool IVAOnly = false; //If set to true then g-effects will be rendered in IVA mode only + //Greyout is a post-processing effect. It may conflict with other post-processing effects like b/w cameras etc, so disable greyouts if necessary. + public bool IVAGreyout = true; //Greyout effect in IVA view + public bool mainCamGreyout = false; //mainCam is used in 3rd person view. The effect is disabled by default because it eats up stock reenty and mach visual effects public String gLocScreenWarning = null; //Text of a warning displayed when a kerbal loses consience. Leave empty to disable. public Color redoutRGB = Color.red; //Red, green, blue components of a redout color (in case you are certain that green men must have green blood, for example) public int gLocFadeSpeed = 4; //Speed of fade-out visual effect when a kerbal is losing consciousness - public int breathThresholdTime = 8; //Time threshold in seconds for a kerbal needed to breathe after AGSM + + public int breathThresholdTime = 8; //Time threshold in seconds for a kerbal needed to breathe after AGSM public int maxBreaths = 6; //Maximum possible breath sounds to be played public int minBreaths = 2; //Minimum breath sounds to be played //You can disable specific sound effects by specifying 0 volumes. @@ -38,7 +43,8 @@ public class Configuration public float heartBeatVolume = 1.0f; //Volume of blood beating in kerbal's ears on negative over-G public float femaleVoicePitch = 1.4f; //How much female kerbals' voice pitch is higher than males' one public float breathSoundPitch = 1.8f; //Pitch of heavy breath's sounds - public bool enableLogging = false; //Enable this only in debug purposes as it floods the logs very much + + public bool enableLogging = false; //Enable this only in debug purposes as it floods the logs very much //Kerbal personal modifiers are used as multipliers for the gResistance parameter and also affect the speed of G effects accumulation public float femaleModifier = 1; //How stronger are females than males @@ -89,6 +95,8 @@ public void loadConfiguration(string root) { } else KSPLog.print("" + root + " node not found"); bool.TryParse(nodes[0].GetValue("IVAOnly"), out IVAOnly); + bool.TryParse(nodes[0].GetValue("IVAGreyout"), out IVAGreyout); + bool.TryParse(nodes[0].GetValue("mainCamGreyout"), out mainCamGreyout); gLocScreenWarning = nodes[0].GetValue("gLocScreenWarning"); string redoutColor = nodes[0].GetValue("redoutRGB"); string[] redoutComponents; diff --git a/G-Effects/G-Effects.cs b/G-Effects/G-Effects.cs index a511db0..ac688e4 100644 --- a/G-Effects/G-Effects.cs +++ b/G-Effects/G-Effects.cs @@ -27,14 +27,14 @@ namespace G_Effects [KSPAddon(KSPAddon.Startup.Flight, false)] public class G_Effects : MonoBehaviour { - + //TODO find a way to disable EVA button on G-LOC //TODO simulate orientation loss on G-LOC GEffectsAPIImplementation gEffectsApiImpl = GEffectsAPIImplementation.instance(); KeepFit.KeepFitAPI keepFitAPI = new KeepFit.KeepFitAPI(); - GrayoutCameraFilter flightCameraFilter; - GrayoutCameraFilter internalCameraFilter; + GreyoutCameraFilter flightCameraFilter; + GreyoutCameraFilter internalCameraFilter; const string APP_NAME = "G-Effects"; const string CONTROL_LOCK_ID = "G_EFFECTS_LOCK"; @@ -49,6 +49,7 @@ public class G_Effects : MonoBehaviour double downwardG; double forwardG; bool playEffects = false; + bool greyOutAllowed = false; bool paused = false; readonly static PortraitAgent PORTRAIT_AGENT = new PortraitAgent(); @@ -69,9 +70,6 @@ protected void Start() if (keepFitAPI.initialize()) { writeLog("KeepFit mod detected. Working in conjunction."); } - /*string path = KSPUtil.ApplicationRootPath.Replace(@"\", "/") + "/GameData/G-Effects/blackout.png"; - byte[] texture = File.ReadAllBytes(path); - blackoutTexture.LoadImage(texture);*/ if (blackoutTexture == null) { blackoutTexture = GameDatabase.Instance.GetTexture("G-Effects/blackout", false); } @@ -82,8 +80,6 @@ protected void Start() GameEvents.onGameUnpause.Add(onUnPause); GameEvents.onCrewKilled.Add(onCrewKilled); GameEvents.onVesselChange.Add(onVesselChange); - // Add another rendering queue hook for the GUI - //RenderingManager.AddToPostDrawQueue(4, new Callback(drawGUI)); PORTRAIT_AGENT.Start(); } @@ -133,14 +129,6 @@ void resetValues() { internalCameraFilter.setBypass(true); } - GrayoutCameraFilter initializeCameraFilter(Camera camera) { - GrayoutCameraFilter filter = camera.gameObject.GetComponent(); - if (filter == null) { - filter = camera.gameObject.AddComponent(); - } - return filter; - } - protected void Awake() { conf.loadConfiguration(APP_NAME.ToUpper()); @@ -148,8 +136,8 @@ protected void Awake() { gAudio.initialize(conf.gruntsVolume, conf.breathVolume, conf.heartBeatVolume, conf.femaleVoicePitch, conf.breathSoundPitch); } - flightCameraFilter = initializeCameraFilter(FlightCamera.fetch.mainCamera); - internalCameraFilter = initializeCameraFilter(InternalCamera.Instance.camera); + flightCameraFilter = GreyoutCameraFilter.initializeCameraFilter(FlightCamera.fetch.mainCamera, conf.mainCamGreyout); + internalCameraFilter = GreyoutCameraFilter.initializeCameraFilter(InternalCamera.Instance.camera, conf.IVAGreyout); } public void Update() { @@ -201,6 +189,7 @@ public void Update() { (!conf.IVAOnly || isIVA) && !MapView.MapIsEnabled; + greyOutAllowed = isIVA && conf.IVAGreyout || !isIVA && conf.mainCamGreyout; flightCameraFilter.setBypass(isIVA || !playEffects); internalCameraFilter.setBypass(!isIVA || !playEffects); gAudio.setAudioEnabled(playEffects); @@ -234,7 +223,7 @@ public void Update() { gState.cumulativeG -= Math.Sign(gState.cumulativeG) * conf.gResistance * kerbalModifier; //gAudio.applyFilter(1 - Mathf.Clamp01((float)(1.25 * Math.Pow(Math.Abs(gData.cumulativeG) / conf.MAX_CUMULATIVE_G, 2) - 0.2))); - doGrayout(gState); + doGreyout(gState); if ((downwardG > conf.positiveThreshold) || (downwardG < conf.negativeThreshold) || (forwardG > conf.positiveThreshold) || (forwardG < conf.negativeThreshold)) { double rebCompensation = conf.gResistance * kerbalModifier - conf.deltaGTolerance * conf.deltaGTolerance / kerbalModifier; //this is calculated so the rebound is in equilibrium with cumulativeG at the very point of G threshold @@ -342,17 +331,6 @@ ProtoCrewMember bestCommander(ProtoCrewMember current, ProtoCrewMember candidate } } - void doGrayout(KerbalGState gState) { - float grayout = Mathf.Clamp(2 * gState.getSeverity(), 0f, 1.0f); - if (gState.cumulativeG > 0) { - flightCameraFilter.setMagnitude(grayout); - internalCameraFilter.setMagnitude(grayout); - } else { - flightCameraFilter.setMagnitude(0.0f); - internalCameraFilter.setMagnitude(0.0f); - } - } - void loseConsciousness(ProtoCrewMember crewMember, KerbalGState kerbalGData, bool isCommander, bool outputAllowed) { kerbalGData.stopAGSM(0); kerbalGData.resetBreath(); @@ -395,6 +373,17 @@ bool isRosterDead(ProtoCrewMember crewMember) { return crewMember.rosterStatus.Equals(ProtoCrewMember.RosterStatus.Dead) || crewMember.rosterStatus.Equals(ProtoCrewMember.RosterStatus.Missing); } + void doGreyout(KerbalGState gState) { + if (gState.cumulativeG > 0) { + float greyout = Mathf.Pow(Mathf.Clamp(gState.getSeverity() / 0.4f, 0f, 1.0f), 2); //Severity is divided by a percent of the total blackout at which greyout should be complete + flightCameraFilter.setMagnitude(greyout); + internalCameraFilter.setMagnitude(greyout); + } else { + flightCameraFilter.setMagnitude(0.0f); + internalCameraFilter.setMagnitude(0.0f); + } + } + void drawGEffects() { if (!playEffects) { @@ -422,7 +411,7 @@ void drawGEffects() colorFill.r = colorOut.r; colorFill.g = colorOut.g; colorFill.b = colorOut.b; - colorFill.a = (float)Math.Pow(severity, kerbalGData.cumulativeG > 0 ? 8 : 4); //this will intensify blackout/redout effect at the very end + colorFill.a = (float)Math.Pow(severity, 4); //this will intensify blackout/redout effect at the very end //The following will fade out in overlay whatever is diplayed if losing consciousness or fade in on wake up float fade = (float)(kerbalGData.gLocFadeAmount * kerbalGData.gLocFadeAmount) / (float)(MAX_GLOC_FADE * MAX_GLOC_FADE); diff --git a/G-Effects/G-Effects.csproj b/G-Effects/G-Effects.csproj index 892c92a..f49558a 100644 --- a/G-Effects/G-Effects.csproj +++ b/G-Effects/G-Effects.csproj @@ -42,7 +42,7 @@ - + diff --git a/G-Effects/GrayoutCameraFilter.cs b/G-Effects/GreyoutCameraFilter.cs similarity index 61% rename from G-Effects/GrayoutCameraFilter.cs rename to G-Effects/GreyoutCameraFilter.cs index c14a1d6..b9f831d 100644 --- a/G-Effects/GrayoutCameraFilter.cs +++ b/G-Effects/GreyoutCameraFilter.cs @@ -7,18 +7,35 @@ namespace G_Effects /// /// Camera filter that provides picture gray out effect /// - public class GrayoutCameraFilter : MonoBehaviour + public class GreyoutCameraFilter : MonoBehaviour { static Material material; bool bypass = true; float magnitude = 0; - public GrayoutCameraFilter() + public GreyoutCameraFilter() : this(true) { + } + + //In case actualEffect = false the filter is just a dummy + public GreyoutCameraFilter(bool actualEffect) { - if (material == null) { - material = loadShader("grayout.shader"); + if (actualEffect && material == null) { + material = loadShader("greyout.shader"); + } + } + + public static GreyoutCameraFilter initializeCameraFilter(Camera camera, bool actualFilter) { + GreyoutCameraFilter filter; + if (actualFilter) { + filter = camera.gameObject.GetComponent(); + if (filter == null) { + filter = camera.gameObject.AddComponent(); + } + } else { + filter = new GreyoutCameraFilter(false); } + return filter; } public void setBypass(bool bypass) { diff --git a/G-Effects/Properties/AssemblyInfo.cs b/G-Effects/Properties/AssemblyInfo.cs index 8a1e00f..ca3c255 100644 --- a/G-Effects/Properties/AssemblyInfo.cs +++ b/G-Effects/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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("0.2.3")] -[assembly: AssemblyFileVersion("0.2.3")] +[assembly: AssemblyVersion("0.3.1")] +[assembly: AssemblyFileVersion("0.3.1")] diff --git a/G-Effects/Shaders_source/grayout.shader b/G-Effects/Shaders_source/grayout.shader deleted file mode 100644 index 9baaf9b..0000000 --- a/G-Effects/Shaders_source/grayout.shader +++ /dev/null @@ -1,47 +0,0 @@ -Shader "Custom/GrayScale" { -Properties { - _MainTex ("", 2D) = "white" {} - _Magnitude("Magnitude", Float) = 0.0 -} - -SubShader { - - Pass{ - CGPROGRAM - #pragma vertex vert - #pragma fragment frag - #include "UnityCG.cginc" - - uniform fixed _Magnitude; - - struct v2f { - float4 pos : POSITION; - half2 uv : TEXCOORD0; - }; - - v2f vert (appdata_img v){ - v2f o; - o.pos = mul (UNITY_MATRIX_MVP, v.vertex); - o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord.xy); - return o; - } - - sampler2D _MainTex; //Reference in Pass is necessary to let us use this variable in shaders - - fixed4 frag (v2f i) : COLOR{ - fixed4 inColor = tex2D(_MainTex, i.uv); //Get the orginal rendered color - - float average = (0.299*inColor.r + 0.587*inColor.g + 0.114*inColor.b)/3.0; - fixed4 outColor = {lerp(inColor.r, average, _Magnitude), - lerp(inColor.g, average, _Magnitude), - lerp(inColor.b, average, _Magnitude), - inColor.a}; - fixed4(average, average, average, 1); - - return outColor; - } - ENDCG - } -} - FallBack "Diffuse" -} \ No newline at end of file diff --git a/G-Effects/Shaders_source/greyout.shader b/G-Effects/Shaders_source/greyout.shader new file mode 100644 index 0000000..31e71fe --- /dev/null +++ b/G-Effects/Shaders_source/greyout.shader @@ -0,0 +1,31 @@ +Shader "G-Effects/Greyout" { + Properties { + _MainTex ("Base (RGB)", 2D) = "white" {} + _Magnitude ("Magnitude", Range (0, 1)) = 0 + } + SubShader { + Pass { + CGPROGRAM + #pragma vertex vert_img + #pragma fragment frag + + #include "UnityCG.cginc" + + uniform sampler2D _MainTex; + uniform float _Magnitude; + + float4 frag(v2f_img input) : COLOR { + float4 color = tex2D(_MainTex, input.uv); + + float average = 0.299*color.r + 0.587*color.g + 0.114*color.b; + float3 greycolor = float3(average, average, average); + + float4 result = color; + result.rgb = lerp(color.rgb, greycolor, _Magnitude); + return result; + } + ENDCG + } + } + Fallback "Diffuse" +} \ No newline at end of file diff --git a/GameData/G-Effects/G-Effects.cfg b/GameData/G-Effects/G-Effects.cfg index ab4c8a2..0a6b391 100644 --- a/GameData/G-Effects/G-Effects.cfg +++ b/GameData/G-Effects/G-Effects.cfg @@ -12,6 +12,9 @@ G-EFFECTS { gDeathEnabled = true //Will the critical conditions and g-deaths take place or not IVAOnly = false //If set to true visual and sound effects will be rendered in IVA mode only but physical effects like G-LOC and loss of control will remain in all views + //Greyout is a post-processing effect. It may conflict with other post-processing effects like b/w cameras etc, so disable greyouts if necessary. + IVAGreyout = true //Greyout effect in IVA view + mainCamGreyout = false //mainCam is used in 3rd person view. The effect is disabled by default because it eats up stock reenty and mach visual effects gLocFadeSpeed = 4 //Speed of fade-out visual effect when a kerbal is losing consciousness gLocScreenWarning = UNCONSCIOUS //Text of a warning displayed when a kerbal loses consciousness. Leave empty to disable. redoutRGB = 180,0,0 //Red, green, blue components of redout color (you can change it even to greenout in case you are certain that green men must have green blood) diff --git a/GameData/G-Effects/Plugins/G-Effects.dll b/GameData/G-Effects/Plugins/G-Effects.dll index 805e34a..d4fc664 100644 Binary files a/GameData/G-Effects/Plugins/G-Effects.dll and b/GameData/G-Effects/Plugins/G-Effects.dll differ diff --git a/GameData/G-Effects/Shaders/grayout.shader b/GameData/G-Effects/Shaders/greyout.shader similarity index 62% rename from GameData/G-Effects/Shaders/grayout.shader rename to GameData/G-Effects/Shaders/greyout.shader index 48ba98a..601570b 100644 --- a/GameData/G-Effects/Shaders/grayout.shader +++ b/GameData/G-Effects/Shaders/greyout.shader @@ -1,9 +1,9 @@ -// Compiled shader for all platforms, uncompressed size: 17.1KB +// Compiled shader for all platforms, uncompressed size: 15.5KB -Shader "Custom/GrayScale" { +Shader "G-Effects/Greyout" { Properties { - _MainTex ("", 2D) = "white" {} - _Magnitude ("Magnitude", Float) = 0 + _MainTex ("Base (RGB)", 2D) = "white" {} + _Magnitude ("Magnitude", Range(0,1)) = 0 } SubShader { @@ -12,17 +12,17 @@ SubShader { // d3d11 : 6 math // d3d11_9x : 6 math // d3d9 : 8 math - // gles : 7 math, 1 texture - // gles3 : 7 math, 1 texture - // glesdesktop : 7 math, 1 texture + // gles : 6 math, 1 texture + // gles3 : 6 math, 1 texture + // glesdesktop : 6 math, 1 texture // metal : 3 math // opengl : 8 math // Stats for Fragment shader: // d3d11 : 3 math, 1 texture // d3d11_9x : 3 math, 1 texture - // d3d9 : 11 math, 1 texture - // metal : 7 math, 1 texture - // opengl : 11 math, 1 texture + // d3d9 : 7 math, 1 texture + // metal : 6 math, 1 texture + // opengl : 7 math, 1 texture Pass { Program "vp" { SubProgram "opengl " { @@ -77,13 +77,13 @@ Matrix 512 [glstate_matrix_texture0] BindCB "UnityPerDraw" 0 BindCB "UnityPerDrawTexMatrices" 1 "vs_4_0 -eefiecedjlfomejbofdklfcgafioaaodagpgfnjcabaaaaaaciacaaaaadaaaaaa +eefiecedeedelkdobbmimfefjdhgabnhlefmpcmlabaaaaaaciacaaaaadaaaaaa cmaaaaaaiaaaaaaaniaaaaaaejfdeheoemaaaaaaacaaaaaaaiaaaaaadiaaaaaa aaaaaaaaaaaaaaaaadaaaaaaaaaaaaaaapapaaaaebaaaaaaaaaaaaaaaaaaaaaa adaaaaaaabaaaaaaadadaaaafaepfdejfeejepeoaafeeffiedepepfceeaaklkl epfdeheofaaaaaaaacaaaaaaaiaaaaaadiaaaaaaaaaaaaaaabaaaaaaadaaaaaa aaaaaaaaapaaaaaaeeaaaaaaaaaaaaaaaaaaaaaaadaaaaaaabaaaaaaadamaaaa -fdfgfpfagphdgjhegjgpgoaafeeffiedepepfceeaaklklklfdeieefceiabaaaa +fdfgfpfaepfdejfeejepeoaafeeffiedepepfceeaaklklklfdeieefceiabaaaa eaaaabaafcaaaaaafjaaaaaeegiocaaaaaaaaaaaaeaaaaaafjaaaaaeegiocaaa abaaaaaaccaaaaaafpaaaaadpcbabaaaaaaaaaaafpaaaaaddcbabaaaabaaaaaa ghaaaaaepccabaaaaaaaaaaaabaaaaaagfaaaaaddccabaaaabaaaaaagiaaaaac @@ -107,7 +107,7 @@ Matrix 512 [glstate_matrix_texture0] BindCB "UnityPerDraw" 0 BindCB "UnityPerDrawTexMatrices" 1 "vs_4_0_level_9_1 -eefiecedkjfdmdegebiaplcnddhiannceeeaamhgabaaaaaaceadaaaaaeaaaaaa +eefieceddhnbicbokkmhnihbiniipgnpnicndjjjabaaaaaaceadaaaaaeaaaaaa daaaaaaaciabaaaahiacaaaammacaaaaebgpgodjpaaaaaaapaaaaaaaaaacpopp laaaaaaaeaaaaaaaacaaceaaaaaadmaaaaaadmaaaaaaceaaabaadmaaaaaaaaaa aeaaabaaaaaaaaaaabaacaaaacaaafaaaaaaaaaaaaaaaaaaaaacpoppbpaaaaac @@ -131,11 +131,11 @@ acaaaaaaaiaaaaaadiaaaaaaaaaaaaaaaaaaaaaaadaaaaaaaaaaaaaaapapaaaa ebaaaaaaaaaaaaaaaaaaaaaaadaaaaaaabaaaaaaadadaaaafaepfdejfeejepeo aafeeffiedepepfceeaaklklepfdeheofaaaaaaaacaaaaaaaiaaaaaadiaaaaaa aaaaaaaaabaaaaaaadaaaaaaaaaaaaaaapaaaaaaeeaaaaaaaaaaaaaaaaaaaaaa -adaaaaaaabaaaaaaadamaaaafdfgfpfagphdgjhegjgpgoaafeeffiedepepfcee +adaaaaaaabaaaaaaadamaaaafdfgfpfaepfdejfeejepeoaafeeffiedepepfcee aaklklkl" } SubProgram "gles " { -// Stats: 7 math, 1 textures +// Stats: 6 math, 1 textures "!!GLES @@ -168,27 +168,23 @@ void main () #endif #ifdef FRAGMENT -uniform lowp float _Magnitude; uniform sampler2D _MainTex; +uniform highp float _Magnitude; varying mediump vec2 xlv_TEXCOORD0; void main () { - lowp vec4 outColor_1; - highp float average_2; + highp vec4 result_1; + highp vec4 color_2; lowp vec4 tmpvar_3; tmpvar_3 = texture2D (_MainTex, xlv_TEXCOORD0); - lowp float tmpvar_4; - tmpvar_4 = ((( - (0.299 * tmpvar_3.x) + color_2 = tmpvar_3; + result_1.w = color_2.w; + result_1.xyz = mix (color_2.xyz, vec3((( + (0.299 * color_2.x) + - (0.587 * tmpvar_3.y) - ) + (0.114 * tmpvar_3.z)) / 3.0); - average_2 = tmpvar_4; - highp vec4 tmpvar_5; - tmpvar_5.xyz = mix (tmpvar_3.xyz, vec3(average_2), vec3(_Magnitude)); - tmpvar_5.w = tmpvar_3.w; - outColor_1 = tmpvar_5; - gl_FragData[0] = outColor_1; + (0.587 * color_2.y) + ) + (0.114 * color_2.z))), vec3(_Magnitude)); + gl_FragData[0] = result_1; } @@ -215,7 +211,7 @@ aaaaaaaaaaaaamaeaaaaaaoeabaaaaaaaaaaaaaaaaaaaaaa mov v0.zw, c0 " } SubProgram "glesdesktop " { -// Stats: 7 math, 1 textures +// Stats: 6 math, 1 textures "!!GLES @@ -248,27 +244,23 @@ void main () #endif #ifdef FRAGMENT -uniform lowp float _Magnitude; uniform sampler2D _MainTex; +uniform highp float _Magnitude; varying mediump vec2 xlv_TEXCOORD0; void main () { - lowp vec4 outColor_1; - highp float average_2; + highp vec4 result_1; + highp vec4 color_2; lowp vec4 tmpvar_3; tmpvar_3 = texture2D (_MainTex, xlv_TEXCOORD0); - lowp float tmpvar_4; - tmpvar_4 = ((( - (0.299 * tmpvar_3.x) + color_2 = tmpvar_3; + result_1.w = color_2.w; + result_1.xyz = mix (color_2.xyz, vec3((( + (0.299 * color_2.x) + - (0.587 * tmpvar_3.y) - ) + (0.114 * tmpvar_3.z)) / 3.0); - average_2 = tmpvar_4; - highp vec4 tmpvar_5; - tmpvar_5.xyz = mix (tmpvar_3.xyz, vec3(average_2), vec3(_Magnitude)); - tmpvar_5.w = tmpvar_3.w; - outColor_1 = tmpvar_5; - gl_FragData[0] = outColor_1; + (0.587 * color_2.y) + ) + (0.114 * color_2.z))), vec3(_Magnitude)); + gl_FragData[0] = result_1; } @@ -276,7 +268,7 @@ void main () #endif" } SubProgram "gles3 " { -// Stats: 7 math, 1 textures +// Stats: 6 math, 1 textures "!!GLES3#version 300 es @@ -312,27 +304,23 @@ void main () layout(location=0) out mediump vec4 _glesFragData[4]; -uniform lowp float _Magnitude; uniform sampler2D _MainTex; +uniform highp float _Magnitude; in mediump vec2 xlv_TEXCOORD0; void main () { - lowp vec4 outColor_1; - highp float average_2; + highp vec4 result_1; + highp vec4 color_2; lowp vec4 tmpvar_3; tmpvar_3 = texture (_MainTex, xlv_TEXCOORD0); - lowp float tmpvar_4; - tmpvar_4 = ((( - (0.299 * tmpvar_3.x) + color_2 = tmpvar_3; + result_1.w = color_2.w; + result_1.xyz = mix (color_2.xyz, vec3((( + (0.299 * color_2.x) + - (0.587 * tmpvar_3.y) - ) + (0.114 * tmpvar_3.z)) / 3.0); - average_2 = tmpvar_4; - highp vec4 tmpvar_5; - tmpvar_5.xyz = mix (tmpvar_3.xyz, vec3(average_2), vec3(_Magnitude)); - tmpvar_5.w = tmpvar_3.w; - outColor_1 = tmpvar_5; - _glesFragData[0] = outColor_1; + (0.587 * color_2.y) + ) + (0.114 * color_2.z))), vec3(_Magnitude)); + _glesFragData[0] = result_1; } @@ -385,49 +373,41 @@ vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], } Program "fp" { SubProgram "opengl " { -// Stats: 11 math, 1 textures +// Stats: 7 math, 1 textures Float 0 [_Magnitude] SetTexture 0 [_MainTex] 2D 0 "!!ARBfp1.0 PARAM c[2] = { program.local[0], - { 0.11401367, 0.29907227, 0.58691406, 0.33333334 } }; + { 0.29899999, 0.58700001, 0.114 } }; TEMP R0; TEMP R1; TEX R0, fragment.texcoord[0], texture[0], 2D; -MUL R1.x, R0.y, c[1].z; -MAD R1.x, R0, c[1].y, R1; -MAD R1.x, R0.z, c[1], R1; -MAD R1.y, R1.x, c[1].w, -R0.x; -MAD result.color.x, R1.y, c[0], R0; -MAD R0.x, R1, c[1].w, -R0.y; -MAD R1.x, R1, c[1].w, -R0.z; -MAD result.color.y, R0.x, c[0].x, R0; -MAD result.color.z, R1.x, c[0].x, R0; +MUL R1.x, R0.y, c[1].y; +MAD R1.x, R0, c[1], R1; +MAD R1.x, R0.z, c[1].z, R1; +ADD R1.xyz, R1.x, -R0; +MAD result.color.xyz, R1, c[0].x, R0; MOV result.color.w, R0; END -# 11 instructions, 2 R-regs +# 7 instructions, 2 R-regs " } SubProgram "d3d9 " { -// Stats: 11 math, 1 textures +// Stats: 7 math, 1 textures Float 0 [_Magnitude] SetTexture 0 [_MainTex] 2D 0 "ps_2_0 dcl_2d s0 -def c1, 0.58691406, 0.29907227, 0.11401367, 0.33333334 +def c1, 0.58700001, 0.29899999, 0.11400000, 0 dcl t0.xy -texld r3, t0, s0 -mul_pp r0.x, r3.y, c1 -mad_pp r0.x, r3, c1.y, r0 -mad_pp r0.x, r3.z, c1.z, r0 -mad_pp r2.x, r0, c1.w, -r3 -mad_pp r1.x, r0, c1.w, -r3.y -mad_pp r0.x, r0, c1.w, -r3.z -mad_pp r2.x, r2, c0, r3 -mad_pp r2.y, r1.x, c0.x, r3 -mov_pp r2.w, r3 -mad_pp r2.z, r0.x, c0.x, r3 -mov_pp oC0, r2 +texld r1, t0, s0 +mul r0.x, r1.y, c1 +mad r0.x, r1, c1.y, r0 +mad r0.x, r1.z, c1.z, r0 +add r0.xyz, r0.x, -r1 +mov r0.w, r1 +mad r0.xyz, r0, c0.x, r1 +mov oC0, r0 " } SubProgram "d3d11 " { @@ -437,21 +417,21 @@ ConstBuffer "$Globals" 32 Float 16 [_Magnitude] BindCB "$Globals" 0 "ps_4_0 -eefiecedncgiodibdhgjdojdfjooplgbmjclmjofabaaaaaaneabaaaaadaaaaaa +eefiecedkkdnenlinafopjmikmealadafomnloggabaaaaaamaabaaaaadaaaaaa cmaaaaaaieaaaaaaliaaaaaaejfdeheofaaaaaaaacaaaaaaaiaaaaaadiaaaaaa aaaaaaaaabaaaaaaadaaaaaaaaaaaaaaapaaaaaaeeaaaaaaaaaaaaaaaaaaaaaa -adaaaaaaabaaaaaaadadaaaafdfgfpfagphdgjhegjgpgoaafeeffiedepepfcee +adaaaaaaabaaaaaaadadaaaafdfgfpfaepfdejfeejepeoaafeeffiedepepfcee aaklklklepfdeheocmaaaaaaabaaaaaaaiaaaaaacaaaaaaaaaaaaaaaaaaaaaaa -adaaaaaaaaaaaaaaapaaaaaafdfgfpfegbhcghgfheaaklklfdeieefcbeabaaaa -eaaaaaaaefaaaaaafjaaaaaeegiocaaaaaaaaaaaacaaaaaafkaaaaadaagabaaa +adaaaaaaaaaaaaaaapaaaaaafdfgfpfegbhcghgfheaaklklfdeieefcaaabaaaa +eaaaaaaaeaaaaaaafjaaaaaeegiocaaaaaaaaaaaacaaaaaafkaaaaadaagabaaa aaaaaaaafibiaaaeaahabaaaaaaaaaaaffffaaaagcbaaaaddcbabaaaabaaaaaa gfaaaaadpccabaaaaaaaaaaagiaaaaacacaaaaaaefaaaaajpcaabaaaaaaaaaaa egbabaaaabaaaaaaeghobaaaaaaaaaaaaagabaaaaaaaaaaabaaaaaakbcaabaaa abaaaaaaegacbaaaaaaaaaaaaceaaaaaihbgjjdokcefbgdpnfhiojdnaaaaaaaa -dcaaaaanhcaabaaaabaaaaaaagaabaaaabaaaaaaaceaaaaaklkkkkdoklkkkkdo -klkkkkdoaaaaaaaaegacbaiaebaaaaaaaaaaaaaadcaaaaakhccabaaaaaaaaaaa -agiacaaaaaaaaaaaabaaaaaaegacbaaaabaaaaaaegacbaaaaaaaaaaadgaaaaaf -iccabaaaaaaaaaaadkaabaaaaaaaaaaadoaaaaab" +aaaaaaaihcaabaaaabaaaaaaegacbaiaebaaaaaaaaaaaaaaagaabaaaabaaaaaa +dcaaaaakhccabaaaaaaaaaaaagiacaaaaaaaaaaaabaaaaaaegacbaaaabaaaaaa +egacbaaaaaaaaaaadgaaaaaficcabaaaaaaaaaaadkaabaaaaaaaaaaadoaaaaab +" } SubProgram "d3d11_9x " { // Stats: 3 math, 1 textures @@ -460,31 +440,28 @@ ConstBuffer "$Globals" 32 Float 16 [_Magnitude] BindCB "$Globals" 0 "ps_4_0_level_9_1 -eefiecedicmjhpgphioiffnjccpichelbbagpeniabaaaaaabiadaaaaaeaaaaaa -daaaaaaahaabaaaaimacaaaaoeacaaaaebgpgodjdiabaaaadiabaaaaaaacpppp -aeabaaaadeaaaaaaabaaciaaaaaadeaaaaaadeaaabaaceaaaaaadeaaaaaaaaaa +eefiecedfcjlhdljbpognhfmhmmbofnieimhlogeabaaaaaakmacaaaaaeaaaaaa +daaaaaaabiabaaaacaacaaaahiacaaaaebgpgodjoaaaaaaaoaaaaaaaaaacpppp +kmaaaaaadeaaaaaaabaaciaaaaaadeaaaaaadeaaabaaceaaaaaadeaaaaaaaaaa aaaaabaaabaaaaaaaaaaaaaaaaacppppfbaaaaafabaaapkakcefbgdpihbgjjdo -nfhiojdnklkkkkdobpaaaaacaaaaaaiaaaaacdlabpaaaaacaaaaaajaaaaiapka -ecaaaaadaaaacpiaaaaaoelaaaaioekaafaaaaadabaaciiaaaaaffiaabaaaaka -aeaaaaaeabaacbiaaaaaaaiaabaaffkaabaappiaaeaaaaaeabaacbiaaaaakkia -abaakkkaabaaaaiaaeaaaaaeabaaaciaabaaaaiaabaappkaaaaaaaibaeaaaaae -aaaacbiaaaaaaakaabaaffiaaaaaaaiaaeaaaaaeabaaaciaabaaaaiaabaappka -aaaaffibaeaaaaaeabaaabiaabaaaaiaabaappkaaaaakkibaeaaaaaeaaaaceia -aaaaaakaabaaaaiaaaaakkiaaeaaaaaeaaaacciaaaaaaakaabaaffiaaaaaffia -abaaaaacaaaicpiaaaaaoeiappppaaaafdeieefcbeabaaaaeaaaaaaaefaaaaaa -fjaaaaaeegiocaaaaaaaaaaaacaaaaaafkaaaaadaagabaaaaaaaaaaafibiaaae -aahabaaaaaaaaaaaffffaaaagcbaaaaddcbabaaaabaaaaaagfaaaaadpccabaaa -aaaaaaaagiaaaaacacaaaaaaefaaaaajpcaabaaaaaaaaaaaegbabaaaabaaaaaa -eghobaaaaaaaaaaaaagabaaaaaaaaaaabaaaaaakbcaabaaaabaaaaaaegacbaaa -aaaaaaaaaceaaaaaihbgjjdokcefbgdpnfhiojdnaaaaaaaadcaaaaanhcaabaaa -abaaaaaaagaabaaaabaaaaaaaceaaaaaklkkkkdoklkkkkdoklkkkkdoaaaaaaaa -egacbaiaebaaaaaaaaaaaaaadcaaaaakhccabaaaaaaaaaaaagiacaaaaaaaaaaa -abaaaaaaegacbaaaabaaaaaaegacbaaaaaaaaaaadgaaaaaficcabaaaaaaaaaaa -dkaabaaaaaaaaaaadoaaaaabejfdeheofaaaaaaaacaaaaaaaiaaaaaadiaaaaaa -aaaaaaaaabaaaaaaadaaaaaaaaaaaaaaapaaaaaaeeaaaaaaaaaaaaaaaaaaaaaa -adaaaaaaabaaaaaaadadaaaafdfgfpfagphdgjhegjgpgoaafeeffiedepepfcee -aaklklklepfdeheocmaaaaaaabaaaaaaaiaaaaaacaaaaaaaaaaaaaaaaaaaaaaa -adaaaaaaaaaaaaaaapaaaaaafdfgfpfegbhcghgfheaaklkl" +nfhiojdnaaaaaaaabpaaaaacaaaaaaiaaaaacdlabpaaaaacaaaaaajaaaaiapka +ecaaaaadaaaaapiaaaaaoelaaaaioekaafaaaaadabaaaiiaaaaaffiaabaaaaka +aeaaaaaeabaaabiaaaaaaaiaabaaffkaabaappiaaeaaaaaeabaaabiaaaaakkia +abaakkkaabaaaaiabcaaaaaeacaaahiaaaaaaakaabaaaaiaaaaaoeiaabaaaaac +acaaaiiaaaaappiaabaaaaacaaaiapiaacaaoeiappppaaaafdeieefcaaabaaaa +eaaaaaaaeaaaaaaafjaaaaaeegiocaaaaaaaaaaaacaaaaaafkaaaaadaagabaaa +aaaaaaaafibiaaaeaahabaaaaaaaaaaaffffaaaagcbaaaaddcbabaaaabaaaaaa +gfaaaaadpccabaaaaaaaaaaagiaaaaacacaaaaaaefaaaaajpcaabaaaaaaaaaaa +egbabaaaabaaaaaaeghobaaaaaaaaaaaaagabaaaaaaaaaaabaaaaaakbcaabaaa +abaaaaaaegacbaaaaaaaaaaaaceaaaaaihbgjjdokcefbgdpnfhiojdnaaaaaaaa +aaaaaaaihcaabaaaabaaaaaaegacbaiaebaaaaaaaaaaaaaaagaabaaaabaaaaaa +dcaaaaakhccabaaaaaaaaaaaagiacaaaaaaaaaaaabaaaaaaegacbaaaabaaaaaa +egacbaaaaaaaaaaadgaaaaaficcabaaaaaaaaaaadkaabaaaaaaaaaaadoaaaaab +ejfdeheofaaaaaaaacaaaaaaaiaaaaaadiaaaaaaaaaaaaaaabaaaaaaadaaaaaa +aaaaaaaaapaaaaaaeeaaaaaaaaaaaaaaaaaaaaaaadaaaaaaabaaaaaaadadaaaa +fdfgfpfaepfdejfeejepeoaafeeffiedepepfceeaaklklklepfdeheocmaaaaaa +abaaaaaaaiaaaaaacaaaaaaaaaaaaaaaaaaaaaaaadaaaaaaaaaaaaaaapaaaaaa +fdfgfpfegbhcghgfheaaklkl" } SubProgram "gles " { "!!GLES" @@ -493,28 +470,19 @@ SubProgram "flash " { Float 0 [_Magnitude] SetTexture 0 [_MainTex] 2D 0 "agal_ps -c1 0.586914 0.299072 0.114014 0.333333 +c1 0.587 0.299 0.114 0.0 [bc] -ciaaaaaaadaaapacaaaaaaoeaeaaaaaaaaaaaaaaafaababb tex r3, v0, s0 <2d wrap linear point> -adaaaaaaaaaaabacadaaaaffacaaaaaaabaaaaoeabaaaaaa mul r0.x, r3.y, c1 -adaaaaaaaaaaacacadaaaaaaacaaaaaaabaaaaffabaaaaaa mul r0.y, r3.x, c1.y -abaaaaaaaaaaabacaaaaaaffacaaaaaaaaaaaaaaacaaaaaa add r0.x, r0.y, r0.x -adaaaaaaabaaabacadaaaakkacaaaaaaabaaaakkabaaaaaa mul r1.x, r3.z, c1.z -abaaaaaaaaaaabacabaaaaaaacaaaaaaaaaaaaaaacaaaaaa add r0.x, r1.x, r0.x -adaaaaaaabaaacacaaaaaaaaacaaaaaaabaaaappabaaaaaa mul r1.y, r0.x, c1.w -acaaaaaaacaaabacabaaaaffacaaaaaaadaaaaaaacaaaaaa sub r2.x, r1.y, r3.x -adaaaaaaaeaaabacaaaaaaaaacaaaaaaabaaaappabaaaaaa mul r4.x, r0.x, c1.w -acaaaaaaabaaabacaeaaaaaaacaaaaaaadaaaaffacaaaaaa sub r1.x, r4.x, r3.y -adaaaaaaaeaaabacaaaaaaaaacaaaaaaabaaaappabaaaaaa mul r4.x, r0.x, c1.w -acaaaaaaaaaaabacaeaaaaaaacaaaaaaadaaaakkacaaaaaa sub r0.x, r4.x, r3.z -adaaaaaaacaaabacacaaaaaaacaaaaaaaaaaaaoeabaaaaaa mul r2.x, r2.x, c0 -abaaaaaaacaaabacacaaaaaaacaaaaaaadaaaaaaacaaaaaa add r2.x, r2.x, r3.x -adaaaaaaacaaacacabaaaaaaacaaaaaaaaaaaaaaabaaaaaa mul r2.y, r1.x, c0.x -abaaaaaaacaaacacacaaaaffacaaaaaaadaaaaffacaaaaaa add r2.y, r2.y, r3.y -aaaaaaaaacaaaiacadaaaappacaaaaaaaaaaaaaaaaaaaaaa mov r2.w, r3.w -adaaaaaaacaaaeacaaaaaaaaacaaaaaaaaaaaaaaabaaaaaa mul r2.z, r0.x, c0.x -abaaaaaaacaaaeacacaaaakkacaaaaaaadaaaakkacaaaaaa add r2.z, r2.z, r3.z -aaaaaaaaaaaaapadacaaaaoeacaaaaaaaaaaaaaaaaaaaaaa mov o0, r2 +ciaaaaaaabaaapacaaaaaaoeaeaaaaaaaaaaaaaaafaababb tex r1, v0, s0 <2d wrap linear point> +adaaaaaaaaaaabacabaaaaffacaaaaaaabaaaaoeabaaaaaa mul r0.x, r1.y, c1 +adaaaaaaacaaabacabaaaaaaacaaaaaaabaaaaffabaaaaaa mul r2.x, r1.x, c1.y +abaaaaaaaaaaabacacaaaaaaacaaaaaaaaaaaaaaacaaaaaa add r0.x, r2.x, r0.x +adaaaaaaacaaabacabaaaakkacaaaaaaabaaaakkabaaaaaa mul r2.x, r1.z, c1.z +abaaaaaaaaaaabacacaaaaaaacaaaaaaaaaaaaaaacaaaaaa add r0.x, r2.x, r0.x +acaaaaaaaaaaahacaaaaaaaaacaaaaaaabaaaakeacaaaaaa sub r0.xyz, r0.x, r1.xyzz +aaaaaaaaaaaaaiacabaaaappacaaaaaaaaaaaaaaaaaaaaaa mov r0.w, r1.w +adaaaaaaaaaaahacaaaaaakeacaaaaaaaaaaaaaaabaaaaaa mul r0.xyz, r0.xyzz, c0.x +abaaaaaaaaaaahacaaaaaakeacaaaaaaabaaaakeacaaaaaa add r0.xyz, r0.xyzz, r1.xyzz +aaaaaaaaaaaaapadaaaaaaoeacaaaaaaaaaaaaaaaaaaaaaa mov o0, r0 " } SubProgram "glesdesktop " { @@ -524,10 +492,10 @@ SubProgram "gles3 " { "!!GLES3" } SubProgram "metal " { -// Stats: 7 math, 1 textures +// Stats: 6 math, 1 textures SetTexture 0 [_MainTex] 2D 0 -ConstBuffer "$Globals" 2 -ScalarHalf 0 [_Magnitude] +ConstBuffer "$Globals" 4 +Float 0 [_Magnitude] "metal_fs #include using namespace metal; @@ -538,28 +506,24 @@ struct xlatMtlShaderOutput { half4 _glesFragData_0 [[color(0)]]; }; struct xlatMtlShaderUniform { - half _Magnitude; + float _Magnitude; }; fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]] , texture2d _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]]) { xlatMtlShaderOutput _mtl_o; - half4 outColor_1; - float average_2; + float4 result_1; + float4 color_2; half4 tmpvar_3; tmpvar_3 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0)); - half tmpvar_4; - tmpvar_4 = ((( - ((half)0.299 * tmpvar_3.x) + color_2 = float4(tmpvar_3); + result_1.w = color_2.w; + result_1.xyz = mix (color_2.xyz, float3((( + (0.299 * color_2.x) + - ((half)0.587 * tmpvar_3.y) - ) + ((half)0.114 * tmpvar_3.z)) / (half)3.0); - average_2 = float(tmpvar_4); - float4 tmpvar_5; - tmpvar_5.xyz = mix ((float3)tmpvar_3.xyz, float3(average_2), (float3)half3(_mtl_u._Magnitude)); - tmpvar_5.w = float(tmpvar_3.w); - outColor_1 = half4(tmpvar_5); - _mtl_o._glesFragData_0 = outColor_1; + (0.587 * color_2.y) + ) + (0.114 * color_2.z))), float3(_mtl_u._Magnitude)); + _mtl_o._glesFragData_0 = half4(result_1); return _mtl_o; }