c

class BaseSkyRenderer

Include: Clouds/BaseWeatherRenderer.h

simul::base::Referenced simul::crossplatform::BaseRenderer

Functions

  BaseSkyRenderer(simul::sky::SkyKeyframer sk, simul::base::MemoryInterface m)
float CalcSunOcclusion(simul::crossplatform::DeviceContext, float cloud_occlusion)
simul::sky::BaseGpuSkyGenerator * CreateGpuSkyGenerator(simul::base::MemoryInterface m)
void EnableMoon(bool val)
void EnsureEffectsAreBuilt(simul::crossplatform::RenderPlatform r)
void EnsureTexturesAreUpToDate(simul::crossplatform::DeviceContext deviceContext)
simul::sky::float4 GetAmbientColour(float alt_km)
simul::sky::BaseGpuSkyGenerator * GetBaseGpuSkyGenerator()
simul::sky::BaseSkyInterface * GetBaseSkyInterface()
simul::crossplatform::Texture * GetIlluminationTexture()
simul::sky::float4 GetLightColour(float alt_km)
LightingQueryResult GetLightingQuery(int id, pos)
simul::crossplatform::Texture * GetLightTableTexture()
simul::sky::PlanetStruct * GetPlanet(int index)
simul::sky::SiderealSkyInterface * GetSiderealSkyInterface()
simul::sky::SkyKeyframer * GetSkyKeyframer()
float GetSunOcclusion()
void InvalidateDeviceObjects()
bool IsMoonEnabled()
void PreRenderUpdate(simul::crossplatform::DeviceContext deviceContext)
void RecompileShaders()
void ReloadTextures()
bool Render2DFades(simul::crossplatform::DeviceContext deviceContext, int numDist, int numElev)
void RenderCelestialDisplay(simul::crossplatform::DeviceContext context, float y_heading)
bool RenderFades(simul::crossplatform::DeviceContext deviceContext, int view_id, int x, int y, int w, int h)
void RenderIlluminationBuffer(simul::crossplatform::DeviceContext deviceContext)
void RenderLightingQueryResultsText(simul::crossplatform::DeviceContext deviceContext, int x, int y)
void RenderPlanet(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture tex, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float rad, float dir, float colr, bool do_lighting, float exposure)
void RenderPlanets(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float exposure)
bool RenderPointStars(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float, float)
void RenderSun(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float exposure)
void RestoreDeviceObjects(simul::crossplatform::RenderPlatform renderPlatform)
void SaveTextures(char)
void SetBackgroundTexture(simul::crossplatform::Texture t)
void SetMoonTexture(simul::crossplatform::Texture t)
void SetOvercastCallback(simul::sky::OvercastCallback ocb)
void SetPlanet(int index, simul::crossplatform::Texture tex, float rad, bool do_lighting)
void SetPlanetColour(int index, float c3)
void SetPlanetDirection(int index, float pos)
void SetPlanetImage(int index, simul::crossplatform::Texture tex)
void SetPlanetRadius(int index, float radians)
void FillFadeTextureBlocks(int, int, int, int, int, int, int, float, float, float)

Base Classes

simul::base::Referenced simul::crossplatform::BaseRenderer

Functions

BaseSkyRenderer(simul::sky::SkyKeyframer sk, simul::base::MemoryInterface m)

The Sky Renderer performs the following tasks:

See

float CalcSunOcclusion(simul::crossplatform::DeviceContext, float cloud_occlusion)

Get a value, from zero to one, which represents how much of the sun is visible. Call this when the current rendering surface is the one that has obscuring objects like mountains etc. in it, and make sure these have already been drawn. GetSunOcclusion executes a pseudo-render of an invisible billboard, then uses a hardware occlusion query to see how many pixels have passed the z-test.

simul::sky::BaseGpuSkyGenerator * CreateGpuSkyGenerator(simul::base::MemoryInterface m)

Override this to create a custom generator.

void EnableMoon(bool val)

The moon is distinct from other planets because its position is taken from the skyInterface. When the moon is enabled, it will be added to the planets list and updated automatically.

void EnsureEffectsAreBuilt(simul::crossplatform::RenderPlatform r)

Check that all shaders have been correctly compiled

void EnsureTexturesAreUpToDate(simul::crossplatform::DeviceContext deviceContext)

Maintains the per-frame textures.

simul::sky::float4 GetAmbientColour(float alt_km)

Returns the current ambient light colour as a float4 (x=red, y=green, z=blue, w unused), i.e. sunlight or moonlight. This is a high-dynamic range value.

simul::sky::BaseGpuSkyGenerator * GetBaseGpuSkyGenerator()

Get a pointer to the Sky Generator.

simul::sky::BaseSkyInterface * GetBaseSkyInterface()

Get the interface to the sky object so that other classes can use it for lighting, distance fades etc.

simul::crossplatform::Texture * GetIlluminationTexture()

Get the 2D texture that represents the extent of illuminated atmosphere visible in any given direction on a per-frame basis.

simul::sky::float4 GetLightColour(float alt_km)

Returns the current directional light colour as a float4 (x=red, y=green, z=blue, w unused), i.e. sunlight or moonlight. This is a high-dynamic range value.

LightingQueryResult GetLightingQuery(int id, pos)

Get the results of a lighting query, and update it for next time. If this is the first call, the returned struct will have valid=false.

simul::crossplatform::Texture * GetLightTableTexture()

Get a texture that represents the variation of sunlight, moonlight, ambient and total directional light with altitude.

simul::sky::PlanetStruct * GetPlanet(int index)

Get the planet structure identified by index.

simul::sky::SiderealSkyInterface * GetSiderealSkyInterface()

Get the sidereal sky interface - if using one, returns NULL otherwise.

simul::sky::SkyKeyframer * GetSkyKeyframer()

Get a pointer to the fade table.

float GetSunOcclusion()

Get a value, from zero to one, which represents how much of the sun is visible.

void InvalidateDeviceObjects()

Platform-dependent function called when uninitializing the sky renderer.

bool IsMoonEnabled()

Is the moon being shown?

void PreRenderUpdate(simul::crossplatform::DeviceContext deviceContext)

Once per-frame update. Do this before any rendering each frame.

void RecompileShaders()

Platform-dependent function to reload the shaders - only use this for debug purposes.

void ReloadTextures()

Platform-dependent function to reload the textures - only use this for debug purposes.

bool Render2DFades(simul::crossplatform::DeviceContext deviceContext, int numDist, int numElev)

This fills in the 2D atmospheric fade textures once per-frame from the keyframed 3D fade textures.

void RenderCelestialDisplay(simul::crossplatform::DeviceContext context, float y_heading)

Draw sidereal and geographic information to screen

bool RenderFades(simul::crossplatform::DeviceContext deviceContext, int view_id, int x, int y, int w, int h)

Draw the 2D fades to screen for debugging.

void RenderIlluminationBuffer(simul::crossplatform::DeviceContext deviceContext)

Perform any necessary updates to the renderer’s textures - particularly the loss, inscatter and skylight textures - at the start of a frame. This is called from simul::clouds::BaseWeatherRenderer::PreRenderUpdate().

void RenderLightingQueryResultsText(simul::crossplatform::DeviceContext deviceContext, int x, int y)

Display LightingQueryResults to screen for debugging

void RenderPlanet(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture tex, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float rad, float dir, float colr, bool do_lighting, float exposure)

This is called by RenderPlanets to render a planet with texture tex, angular radius radradians, in direction dir(x,y,z), with colour colr. If do_lightingis true, the planet will be directionally-lit - e.g. moon phases.

void RenderPlanets(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float exposure)

Draw planets in the sky, e.g. the Moon.

bool RenderPointStars(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float, float)

Draw the stars.

void RenderSun(simul::crossplatform::DeviceContext, simul::crossplatform::ViewStruct viewStruct, simul::crossplatform::Texture depthTexture, vec4 viewportTextureRegionXYWH, float exposure)

Draw the sun.

void RestoreDeviceObjects(simul::crossplatform::RenderPlatform renderPlatform)

Platform-dependent function called when initializing the sky renderer.

void SaveTextures(char)

Save the current texture set to disk. Useful, but not necessary for normal operation.

void SetBackgroundTexture(simul::crossplatform::Texture t)

Get some per-frame text information for debugging - usually timing data.

void SetMoonTexture(simul::crossplatform::Texture t)

Override the Moon texture

void SetOvercastCallback(simul::sky::OvercastCallback ocb)

Inform the sky renderer of a callback to use to get overcast information.

void SetPlanet(int index, simul::crossplatform::Texture tex, float rad, bool do_lighting)

Create a planet, identified by the index, which can be any unique number. The texture texis an API-specific texture identifier, e.g. a GLuint, or LPDIRECT3D9TEXTURE. The angular radius will be rad, in radians. If do_lightingis true, the planet should be directionally lit by the sun to produce phases.

void SetPlanetColour(int index, float c3)

Set the colour of the planet identified by index.

void SetPlanetDirection(int index, float pos)

Set the direction to the planet identified by index.

void SetPlanetImage(int index, simul::crossplatform::Texture tex)

Set the texture for planet indexto tex, an API-specific texture identifier, e.g. a GLuint, a DX9 LPDIRECT3D9TEXTURE, or DX11 ShaderResourceView.

void SetPlanetRadius(int index, float radians)

Set the angular radius of the planet identified by index.

void FillFadeTextureBlocks(int, int, int, int, int, int, int, float, float, float)

Inform the derived class that the loss and inscatter textures texture_index, either 0, 1 or 2, at altitude index alt_index, (not used if not using multiple altitudes) should fill a block of texels starting at x, y, z, and wwide, llong, ddeep, with the values in the array uint32_array, with the values in the arrays loss_float4_array and inscatter_float4_array, each of which contains four times num_texels floats. The first number is the value for texel_index, rather than the start of the whole table. Each group of four represents the r,g,b and a of a colour value, and the values may be greater than one, so floating point textures are preferred. Only one of FillFadeTexturesSequentially and FillFadeTextureBlocks need be implemented, depending on the graphics API. Some API’s permit transfer of data sequentially in memory to textures (e.g. DirectX 9), some expect cuboid blocks of texels to be filled (e.g. OpenGL). The unwanted function should be implemented as a stub, with an assert() or some other fail condition, to make sure it is never called.