#UNITY_MATRIX_IT_MVの使い方とか
View空間座標から、Object空間座標に変換する。
float4 objectSpacePos = mul(viewSpacePos, UNITY_MATRIX_IT_MV);
Projection空間座標から、View空間座標に変換 これは違った!!
float4 viewSpacePos = mul(eyeSpacePos, UNITY_MATRIX_P);
#UNITY_MATRIX_IT_MVの使い方とか
View空間座標から、Object空間座標に変換する。
float4 objectSpacePos = mul(viewSpacePos, UNITY_MATRIX_IT_MV);
Projection空間座標から、View空間座標に変換 これは違った!!
float4 viewSpacePos = mul(eyeSpacePos, UNITY_MATRIX_P);
| void vert(inout appdata_full v){ | |
| half4 worldPos = mul(_Object2World, v.vertex); | |
| half4 viewPos = mul(UNITY_MATRIX_V, worldPos); | |
| half4 eyePos = mul(UNITY_MATRIX_P, viewPos); | |
| viewPos = mul(unity_CameraInvProjection, eyePos); | |
| half4 localPos = mul(viewPos, UNITY_MATRIX_IT_MV); | |
| v.vertex = localPos; | |
| } |
| Shader "Unlit/ViewPortToPos" | |
| { | |
| Properties | |
| { | |
| _MainTex ("Texture", 2D) = "white" {} | |
| _VP ("viewport position", Vector) = (0.5,0.5,1,0) | |
| } | |
| SubShader | |
| { | |
| Tags { "RenderType"="Opaque" } |
| Shader "Custom/OnlyShadowsAndAtten" | |
| { | |
| SubShader | |
| { | |
| Tags { "RenderType"="Opaque" } | |
| LOD 200 | |
| // Forward rendering base (main directional light) pass. | |
| Pass | |
| { |
| using System.Collections; using System.Collections.Generic; | |
| using System.IO; using UnityEngine; | |
| /// <summary> | |
| /// Attach this script to an empty gameObject. Create a secondary camera | |
| /// gameObject for offscreen rendering (not your main camera) and connect it | |
| /// with this script. Offscreen camera should have a texture object attached to it. | |
| /// OffscreenCamera texture object is used for rendering (please see camera properties). | |
| /// </summary> | |
| public class OffscreenRendering : MonoBehaviour { |
Unity's SerializedProperty not support custom type value setting. This extension use Reflection to get target instance of SerializedProperty in Custom Editor, made value setting of general type is posible.
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEditor.Experimental.AssetImporters; | |
| using System.IO; | |
| using UnityEditor; | |
| using UnityEngine.Assertions; | |
| using System.Linq; | |
| [ScriptedImporter(1, "cube")] |
| // DONT PUT IN EDITOR FOLDER | |
| using System; | |
| using UnityEngine; | |
| /// <summary> | |
| /// Attribute used to show or hide the Field depending on certain conditions | |
| /// </summary> | |
| [AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)] | |
| public class ShowWhenAttribute : PropertyAttribute { |
| //関数内で大量に変数を定義するとGPU時間がめちゃ遅くなるのでスコープを使って書き直している部分があるので可読性が少し落ちている。ので注意。 | |
| ///ret : 0.0 - <1.0 | |
| float rand(float n) | |
| { | |
| return frac(sin(n) * 63452.5453123); | |
| } | |
| ///ret : 0.0 - <1.0 | |
| float rand(float2 co) | |
| { |
| using UnityEngine; | |
| using UnityEditor; | |
| using System; | |
| namespace GatoMaterialPropertyDrawer | |
| { | |
| internal class LineDecorator : MaterialPropertyDrawer | |
| { | |
| private float spaceSize; |