Skip to content

Instantly share code, notes, and snippets.

Dave Pape davepape

Block or report user

Report or block davepape

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davepape
davepape / gpw.cs
Last active Nov 19, 2019
Convert SEDAC global population data into a texture.
View gpw.cs
/*
Visualize data from SEDAC's Gridded Population of the World data set - https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11
Parses the population counts and converts the data into a greyscale texture.
The data file must be in ASCII format, with its extension changed to ".txt" in order for Unity to recognize it as a TextAsset.
*/
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
@davepape
davepape / dynamicTexture.cs
Created Nov 19, 2019
Create a Texture2D from scratch, and modify it slightly each frame.
View dynamicTexture.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dynamicTexture : MonoBehaviour
{
public int width=32;
public int height=32;
void Start()
@davepape
davepape / readQuakes.cs
Created Nov 12, 2019
Starting point for visualization project - read earthquake data from the USGS geojson data feed.
View readQuakes.cs
/* Example of reading earthquake data from the USGS data feed.
Starting point for visualization project.
This script requests GEOJson formatted data, then parses it and prints some of the information.
It requires the JSONObject class for Unity, which can be downloaded from https://github.com/mtschoen/JSONObject
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
@davepape
davepape / LatLonSphere.cs
Created Nov 12, 2019
Create a sphere, as a grid of points regularly spaced in latitude and longitude
View LatLonSphere.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LatLonSphere : MonoBehaviour
{
public int latRes=20, lonRes=40;
void Start()
{
@davepape
davepape / showInput.cs
Last active Oct 24, 2019
Display the state of a few example Unity Input values
View showInput.cs
// Display the state of a few example Unity Input values
// This script should be attached to a text object.
// It uses the "Jump" and "Cancel" buttons to switch between very slow framerate & 60 fps, so that the behavior of GetButtonDown & GetButtonUp can be seen.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class showInput : MonoBehaviour
{
@davepape
davepape / noiseland2.cs
Last active Nov 6, 2018
Combination of noiseland.cs & noisetex.cs - creates landscape geometry and a texture to apply to the geometry
View noiseland2.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class noiseland2 : MonoBehaviour {
public int numRows=10, numCols=10;
public float minX=-1, maxX=1, minY=-1, maxY=1;
public int tex_width=256;
@davepape
davepape / noisetex.cs
Last active Nov 6, 2018
Create a fractal, procedural texture by combining different frequencies of Perlin noise
View noisetex.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class noisetex : MonoBehaviour {
public int width=256;
public int height=256;
private Texture2D tex;
private Color32[] colors;
@davepape
davepape / noiseland.cs
Last active Nov 6, 2018
Create a fractal landscape by combining different frequencies of Perlin noise
View noiseland.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class noiseland : MonoBehaviour {
public int numRows=10, numCols=10;
public float minX=-1, maxX=1, minY=-1, maxY=1;
float height(float x, float y)
@davepape
davepape / fractalland.cs
Created Nov 1, 2018
Create a fractal landscape mesh in Unity3D, using midpoint subdivision
View fractalland.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fractalland : MonoBehaviour {
Vector3[][] newArray(int size)
{
Vector3[][] v = new Vector3[size][];
for (int i=0; i < size; i++)
@davepape
davepape / triangles3.cs
Last active Oct 18, 2018
Create a mesh of 2 triangles, with texture coordinates
View triangles3.cs
// Creating Mesh data in Unity
// This script should be attached to a GameObject that has a MeshFilter and MeshRenderer.
// The script will replace the MeshFilter's geometry by 2 triangles with texture coordinates.
// The vertex coords & tex coords are public variables so they can be manipulated from the Unity inspector.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class triangles3 : MonoBehaviour {
You can’t perform that action at this time.