Cloud Renderer¶
-
class CloudRenderer
Class for real-time volumetric cloud rendering.
There should exist a “trueSKY space”, where the origin(0,0,0 Cartesian) is at global mean sea level, and an arbitrary point on the Earth’s surface. The Z axis points up, the X and Y axes are arbitrary (for reasons described below). To avoid singularities, this point, and the orientation of its axes should be represented by a double-precision quaternion, which represents the rotation from (say) latitude and longitude zero with X pointing East and Y pointing North.
The Volume Window is a deformed cuboid, its upper and lower surfaces matching the Earth’s curvature. On the GPU, it is a 3D texture.
This trueSKY space moves in steps equivalent to one horizontal texel. The function CloudRenderer::MoveCloudWindowGridCentreTexel(x,y) does this. This should be done when the chosen viewpoint (this is up to you) moves more than a texel in any horizontal direction. This way, we need only update the edges as the window moves.
Public Functions
-
CloudRenderer(simul::clouds::Environment *e, simul::base::MemoryInterface *mem)¶
Constructor: An external keyframer is provided, and an optional memory manager.
-
virtual ~CloudRenderer()¶
Destructor.
- META_BeginProperties META_Property (bool, UseAltCloudShadows,"Whether this cloud renderer should use an alternate method of cloud shadow generation (Unity only).") META_EndProperties void SetPointLight(int id
Place a point light source.
-
VolumeQueryResult GetPointQuery(int id, vec3 pos_km)¶
Set, or create a cloud query. This returns the previous results of the same query.
-
VolumeQueryResult GetPointQuery(int id) const¶
Get results of a cloud query.
-
int GetQueryIdForViewId(int view_id) const¶
Get the query id for the specified view. If Render() has been called for the view, the query should have a valid set of results for the last frame rendered.
-
LineQueryResult GetLineQuery(int id, vec3 pos1_km, vec3 pos2_km)¶
Set, or create a line query. This returns the previous results of the same query.
-
LineQueryResult GetLineQuery(int id) const¶
Get results of line query.
-
void SetMaxSlices(int viewport_id, int maxs)¶
Cloud rendering detail is determined by the number of slices. If not set the value from the CloudKeyframer will be used (GetDefaultNumSlices), but each viewport id can have a separate setting.
-
int GetMaxSlices(int viewport_id)¶
Cloud rendering detail is determined by the number of slices. See SetMaxSlices.
-
virtual void RecompileShaders()¶
Platform-dependent function to reload the shaders - only use this for debug purposes.
-
virtual void RestoreDeviceObjects(crossplatform::RenderPlatform *renderPlatform)¶
Platform-dependent function to generate device objects for the renderer.
-
virtual void InvalidateDeviceObjects()¶
Call this Platform-dependent function when the 3D device has been lost.
-
void AsynchronousUpdate(crossplatform::DeviceContext &deviceContext, float real_time)¶
-
virtual void PreRenderUpdate(crossplatform::GraphicsDeviceContext &deviceContext, float real_time)¶
Once per-frame update. Do this before any rendering each frame. Called by BaseWeatherRenderer.
-
virtual bool Render(crossplatform::GraphicsDeviceContext &deviceContext, float exposure, TrueSkyRenderMode renderMode, crossplatform::NearFarPass nearFarPass, crossplatform::Texture *depth_tex, const sky::ScatteringVolume *scatteringVolume, bool write_alpha, const vec4 &viewportTextureRegionXYWH, const crossplatform::AmortizationStruct &amortizationStruct, clouds::TwoResFramebuffer *fb, sky::LocalFadeTextures *localFadeTextures, crossplatform::Texture *ambientCubemap)¶
Platform-dependent render function.
-
virtual void RenderCloudShadowTexture(crossplatform::GraphicsDeviceContext &deviceContext)¶
The cloud shadow texture: Centred on the viewer Aligned to the sun. Output is km in front of or behind the view pos where shadow starts
-
virtual void RenderPrecipitationVolumeTexture(crossplatform::GraphicsDeviceContext &deviceContext)¶
-
virtual void RenderRainbowLookupTexture(crossplatform::GraphicsDeviceContext &deviceContext)¶
-
virtual void RenderQueries(crossplatform::GraphicsDeviceContext &deviceContext)¶
Draw the queries in 3D.
-
void RenderCloudVolumes(crossplatform::GraphicsDeviceContext &deviceContext, CloudKeyframer *ck)¶
Render the cloud volumes for debugging purposes.
-
void RenderCloudGrid(crossplatform::GraphicsDeviceContext &deviceContext, CloudKeyframer *ck)¶
Render the cloud grid for debugging purposes.
-
void RenderShapeMasks(crossplatform::GraphicsDeviceContext &deviceContext, CloudKeyframer *ck)¶
-
virtual void RenderDebugInfo(crossplatform::GraphicsDeviceContext &deviceContext, int width, int height)¶
-
virtual const char *GetDebugText() const¶
Get some per-frame text information for debugging - usually timing data.
-
virtual void RenderCrossSections(crossplatform::GraphicsDeviceContext &context, bool showLayerTextures = true, bool showVolumeTextures = true, bool debugValues = true)¶
Show the cloud volumes onscreen by cross section.
-
virtual void RenderAuxiliaryTextures(crossplatform::GraphicsDeviceContext &context)¶
-
inline void SetLightingQueryResult(const LightingQueryResult &_lightingQueryResult)¶
Show the cloud volume window on the lat-long sphere.
-
void Reset()¶
-
void SetIlluminationTexture(crossplatform::Texture*)¶
-
void SetLightTableTexture(crossplatform::Texture*)¶
-
inline virtual simul::clouds::BaseGpuCloudGenerator *GetBaseGpuCloudGenerator()¶
Get a pointer to the Cloud Generator.
-
virtual simul::clouds::BaseGpuCloudGenerator *CreateGpuCloudGenerator(base::MemoryInterface *m)¶
-
void SetEnvironment(simul::clouds::Environment *e)¶
Set the sky interface.
-
CloudGeometryHelper *GetCloudGeometryHelper(int view_id)¶
Returns a new geometry helper.
-
virtual crossplatform::Texture *GetRandomTexture3D()¶
Get the random 3D texture.
-
bool IsCameraAboveCloudBase(math::Vector3 cam_pos) const¶
Return true if the camera is above the cloudbase altitude.
-
float GetSunOcclusion(crossplatform::GraphicsDeviceContext &deviceContext, math::Vector3 cam_pos)¶
Get a value for how much the sun is blocked from the clouds.
-
void SetEnableStorms(bool s)¶
Where supported, enable lightning generation.
-
void SetNoiseTextureProperties(int size, int freq, int octaves, float persistence)¶
Adjust the noise texture.
-
virtual const float *GetCloudScales() const¶
Get the xyz scales of the clouds in metres.
-
void InitialiseCloudShadowData()¶
Get an API-dependent identifier for the cloud’s 2D shadow.
-
sky::CloudShadowData &GetCloudShadowData()¶
-
void SetMaxFadeDistanceKm(float dist_km)¶
Distance for fade texture lookups:
-
void SetMaxFadeAltitudeKm(float ma_km)¶
Altitude for fade texture lookups:
-
void ExportCloudVolume(unsigned char *target)¶
-
CloudRenderingOptions &GetCloudRenderingOptions()
Get a pointer to the current cloud rendering options.
-
void SetCloudRenderingOptions(const CloudRenderingOptions &c)
Set new cloud rendering options.
-
CloudWindow &GetCloudWindow()¶
-
float GetPrecipitation() const¶
-
float GetRainToSnow() const¶
-
inline crossplatform::Texture *GetLightTableTexture()¶
Get a pointer to the current light table texture.
-
vec4 GetCloudLightResponse() const¶
-
void SetBlendRatio(float ratio)¶
Public Members
- META_BeginProperties vec3 pos
- META_BeginProperties vec3 float min_radius
- META_BeginProperties vec3 float float max_radius
- META_BeginProperties vec3 float float vec3 irradiance
Public Static Functions
-
static void EnsureEffectsAreBuilt(crossplatform::RenderPlatform *renderPlatform)¶
If possible, build all shader effect variations.
-
CloudRenderer(simul::clouds::Environment *e, simul::base::MemoryInterface *mem)¶