Trinus Forum › Forums › Developers › Patch for iOS Color issues.
Tagged: iOS
- This topic has 0 replies, 1 voice, and was last updated 4 years, 5 months ago by
DrBlackAdder.
-
AuthorPosts
-
January 22, 2018 at 10:22 pm #7441
DrBlackAdder
ParticipantHere’s a two piece solution to the current iOS color rendering issues:
C# Code: ColorSwapBandaid.cs
/*
iOS Color and orientation Correction Shader Loader for TrinusVR
Developer: Paul Taylor (DrBlackAdder)
Contact: @DrBlackAdder / Doctar.Paul@gmail.com
Licence: GPLv3 with Attirbution RequiredThis code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/// This code should be added to each Camera that renders for the iPhone View (e.g. LeftCamera & RightCamera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;[ExecuteInEditMode]
public class ColorSwapBandaid : MonoBehaviour
{
private Material material;
public bool isIphone = true;// Creates a private material used to the effect
void Awake()
{
if (isIphone) //Patch the colors
material = new Material(Shader.Find(“Hidden/ColorParty”));
}// Postprocess the image
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (!isIphone) // Just
{
Graphics.Blit(source, destination);
return;
}
Graphics.Blit(source, destination, material);
}
}CG Shader Code: ColorParty.shader
/*
iOS Color and orientation Correction Shader for TrinusVR
Developer: Paul Taylor (DrBlackAdder)
Contact: @DrBlackAdder / Doctar.Paul@gmail.com
Licence: GPLv3 with Attirbution RequiredThis code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/Shader “Hidden/ColorParty”
{
Properties
{
_MainTex(“Texture”, 2D) = “white” {}
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest AlwaysPass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag#include “UnityCG.cginc”
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}sampler2D _MainTex;
fixed4 frag(v2f i) : SV_Target
{
float2 length = { 1.0,1.0 };
float2 mirrorTexCoords = i.uv;
mirrorTexCoords[1] = length – i.uv[1]; // Reverse Texture on v axis (equiv of y in xy coords)// Pull pixel out of texture
fixed4 col = tex2D(_MainTex, mirrorTexCoords);//Store red channel
fixed red = col.r;// Rotate the color channels
// Red = Blue
col.r = col.b;
//Green = Green
col.g = col.g;
//Set blue from stored Red Value
col.b = red;
return col;
}
ENDCG
}
}
}Enjoy!
-
This topic was modified 4 years, 5 months ago by
DrBlackAdder.
-
This topic was modified 4 years, 5 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.