Rise
The Vieneo Province
Loading...
Searching...
No Matches
SkyRingRenderer.h
Go to the documentation of this file.
1#pragma once
3#include <wrl/client.h>
4
6{
7 constexpr unsigned Segments=1024;
8 // The ring used to inherit blending, lighting and stencil state from the
9 // sun/legacy cloud passes. Own this state so replacing either pass is safe.
11 Rendering::RenderBuffer* vertices, const RiseMath::Matrix& world, UINT segments,
12 Rendering::RenderMaterial* volumeEffect=nullptr, float physicalScale=1)
13 {
14 Microsoft::WRL::ComPtr<Rendering::RenderStateSnapshot> state;
15 HRESULT hr=device->CreateStateBlock(0,&state);
16 if (FAILED(hr)) return hr;
17 device->SetVertexShader(nullptr); device->SetPixelShader(nullptr);
24 if (volumeEffect) device->SetRenderState(Rendering::RenderState::ZENABLE,TRUE);
27 device->SetRenderState(Rendering::RenderState::STENCILREF,3); // exterior 0/1/2; protect cockpit 3/4
56 device->SetTexture(0,texture);
58 device->SetStreamSource(0,vertices,0,6*sizeof(float));
59 if (volumeEffect)
60 {
61 Rendering::Viewport viewport{};
62 device->GetViewport(&viewport);
63 const RiseMath::Vector4 screen(float(viewport.X),float(viewport.Y),1.f/viewport.Width,1.f/viewport.Height);
64 volumeEffect->SetMatrix("ringWorld",&world);
65 volumeEffect->SetVector("ringViewport",&screen);
66 volumeEffect->SetFloat("ringScale",physicalScale);
67 volumeEffect->SetTexture("atmosphereImage",texture);
68 hr=volumeEffect->Begin(nullptr,0);
69 if (SUCCEEDED(hr))
70 {
71 hr=volumeEffect->BeginPass(3);
72 if (SUCCEEDED(hr))
73 {
75 volumeEffect->EndPass();
76 }
77 volumeEffect->End();
78 }
79 volumeEffect->SetTexture("atmosphereImage",nullptr);
80 }
81 else hr=device->DrawPrimitive(Rendering::Primitive::TriangleStrip,0,segments*2);
82 const HRESULT restored=state->Apply();
83 return FAILED(hr) ? hr : restored;
84 }
85}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
HRESULT DrawPrimitive(Primitive type, UINT first, UINT count)
HRESULT CreateStateBlock(UINT type, RenderStateSnapshot **result)
HRESULT SetPixelShader(std::nullptr_t)
HRESULT GetViewport(Viewport *value) const
HRESULT SetStreamSource(UINT stream, RenderBuffer *buffer, UINT offset, UINT stride)
HRESULT SetRenderState(DWORD state, DWORD value)
HRESULT SetFVF(DWORD value)
HRESULT SetTransform(DWORD slot, const RiseMath::Matrix *value)
HRESULT SetTextureStageState(DWORD stage, DWORD state, DWORD value)
HRESULT SetTexture(DWORD stage, RenderTexture *texture)
HRESULT SetSamplerState(DWORD sampler, DWORD state, DWORD value)
HRESULT SetVertexShader(std::nullptr_t)
constexpr uint32_t CLAMP
constexpr uint32_t WRAP
constexpr uint32_t INVSRCALPHA
constexpr uint32_t SRCALPHA
constexpr uint32_t ADD
constexpr uint32_t GREATER
constexpr uint32_t ALWAYS
constexpr uint32_t LESSEQUAL
constexpr uint32_t NONE
constexpr uint32_t LINEAR
constexpr uint32_t NONE
constexpr uint32_t COLORWRITEENABLE
constexpr uint32_t SRCBLEND
constexpr uint32_t STENCILFUNC
constexpr uint32_t SEPARATEALPHABLENDENABLE
constexpr uint32_t CULLMODE
constexpr uint32_t STENCILREF
constexpr uint32_t ALPHABLENDENABLE
constexpr uint32_t STENCILENABLE
constexpr uint32_t ALPHATESTENABLE
constexpr uint32_t STENCILPASS
constexpr uint32_t FOGENABLE
constexpr uint32_t STENCILMASK
constexpr uint32_t DESTBLEND
constexpr uint32_t LIGHTING
constexpr uint32_t SRGBWRITEENABLE
constexpr uint32_t ZFUNC
constexpr uint32_t ZWRITEENABLE
constexpr uint32_t WRAP0
constexpr uint32_t ZENABLE
constexpr uint32_t STENCILZFAIL
constexpr uint32_t BLENDOP
constexpr uint32_t STENCILFAIL
constexpr uint32_t SRGBTEXTURE
constexpr uint32_t ADDRESSU
constexpr uint32_t ADDRESSV
constexpr uint32_t MIPFILTER
constexpr uint32_t MAGFILTER
constexpr uint32_t MINFILTER
constexpr uint32_t DIFFUSE
constexpr uint32_t TEXTURE
constexpr uint32_t DISABLE
constexpr uint32_t SELECTARG1
constexpr uint32_t MODULATE
constexpr uint32_t COLOROP
constexpr uint32_t COLORARG1
constexpr uint32_t ALPHAARG1
constexpr uint32_t ALPHAOP
constexpr uint32_t TEXCOORDINDEX
constexpr uint32_t COLORARG2
constexpr uint32_t TEXTURETRANSFORMFLAGS
constexpr uint32_t DISABLE
constexpr uint32_t WORLD
constexpr uint32_t TEX1
constexpr uint32_t DIFFUSE
constexpr uint32_t XYZ
HRESULT Draw(Rendering::RenderDevice *device, Rendering::RenderTexture *texture, Rendering::RenderBuffer *vertices, const RiseMath::Matrix &world, UINT segments, Rendering::RenderMaterial *volumeEffect=nullptr, float physicalScale=1)
constexpr unsigned Segments