Skip to content

Instantly share code, notes, and snippets.

@leon196
leon196 / raymarch.gdshader
Created March 29, 2022 23:26
Raymarching example for Godot custom post process
// Godot custom post process manual:
// https://docs.godotengine.org/en/stable/tutorials/shaders/advanced_postprocessing.html
shader_type spatial;
render_mode unshaded;
uniform float ray_count = 20.;
uniform float geo_count = 8.;
uniform float geo_size = 2.5;
uniform float geo_shell = .1;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class Geometry : MonoBehaviour {
public Material material;
private Transform camTransform;
// En C# dans un script
width = 100;
height = 1;
texture = new Texture2D(width, height, TextureFormat.RGBAFloat, false);
texture.filterMode = FilterMode.Point;
Color[] array = new Color[width*height];
@leon196
leon196 / boid.shader
Last active December 26, 2017 11:17
[numthreads(8,8,1)]
void ComputeBoid (uint3 id : SV_DispatchThreadID)
{
float epsilon = 0.0001;
float2 position = _BoidBuffer[id.xy].xy;
float2 velocity = _BoidBuffer[id.xy].zw;
float2 target = float2(0,0);
float2 offset = float2(0,epsilon);
float2 gravity = normalize(target-position+epsilon);
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class RenderImage : MonoBehaviour
{
public int width = 4096;
using UnityEngine;
using System.Collections;
public class FrameBuffer
{
RenderTexture[] textures;
int currentTexture;
public FrameBuffer (int count)
{
Shader "Custom/Equirectangle"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Panorama ("Panorama", CUBE) = "white" {}
}
SubShader
{
Pass
Shader "Custom/NormalDisplace" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
Cull Off
Shader "Unlit/Test" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
Cull Off
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Camera))]
public class FrameBuffer : MonoBehaviour
{
public string textureName = "_FrameBuffer";
Camera cameraCapture;
int currentTexture;
RenderTexture[] textures;