devNotes 3-25-16 paint_track – paintList_track – movement recording

Color on Verts – reflect speed
State machine to adjust material colors on animations in animator
Layered texture on material to crossfade
inject color on speed change

Paint_Develop

Argos.Vu First Shaders

Written to assure render order of Hex Quads after Paint Quads

// Argos First Shaders - Custom/Unlit/ArgosCursor_Layer_1
//
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color

Shader "Custom/Unlit/ArgosCursor_Layer_0" 
{
	Properties 
	{
		_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
	}

	SubShader 
	{
		Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
		LOD 100
	
		ZWrite Off
		Blend SrcAlpha OneMinusSrcAlpha
		// Added to make sure that this draws above
		// stuff at the same depth.
		Offset -1, -1
	
		Pass {  
			CGPROGRAM
				#pragma vertex vert
				#pragma fragment frag
				#pragma multi_compile_fog
			
				#include "UnityCG.cginc"

				struct appdata_t {
					float4 vertex : POSITION;
					float2 texcoord : TEXCOORD0;
				};

				struct v2f {
					float4 vertex : SV_POSITION;
					half2 texcoord : TEXCOORD0;
					UNITY_FOG_COORDS(1)
				};

				sampler2D _MainTex;
				float4 _MainTex_ST;
			
				v2f vert (appdata_t v)
				{
					v2f o;
					o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
					o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
					UNITY_TRANSFER_FOG(o,o.vertex);
					return o;
				}
			
				fixed4 frag (v2f i) : SV_Target
				{
					fixed4 col = tex2D(_MainTex, i.texcoord);
					UNITY_APPLY_FOG(i.fogCoord, col);
					return col;
				}
			ENDCG
		}
	}
}

 

// Argos First Shaders - Custom/Unlit/ArgosCursor_Layer_1
//
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color

Shader "Custom/Unlit/ArgosCursor_Layer_1" 
{
	Properties 
	{
		_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
	}

	SubShader 
	{
		Tags {"Queue"="Transparent+1" "IgnoreProjector"="True" "RenderType"="Transparent"}
		LOD 100
	
		ZWrite Off
		Blend SrcAlpha OneMinusSrcAlpha
		// Added to make sure that this draws above
		// stuff at the same depth.
		Offset -1, -1
	
		Pass {  
			CGPROGRAM
				#pragma vertex vert
				#pragma fragment frag
				#pragma multi_compile_fog
			
				#include "UnityCG.cginc"

				struct appdata_t {
					float4 vertex : POSITION;
					float2 texcoord : TEXCOORD0;
				};

				struct v2f {
					float4 vertex : SV_POSITION;
					half2 texcoord : TEXCOORD0;
					UNITY_FOG_COORDS(1)
				};

				sampler2D _MainTex;
				float4 _MainTex_ST;
			
				v2f vert (appdata_t v)
				{
					v2f o;
					o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
					o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
					UNITY_TRANSFER_FOG(o,o.vertex);
					return o;
				}
			
				fixed4 frag (v2f i) : SV_Target
				{
					fixed4 col = tex2D(_MainTex, i.texcoord);
					UNITY_APPLY_FOG(i.fogCoord, col);
					return col;
				}
			ENDCG
		}
	}
}

 

Cursor_1 and Paint_Controller updated to fix initial quad vertex coordinates:

//in Cursor_1

private void UpdatePaintQuads()
{
    vCurrLoc = userMovement.cursorTran.pos - argos_Sphere.transform.position;
    Quaternion LocalRotation = myStartRotation * Quaternion.Inverse(argos_Sphere.transform.rotation);
    vCurrLoc = LocalRotation * vCurrLoc;

    if (vCurrLoc != vLastLoc)
    {
        Vector3 vLen = vCurrLoc - vLastLoc;

        if (vLen.magnitude > minPaintLen || iStartPaint < 2)
        {
            //MeshDraft
            Vector3 vFwd = userMovement.cursorTran.screenProjTrans.forward;

            Vector3 vFwdRtd = LocalRotation * vFwd;

            Vector3 vUp = Vector3.Cross(vFwdRtd, vLen);
            vUp.Normalize();

            v1curr = vCurrLoc + (lineWidth / 2f) * vUp;
            v2curr = vCurrLoc - (lineWidth / 2f) * vUp;

            if (++iStartPaint > 2) //don't write 2 times though
            {
                instPaintElement.AddQuad(v2last, v1last, v1curr, v2curr);
            }

            vLastLoc = vCurrLoc;

            v1last = v1curr;
            v2last = v2curr;

            //Paint_Track
            pt = new Paint_Track();
            pt.timer = 0f;
            pt.vCursorLoc_at_t = vCurrLoc;
            pt.vLenRtd = vLen;
            pt.vUpRtd = vUp;
            pt.type = 0;
            ptPaintList.Add(pt);
        }
    }
    for (int i = 0; i < ptPaintList.Count; i++)
    {
        ptPaintList[i].timer += Time.deltaTime;
        float scale = argos_bloom_envelope(pT1, pT2, ptPaintList[i].timer);
            
        // This Comes Next :)
    }
}
//in void Update() in  PaintController

if (bPaintOn)
{
    vCurrLoc = userMovement.cursorTran.pos - argos_Sphere.transform.position;
    Quaternion LocalRotation = myPaintRotation*Quaternion.Inverse(argos_Sphere.transform.rotation);
    vCurrLoc = LocalRotation *  vCurrLoc;

    if (vCurrLoc != vLastLoc)
    {
        Vector3 len = vCurrLoc - vLastLoc;

        if (len.magnitude > minPaintLen || iStartPaint<2)
        {
            Vector3 vFwd = userMovement.cursorTran.screenProjTrans.forward;

            Vector3 vFwdRtd = LocalRotation * vFwd;

            Vector3 vUp = Vector3.Cross(vFwdRtd, len );
            vUp.Normalize();

            v1curr = vCurrLoc + (lineWidth / 2f) * vUp;
            v2curr = vCurrLoc - (lineWidth / 2f) * vUp;

            sWrite.WriteLine("len =" + v2last.ToString("F3") + " vFwdRtd =" + vFwdRtd.ToString("F3") + " vUp =" + vUp.ToString("F3") + " vLastLoc =" + vLastLoc.ToString("F3") + " vCurrLoc =" + vCurrLoc.ToString("F3"));

            if (++iStartPaint > 2) //don't write 2 times though
            {
                paintList[currPE_Idx].AddQuad(v2last, v1last, v1curr, v2curr);
                //sWrite.WriteLine("v0 =" + v2last.ToString("F3") + "v1 =" + v1last.ToString("F3") + "v2 =" + v1curr.ToString("F3") + "v3 =" + v2curr.ToString("F3"));
            }
            vLastLoc = vCurrLoc;

            v1last = v1curr;
            v2last = v2curr;

            if (currPE_Idx > -1 && paintList[currPE_Idx].Mdraft != null)
                InfoLineTxt.text = " Pn = " + (paintList[currPE_Idx].Mdraft.triangles.Count / 2).ToString();
        }
    }
}