Skip to content

Instantly share code, notes, and snippets.

View hiepnd's full-sized avatar

Ngo Duc Hiep hiepnd

  • No Power-up
  • Ha Noi, Viet Nam
View GitHub Profile
Shader "Screw/Silhouetted Diffuse" {
Properties {
_Color ("Main Color", Color) = (.5,.5,.5,1)
_FrontColor ("Front Color", Color) = (.5,.5,.5,1)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.0, 0.1)) = .005
_MainTex ("Base (RGB)", 2D) = "white" { }
_Alpha ("Alpha", Range(0, 1)) = 1
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MeshModifier : MonoBehaviour {
const float EPSILON = 0.01f;
public void FindPoint (List<int> includes, Vector3[] vs, Vector3[] ns, Color[] cs) {
List<int> ps = new List<int>();
Shader "Screw/Silhouetted Diffuse" {
Properties {
_Color ("Main Color", Color) = (.5,.5,.5,1)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.0, 0.03)) = .005
_MainTex ("Base (RGB)", 2D) = "white" { }
_Alpha ("Alpha", Range(0, 1)) = 1
}
CGINCLUDE
@hiepnd
hiepnd / ColorLit.shader.cpp
Last active December 2, 2015 10:37
Unity Color Lit shader
Shader "Screw/Lit Color" {
Properties {
_Color ("Color", Color) = (1, 1, 1, 1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
CGPROGRAM
@hiepnd
hiepnd / CustomMenuItem.cs
Last active July 29, 2021 10:53
Some custom menu items for Unity
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
/*
* To create a hotkey you can use the following special characters:
* % (ctrl on Windows, cmd on OS X), # (shift), & (alt), <b>_</b> (no key modifiers).
* For example to create a menu with hotkey shift-alt-g use "MyMenu/Do Something #&g".
* To create a menu with hotkey g and no key modifiers pressed use "MyMenu/Do Something _g".
@hiepnd
hiepnd / Outline.shader
Last active March 24, 2024 00:04
Unity Outline shader for transparent object
Shader "Screw/Alpha Outline" {
Properties {
_Color ("Main Color", Color) = (.5,.5,.5,1)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.0, 0.15)) = .005
_OutlineOffset ("Outline Offset", Vector) = (0, 0, 0)
_MainTex ("Base (RGB)", 2D) = "white" { }
_Alpha ("Alpha", Float) = 1
}
@hiepnd
hiepnd / CharacterNavigationEditor.cs
Created October 30, 2015 02:32
Alternative to OnDrawGizmos
using UnityEngine;
using UnityEditor;
// http://unity3d.com/learn/tutorials/modules/intermediate/unity-tips-and-tricks-grab-bag
[CustomEditor(typeof(CharacterNavigation))]
public class CharacterNavigationEditor : Editor
{
static bool visualizePath = false;
@hiepnd
hiepnd / Tail.java
Created November 26, 2014 03:25
Amazing Wire's tail, rewritten in libgdx
package com.badlogicgames.plane;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
@hiepnd
hiepnd / evil.h
Last active August 29, 2015 13:57
Subtle bug that causes stack corruption on Android (run ok on iOS)
#include <openssl/md5.h>
string md5_evil(const char *message) {
unsigned char digest[MD5_DIGEST_LENGTH];
MD5((unsigned char*)message, strlen(message), digest);
char md[2*MD5_DIGEST_LENGTH];
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(&md[i*2], "%02x", (unsigned int)digest[i]);
}
return string(md);
@hiepnd
hiepnd / gist:9303658
Last active August 29, 2015 13:56
Never trust a C++ function that return char *
#include <iostream>
/**
* You can run online at http://code.hackerearth.com/
*/
using namespace std;
const char *doubleString(const char *s){
string ss = string(s) + string(s);