# Dual mat-cap corrected technique

I was used screen space light texture technique (matcap or lightcap) since from 2006 in years.

And then my new stuff of new matcap technique (I called dual matcap technique) since by 2015 in years When I developed android mobile game in Korea.

Basically matcap technique is So famous tweak shader lighting technique for mobile games.

But I curious Could I use to dual side of matcap?

So here is results.

Paraboloid意思就是数学上的抛物面公式。

https://en.wikipedia.org/wiki/Paraboloid

★ What is the dual parabolic environment map
(A View-Independent Parameterization for Environment Maps)

# Result is here

## Dual Matcap Preview Demo Clip here

Shader /*ase_name*/ "Leegoonz/ASETemplateShaders/ParabolicMatcap" /*end*/
{
Properties
{
_FrontParaboloid ("_FrontParaboloid", 2D) = "white" { }
_RearParaboloid ("_RearParaboloid", 2D) = "white" { }
/*ase_props*/

}

{
Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" /*ase_tags*/}
LOD 100
Cull Off
/*ase_pass*/

Pass
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
/*ase_pragma*/

struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
/*ase_vdata:p=p;uv0=tc0.xy;uv1=tc1.xy*/
};

struct v2f
{
float4 vertex : SV_POSITION;
float4 texcoord : TEXCOORD0;
float3 worldNormal : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
/*ase_interp(1,7):sp=sp.xyzw;uv0=tc0.xy;uv1=tc0.zw*/
};

uniform fixed4 _Color;
uniform sampler2D _FrontParaboloid;
uniform sampler2D _RearParaboloid;
/*ase_globals*/

v2f vert ( appdata v /*ase_vert_input*/)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.texcoord.xy = v.texcoord.xy;
o.texcoord.zw = v.texcoord1.xy;

// ase common template code
/*ase_vert_code:v=appdata;o=v2f*/

v.vertex.xyz += /*ase_vert_out:Local Vertex;Float3*/ float3(0,0,0) /*end*/;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldNormal = normalize(mul((float3x3)unity_ObjectToWorld, v.normal));
return o;
}

inline fixed4 texParaboloidXFliped(sampler2D front, sampler2D back, float3 refl)
{
if (refl.x > 0)
{
float2 frontUv;
frontUv.x = refl.z / (refl.x + 1);
frontUv.y = refl.y / (refl.x + 1);
frontUv = (frontUv * .5f) + 0.5f;

frontUv.x = 1 - frontUv.x;

return tex2D(front, frontUv);
}
else
{
float2 backUv;
backUv.x = refl.z / (1 - refl.x);
backUv.x *= -1;
backUv.y = refl.y / (1 - refl.x);
backUv = (backUv * .5f) + 0.5f;

backUv.x = backUv.x;

return tex2D(back, backUv);
}
}

fixed4 frag (v2f i /*ase_frag_input*/) : SV_Target
{
fixed4 parabolicOut;
// ase common template code
/*ase_frag_code:i=v2f*/

parabolicOut = /*ase_frag_out:Albedo Color;Float4*/float4(1,1,1,1)/*end*/;
//return myColorVar;
return parabolicOut * texParaboloidXFliped(_FrontParaboloid, _RearParaboloid, i.worldNormal);;
}
ENDCG
}
}
CustomEditor "ASEMaterialInspector"
}


1997年开始从事电脑图形视觉化工作后，在这个行业已经有21年经验了。

06-02 2066
04-10 2022

11-13 179
02-23 5589
07-15 3479
10-12
02-22 7246
05-10 4721
09-27 1258
06-05 295