Skip to content

Instantly share code, notes, and snippets.

View Stektpotet's full-sized avatar
🎯
Focusing

Halvor Stektpotet

🎯
Focusing
  • Norwegian University of Science and Technology, SINTEF Ocean
  • Trondheim, Norway
View GitHub Profile
@Stektpotet
Stektpotet / Something.hlsl
Last active January 2, 2020 14:33
Compute Shader variations
//named with '.hlsl' extension to get highlighting, it's really a '.compute'-file
#pragma kernel CSMain
RWTexture3D<float4> Result;
// if Shader Model doesn't support kernel threadgroups in the Z axis
// organize the threads differently
#if SHADER_TARGET < 40
[numthreads(16, 16, 1)]
#else
@Stektpotet
Stektpotet / MinMaxSliderAttribute.cs
Created May 14, 2019 20:37
MinMax attribute with text fields to set upper and lower limits
using UnityEngine;
public class MinMaxSliderAttribute : PropertyAttribute
{
public readonly float max;
public readonly float min;
public MinMaxSliderAttribute( float min, float max )
{
this.min = min;
this.max = max;
using System;
using UnityEngine;
using UnityEngine.Events;
namespace HumanAPI
{
[RequireComponent(typeof(Collider))]
public class Trigger : MonoBehaviour
{
@Stektpotet
Stektpotet / Trigger.cs
Last active September 15, 2017 22:40
Unity: Simple Trigger system. (Extremely useful for making different parts of your game/app connect quickly by unity's own implementation of delegate types)
using UnityEngine;
using UnityEngine.Events;
public abstract class Trigger : MonoBehaviour {
public LayerMask activatorLayers;
[SerializeField]
private bool explicitActivator;
@Stektpotet
Stektpotet / SplatLayer.cs
Last active February 14, 2017 19:15
WIP stuff for blending textures (SplatLayers)
using System;
using System.Collections.Generic;
using UnityEngine;
namespace LowPolySystems
{
[System.Serializable]
[CreateAssetMenu( fileName = "default blends", menuName = "wat")]
public class BlendMode : ScriptableObject
{
Shader "Custom/StandardVertex" {
Properties {
_Color ("ColorTint", Color) = (1,1,1)
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
@Stektpotet
Stektpotet / AttributeDrawer.cs
Last active August 30, 2016 21:24
C# Scripts I've made to test implementation of a few topics in number theory
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;
namespace EditorAttributes
{
[CustomPropertyDrawer(typeof(ButtonAttribute))]
public class ButtonDrawer : PropertyDrawer
{
using UnityEngine;
using System;
/// <summary>
/// All scripted behaviour that needs access to internal components should inherit from this.
/// </summary>
public static class ExtensionMethods
{
/// <summary>
/// Requires a component from the gameobject currently beeing scripted
/// without the need for constant use of GetComponent or messy inspectors
using UnityEngine;
using System;
/// <summary>
/// All scripted behaviour that needs access to internal components should inherit from this.
/// </summary>
public abstract class ScriptedBehaviour : MonoBehaviour
{
/// <summary>
/// Requires a component from the gameobject currently beeing scripted
/// without the need for constant use of GetComponent or messy inspectors
@Stektpotet
Stektpotet / core-manual.css
Last active November 1, 2015 15:05
Dark-theme documentation for viewing in Visual Studio 2015 dark-themed. Place core.css in `...\Unity\Editor\Data\Documentation\en\StaticFiles\css\`. Place core-manual.css in `...\Unity\Editor\Data\Documentation\en\StaticFilesManual\css\` and rename it to `core.css`.
/* ====================================================
* Company: Unity Technologies
* Author: Rickard Andersson, rickard@unity3d.com
* ====================================================
* Modified by : Halvor Smedås, stektpotet@gmail.com
* ==================================================== */
/*Fix for bottom part of the page, as pointed out by /u/EristicEscalator. Thanks!*/
body { background-color: #1E1E1E; }