Initial commit
This commit is contained in:
commit
686dcaf351
68 changed files with 6230 additions and 0 deletions
2
glsl/PI.glsl
Normal file
2
glsl/PI.glsl
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Half the circumference of a unit circle
|
||||
#define M_PI 3.1415926535897932384626433
|
27
glsl/bump_height.glsl
Normal file
27
glsl/bump_height.glsl
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Create a bumpy surface by using procedural noise to generate a height (
|
||||
// displacement in normal direction).
|
||||
//
|
||||
// Inputs:
|
||||
// is_moon whether we're looking at the moon or centre planet
|
||||
// s 3D position of seed for noise generation
|
||||
// Returns elevation adjust along normal (values between -0.1 and 0.1 are
|
||||
// reasonable.
|
||||
float bump_height( bool is_moon, vec3 s)
|
||||
{
|
||||
float b =
|
||||
+0.05*(0.5+0.5*smooth_heaviside(perlin_noise( 1.0*s),10)*2-1)
|
||||
+(0.5 + 0.44*float(!is_moon))*(0.5+0.5*smooth_heaviside((
|
||||
+(0.6+0.14*float(is_moon))*perlin_noise( 2.0*s)
|
||||
+(0.2-0.04*float(is_moon))*perlin_noise( 4.0*s)
|
||||
+(0.2-0.1*float(is_moon))*perlin_noise( 8.0*s)
|
||||
-0.005*perlin_noise( 64.0*s)
|
||||
-0.001*perlin_noise( 128.0*s)
|
||||
),8-float(is_moon)*-s.x*7)*2-1)
|
||||
+0.01*(0.5+0.5*smooth_heaviside((
|
||||
+0.1*perlin_noise( 16.0*s)
|
||||
+0.8*perlin_noise( 32.0*s)
|
||||
+0.1*perlin_noise( 64.0*s)
|
||||
),4)*2-1)
|
||||
-.5;
|
||||
return 0.06*b+0.07;
|
||||
}
|
16
glsl/interpolate.glsl
Normal file
16
glsl/interpolate.glsl
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Using gl_TessCoord interpolate between values stored at three corners of a
|
||||
// triangle.
|
||||
//
|
||||
// Inputs:
|
||||
// v0 value at corner 0
|
||||
// v1 value at corner 1
|
||||
// v2 value at corner 2
|
||||
// Return linearly interpolated value based on gl_TessCoord.
|
||||
vec3 interpolate(vec3 bary, vec3 v0, vec3 v1, vec3 v2)
|
||||
{
|
||||
return bary.x * v0 + bary.y * v1 + bary.z * v2;
|
||||
}
|
||||
vec4 interpolate(vec3 bary, vec4 v0, vec4 v1, vec4 v2)
|
||||
{
|
||||
return bary.x * v0 + bary.y * v1 + bary.z * v2;
|
||||
}
|
8
glsl/pass-through.fs
Normal file
8
glsl/pass-through.fs
Normal file
|
@ -0,0 +1,8 @@
|
|||
in vec4 pos_fs_in;
|
||||
out vec3 color;
|
||||
void main()
|
||||
{
|
||||
// Set color to screen position to show something
|
||||
color = 0.5+0.5*pos_fs_in.xyz;
|
||||
}
|
||||
|
18
glsl/pass-through.tcs
Normal file
18
glsl/pass-through.tcs
Normal file
|
@ -0,0 +1,18 @@
|
|||
layout (vertices = 3) out;
|
||||
|
||||
in vec4 pos_cs_in[];
|
||||
out vec4 pos_es_in[];
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate the tess levels
|
||||
if(gl_InvocationID == 0)
|
||||
{
|
||||
gl_TessLevelOuter[0] = 1;
|
||||
gl_TessLevelOuter[1] = 1;
|
||||
gl_TessLevelOuter[2] = 1;
|
||||
gl_TessLevelInner[0] = 1;
|
||||
}
|
||||
pos_es_in[gl_InvocationID] = pos_cs_in[gl_InvocationID];
|
||||
}
|
||||
|
10
glsl/pass-through.tes
Normal file
10
glsl/pass-through.tes
Normal file
|
@ -0,0 +1,10 @@
|
|||
layout(triangles, equal_spacing, ccw) in;
|
||||
in vec4 pos_es_in[];
|
||||
out vec4 pos_fs_in;
|
||||
// expects: interpolate
|
||||
void main()
|
||||
{
|
||||
pos_fs_in = interpolate(gl_TessCoord,pos_es_in[0], pos_es_in[1], pos_es_in[2]);
|
||||
gl_Position = pos_fs_in;
|
||||
}
|
||||
|
6
glsl/pass-through.vs
Normal file
6
glsl/pass-through.vs
Normal file
|
@ -0,0 +1,6 @@
|
|||
in vec4 pos_vs_in;
|
||||
out vec4 pos_cs_in;
|
||||
void main()
|
||||
{
|
||||
pos_cs_in = pos_vs_in;
|
||||
}
|
21
glsl/random2.glsl
Normal file
21
glsl/random2.glsl
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Generate a pseudorandom 2D vector based on a 2D or 3D seed.
|
||||
//
|
||||
// https://thebookofshaders.com/edit.php#11/2d-gnoise.frag
|
||||
//
|
||||
// Inputs:
|
||||
// st 2D seed
|
||||
// Returns 2D random point in [0,1]²
|
||||
vec2 random2(vec2 st){
|
||||
st = vec2( dot(st,vec2(127.1,311.7)),
|
||||
dot(st,vec2(269.5,183.3)) );
|
||||
return fract(sin(st)*43758.5453123);
|
||||
}
|
||||
// Inputs:
|
||||
// st 3D seed
|
||||
// Returns 2D random point in [0,1]²
|
||||
vec2 random2(vec3 st){
|
||||
vec2 S = vec2( dot(st,vec3(127.1,311.7,783.089)),
|
||||
dot(st,vec3(269.5,183.3,173.542)) );
|
||||
return fract(sin(S)*43758.5453123);
|
||||
}
|
||||
|
13
glsl/smooth_heaviside.glsl
Normal file
13
glsl/smooth_heaviside.glsl
Normal file
|
@ -0,0 +1,13 @@
|
|||
// A useful filter, behaves like a smoothly parameterized smooth Heaviside
|
||||
// function.
|
||||
//
|
||||
// Inputs:
|
||||
// x input scalar (-inf, inf)
|
||||
// t control steepness of step function: --> 0 more linear, --> inf more like
|
||||
// Heaviside function (piecewise constant function x<0--> -1 , x>0 --> 1)
|
||||
// Returns scalar value
|
||||
float smooth_heaviside( float x, float t)
|
||||
{
|
||||
return (1./(1.+exp(-2.*t*(x)))-1./2.)/(1./(1.+exp(-2.*t*1.))-1./2.);
|
||||
}
|
||||
|
3
glsl/version410.glsl
Normal file
3
glsl/version410.glsl
Normal file
|
@ -0,0 +1,3 @@
|
|||
#version 410 core
|
||||
// We're using version 4.10. This should always be the first file listed and no
|
||||
// other files should attempt to specify a version.
|
Reference in a new issue