Skip to content

Instantly share code, notes, and snippets.

View douduck08's full-sized avatar

douduck08 douduck08

View GitHub Profile
@douduck08
douduck08 / UnityComputeShader.compute
Created December 28, 2021 05:57
Unity compute shader template
#pragma kernel CSMain
#define THREAD_GROUP_SIZE_X 8
#define THREAD_GROUP_SIZE_Y 8
#define THREAD_GROUP_SIZE_Z 1
// Buffers
RWTexture2D<float4> Result;
// Functions
@douduck08
douduck08 / reflect_inputlayout.cpp
Created October 19, 2021 11:12 — forked from mobius/reflect_inputlayout.cpp
Reflect DX11 Vertex shader to create input layout
HRESULT CreateInputLayoutDescFromVertexShaderSignature( ID3DBlob* pShaderBlob, ID3D11Device* pD3DDevice, ID3D11InputLayout** pInputLayout )
{
// Reflect shader info
ID3D11ShaderReflection* pVertexShaderReflection = NULL;
if ( FAILED( D3DReflect( pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pVertexShaderReflection ) ) )
{
return S_FALSE;
}
// Get shader info
@douduck08
douduck08 / VertexShader.cpp
Last active October 19, 2021 10:19 — forked from Cody-Duncan/gist:d85740563ceea99f6619
DirectX11 Generate Input Layout from Vertex Shader using D3DReflect.
//Function Creates an input layout from the vertex shader, after compilation.
//Input layout can be reused with any vertex shaders that use the same input layout.
HRESULT CreateInputLayoutDescFromVertexShaderSignature( ID3DBlob* pShaderBlob, ID3D11Device* pD3DDevice, ID3D11InputLayout** pInputLayout, int* inputLayoutByteLength )
{
// Reflect shader info
ID3D11ShaderReflection* pVertexShaderReflection = nullptr;
HRESULT hr = S_OK;
if ( FAILED( D3DReflect( pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pVertexShaderReflection ) ) )
{
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public static class DirectorExtension {
/// <summary>
/// When 'trackName' is null or empty, this method will set all the tracks without name check.
@douduck08
douduck08 / Template.cginc
Created February 25, 2020 07:59
A Note/Template for writing non-surface lit shaders of Unity
#ifndef TEMPLETE_INCLUDED
#define TEMPLETE_INCLUDED
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "UnityGlobalIllumination.cginc"
#include "UnityPBSLighting.cginc"
// ----------------------------- //
// material property and uniform //
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public interface IService {}
public abstract class InitialzeArgs {}
public interface IInitializable {
void Initialize (InitialzeArgs args);
}
@douduck08
douduck08 / README.md
Last active August 18, 2024 14:03
The general GetValue extension of SerializedProperty in Unity Editor.

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.