This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @Cyanilux | |
// Note : Also requires setting up "_TessellationUniform" Float in Blackboard | |
/* | |
Allows you to inject tessellation into SG & URP, but hacky / can be difficult to work with. | |
While this works, it's maybe not as useful as you might think. I believe any vertex displacement would need to be | |
taken out of the graph and moved into the domain function below (since tessellation still runs after vertex shader). | |
I thought about using the VertexDescriptionFunction from the generated code, but sadly that's generated after the injection point | |
so can't be called as it's undeclared at that point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/Cyanilux/status/1396848736022802435?s=20 | |
#ifndef GRASS_INSTANCED_INCLUDED | |
#define GRASS_INSTANCED_INCLUDED | |
// ---------------------------------------------------------------------------------- | |
// Graph should contain Boolean Keyword, "PROCEDURAL_INSTANCING_ON", Global, Multi-Compile. | |
// Must have two Custom Functions in vertex stage. One is used to attach this file (see Instancing_float below), | |
// and another to set #pragma instancing_options : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/Cyanilux/status/1396848736022802435 | |
// Requires a specific shader to read the _PerInstanceData buffer at SV_InstanceID | |
// I use a shader made in Shader Graph, See : https://gist.github.com/Cyanilux/4046e7bf3725b8f64761bf6cf54a16eb | |
// Also note, there's no frustum culling involved in this example. Typically a compute shader is used for this. | |
using UnityEngine; | |
public class DrawGrass : MonoBehaviour { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.Rendering.Universal; | |
public class CustomRendererFeature : ScriptableRendererFeature { | |
public class CustomRenderPass : ScriptableRenderPass { | |
private Settings settings; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.Rendering.Universal; | |
public class GlitchRenderFeature : ScriptableRendererFeature { | |
class CustomRenderPass : ScriptableRenderPass { | |
private Settings settings; | |
private FilteringSettings filteringSettings; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copies the camera buffer after rendering opaques, to _CameraOpaqueTexture property so the Scene Color node can work in the Built-in RP. | |
Attach this script to the Main Camera (and any other cameras you want an Opaque Texture for) | |
Will also work for Scene Views (Though if a new window is opened will need to enter & exit play mode) | |
Tested in 2022.2 | |
@Cyanilux | |
*/ | |
using UnityEngine; | |
using UnityEngine.Rendering; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.Rendering.Universal; | |
/* | |
- Renders DepthOnly pass to _CameraDepthTexture, filtered by LayerMask | |
- If the depth texture is generated via a Depth Prepass, URP uses the Opaque Layer Mask at the top of the Forward/Universal Renderer asset | |
to determine which objects should be rendered to the depth texture. This feature can be used to render objects on *other layers* into the depth texture as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Afaik in Unity 2022.2, | |
If URP uses a Depth Prepass : | |
- The depth texture will only contain opaque objects, based on the Default Opaque Layer Mask | |
at the top of the Universal Renderer asset. | |
- So if you remove a layer from that and instead render it with RenderObjects features, | |
those objects no longer appear in the depth texture, even if their shader is writing depth :( | |
- Same goes for any Transparent objects with ZWrite On. The depth texture won't include those | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage in some other script | |
[FilterObjectPicker("Projectile")] | |
public GameObject projectilePrefab; | |
// When clicking object field in inspector, would only see gameobjects with "Projectile" in name. | |
// Can remove filter text at top of object picker to see all gameobjects again. | |
// To allow scene references, add second param as true. e.g. : | |
[FilterObjectPicker("Test", true)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
using UnityEditorInternal; | |
using System.IO; | |
public class Tex2DArrayCreator : EditorWindow { | |
private string fileName; | |
private List<Texture2D> textures = new List<Texture2D>(); |
NewerOlder