Skip to content

Instantly share code, notes, and snippets.

Avatar

Felipe Lira phi-lira

View GitHub Profile
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active Dec 5, 2022
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
View UniversalPipelineTemplateShader.shader
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@phi-lira
phi-lira / UnlitTextureShadows.shader
Created Apr 30, 2020
Unlit Texture + Realtime Shadows shader
View UnlitTextureShadows.shader
Shader "Universal Render Pipeline/Custom/UnlitTextureShadows"
{
Properties
{
[MainColor] _BaseColor("BaseColor", Color) = (1,1,1,1)
[MainTexture] _BaseMap("BaseMap", 2D) = "white" {}
}
SubShader
{
@phi-lira
phi-lira / UnlitTexture.shader
Last active Nov 13, 2022
URP Unlit Texture example
View UnlitTexture.shader
Shader "Custom/UnlitTexture"
{
Properties
{
[MainColor] _BaseColor("BaseColor", Color) = (1,1,1,1)
[MainTexture] _BaseMap("BaseMap", 2D) = "white" {}
}
// Universal Render Pipeline subshader. If URP is installed this will be used.
SubShader
@phi-lira
phi-lira / HowToProfilerBuildTime.txt
Created Jul 15, 2020
How to profile build time for a Unity project
View HowToProfilerBuildTime.txt
1) Enable Profiler in OnPreprocessBuild like following:
public void OnPreprocessBuild(BuildReport report)
{
Profiler.enabled = true;
Profiler.enableBinaryLog = true;
Profiler.logFile = "profilerlog.raw";
Debug.Log("Enabling Profiler");
}
2) Disable Profiler in OnPostProcessBuild
3) Now put Profiler.Begin/EndSample in the desired code.
@phi-lira
phi-lira / DrawMeshPass
Last active Sep 6, 2022
Custom Pass injected by script
View DrawMeshPass
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
[ExecuteInEditMode]
public class CustomPass : MonoBehaviour
{
public Mesh mesh;
public Material material;
DrawMeshPass m_DrawMeshPass;
@phi-lira
phi-lira / LightweightLightSorting.cs
Created Dec 11, 2019
Old example of LWRP that sorted lights using the LightIndexMap
View LightweightLightSorting.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
#if UNITY_EDITOR
using UnityEditor.Experimental.Rendering.LightweightPipeline;
#endif
using UnityEngine.Experimental.GlobalIllumination;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
@phi-lira
phi-lira / CustomRenderPassFeature.cs
Created Jun 19, 2019
Custom Render Feature script template to be added to a LWRP Renderer. Drag 'n Drop this script to your project, write the desired rendering code. It now it's available to be added to a LWRP renderer by clicking on the + icon under renderer features in the Renderer inspector.
View CustomRenderPassFeature.cs
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.LWRP;
public class CustomRenderPassFeature : ScriptableRendererFeature
{
class CustomRenderPass : ScriptableRenderPass
{
// This method is called before executing the render pass.
// It can be used to configure render targets and their clear state. Also to create temporary render target textures.
@phi-lira
phi-lira / CustomMaterialEditor.cs
Created Jan 20, 2016
CustomMaterialEditor - Unity
View CustomMaterialEditor.cs
//Copyright(c) 2015 Phil Lira - phil.rlira [at] gmail [dot] com
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all
@phi-lira
phi-lira / OverdrawDebugReplacement.cs
Last active Dec 21, 2021
Overdraw Debugger Unity
View OverdrawDebugReplacement.cs
using UnityEngine;
using System.Collections;
public class OverdrawDebugReplacement : MonoBehaviour
{
public Shader _OverdrawShader;
private Camera _Camera;
private bool _SceneFogSettings = false;
@phi-lira
phi-lira / manifest.json
Last active Oct 28, 2021
Lightweight Pipeline package manager manifest
View manifest.json
{
"registry": "https://staging-packages.unity.com",
"dependencies": {
"com.unity.render-pipelines.lightweight" : "2.0.0-preview"
}
}