Weather Renderer¶
-
class WeatherRenderer
The main base class for all weather renderers, such as SimulGLWeatherRenderer, SimulWeatherRenderer (DX11) etc.
The derived classes of WeatherRenderer 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
-
WeatherRenderer(Environment *env, platform::core::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(platform::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.
-
void LoadShaders()¶
Platform-dependent function to reload the shaders - only use this for debug purposes.
-
void RecompileShaders()
Recompile the shaders asynchronously.
-
void SetCubemapTransform(const float *m)¶
A transform for the cubemap set by SetCubemapTexture().
-
TransparencyAtmospherics GetTransparencyAtmospherics(const platform::crossplatform::ViewStruct &viewStruct)¶
This returns a struct containing the textures and values needed to apply atmospherics to transparent objects.
-
platform::crossplatform::Quaterniond GetSiderealTransform()¶
Get the view matrix in sidereal space, e.g. for rendering celestial objects.
-
virtual void RenderCelestialBackground(platform::crossplatform::GraphicsDeviceContext &deviceContext, const platform::crossplatform::ViewStruct &viewStruct, TrueSkyRenderMode renderMode, platform::crossplatform::Texture *depthTexture, vec4 viewportTextureRegionXYWH, float exposure)¶
Draw the sun, moon and stars - call this while the depth buffer is bound.
-
virtual void Render(platform::crossplatform::GraphicsDeviceContext &deviceContext, const platform::crossplatform::ViewStruct &viewStruct2, TrueSkyRenderMode renderMode, float exposure, float gamma, platform::crossplatform::Texture *mainDepthTexture, platform::crossplatform::Texture *cubemapTexture, const platform::crossplatform::Viewport *depthViewport, const platform::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 platform::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.
-
bool RenderMixedResolution(platform::crossplatform::GraphicsDeviceContext &deviceContext, const platform::crossplatform::ViewStruct &viewStruct2, platform::crossplatform::Texture *depthTexture, TrueSkyRenderMode renderMode, float exposure, float gamma, const platform::crossplatform::Viewport *depthViewports, platform::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 platform::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.
-
void CompositeCloudsToScreen(platform::crossplatform::GraphicsDeviceContext &deviceContext, const platform::crossplatform::ViewStruct &viewStruct2, TrueSkyRenderMode renderMode, float exposure, float gamma, bool depth_blend, platform::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(platform::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 WeatherRenderer &operator=(const WeatherRenderer &W)¶
Copy the properties of one WeatherRenderer to another, including copying the properties of their sky and cloud renderers.
-
virtual void ConnectInterfaces()¶
Connect-up sky, clouds etc.
-
const vec4 &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 vec4 &GetLightColour(float view_altitude_km) const¶
Get the HDR light colour, as seen from the specified altitude.
- Parameters:
view_altitude_km –
-
simul::sky::SkyRenderer *GetSkyRenderer()¶
Get a pointer to the sky renderer.
-
LightningRenderer *GetLightningRenderer()¶
Get a pointer to the lightning renderer.
-
simul::clouds::PrecipitationRenderer *GetPrecipitationRenderer()¶
Get a pointer to the rain/snow renderer.
-
simul::clouds::CloudRenderer *GetCloudRenderer()
Get a pointer to the cloud renderer.
-
simul::sky::AtmosphericsRenderer *GetAtmosphericsRenderer()¶
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 WeatherRenderer *Create(Environment *env, platform::core::MemoryInterface *m = NULL)¶
Create a weather renderer: if env is NULL, a new Environment will be created.
-
static void Destroy(WeatherRenderer *baseWeatherRenderer)¶
Destroy a weather renderer.
-
WeatherRenderer(Environment *env, platform::core::MemoryInterface *m = NULL)¶