Skip to content

Instantly share code, notes, and snippets.

View JSandusky's full-sized avatar

Jonathan Sandusky JSandusky

  • Ohio, United States
View GitHub Profile
@JSandusky
JSandusky / Bytes.cpp
Last active November 17, 2018 02:19
Urho3D "Bytes" resource for arbitrary binary files in attributes/etc
#include <Urho3D/Resource/Bytes.h>
#include <Urho3D/Core/Context.h>
namespace Urho3D
{
/// Construct.
Bytes::Bytes(Context* context) : Resource(context)
{
@JSandusky
JSandusky / ParticleEmitter.cpp
Created October 28, 2018 00:56
Particle emission with interpolation
//
// Copyright (c) 2008-2018 the Urho3D project.
//
// 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:
//
@JSandusky
JSandusky / BakeNorm.fx
Created October 1, 2018 06:52
Render normal to texture
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif
matrix WorldViewProjection;
@JSandusky
JSandusky / Disp.inc
Created September 23, 2018 19:49
Monogame PBR Effect w/ POM
// Performs parallax
float HeightFieldRaycast(float2 dp, float2 ds)
{
const int linearSteps = 20;
const int binarySteps = 10;
float size = 1.0 / float(linearSteps);
float depth = 0.0;
for (int i = 0; i < linearSteps; i++)
@JSandusky
JSandusky / DebugRenderer.cs
Created September 10, 2018 06:40
MonoGame DebugRenderer w/ depth + tris
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Graphics
{
@JSandusky
JSandusky / MeshBatch.cs
Created September 8, 2018 02:35
Monogame automatic sorting and instancing of common draws
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using DelveLib;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Delve.Graphics
@JSandusky
JSandusky / imgui.cpp
Last active July 30, 2018 02:15
ImGui::InputText with caret at end
bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
ImGuiContext& g = *GImGui;
std::vector<String> excludedExtensions = {
".exe",
".dll",
".bat",
".ini",
".layout",
".ilk",
".lib",
".pdb",
};
@JSandusky
JSandusky / Effects\WaterGS.hlsl
Created May 13, 2018 03:31
DX11 Geometry Shader in Monogame
cbuffer ShaderData : register(b0)
{
matrix WorldViewProjection;
float3 LightDirection;
float3 LightColor;
};
struct VertexShaderOutput
{
@JSandusky
JSandusky / Example.cs
Created April 28, 2018 19:52
ImGuiCLI Example
using ImGuiCLI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace ImGuiCLITest
{
/// <summary>
/// This is the main type for your game.
/// </summary>