Tag GLSL

GLSL Astronomy compute shader

Today I present you my GLSL Astronomy compute shader, which I use in my demo productions and games. ☺

// Copyright (C) 2018, Benjamin "BeRo" Rosseaux (benjamin@rosseaux.de) - License: CC0// Hint: It's not super accurate, but it should be good enough for games and demos with sky rendering.#version 430
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
uniform vec3 tc; // Time constant
layout(std430) buffer ssboAstronomy { vec3 sunPosition; float sunDistance; vec3 moonPosition; float moonDistance; float moonPhase; mat3 celestialTransform; };
const float HalfPI = 1.5707963267948966, // 1.570796326794896619231, PI = 3.141592653589793, // 3.141592653589793238463, PI2 = 6.283185307179586; // 6.283185307179586476925
// The AMD windows GPU drivers do not seem to like constant double precision values here, // so no const prefix in this case.double astronomicalUnitsToKiloMeters = 149597871.0;
const vec2 sinCosOffsets = vec2(0.0, HalfPI);
double(read more)