Space Sim
Loading...
Searching...
No Matches
mesh.frag File Reference

Renders the mesh planet surface and calculates light. More...

Go to the source code of this file.

Data Structures

struct  Particle
struct  WarpLayer
struct  PerlinLayer
struct  FBMLayer

Macros

#define BODY_COUNT   30000
#define MAX_NODES   100000
#define LODMAX   4
#define MAX_CHUNKS   1000
#define MAX_LAYERS   24

Functions

 layout (location=0) out vec4 fragColor
 layout (std140) uniform CameraData
 layout (std430, binding=1) buffer ParticleData
float hash (vec2 p)
float shadow_calculation (vec4 pos, float diff)
float linearize (float z)
 layout (std140, binding=2) uniform RenderingData
void main ()

Variables

in vec4 vColor
in vec3 vNormal
in vec4 FragPos
in float vDist
in vec4 vFragPosLightSpace
uniform int uSelected
uniform float uTime
uniform sampler2D normal_map
uniform sampler2D diffuse_tex
uniform sampler2D spec_tex
uniform sampler2D ao_tex
uniform sampler2D shadow_map
uniform int uType
uniform int lod_level
uniform int cid
const mat4 ditherMatrix
const int bayer16x16 [16][16]
uniform float uChunkDist
const vec3 tX = vec3(0, 0, 1)
const vec3 bX = vec3(0, 1, 0)
const vec3 nXw = vec3(1, 0, 0)
const vec3 tY = vec3(1, 0, 0)
const vec3 bY = vec3(0, 0, 1)
const vec3 nYw = vec3(0, 1, 0)
const vec3 tZ = vec3(1, 0, 0)
const vec3 bZ = vec3(0, 1, 0)
const vec3 nZw = vec3(0, 0, 1)

Detailed Description

Renders the mesh planet surface and calculates light.

Definition in file mesh.frag.


Data Structure Documentation

◆ Particle

struct Particle

Definition at line 7 of file main.h.

Data Fields
vec3 pos
vec3 vel
vec4 p_m
vec4 mat
vec4 vel
vec4 acc

◆ WarpLayer

struct WarpLayer

Definition at line 371 of file types.h.

Data Fields
vec3 offset0
float freq0
vec3 offset1
float freq1
vec3 offset2
float freq2
float amp
float pad0
float pad1
float pad3

◆ PerlinLayer

struct PerlinLayer

Definition at line 387 of file types.h.

Data Fields
float freq
float amp
float pad0
float pad1

◆ FBMLayer

struct FBMLayer

Definition at line 397 of file types.h.

Data Fields
float freq
float amp
float pad0
float pad1

Macro Definition Documentation

◆ BODY_COUNT

#define BODY_COUNT   30000

Definition at line 27 of file mesh.frag.

◆ MAX_NODES

#define MAX_NODES   100000

Definition at line 28 of file mesh.frag.

◆ LODMAX

#define LODMAX   4

Definition at line 53 of file mesh.frag.

◆ MAX_CHUNKS

#define MAX_CHUNKS   1000

Definition at line 54 of file mesh.frag.

◆ MAX_LAYERS

#define MAX_LAYERS   24

Definition at line 70 of file mesh.frag.

Function Documentation

◆ layout() [1/4]

layout ( location = 0)

References fragColor, and layout().

◆ layout() [2/4]

layout ( std140 )

Definition at line 14 of file mesh.frag.

References layout(), projection, and view.

◆ layout() [3/4]

layout ( std430 ,
binding = 1 )

Definition at line 36 of file mesh.frag.

References BODY_COUNT, and layout().

◆ hash()

float hash ( vec2 p)

Definition at line 143 of file mesh.frag.

References hash().

◆ shadow_calculation()

float shadow_calculation ( vec4 pos,
float diff )

Definition at line 162 of file mesh.frag.

References shadow_calculation(), shadow_map, vec4::w, and vec3::z.

Referenced by main(), and shadow_calculation().

◆ linearize()

float linearize ( float z)

Definition at line 191 of file mesh.frag.

References linearize().

◆ layout() [4/4]

layout ( std140 ,
binding = 2 )

Definition at line 197 of file mesh.frag.

References layout().

◆ main()

Variable Documentation

◆ vColor

in vec4 vColor

Definition at line 8 of file mesh.frag.

◆ vNormal

in vec3 vNormal

Definition at line 9 of file mesh.frag.

◆ FragPos

in vec4 FragPos

Definition at line 10 of file mesh.frag.

Referenced by main().

◆ vDist

in float vDist

Definition at line 11 of file mesh.frag.

◆ vFragPosLightSpace

in vec4 vFragPosLightSpace

Definition at line 12 of file mesh.frag.

Referenced by main().

◆ uSelected

uniform int uSelected

Definition at line 25 of file mesh.frag.

Referenced by main().

◆ uTime

uniform float uTime

Definition at line 26 of file mesh.frag.

◆ normal_map

uniform sampler2D normal_map

Definition at line 61 of file mesh.frag.

◆ diffuse_tex

uniform sampler2D diffuse_tex

Definition at line 62 of file mesh.frag.

Referenced by main().

◆ spec_tex

uniform sampler2D spec_tex

Definition at line 63 of file mesh.frag.

◆ ao_tex

uniform sampler2D ao_tex

Definition at line 64 of file mesh.frag.

◆ shadow_map

uniform sampler2D shadow_map

Definition at line 65 of file mesh.frag.

Referenced by shadow_calculation().

◆ uType

uniform int uType

Definition at line 67 of file mesh.frag.

◆ lod_level

uniform int lod_level

Definition at line 68 of file mesh.frag.

Referenced by load_chunks(), and main().

◆ cid

uniform int cid

Definition at line 69 of file mesh.frag.

◆ ditherMatrix

const mat4 ditherMatrix
Initial value:
= mat4(
0.0, 0.5, 0.125, 0.625,
0.75, 0.25, 0.875, 0.375,
0.1875, 0.6875, 0.0625, 0.5625,
0.9375, 0.4375, 0.8125, 0.3125
)
Definition types.h:51

Definition at line 119 of file mesh.frag.

◆ bayer16x16

const int bayer16x16[16][16]
Initial value:
= {{0, 128, 32, 160, 8, 136, 40, 168, 2, 130, 34, 162, 10, 138, 42, 170},
{192, 64, 224, 96, 200, 72, 232, 104, 194, 66, 226, 98, 202, 74, 234, 106},
{48, 176, 16, 144, 56, 184, 24, 152, 50, 178, 18, 146, 58, 186, 26, 154},
{240, 112, 208, 80, 248, 120, 216, 88, 242, 114, 210, 82, 250, 122, 218, 90},
{12, 140, 44, 172, 4, 132, 36, 164, 14, 142, 46, 174, 6, 134, 38, 166},
{204, 76, 236, 108, 196, 68, 228, 100, 206, 78, 238, 110, 198, 70, 230, 102},
{60, 188, 28, 156, 52, 180, 20, 148, 62, 190, 30, 158, 54, 182, 22, 150},
{252, 124, 220, 92, 244, 116, 212, 84, 254, 126, 222, 94, 246, 118, 214, 86},
{3, 131, 35, 163, 11, 139, 43, 171, 1, 129, 33, 161, 9, 137, 41, 169},
{195, 67, 227, 99, 203, 75, 235, 107, 193, 65, 225, 97, 201, 73, 233, 105},
{51, 179, 19, 147, 59, 187, 27, 155, 49, 177, 17, 145, 57, 185, 25, 153},
{243, 115, 211, 83, 251, 123, 219, 91, 241, 113, 209, 81, 249, 121, 217, 89},
{15, 143, 47, 175, 7, 135, 39, 167, 13, 141, 45, 173, 5, 133, 37, 165},
{207, 79, 239, 111, 199, 71, 231, 103, 205, 77, 237, 109, 197, 69, 229, 101},
{63, 191, 31, 159, 55, 183, 23, 151, 61, 189, 29, 157, 53, 181, 21, 149},
{255, 127, 223, 95, 247, 119, 215, 87, 253, 125, 221, 93, 245, 117, 213, 85}}

Definition at line 125 of file mesh.frag.

◆ uChunkDist

uniform float uChunkDist

Definition at line 148 of file mesh.frag.

◆ tX

const vec3 tX = vec3(0, 0, 1)

Definition at line 149 of file mesh.frag.

◆ bX

const vec3 bX = vec3(0, 1, 0)

Definition at line 150 of file mesh.frag.

◆ nXw

const vec3 nXw = vec3(1, 0, 0)

Definition at line 151 of file mesh.frag.

◆ tY

const vec3 tY = vec3(1, 0, 0)

Definition at line 153 of file mesh.frag.

◆ bY

const vec3 bY = vec3(0, 0, 1)

Definition at line 154 of file mesh.frag.

◆ nYw

const vec3 nYw = vec3(0, 1, 0)

Definition at line 155 of file mesh.frag.

◆ tZ

const vec3 tZ = vec3(1, 0, 0)

Definition at line 157 of file mesh.frag.

◆ bZ

const vec3 bZ = vec3(0, 1, 0)

Definition at line 158 of file mesh.frag.

◆ nZw

const vec3 nZw = vec3(0, 0, 1)

Definition at line 159 of file mesh.frag.