KITASENJU DESIGN BLOG

memo, html, javascript, unity

unity

Depthの位置取得

#pragma kernel MainCS //#include "UnityCG.cginc" #include "./CGINC/SimplexNoise3Db.cginc" #include "./StencilUV.hlsl"// // スレッドグループのスレッドサイズ #define ThreadBlockSize 64//256 // data struct CubeData { // 座標 float3 position; …

substance -> unity (standard shader)

www.youtube.com

エッジを取得する

answers.unity.com

capture images with for loop

画像をforループでいっぱいキャプチャする 文字をRenderTextureにキャプチャしたくて _camera.Renderをforループで回したらいけた using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class TextsCapture…

sigmoid function in shader

シグモイド関数 float y(float x) { float contrast=16.0;//4.0,8.0,16.0 return 1.0/(1.0+exp(-contrast*(x-0.5))); //return 1.0/(1.0+exp(-(x-0.5))); } 参考 シェーダ

三角波的なfract

fract like triangle wave UVをミラー的に折り返したいとき。 GLSL Grapher で描画 float y(float x) { return abs(2.0*fract(0.5*x-0.5)-1.0); } unityのシェーダーで。 //hlsl float2 sankaku(float2 x) { return abs(2.0*frac(0.5*x-0.5)-1.0); } 参考 gl…

zwriteをシェーダーから指定

qiita.com

UnityでEventを作る

note.com using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; // コールバックテスト public class MyCallbackTest : MonoBehaviour { // UnityEventの定義 UnityEvent unityEvent; // スタート時…

how to use transform.localToWorldMatrix on c#

answers.unity.com Vector3 lPos; // your local pos Vector3 wPos = transform.TransformPoint(lPos); //is the same as Vector3 wPos = transform.localToWorld * new Vector4(lPos.x, lPos.y, lPos.z, 1f); //or just Vector3 wPos = transform.localToWo…

ARFoundationのprojectionMatrix

projectionMatrixかviewMatrixがバグってる.たぶんprojection. _projMat = _camera.projectionMatrix; _viewMat = _camera.worldToCameraMatrix; これをつかってスクリーンスペースのプロジェクションをしようとしたら、なんかおかしい。 ポストエフェクトを…

How to split mesh triangles

Split the connected triangles. ポリゴンを分解する gist.github.com

スプライトのためにgrid上に分割したときの座標

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; public class SpriteUV { public static Vector4 GetUv(int idx,int numX, int numY){ int splitX = numX; int splitY = numY; int xx = idx…

How to modify background shader on ARFoundation

There is ARKitBackground.shader in Library/PackageCache. Copy and rewrite it. I added it so that you can change the brightness. gist.github.com

レビューを促すやつ

【Unity】iOS / Android でレビューを促す。(2018年10月版) - 実践ゲーム製作メモ帳2 Unity - Scripting API: iOS.Device.RequestStoreReview

iOS14でVideoPlayerがクラッシュする

issuetracker.unity3d.com 音をnoneにしたら、マジで治った。

unity2020でpackgeManagerでpackageが見つからない

gitからさがす方法 helpdesk.unity3d.co.jp add package from diskでローカルのを読み取る 他のプロジェクトの Libray/PackageCacheからmanifest.jsonをよみとったらAsssetのpackagesフォルダに読み込まれた!

script for motion with delta-time

deltaTimeを考慮したモーション //対応前 x += (tgt-x)/2f; //対応後 x+= (tgt-x)/2 * Time.deltaTime/0.01666;// 0.0166=1/60sec

iOS端末判別

SystemInfo.deviceModel で取得できる List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names · GitHub

unityで環境マップを有効に

Lighting SettingからEnvironmentReflectionsをCustomにしCubemapをセットしないと、なんか反射しないなー 。skyboxってなんなんだろ

CustomRenderTextureと波動方程式を勉強

使い方 【Unity】【シェーダ】Custom Render Textureを使ってみる - LIGHT11 CustomRenderTextureを使って波紋エフェクトを作る - e.blog GitHub - edom18/CustomRenderTextureSample custom render texture使い方

ComputeScreenPosで忘れること

ComputeScreenPosを使い、ごにょごにょする際 入出力の構造体にscreenPosという名前を使ってしまうことがあるが この名前は別の値が代入されちゃうので気を付ける 2時間解けた。気を付けろ!

compute shaderまわりでArgumentException: ComputeBuffer.SetData()エラー

unityのバージョンを変えたらcompute shaderまわりでエラーがでた。ArgumentException: ComputeBuffer.SetData() computeBuffer.SetData(indices, 0, 0, computeBuffer.count); tmls.hatenablog.com

A12チップ以上にアプリを制限

Apple Developer Documentation Required device capabilities に iphone-ipad-minimum-performance-a12 をセットするみたい xcodeで手動設定はいけた。 (unity上からできるといいが・・・) iOS14以上じゃないとダメみたい!!

PostProcessingV2をスクリプトからコントロール

PostProcessingV2をscriptからcontrolする。 public PostProcessVolume ppVolume; var bloom = ppVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>(); bloom.active=true; bloom.intensity.value=30f;</unityengine.rendering.postprocessing.bloom>

IEnumerator Start()

C# - Unity)IEnumerator Start()の使い方|teratail

Spriteにマスク画像をつける

gist.github.com

commandbufferを使ってレンダリング結果をコピー

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; public class CopyToRenderTex : MonoBehaviour { [SerializeField] private Camera _camera; [SerializeField] private RenderTexture _ren…

iOSスリープを無効

// 自動スリープを無効にする場合 Screen.sleepTimeout = SleepTimeout.NeverSleep; https://loumo.jp/archives/6764

端末を判定する

端末・機種を選択 参考: 【Swift,Objective-C】iOSデバイスのモデル名を取得する 例:iPhoneXS Maxとか【CocoaPodsもあるよ】 - Qiita using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //https://qi…

おすすめシェーダー100

すごい数! 【Unity】無料のオススメシェーダまとめ(110個) - コガネブログ

"FOOTER"