Posted: 13th Nov 2021 22:57
As with most complicated things I attempt I always check with you lot first so I don't spend 2 days reinventing the wheel when there is already a solution out there but this search revealed nothing of any direct use, so ..

Has anyone coded, got or can link to a 3D atmosphere shader that's compatible with AppGameKit?

I know I can use the outline shader in the pack, make it wide and blue but its not quite the same effect, combined with the shield shader it gives some interesting results but there is no "scattering" so it just kills the overall effect.

I will attempt to code a shader tomorrow, so Sunday, really be a Sunday!!
Posted: 1st Dec 2021 17:30
I've found from BGE.
You need to convert shaders to AGK

http://www.mediafire.com/file/x7osasnh41nrbb1/atmosphere_26x.blend
https://blenderartists.org/t/atmospheric-scattering/462134/72

Open blend file in UPBGE 2.79



+ Code Snippet
VertexShader = """

//
// Atmospheric scattering vertex shader
//
// Author: Sean O'Neil
//
// Copyright (c) 2004 Sean O'Neil
//



uniform vec3 v3CameraPos;	   // The camera's current position
uniform vec3 v3LightPos;		// The direction vector to the light source
uniform vec3 m_fWavelength;	 // 1 / pow(wavelength, 4) for the red, green, and blue channels
uniform float fCameraHeight;	// The camera's current height
uniform float fCameraHeight2;   // fCameraHeight^2
uniform float fOuterRadius;	 // The outer (atmosphere) radius
uniform float fOuterRadius2;	// fOuterRadius^2
uniform float fInnerRadius;	 // The inner (planetary) radius
uniform float fInnerRadius2;	// fInnerRadius^2
uniform float fKrESun;		  // Kr * ESun
uniform float fKmESun;		  // Km * ESun
uniform float fKr4PI;		   // Kr * 4 * PI
uniform float fKm4PI;		   // Km * 4 * PI
uniform float fScale;		   // 1 / (fOuterRadius - fInnerRadius)
uniform float fScaleDepth;	  // The scale depth (i.e. the altitude at which the atmosphere's average density is found)
uniform float fScaleOverScaleDepth; // fScale / fScaleDepth

uniform int nSamples;
uniform float fSamples;



varying vec3 v3Direction, v, Vert;
varying float depth;

float scale(float fCos)
{
	float x = 1.0 - fCos;
	return fScaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));
}

void main(void)
{

	vec3 v3InvWavelength;
	
	v3InvWavelength.x = 1.0/pow(m_fWavelength.x, 4.0);
	v3InvWavelength.y = 1.0/pow(m_fWavelength.y, 4.0);
	v3InvWavelength.z = 1.0/pow(m_fWavelength.z, 4.0);


	// Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere)
	vec3 v3Pos = gl_Vertex.xyz;
	vec3 v3Ray = v3Pos - v3CameraPos;
	float fFar = length(v3Ray);
	v3Ray /= fFar;

	// Calculate the ray's starting position, then calculate its scattering offset
	vec3 v3Start = v3CameraPos;
	float fHeight = length(v3Start);
	float fDepth = exp(fScaleOverScaleDepth * (fInnerRadius - fCameraHeight));
	float fStartAngle = dot(v3Ray, v3Start) / fHeight;
	float fStartOffset = fDepth*scale(fStartAngle);


	float fStartDepth = exp(fScaleOverScaleDepth * (fInnerRadius - fCameraHeight));
	depth = clamp(fStartDepth*scale(fStartAngle),0.0,1.0);

	// Initialize the scattering loop variables
	//gl_FrontColor = vec4(0.0, 0.0, 0.0, 0.0);
	float fSampleLength = fFar / fSamples;
	float fScaledLength = fSampleLength * fScale;
	vec3 v3SampleRay = v3Ray * fSampleLength;
	vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5;

	// Now loop through the sample rays
	vec3 v3FrontColor = vec3(0.0, 0.0, 0.0);
	vec3 v3Attenuate = vec3(0.0, 0.0, 0.0);
	for(int i=0; i<nSamples; i++)
	{
		float fHeight = length(v3SamplePoint);
		float fDepth = exp(fScaleOverScaleDepth * (fInnerRadius - fHeight));
		float fLightAngle = dot(v3LightPos, v3SamplePoint) / fHeight;
		float fCameraAngle = dot(v3Ray, v3SamplePoint) / fHeight;
		float fScatter = (fStartOffset + fDepth*(scale(fLightAngle) - scale(fCameraAngle)));
		vec3 v3Attenuate = exp(-fScatter * (v3InvWavelength * fKr4PI + fKm4PI));
		v3FrontColor += v3Attenuate * (fDepth * fScaledLength);
		v3SamplePoint += v3SampleRay;
	}

	// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader
	gl_FrontSecondaryColor.rgb = v3FrontColor * fKmESun;
	gl_FrontColor.rgb = v3FrontColor * (v3InvWavelength * fKrESun);
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
	v3Direction = v3CameraPos - v3Pos;
}

"""
 
 
 
FragmentShader = """

//
// Atmospheric scattering fragment shader
//
// Author: Sean O'Neil
//
// Copyright (c) 2004 Sean O'Neil
//

uniform vec3 v3LightPos;
const float g = -0.98;
const float g2 = (-0.98)*(-0.98);

uniform float fCameraHeight, fOuterRadius, fScaleDepth;
uniform float fExposure;
varying vec3 v3Direction;
varying float depth;

void main (void)
{

	float fCos = dot(v3LightPos, v3Direction) / length(v3Direction);
	float fRayleighPhase = 0.75 * (1.0 + (fCos*fCos));
	float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);
	
	float sun = 2.0*((1.0 - 0.2) / (2.0 + 0.2)) * (1.0 + fCos*fCos) / pow(1.0 + 0.2 - 2.0*(-0.2)*fCos, 1.0);
	
	vec4 f4Ambient = (sun * depth + (fOuterRadius - fCameraHeight))*vec4(0.05, 0.05, 0.1,1.0);
	
	vec4 f4Color = (fRayleighPhase * gl_Color + fMiePhase * gl_SecondaryColor)+f4Ambient;
	vec4 HDR = 1.0 - exp(f4Color * -fExposure);
	float nightmult = clamp(max(HDR.x, max(HDR.y, HDR.z))*1.5,0.0,1.0);

	//gl_FragColor = vec4(ambient);
	gl_FragColor = HDR;
	gl_FragColor.a = nightmult+(fOuterRadius - fCameraHeight);

}
"""