Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Rånman rondreas

View GitHub Profile
@rondreas
rondreas / cutHardEdges.py
Created Feb 13, 2018
Cut Hard Edges on selected object
View cutHardEdges.py
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 Feb 26, 2018
MEL Command for selecting hard edges,
View selectHardEdges.cpp
//
// Copyright (C) Andreas Rånman
//
// File: selectHardEdgesCmd.cpp
//
// MEL Command: selectHardEdges
//
// Author: Maya Plug-in Wizard 2.0
//
@rondreas
rondreas / xformMirror.py
Last active Jun 8, 2021
Script to mirror transform similar to Maya's Joint Mirror Tool.
View xformMirror.py
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
"""
View SDFSphere.cs
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 Oct 10, 2018
Unity Editor Tool to attempt replace selected GameObjects with any asset matching the name of selected.
View Replacer.cs
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 Oct 11, 2018
Vertex displacement shader to simulate wind.
View VertexWind.shader
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
View DrawSimple.shader
// 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
View makelinks.py
@rondreas
rondreas / fixNormals.py
Last active Nov 19, 2018
hardsurface modelling script to set normals for all vertices on a face.
View fixNormals.py
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 Nov 19, 2018
Quick script to allow hotkeying a toggle for converting selection, to imitate the default command of CTRL + F9/F10/F11.
View toggleComponents.py
"""
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):