Original source: https://discordapp.com/channels/189511567539306508/336764732482650112?jump=354647452747300865
Last active
May 3, 2019 08:31
-
-
Save hakanai/09719eb1c4276d8de7bfe9261f68eb7e to your computer and use it in GitHub Desktop.
Shaders to render 3D images and video (example of unity_StereoEyeIndex)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Made with Amplify Shader Editor | |
// Available at the Unity Asset Store - http://u3d.as/y3X | |
Shader "3D/OU3DScreen" | |
{ | |
Properties | |
{ | |
[HideInInspector] __dirty( "", Int ) = 1 | |
_MainTex("MainTex", 2D) = "white" {} | |
[Toggle]_ToggleSwitch2("Toggle Switch2", Float) = 0 | |
} | |
SubShader | |
{ | |
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" } | |
Cull Back | |
CGPROGRAM | |
#pragma target 3.5 | |
#pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc | |
struct Input | |
{ | |
float2 texcoord_0; | |
float2 texcoord_1; | |
float2 texcoord_2; | |
}; | |
uniform sampler2D _MainTex; | |
uniform fixed _ToggleSwitch2; | |
float3 HSVToRGB( float3 c ) | |
{ | |
float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 ); | |
float3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www ); | |
return c.z * lerp( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y ); | |
} | |
float3 RGBToHSV(float3 c) | |
{ | |
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); | |
float4 p = lerp( float4( c.bg, K.wz ), float4( c.gb, K.xy ), step( c.b, c.g ) ); | |
float4 q = lerp( float4( p.xyw, c.r ), float4( c.r, p.yzx ), step( p.x, c.r ) ); | |
float d = q.x - min( q.w, q.y ); | |
float e = 1.0e-10; | |
return float3( abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); | |
} | |
void vertexDataFunc( inout appdata_full v, out Input o ) | |
{ | |
UNITY_INITIALIZE_OUTPUT( Input, o ); | |
o.texcoord_0.xy = v.texcoord.xy * float2( 1,1 ) + float2( 0,0 ); | |
float2 temp_cast_0 = (0.5).xx; | |
float2 temp_cast_1 = (0.5).xx; | |
o.texcoord_1.xy = v.texcoord.xy * temp_cast_0 + temp_cast_1; | |
float2 temp_cast_2 = (0.5).xx; | |
float2 temp_cast_3 = (0.0).xx; | |
o.texcoord_2.xy = v.texcoord.xy * temp_cast_2 + temp_cast_3; | |
} | |
void surf( Input i , inout SurfaceOutputStandard o ) | |
{ | |
float2 appendResult13 = float2( i.texcoord_0.x , lerp( i.texcoord_1.y , i.texcoord_2.y , lerp(unity_StereoEyeIndex,( -unity_StereoEyeIndex + 1.0 ),_ToggleSwitch2) ) ); | |
float3 hsvTorgb42 = RGBToHSV( tex2D( _MainTex, appendResult13 ).xyz ); | |
float3 hsvTorgb44 = HSVToRGB( float3(hsvTorgb42.x,hsvTorgb42.y,( hsvTorgb42.z * 2.0 )) ); | |
o.Emission = hsvTorgb44; | |
o.Alpha = 1; | |
} | |
ENDCG | |
} | |
Fallback "Diffuse" | |
CustomEditor "ASEMaterialInspector" | |
} | |
/*ASEBEGIN | |
Version=10001 | |
1704;59;1640;921;1320.507;236.999;1.4;True;True | |
Node;StereoEyeIndex;49;-844.5251,521.0756;Float;False;0;1;FLOAT | |
Node;AmplifyShaderEditor.NegateNode;50;-628.2338,627.7761;Float;False;1;0;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;40;-827.4974,335.0994;Float;False;Constant;_Float2;Float 2;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;39;-826.3977,250.4;Float;False;Constant;_Float1;Float 1;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;41;-828.5983,415.4;Float;False;Constant;_Float3;Float 3;1;0;0;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.SimpleAddOpNode;51;-450.234,627.7761;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;1.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;38;-824.2,163.4997;Float;False;Constant;_Float0;Float 0;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.ToggleSwitchNode;52;-262.2344,517.7761;Fixed;False;Property;_ToggleSwitch2;Toggle Switch2;1;1;[Toggle];0;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;37;-429.1076,190.5996;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;36;-427.407,343.5999;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;10;75.70391,-90.59937;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.LerpOp;34;-4.10711,374.1992;Float;False;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.TexturePropertyNode;7;437.8016,-152.3;Float;True;Property;_MainTex;MainTex;0;0;None;False;white;Auto;0;1;SAMPLER2D | |
Node;AmplifyShaderEditor.AppendNode;13;519.0016,42.30068;Float;False;FLOAT2;0;0;0;0;4;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;3;FLOAT;0.0;False;1;FLOAT2 | |
Node;AmplifyShaderEditor.SamplerNode;8;757.0021,-29.09985;Float;True;Property;_TextureSample0;Texture Sample 0;1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;0.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.RGBToHSVNode;42;1159.294,6.600829;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;43;1400.294,101.8008;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;2.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.HSVToRGBNode;44;1597.094,-8.799198;Float;False;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1798.805,-21.00001;Float;False;True;3;Float;ASEMaterialInspector;0;Standard;3D/HalfOU3DScreen;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;Relative;0;;-1;-1;-1;-1;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;13;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 | |
WireConnection;50;0;49;0 | |
WireConnection;51;0;50;0 | |
WireConnection;52;0;49;0 | |
WireConnection;52;1;51;0 | |
WireConnection;37;0;38;0 | |
WireConnection;37;1;39;0 | |
WireConnection;36;0;40;0 | |
WireConnection;36;1;41;0 | |
WireConnection;34;0;37;2 | |
WireConnection;34;1;36;2 | |
WireConnection;34;2;52;0 | |
WireConnection;13;0;10;1 | |
WireConnection;13;1;34;0 | |
WireConnection;8;0;7;0 | |
WireConnection;8;1;13;0 | |
WireConnection;42;0;8;0 | |
WireConnection;43;0;42;3 | |
WireConnection;44;0;42;1 | |
WireConnection;44;1;42;2 | |
WireConnection;44;2;43;0 | |
WireConnection;0;2;44;0 | |
ASEEND*/ | |
//CHKSM=5B0101F0B3D928559D109668EBE077949C25E0D2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Made with Amplify Shader Editor | |
// Available at the Unity Asset Store - http://u3d.as/y3X | |
Shader "3D/SBS3DScreen" | |
{ | |
Properties | |
{ | |
[HideInInspector] __dirty( "", Int ) = 1 | |
_MainTex("MainTex", 2D) = "white" {} | |
[Toggle]_SwapEyes("Swap Eyes", Float) = 0 | |
} | |
SubShader | |
{ | |
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" } | |
Cull Back | |
CGPROGRAM | |
#pragma target 3.5 | |
#pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc | |
struct Input | |
{ | |
float2 texcoord_0; | |
float2 texcoord_1; | |
float2 texcoord_2; | |
}; | |
uniform sampler2D _MainTex; | |
uniform fixed _SwapEyes; | |
float3 HSVToRGB( float3 c ) | |
{ | |
float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 ); | |
float3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www ); | |
return c.z * lerp( K.xxx, clamp( p - K.xxx, 0.0, 1.0 ), c.y ); | |
} | |
float3 RGBToHSV(float3 c) | |
{ | |
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); | |
float4 p = lerp( float4( c.bg, K.wz ), float4( c.gb, K.xy ), step( c.b, c.g ) ); | |
float4 q = lerp( float4( p.xyw, c.r ), float4( c.r, p.yzx ), step( p.x, c.r ) ); | |
float d = q.x - min( q.w, q.y ); | |
float e = 1.0e-10; | |
return float3( abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); | |
} | |
void vertexDataFunc( inout appdata_full v, out Input o ) | |
{ | |
UNITY_INITIALIZE_OUTPUT( Input, o ); | |
float2 temp_cast_0 = (0.5).xx; | |
float2 temp_cast_1 = (0.0).xx; | |
o.texcoord_0.xy = v.texcoord.xy * temp_cast_0 + temp_cast_1; | |
float2 temp_cast_2 = (0.5).xx; | |
float2 temp_cast_3 = (0.5).xx; | |
o.texcoord_1.xy = v.texcoord.xy * temp_cast_2 + temp_cast_3; | |
o.texcoord_2.xy = v.texcoord.xy * float2( 1,1 ) + float2( 0,0 ); | |
} | |
void surf( Input i , inout SurfaceOutputStandard o ) | |
{ | |
float2 appendResult13 = float2( lerp( i.texcoord_0.x , i.texcoord_1.x , lerp(unity_StereoEyeIndex,( -unity_StereoEyeIndex + 1.0 ),_SwapEyes) ) , i.texcoord_2.y ); | |
float3 hsvTorgb42 = RGBToHSV( tex2D( _MainTex, appendResult13 ).xyz ); | |
float3 hsvTorgb44 = HSVToRGB( float3(hsvTorgb42.x,hsvTorgb42.y,( hsvTorgb42.z * 2.0 )) ); | |
o.Emission = hsvTorgb44; | |
o.Alpha = 1; | |
} | |
ENDCG | |
} | |
Fallback "Diffuse" | |
CustomEditor "ASEMaterialInspector" | |
} | |
/*ASEBEGIN | |
Version=10001 | |
1704;59;1640;921;1133.808;-84.40109;1;True;True | |
Node;StereoEyeIndex;18;-825.0994,567.7006;Float;False;0;1;FLOAT | |
Node;AmplifyShaderEditor.NegateNode;49;-608.808,674.4011;Float;False;1;0;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.SimpleAddOpNode;50;-430.808,674.4011;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;1.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;38;-824.2,163.4997;Float;False;Constant;_Float0;Float 0;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;39;-826.3977,250.4;Float;False;Constant;_Float1;Float 1;1;0;0;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;41;-828.5983,415.4;Float;False;Constant;_Float3;Float 3;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.RangedFloatNode;40;-827.4974,335.0994;Float;False;Constant;_Float2;Float 2;1;0;0.5;0;0;0;1;FLOAT | |
Node;AmplifyShaderEditor.ToggleSwitchNode;47;-242.8082,564.4011;Fixed;False;Property;_SwapEyes;Swap Eyes;1;1;[Toggle];0;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;36;-427.407,343.5999;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;37;-429.1076,190.5996;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.TextureCoordinatesNode;10;0.503952,571.8007;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.LerpOp;34;-3.10711,374.1992;Float;False;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.TexturePropertyNode;7;437.8016,-152.3;Float;True;Property;_MainTex;MainTex;0;0;None;False;white;Auto;0;1;SAMPLER2D | |
Node;AmplifyShaderEditor.AppendNode;13;519.0016,42.30068;Float;False;FLOAT2;0;0;0;0;4;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;3;FLOAT;0.0;False;1;FLOAT2 | |
Node;AmplifyShaderEditor.SamplerNode;8;757.0021,-29.09985;Float;True;Property;_TextureSample0;Texture Sample 0;1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;0.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.RGBToHSVNode;42;1159.294,6.600829;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;43;1400.294,101.8008;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;2.0;False;1;FLOAT | |
Node;AmplifyShaderEditor.HSVToRGBNode;44;1597.094,-8.799198;Float;False;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT | |
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1798.805,-21.00001;Float;False;True;3;Float;ASEMaterialInspector;0;Standard;3D/FullSBS3DScreen;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;Relative;0;;-1;-1;-1;-1;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;13;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 | |
WireConnection;49;0;18;0 | |
WireConnection;50;0;49;0 | |
WireConnection;47;0;18;0 | |
WireConnection;47;1;50;0 | |
WireConnection;36;0;40;0 | |
WireConnection;36;1;41;0 | |
WireConnection;37;0;38;0 | |
WireConnection;37;1;39;0 | |
WireConnection;34;0;37;1 | |
WireConnection;34;1;36;1 | |
WireConnection;34;2;47;0 | |
WireConnection;13;0;34;0 | |
WireConnection;13;1;10;2 | |
WireConnection;8;0;7;0 | |
WireConnection;8;1;13;0 | |
WireConnection;42;0;8;0 | |
WireConnection;43;0;42;3 | |
WireConnection;44;0;42;1 | |
WireConnection;44;1;42;2 | |
WireConnection;44;2;43;0 | |
WireConnection;0;2;44;0 | |
ASEEND*/ | |
//CHKSM=A86D23912648BD8F1BB78752A02A4CD8D3BBA766 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I checked in oculus go, but it's not working, Please guide me on how to make working.