Skip to content

Instantly share code, notes, and snippets.

View rondreas's full-sized avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / cutHardEdges.py
Created February 13, 2018 15:43
Cut Hard Edges on selected object
import pymel.core as pm
# Get all non smooth edges, and cut their UVs
hard_edges = [e for e in pm.selected()[0].e if not e.isSmooth()]
pm.polyMapCut(hard_edges)
@rondreas
rondreas / selectHardEdges.cpp
Created February 26, 2018 16:41
MEL Command for selecting hard edges,
//
// Copyright (C) Andreas Rånman
//
// File: selectHardEdgesCmd.cpp
//
// MEL Command: selectHardEdges
//
// Author: Maya Plug-in Wizard 2.0
//
@rondreas
rondreas / xformMirror.py
Last active June 8, 2021 21:49
Script to mirror transform similar to Maya's Joint Mirror Tool.
import pymel.core as pm
def xformMirror(transforms=[], across='YZ', behaviour=True):
""" Mirrors transform across hyperplane.
transforms -- list of Transform or string.
across -- plane which to mirror across.
behaviour -- bool
"""
@rondreas
rondreas / SDFSphere.cs
Last active September 13, 2018 14:41
Attempting to get a grip on shaders after being inspired by: http://blog.camposanto.com/post/171934927979/hi-im-matt-wilde-an-old-man-from-the-north-of
using UnityEngine;
[ExecuteInEditMode]
public class SDFSphere : MonoBehaviour {
private void Update()
{
// Set a global value that we can use in our shader.
Shader.SetGlobalVector("_sdfSphere_position", this.transform.position);
}
@rondreas
rondreas / Replacer.cs
Created October 10, 2018 11:44
Unity Editor Tool to attempt replace selected GameObjects with any asset matching the name of selected.
using UnityEngine;
using UnityEditor;
public class Replacer : EditorWindow
{
[MenuItem("Window/Replacer")]
public static void ShowWindow()
{
EditorWindow.GetWindow<Replacer>("Replace GameObject");
}
@rondreas
rondreas / VertexWind.shader
Created October 11, 2018 09:47
Vertex displacement shader to simulate wind.
Shader "Custom/VertexWind" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
_Normal("Normal Map", 2D) = "bump" {}
_CutOff("Alpha Cutoff", Range(0, 1)) = 0.5
// Implementation of effect described at: https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/
Shader "Custom/DrawSimple" {
SubShader{
ZWrite Off
ZTest Always
Lighting Off
Pass {
CGPROGRAM
#pragma vertex VShader
@rondreas
rondreas / fixNormals.py
Last active November 19, 2018 15:33
hardsurface modelling script to set normals for all vertices on a face.
import pymel.core as pm
def faceNormal():
""" """
# Store old selection,
selection = pm.selected()
# Convert selection to faces,
pm.mel.ConvertSelectionToFaces()
@rondreas
rondreas / toggleComponents.py
Created November 19, 2018 16:44
Quick script to allow hotkeying a toggle for converting selection, to imitate the default command of CTRL + F9/F10/F11.
"""
Quick script to allow hotkeying a toggle for converting selection, to imitate the default
command of CTRL + F9/F10/F11.
"""
import pymel.core as pm
class eSelection(object):