public override void SetupEntity(MyEffectBase shader, MyRender.MyRenderElement renderElement) { MyEffectAtmosphere effectAtmosphere = shader as MyEffectAtmosphere; effectAtmosphere.SetWorldMatrix((Matrix)renderElement.WorldMatrixForDraw); effectAtmosphere.SetDiffuseColor(renderElement.Color); var atmosphere = renderElement.RenderObject as MyRenderAtmosphere; float depthScale = 0.2f; effectAtmosphere.SetInnerRadius(atmosphere.PlanetRadius); effectAtmosphere.SetOutherRadius(atmosphere.AtmosphereRadius); float scaleAtmosphere = 1.0f / (atmosphere.AtmosphereRadius - atmosphere.PlanetRadius); effectAtmosphere.SetScaleAtmosphere(scaleAtmosphere); effectAtmosphere.SetScaleAtmosphereOverScaleDepth(scaleAtmosphere / depthScale); Vector3 cameraToCenter = atmosphere.GetRelativeCameraPos(MyRenderCamera.Position); effectAtmosphere.SetRelativeCameraPos(cameraToCenter); effectAtmosphere.SetLightPos(-MySunGlare.GetSunDirection()); effectAtmosphere.SetIsInside(atmosphere.IsInside(MyRenderCamera.Position)); effectAtmosphere.SetScaleDepth(depthScale); effectAtmosphere.SetWavelength(atmosphere.AtmosphereWavelengths); }
static void SetupAtmosphere(MyEffectVoxels shader, MyRenderVoxelCellBackground element) { shader.SetHasAtmosphere(element.HasAtmosphere); if (element.HasAtmosphere) { float depthScale = 0.2f; shader.SetInnerRadius(element.PlanetRadius); shader.SetOutherRadius(element.AtmosphereRadius); float scaleAtmosphere = 1.0f / (element.AtmosphereRadius - element.PlanetRadius); shader.SetScaleAtmosphere(scaleAtmosphere); shader.SetScaleAtmosphereOverScaleDepth(scaleAtmosphere / depthScale); Vector3 cameraToCenter = element.GetRelativeCameraPos(MyRenderCamera.Position); shader.SetRelativeCameraPos(cameraToCenter); shader.SetLightPos(-MySunGlare.GetSunDirection()); shader.SetIsInside(element.IsInside(MyRenderCamera.Position)); shader.SetScaleDepth(depthScale); shader.SetPositonToLeftBottomOffset(element.PositiontoLeftBottomOffset); shader.SetWavelength(element.AtmosphereWavelengths); } }