Base Weather Renderer

class simul::clouds::BaseWeatherRenderer

The main base class for all weather renderers, such as SimulGLWeatherRenderer, SimulWeatherRenderer (DX11) etc.

The derived classes of BaseWeatherRenderer create and maintain the renderers for weather elements such as clouds, sky, rain and so on. So to use these sub-renderers it is usual to create an instance of one of the weather renderers, and allow this instance to manage the others.

Public Functions

BaseWeatherRenderer(Environment *env, simul::base::MemoryInterface *m = NULL)

Default constructor: if env is NULL, a new Environment will be created.

void SetAllDownscale(float)

Override the downscale for all current views; does not affect the default - see SetDefaultDownscale.

void CreateSubObjects()

Create the member sub-objects: CloudRenderer etc.

virtual void RestoreDeviceObjects(crossplatform::RenderPlatform *renderPlatform)

Platform-dependent function called when initializing the weather renderer.

virtual void InvalidateDeviceObjects()

Platform-dependent function called when uninitializing the weather renderer.

void RemoveView(int view_id)

Ensure that per-view objects are destroyed for the view in question: they will be rebuilt if needed later.

virtual void RecompileShaders()

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

void SetCubemapTransform(const float *m)

A transform for the cubemap set by SetCubemapTexture().

void SetBlurTexture(crossplatform::Texture *t)

A blurred texture, to be drawn usually per-frame.

TransparencyAtmospherics GetTransparencyAtmospherics(const crossplatform::ViewStruct &viewStruct)

This returns a struct containing the textures and values needed to apply atmospherics to transparent objects.

crossplatform::Quaterniond GetSiderealTransform()

Get the view matrix in sidereal space, e.g. for rendering celestial objects.

virtual void RenderCelestialBackground(crossplatform::GraphicsDeviceContext &deviceContext, const crossplatform::ViewStruct &viewStruct, TrueSkyRenderMode renderMode, crossplatform::Texture *depthTexture, vec4 viewportTextureRegionXYWH, float exposure)

Draw the sun, moon and stars - call this while the depth buffer is bound.

virtual void Render(crossplatform::GraphicsDeviceContext &deviceContext, const crossplatform::ViewStruct &viewStruct2, TrueSkyRenderMode renderMode, float exposure, float gamma, crossplatform::Texture *mainDepthTexture, crossplatform::Texture *cubemapTexture, const crossplatform::Viewport *depthViewport, const crossplatform::Viewport *viewports = nullptr, vec3 cubemap_ground_colour = vec3(0, 0, 0), int amortization = 0)

Render the sky including atmospherics, into the current rendertarget, using a supplied depth texture.

deviceContext is the platform-dependent render context, viewStruct2 is the view structure for alternate eye in VR, exposure is a multiplier for the rendered sky brightness, The view_id is an integer that distinguishes between multiple simultaneous viewports onscreen. By convention, viewport 0 is the main view, and viewport 1 is the cubemap for reflections and lighting. If is_cubemap is set, low-definition rendering is used. The mainDepthTexture is a single-sampled or MSAA depth texture. You can use a simul::crossplatform::Texture-derived class to wrapper your depth texture. The depthViewport determines what part of the depth texture represents this viewport - normally (0,0,1,1). Optional viewports specifies the left and right eye viewports if we’re rendering both at once in VR.

virtual bool RenderMixedResolution(crossplatform::GraphicsDeviceContext &deviceContext, const crossplatform::ViewStruct &viewStruct2, crossplatform::Texture *depthTexture, TrueSkyRenderMode renderMode, float exposure, float gamma, const crossplatform::Viewport *depthViewports, crossplatform::Texture *ambientCubemapTexture)

Render the sky including atmospherics as an overlay, using a supplied platform-dependent depth texture. deviceContext is the platform-dependent render context, exposure is a multiplier for the rendered sky brightness, The view_id is an integer that distinguishes between multiple simultaneous viewports onscreen. By convention, viewport 0 is the main view, and viewport 1 is the cubemap for reflections and lighting. If is_cubemap is set, low-definition rendering is used. The mainDepthTexture is a single-sampled or MSAA depth texture. You can use a simul::crossplatform::Texture-derived class to wrapper your depth texture. The lowResDepthTexture is an API-dependent texture or texture resource pointer, with near far depth in the r and g, and b 0 or 1 for edges. The depthViewportXYWH determines what part of the depth texture represents this viewport - normally (0,0,1,1). Returns true if there is a lightpass.

virtual void CompositeCloudsToScreen(crossplatform::GraphicsDeviceContext &deviceContext, const crossplatform::ViewStruct &viewStruct2, TrueSkyRenderMode renderMode, float exposure, float gamma, bool depth_blend, crossplatform::Texture *mainDepthTexture, const vec4 &viewportRegionXYWH, bool any_lightpass, const LightingQueryResult &lightingQueryResult, const vec3 &cubemap_ground_colour)

This composites the clouds and other buffers to the screen.

int GetExportLightningStrikes(ExportLightningStrike *export_strikes, int max_s, float game_time, float real_time) const

Get lightning strikes. This calls GetExportLightningStrikes in CloudKeyframer, but also includes a cloud density query so that lightning can’t come from empty sky.

virtual void PreRenderUpdate(crossplatform::GraphicsDeviceContext &deviceContext, float real_time)

Once per-frame update. Do this before any rendering each frame. For most platform implementations, you should set the matrices relevant to the main view before calling this.

const BaseWeatherRenderer &operator=(const BaseWeatherRenderer &W)

Copy the properties of one BaseWeatherRenderer to another, including copying the properties of their sky and cloud renderers.

virtual void ConnectInterfaces()

Connect-up sky, clouds etc.

const simul::sky::float4 &GetHorizonColour(float view_altitude_km)

Set a depth texture, whose alpha values represent the depth co-ordinate. This will be used when clouds are rendered in front of terrain etc.

Get the representative HDR colour of the horizon, as seen from the specified altitude

Parameters

view_altitude_km – .

const simul::sky::float4 &GetLightColour(float view_altitude_km) const

Get the HDR light colour, as seen from the specified altitude.

Parameters

view_altitude_km

simul::sky::BaseSkyRenderer *GetBaseSkyRenderer()

Get a pointer to the sky renderer.

BaseLightningRenderer *GetLightningRenderer()

Get a pointer to the lightning renderer.

simul::clouds::PrecipitationRenderer *GetPrecipitationRenderer()

Get a pointer to the rain/snow renderer.

inline simul::clouds::CloudRenderer *GetBaseCloudRenderer()

Get a pointer to the cloud renderer.

simul::clouds::CloudRenderer *GetCloudRenderer()

Get a pointer to the cloud renderer.

simul::sky::BaseAtmosphericsRenderer *GetBaseAtmosphericsRenderer()

Get a pointer to the atmospheric renderer.

simul::sky::SkyKeyframer *GetSkyKeyframer()

Convenience function to get the next sky keyframe that can be modified without any recalculation.

Environment *GetEnvironment()

Get a pointer to the current Environment.

void SetEnvironment(Environment *env)

Set the Environment.

void CleanUpFramebuffers(int max_age)

Delete framebuffers that have not been used in max_age frames, to free GPU memory.

Public Static Functions

static BaseWeatherRenderer *Create(Environment *env, simul::base::MemoryInterface *m = NULL)

Create a base weather renderer: if env is NULL, a new Environment will be created.

static void Destroy(BaseWeatherRenderer *baseWeatherRenderer)

Destroy a base weather renderer.