0
Completed

it_matrix

Seungseob Lee 10 years ago updated by Freya Holmér (Developer) 10 years ago 6
Sorry for the questions here. I'd like to implement node to the code below, but the method does not know. Maybe, would I be able to get a hint about this?

----------------------------------------------------------------------------------------------------------
capCoord.x = dot(UNITY_MATRIX_IT_MV[0].xyz, v.normal);
capCoord.y = dot(UNITY_MATRIX_IT_MV[1].xyz, v.normal);
What are you going to use that code for / what does it do?
I would like to implement a Matcap Shader using your tools.

like this : http://www.digitalrune.com/Portals/0/Blog/Files/11...

Mathematical understanding of the matrix is insufficient me. It is also the same coding. ShaderForge of you to understand me Shader has become a big help. However, I think I want to get a hint of a portion clogged.
Thank you! Have a nice day...
Oh, well, why didn't you say so from the start? :)

// MatCap Shader, (c) 2013 Jean Moreno
//MatCap Shader Ghost based Texture unit added Customizing Author (c) 2013 JP.Lee
Shader "MatCap/Vertex/Textured Multiply_Rim"
{
Properties
{
_RimPower ("RimPower", Range(0,3)) = 1
_MainTex ("Base (RGB)", 2D) = "white" {}
_MatCap ("MatCap (RGB)", 2D) = "white" {}
_MatRim ("RimTex (RGB)", 2D) = "white" {}
}
Subshader
{
Tags { "RenderType"="Opaque" }
Pass
{
Tags { "LightMode" = "Always" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
float2 cap: TEXCOORD1;
};
uniform float4 _MainTex_ST;
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
half2 capCoord;
capCoord.x = dot(UNITY_MATRIX_IT_MV[0].xyz,v.normal);
capCoord.y = dot(UNITY_MATRIX_IT_MV[1].xyz,v.normal);
o.cap = capCoord * 0.5 + 0.5;
return o;
}
uniform sampler2D _MainTex;
uniform sampler2D _MatCap;
uniform sampler2D _MatRim;
uniform float _RimPower;
fixed4 frag (v2f i) : COLOR
{
fixed4 tex = tex2D(_MainTex, i.uv);
fixed4 mc = tex2D(_MatCap, i.cap);
fixed4 mcRim = tex2D(_MatRim, i.cap);
return tex * mc * 2.0 + (mcRim * _RimPower);
}
ENDCG
}
}
Fallback "VertexLit"
}