Skip to content

Instantly share code, notes, and snippets.

@mafaca
Created December 9, 2019 22:33
Show Gist options
  • Save mafaca/ee88da81881df6fc8caa1e1e54108e94 to your computer and use it in GitHub Desktop.
Save mafaca/ee88da81881df6fc8caa1e1e54108e94 to your computer and use it in GitHub Desktop.
GLSL shader conversion
Shader "Unlit/CustomUnlit_restored"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex0 : POSITION0;
float2 tex0 : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 tex0 : TEXCOORD0;
float tex1 : TEXCOORD1;
};
float4 hlslcc_mtx4x4unity_ObjectToWorld[4];
float4 hlslcc_mtx4x4unity_MatrixVP[4];
float4 _MainTex_ST;
sampler2D _MainTex;
v2f vert(appdata v)
{
v2f o;
float4 u_xlat1;
o.vertex = UnityObjectToClipPos(v.vertex0);
float u_xlat0 = o.vertex.x * (-o.vertex.x);
o.tex1 = exp2(u_xlat0);
o.tex0.xy = v.tex0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
float4 color0;
float u_xlat0;
float4 u_xlat1;
float3 u_xlat2;
u_xlat0 = i.tex1;
u_xlat0 = clamp(u_xlat0, 0.0, 1.0);
u_xlat1 = tex2D(_MainTex, i.tex0.xy);
u_xlat2.xyz = u_xlat1.xyz + (-unity_FogColor.xyz);
u_xlat1.xyz = u_xlat0 * u_xlat2.xyz + unity_FogColor.xyz;
color0 = u_xlat1;
return color0;
}
ENDCG
}
}
}
Shader "Unlit/CustomUnlit"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
Shader "Unlit/CustomUnlit_restored"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex0 : POSITION0;
float2 tex0 : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 tex0 : TEXCOORD0;
float tex1 : TEXCOORD1;
};
float4 hlslcc_mtx4x4unity_ObjectToWorld[4];
float4 hlslcc_mtx4x4unity_MatrixVP[4];
float4 _MainTex_ST;
sampler2D _MainTex;
v2f vert(appdata v)
{
v2f o;
vec4 u_xlat0;
vec4 u_xlat1;
u_xlat0 = v.vertex0.yyyy * hlslcc_mtx4x4unity_ObjectToWorld[1];
u_xlat0 = hlslcc_mtx4x4unity_ObjectToWorld[0] * v.vertex0.xxxx + u_xlat0;
u_xlat0 = hlslcc_mtx4x4unity_ObjectToWorld[2] * v.vertex0.zzzz + u_xlat0;
u_xlat0 = u_xlat0 + hlslcc_mtx4x4unity_ObjectToWorld[3];
u_xlat1 = u_xlat0.yyyy * hlslcc_mtx4x4unity_MatrixVP[1];
u_xlat1 = hlslcc_mtx4x4unity_MatrixVP[0] * u_xlat0.xxxx + u_xlat1;
u_xlat1 = hlslcc_mtx4x4unity_MatrixVP[2] * u_xlat0.zzzz + u_xlat1;
u_xlat0 = hlslcc_mtx4x4unity_MatrixVP[3] * u_xlat0.wwww + u_xlat1;
u_xlat1.x = u_xlat0.z * unity_FogParams.x;
o.vertex = u_xlat0;
u_xlat0.x = u_xlat1.x * (-u_xlat1.x);
o.tex1 = exp2(u_xlat0.x);
o.tex0.xy = v.tex0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 color0;
float u_xlat0;
vec4 u_xlat1;
vec3 u_xlat2;
u_xlat0 = i.tex1;
u_xlat0 = clamp(u_xlat0, 0.0, 1.0);
u_xlat1 = tex2D(_MainTex, i.tex0.xy);
u_xlat2.xyz = u_xlat1.xyz + (-unity_FogColor.xyz);
u_xlat1.xyz = u_xlat0 * u_xlat2.xyz + unity_FogColor.xyz;
color0 = u_xlat1;
return color0;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment