Skip to content

Commit

Permalink
feat: added the getting started notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
samthakur587 committed Jul 30, 2024
1 parent 7e92df3 commit d0c9f2c
Show file tree
Hide file tree
Showing 14 changed files with 946 additions and 777 deletions.
29 changes: 29 additions & 0 deletions examples/PerlinNoise.cgl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
shader PerlinNoise {
vertex {
input vec3 position;
output vec2 vUV;

void main() {
vUV = position.xy * 10.0;
gl_Position = vec4(position, 1.0);
}
}

// Perlin Noise Function
float perlinNoise(vec2 p) {
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}

// Fragment Shader
fragment {
input vec2 vUV;
output vec4 fragColor;

void main() {
float noise = perlinNoise(vUV);
float height = noise * 10.0;
vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
fragColor = vec4(color, 1.0);
}
}
}
28 changes: 28 additions & 0 deletions examples/PerlinNoise.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#version 450 core

//vertex shader
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 texCoord;

out vec2 vTexCoord;

void main()
{
vTexCoord = texCoord;
gl_Position = vec4(position, 1.0);
}

in vec2 vTexCoord;
out vec4 fragColor;

// fragment shader

float marblePattern(vec2 uv) {
return 0.5 + 0.5 * sin(10.0 * uv.x + iTime);
}

void main()
{
vec3 color = vec3(marblePattern(vTexCoord), 0.0, 0.0);
fragColor = vec4(color, 1.0);
}
38 changes: 38 additions & 0 deletions examples/PerlinNoise.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
float perlinNoise(float2 p) {
return fract((sin(dot(p, float2(12.9898, 78.233))) * 43758.5453));
}

struct Vertex_INPUT {
float3 position : POSITION;
};

struct Vertex_OUTPUT {
float4 position : SV_POSITION;
float2 vUV : TEXCOORD0;
};

Vertex_OUTPUT VSMain(Vertex_INPUT input) {
Vertex_OUTPUT output;
output.vUV = (input.position.xy * 10.0);
output.position = float4(input.position, 1.0);
return output;
}

struct Fragment_INPUT {
float2 vUV : TEXCOORD0;
};

struct Fragment_OUTPUT {
float4 fragColor : SV_TARGET0;
};

Fragment_OUTPUT PSMain(Fragment_INPUT input) {
Fragment_OUTPUT output;
float noise = perlinNoise(input.vUV);
float height = (noise * 10.0);
float3 color = float3((height / 10.0), (1.0 - (height / 10.0)), 0.0);
output.fragColor = float4(color, 1.0);
return output;
}


39 changes: 39 additions & 0 deletions examples/PerlinNoise.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <metal_stdlib>
using namespace metal;

float perlinNoise(float2 p) {
return fract((sin(dot(p, float2(12.9898, 78.233))) * 43758.5453));
}

struct Vertex_INPUT {
float3 position [[attribute(0)]];
};

struct Vertex_OUTPUT {
float4 position [[position]];
float2 vUV;
};

vertex Vertex_OUTPUT vertex_main(Vertex_INPUT input [[stage_in]]) {
Vertex_OUTPUT output;
output.vUV = (input.position.xy * 10.0);
output.position = float4(input.position, 1.0);
return output;
}

struct Fragment_INPUT {
float2 vUV [[stage_in]];
};

struct Fragment_OUTPUT {
float4 fragColor [[color(0)]];
};

fragment Fragment_OUTPUT fragment_main(Fragment_INPUT input [[stage_in]]) {
Fragment_OUTPUT output;
float noise = perlinNoise(input.vUV);
float height = (noise * 10.0);
float3 color = float3((height / 10.0), (1.0 - (height / 10.0)), 0.0);
output.fragColor = float4(color, 1.0);
return output;
}
8 changes: 0 additions & 8 deletions examples/example_program.cgl

This file was deleted.

Loading

0 comments on commit d0c9f2c

Please sign in to comment.