Finish CAuiImagePane

This commit is contained in:
Jack Andersen 2017-05-17 21:07:49 -10:00
parent 08a8b1819a
commit 1f25becf8e
12 changed files with 243 additions and 48 deletions

View File

@ -94,7 +94,7 @@ struct ITweakGui : ITweak
virtual float GetHudDecoShakeTranslateGain() const=0; virtual float GetHudDecoShakeTranslateGain() const=0;
virtual float GetHudLagOffsetScale() const=0; virtual float GetHudLagOffsetScale() const=0;
virtual float GetScanAppearanceDuration() const=0; virtual float GetScanAppearanceDuration() const=0;
virtual float GetScanPaneFadeAlpha() const=0; virtual float GetScanPaneFlashFactor() const=0;
virtual float GetScanPaneFadeInTime() const=0; virtual float GetScanPaneFadeInTime() const=0;
virtual float GetScanPaneFadeOutTime() const=0; virtual float GetScanPaneFadeOutTime() const=0;
virtual float GetBallViewportYReduction() const=0; virtual float GetBallViewportYReduction() const=0;
@ -109,10 +109,10 @@ struct ITweakGui : ITweak
virtual float GetScanSidesEndTime() const=0; virtual float GetScanSidesEndTime() const=0;
virtual float GetScanDataDotRadius() const=0; virtual float GetScanDataDotRadius() const=0;
virtual float GetScanDataDotPosRandMagnitude() const=0; virtual float GetScanDataDotPosRandMagnitude() const=0;
virtual float GetScanDataDotDuration1Min() const=0; virtual float GetScanDataDotSeekDurationMin() const=0;
virtual float GetScanDataDotDuration1Max() const=0; virtual float GetScanDataDotSeekDurationMax() const=0;
virtual float GetScanDataDotDuration2Min() const=0; virtual float GetScanDataDotHoldDurationMin() const=0;
virtual float GetScanDataDotDuration2Max() const=0; virtual float GetScanDataDotHoldDurationMax() const=0;
virtual float GetScanSidesPositionStart() const=0; virtual float GetScanSidesPositionStart() const=0;
virtual bool GetLatchArticleText() const=0; virtual bool GetLatchArticleText() const=0;
virtual float GetWorldTransManagerCharsPerSfx() const=0; virtual float GetWorldTransManagerCharsPerSfx() const=0;

View File

@ -132,12 +132,12 @@ struct CTweakGui : ITweakGui
float x228_scanSidesEndTime; float x228_scanSidesEndTime;
Value<float> x22c_scanDataDotRadius; Value<float> x22c_scanDataDotRadius;
Value<float> x230_scanDataDotPosRandMag; Value<float> x230_scanDataDotPosRandMag;
Value<float> x234_scanDataDotDuration1Min; Value<float> x234_scanDataDotSeekDurationMin;
Value<float> x238_scanDataDotDuration1Max; Value<float> x238_scanDataDotSeekDurationMax;
Value<float> x23c_scanDataDotDuration2Min; Value<float> x23c_scanDataDotHoldDurationMin;
Value<float> x240_scanDataDotDuration2Max; Value<float> x240_scanDataDotHoldDurationMax;
Value<float> x244_scanAppearanceDuration; Value<float> x244_scanAppearanceDuration;
Value<float> x248_scanPaneFadeAlpha; Value<float> x248_scanPaneFlashFactor;
Value<float> x24c_scanPaneFadeInTime; Value<float> x24c_scanPaneFadeInTime;
Value<float> x250_scanPaneFadeOutTime; Value<float> x250_scanPaneFadeOutTime;
Value<float> x254_ballViewportYReduction; Value<float> x254_ballViewportYReduction;
@ -255,11 +255,6 @@ struct CTweakGui : ITweakGui
float GetHudDamageColorGain() const { return x1d4_hudDamageColorGain; } float GetHudDamageColorGain() const { return x1d4_hudDamageColorGain; }
float GetHudDecoShakeTranslateGain() const { return x1d8_hudDecoShakeTranslateGain; } float GetHudDecoShakeTranslateGain() const { return x1d8_hudDecoShakeTranslateGain; }
float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; } float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; }
float GetScanAppearanceDuration() const { return x244_scanAppearanceDuration; }
float GetScanPaneFadeAlpha() const { return x248_scanPaneFadeAlpha; }
float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; }
float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; }
float GetBallViewportYReduction() const { return x254_ballViewportYReduction; }
float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; } float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; }
float GetXrayBlurScaleQuadratic() const { return x208_xrayBlurScaleQuadratic; } float GetXrayBlurScaleQuadratic() const { return x208_xrayBlurScaleQuadratic; }
float GetScanSidesAngle() const { return x210_scanSidesAngle; } float GetScanSidesAngle() const { return x210_scanSidesAngle; }
@ -270,10 +265,15 @@ struct CTweakGui : ITweakGui
float GetScanSidesEndTime() const { return x228_scanSidesEndTime; } float GetScanSidesEndTime() const { return x228_scanSidesEndTime; }
float GetScanDataDotRadius() const { return x22c_scanDataDotRadius; } float GetScanDataDotRadius() const { return x22c_scanDataDotRadius; }
float GetScanDataDotPosRandMagnitude() const { return x230_scanDataDotPosRandMag; } float GetScanDataDotPosRandMagnitude() const { return x230_scanDataDotPosRandMag; }
float GetScanDataDotDuration1Min() const { return x234_scanDataDotDuration1Min; } float GetScanDataDotSeekDurationMin() const { return x234_scanDataDotSeekDurationMin; }
float GetScanDataDotDuration1Max() const { return x238_scanDataDotDuration1Max; } float GetScanDataDotSeekDurationMax() const { return x238_scanDataDotSeekDurationMax; }
float GetScanDataDotDuration2Min() const { return x23c_scanDataDotDuration2Min; } float GetScanDataDotHoldDurationMin() const { return x23c_scanDataDotHoldDurationMin; }
float GetScanDataDotDuration2Max() const { return x240_scanDataDotDuration2Max; } float GetScanDataDotHoldDurationMax() const { return x240_scanDataDotHoldDurationMax; }
float GetScanAppearanceDuration() const { return x244_scanAppearanceDuration; }
float GetScanPaneFlashFactor() const { return x248_scanPaneFlashFactor; }
float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; }
float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; }
float GetBallViewportYReduction() const { return x254_ballViewportYReduction; }
float GetScanSidesPositionStart() const { return x270_scanSidesPositionStart; } float GetScanSidesPositionStart() const { return x270_scanSidesPositionStart; }
bool GetLatchArticleText() const { return x275_latchArticleText; } bool GetLatchArticleText() const { return x275_latchArticleText; }
float GetWorldTransManagerCharsPerSfx() const { return x278_wtMgrCharsPerSfx; } float GetWorldTransManagerCharsPerSfx() const { return x278_wtMgrCharsPerSfx; }

View File

@ -67,6 +67,7 @@ public:
{return x0_fmt == ETexelFormat::C8PC ? ETexelFormat::C8 : ETexelFormat::RGB5A3;} {return x0_fmt == ETexelFormat::C8PC ? ETexelFormat::C8 : ETexelFormat::RGB5A3;}
u16 GetWidth() const {return x4_w;} u16 GetWidth() const {return x4_w;}
u16 GetHeight() const {return x6_h;} u16 GetHeight() const {return x6_h;}
u32 GetNumMips() const {return x8_mips;}
void Load(int slot, EClampMode clamp) const; void Load(int slot, EClampMode clamp) const;
boo::ITexture* GetBooTexture() const {return m_booTex;} boo::ITexture* GetBooTexture() const {return m_booTex;}
boo::ITexture* GetPaletteTexture() const {return m_paletteTex;} boo::ITexture* GetPaletteTexture() const {return m_paletteTex;}

View File

@ -73,12 +73,13 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
CGraphics::g_BooMainCommandQueue->draw(0, 4); CGraphics::g_BooMainCommandQueue->draw(0, 4);
} }
void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[4]) void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const Vert verts[4], float lod)
{ {
m_vbo->load(verts, sizeof(Vert) * 4); m_vbo->load(verts, sizeof(Vert) * 4);
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color; m_uniform.m_color = color;
m_uniform.m_lod = lod;
m_uniBuf->load(&m_uniform, sizeof(m_uniform)); m_uniBuf->load(&m_uniform, sizeof(m_uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);

View File

@ -23,6 +23,7 @@ protected:
{ {
zeus::CMatrix4f m_matrix; zeus::CMatrix4f m_matrix;
zeus::CColor m_color; zeus::CColor m_color;
float m_lod = 0.f;
}; };
TLockedToken<CTexture> m_tex; TLockedToken<CTexture> m_tex;
boo::ITexture* m_booTex; boo::ITexture* m_booTex;
@ -50,7 +51,7 @@ public:
CTexturedQuadFilter& operator=(CTexturedQuadFilter&&) = default; CTexturedQuadFilter& operator=(CTexturedQuadFilter&&) = default;
void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect); void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect);
void drawCropped(const zeus::CColor& color, float uvScale); void drawCropped(const zeus::CColor& color, float uvScale);
void drawVerts(const zeus::CColor& color, const Vert verts[4]); void drawVerts(const zeus::CColor& color, const Vert verts[4], float lod=0.f);
const TLockedToken<CTexture>& GetTex() const { return m_tex; } const TLockedToken<CTexture>& GetTex() const { return m_tex; }
using _CLS = CTexturedQuadFilter; using _CLS = CTexturedQuadFilter;

View File

@ -15,12 +15,14 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" mat4 mtx;\n" " mat4 mtx;\n"
" vec4 color;\n" " vec4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
" vec4 color;\n" " vec4 color;\n"
" vec2 uv;\n" " vec2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"SBINDING(0) out VertToFrag vtf;\n" "SBINDING(0) out VertToFrag vtf;\n"
@ -28,6 +30,7 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" vtf.color = color;\n" " vtf.color = color;\n"
" vtf.uv = uvIn.xy;\n" " vtf.uv = uvIn.xy;\n"
" vtf.lod = lod;\n"
" gl_Position = mtx * vec4(posIn.xyz, 1.0);\n" " gl_Position = mtx * vec4(posIn.xyz, 1.0);\n"
" gl_Position = FLIPFROMGL(gl_Position);\n" " gl_Position = FLIPFROMGL(gl_Position);\n"
"}\n"; "}\n";
@ -42,12 +45,14 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" mat4 mtx;\n" " mat4 mtx;\n"
" vec4 color;\n" " vec4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
"{\n" "{\n"
" vec4 color;\n" " vec4 color;\n"
" vec2 uv;\n" " vec2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"SBINDING(0) out VertToFrag vtf;\n" "SBINDING(0) out VertToFrag vtf;\n"
@ -55,6 +60,7 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" vtf.color = color;\n" " vtf.color = color;\n"
" vtf.uv = -uvIn.xy;\n" " vtf.uv = -uvIn.xy;\n"
" vtf.lod = lod;\n"
" gl_Position = mtx * vec4(posIn.xyz, 1.0);\n" " gl_Position = mtx * vec4(posIn.xyz, 1.0);\n"
" gl_Position = FLIPFROMGL(gl_Position);\n" " gl_Position = FLIPFROMGL(gl_Position);\n"
"}\n"; "}\n";
@ -66,6 +72,7 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" vec4 color;\n" " vec4 color;\n"
" vec2 uv;\n" " vec2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"SBINDING(0) in VertToFrag vtf;\n" "SBINDING(0) in VertToFrag vtf;\n"
@ -73,7 +80,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n" "TBINDING0 uniform sampler2D tex;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = vtf.color * vec4(texture(tex, vtf.uv).rgb, 1.0);\n" " colorOut = vtf.color * vec4(textureLod(tex, vtf.uv, lod).rgb, 1.0);\n"
"}\n"; "}\n";
static const char* FSAlpha = static const char* FSAlpha =
@ -83,6 +90,7 @@ BOO_GLSL_BINDING_HEAD
"{\n" "{\n"
" vec4 color;\n" " vec4 color;\n"
" vec2 uv;\n" " vec2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"SBINDING(0) in VertToFrag vtf;\n" "SBINDING(0) in VertToFrag vtf;\n"
@ -90,7 +98,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n" "TBINDING0 uniform sampler2D tex;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = vtf.color * texture(tex, vtf.uv);\n" " colorOut = vtf.color * textureLod(tex, vtf.uv, lod);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -16,6 +16,7 @@ static const char* VSFlip =
"{\n" "{\n"
" float4x4 mat;\n" " float4x4 mat;\n"
" float4 color;\n" " float4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -23,6 +24,7 @@ static const char* VSFlip =
" float4 position : SV_Position;\n" " float4 position : SV_Position;\n"
" float4 color : COLOR;\n" " float4 color : COLOR;\n"
" float2 uv : UV;\n" " float2 uv : UV;\n"
" float lod : LOD;\n"
"};\n" "};\n"
"\n" "\n"
"VertToFrag main(in VertData v)\n" "VertToFrag main(in VertData v)\n"
@ -30,6 +32,7 @@ static const char* VSFlip =
" VertToFrag vtf;\n" " VertToFrag vtf;\n"
" vtf.color = color;\n" " vtf.color = color;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.lod = lod;\n"
" vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -45,6 +48,7 @@ static const char* VSNoFlip =
"{\n" "{\n"
" float4x4 mat;\n" " float4x4 mat;\n"
" float4 color;\n" " float4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -52,6 +56,7 @@ static const char* VSNoFlip =
" float4 position : SV_Position;\n" " float4 position : SV_Position;\n"
" float4 color : COLOR;\n" " float4 color : COLOR;\n"
" float2 uv : UV;\n" " float2 uv : UV;\n"
" float lod : LOD;\n"
"};\n" "};\n"
"\n" "\n"
"VertToFrag main(in VertData v)\n" "VertToFrag main(in VertData v)\n"
@ -60,6 +65,7 @@ static const char* VSNoFlip =
" vtf.color = color;\n" " vtf.color = color;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.uv.y = -vtf.uv.y;\n" " vtf.uv.y = -vtf.uv.y;\n"
" vtf.lod = lod;\n"
" vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -70,6 +76,7 @@ static const char* FS =
" float4 position : SV_Position;\n" " float4 position : SV_Position;\n"
" float4 color : COLOR;\n" " float4 color : COLOR;\n"
" float2 uv : UV;\n" " float2 uv : UV;\n"
" float lod : LOD;\n"
"};\n" "};\n"
"\n" "\n"
"Texture2D tex : register(t0);\n" "Texture2D tex : register(t0);\n"
@ -77,7 +84,7 @@ static const char* FS =
"\n" "\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
" return vtf.color * float4(tex.Sample(samp, vtf.uv).rgb, 1.0);\n" " return vtf.color * float4(tex.SampleLevel(samp, vtf.uv, vtf.lod).rgb, 1.0);\n"
"}\n"; "}\n";
static const char* FSAlpha = static const char* FSAlpha =
@ -86,6 +93,7 @@ static const char* FSAlpha =
" float4 position : SV_Position;\n" " float4 position : SV_Position;\n"
" float4 color : COLOR;\n" " float4 color : COLOR;\n"
" float2 uv : UV;\n" " float2 uv : UV;\n"
" float lod : LOD;\n"
"};\n" "};\n"
"\n" "\n"
"Texture2D tex : register(t0);\n" "Texture2D tex : register(t0);\n"
@ -93,7 +101,7 @@ static const char* FSAlpha =
"\n" "\n"
"float4 main(in VertToFrag vtf) : SV_Target0\n" "float4 main(in VertToFrag vtf) : SV_Target0\n"
"{\n" "{\n"
" return vtf.color * tex.Sample(samp, vtf.uv);\n" " return vtf.color * tex.SampleLevel(samp, vtf.uv, vtf.lod);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -18,6 +18,7 @@ static const char* VSFlip =
"{\n" "{\n"
" float4x4 mat;\n" " float4x4 mat;\n"
" float4 color;\n" " float4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -25,6 +26,7 @@ static const char* VSFlip =
" float4 position [[ position ]];\n" " float4 position [[ position ]];\n"
" float4 color;\n" " float4 color;\n"
" float2 uv;\n" " float2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n" "vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n"
@ -32,6 +34,7 @@ static const char* VSFlip =
" VertToFrag vtf;\n" " VertToFrag vtf;\n"
" vtf.color = tqu.color;\n" " vtf.color = tqu.color;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.lod = tqu.lod;\n"
" vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n" " vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -49,6 +52,7 @@ static const char* VSNoFlip =
"{\n" "{\n"
" float4x4 mat;\n" " float4x4 mat;\n"
" float4 color;\n" " float4 color;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"struct VertToFrag\n" "struct VertToFrag\n"
@ -56,6 +60,7 @@ static const char* VSNoFlip =
" float4 position [[ position ]];\n" " float4 position [[ position ]];\n"
" float4 color;\n" " float4 color;\n"
" float2 uv;\n" " float2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n" "vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n"
@ -64,6 +69,7 @@ static const char* VSNoFlip =
" vtf.color = tqu.color;\n" " vtf.color = tqu.color;\n"
" vtf.uv = v.uvIn.xy;\n" " vtf.uv = v.uvIn.xy;\n"
" vtf.uv.y = -vtf.uv.y;\n" " vtf.uv.y = -vtf.uv.y;\n"
" vtf.lod = tqu.lod;\n"
" vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n" " vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n"
" return vtf;\n" " return vtf;\n"
"}\n"; "}\n";
@ -78,11 +84,12 @@ static const char* FS =
" float4 position [[ position ]];\n" " float4 position [[ position ]];\n"
" float4 color;\n" " float4 color;\n"
" float2 uv;\n" " float2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n" "fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"{\n" "{\n"
" return vtf.color * float4(tex.sample(samp, vtf.uv).rgb, 1.0);\n" " return vtf.color * float4(tex.sample(samp, vtf.uv, level(vtf.lod)).rgb, 1.0);\n"
"}\n"; "}\n";
static const char* FSAlpha = static const char* FSAlpha =
@ -94,11 +101,12 @@ static const char* FSAlpha =
" float4 position [[ position ]];\n" " float4 position [[ position ]];\n"
" float4 color;\n" " float4 color;\n"
" float2 uv;\n" " float2 uv;\n"
" float lod;\n"
"};\n" "};\n"
"\n" "\n"
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n" "fragment float4 fmain(VertToFrag vtf [[ stage_in ]], texture2d<float> tex [[ texture(0) ]])\n"
"{\n" "{\n"
" return vtf.color * tex.sample(samp, vtf.uv);\n" " return vtf.color * tex.sample(samp, vtf.uv, level(vtf.lod));\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

View File

@ -1,5 +1,7 @@
#include "CAuiImagePane.hpp" #include "CAuiImagePane.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "Graphics/CTexture.hpp"
#include "CGuiWidgetDrawParms.hpp"
namespace urde namespace urde
{ {
@ -34,6 +36,160 @@ std::shared_ptr<CGuiWidget> CAuiImagePane::Create(CGuiFrame* frame, CInputStream
return ret; return ret;
} }
void CAuiImagePane::Update(float dt)
{
xd0_uvBias0.x = std::fmod(xd0_uvBias0.x, 1.f);
xd0_uvBias0.y = std::fmod(xd0_uvBias0.y, 1.f);
if (x138_tileSize != zeus::CVector2f::skZero && xb8_tex0Tok.IsLoaded())
{
zeus::CVector2f tmp = zeus::CVector2f(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()) / x138_tileSize;
x144_frameTimer = std::fmod(x144_frameTimer + dt * x140_interval, std::floor(tmp.x) * std::floor(tmp.y));
}
CGuiWidget::Update(dt);
}
CAuiImagePane::Filters::Filters(TLockedToken<CTexture>& tex)
: m_darkenerQuad(CCameraFilterPass::EFilterType::Blend, tex),
m_flashQuad{{CCameraFilterPass::EFilterType::Add, tex}, {CCameraFilterPass::EFilterType::Add, tex}},
m_alphaQuad{{CCameraFilterPass::EFilterType::Blend, tex}, {CCameraFilterPass::EFilterType::Blend, tex}},
m_addQuad{{CCameraFilterPass::EFilterType::Add, tex}, {CCameraFilterPass::EFilterType::Add, tex}}
{
}
void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& tex,
int frame, float alpha, bool noBlur, CTexturedQuadFilterAlpha& quad) const
{
zeus::CColor useColor = color;
useColor.a *= alpha;
rstl::reserved_vector<zeus::CVector2f, 4> vec;
const rstl::reserved_vector<zeus::CVector2f, 4>* useUVs;
if (x138_tileSize != zeus::CVector2f::skZero)
{
zeus::CVector2f res(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight());
zeus::CVector2f tmp = res / x138_tileSize;
zeus::CVector2f tmpRecip = x138_tileSize / res;
float x0 = tmpRecip.x * (frame % int(tmp.x));
float x1 = x0 + tmpRecip.x;
float y0 = tmpRecip.y * (frame % int(tmp.y));
float y1 = y0 + tmpRecip.y;
vec.push_back(zeus::CVector2f(x0, y0));
vec.push_back(zeus::CVector2f(x0, y1));
vec.push_back(zeus::CVector2f(x1, y0));
vec.push_back(zeus::CVector2f(x1, y1));
useUVs = &vec;
}
else
{
useUVs = &x114_uvs;
}
CTexturedQuadFilter::Vert verts[] =
{
{xe0_coords[0], (*useUVs)[0] + xd0_uvBias0},
{xe0_coords[1], (*useUVs)[1] + xd0_uvBias0},
{xe0_coords[2], (*useUVs)[2] + xd0_uvBias0},
{xe0_coords[3], (*useUVs)[3] + xd0_uvBias0}
};
if (noBlur)
{
quad.drawVerts(useColor, verts);
}
else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumMips() == 1)
{
quad.drawVerts(useColor, verts, 0.f);
}
else
{
float tmp = (1.f - x14c_deResFactor) * alpha;
float tmp3 = 1.f - tmp * tmp * tmp;
float mip = tmp3 * (tex.GetNumMips() - 1);
quad.drawVerts(useColor, verts, mip);
}
}
void CAuiImagePane::Draw(const CGuiWidgetDrawParms& params) const
{
CGraphics::SetModelMatrix(x34_worldXF);
if (!GetIsVisible() || !xb8_tex0Tok.IsLoaded())
return;
GetIsFinishedLoadingWidgetSpecific();
if (!m_filters)
const_cast<CAuiImagePane*>(this)->m_filters.emplace(const_cast<CAuiImagePane*>(this)->xb8_tex0Tok);
Filters& filters = const_cast<Filters&>(*m_filters);
zeus::CColor color = xa8_color2;
color.a *= params.x0_alphaMod;
//SetZUpdate(xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque);
float blur0 = 1.f;
float blur1 = 0.f;
int frame0 = x144_frameTimer;
int frame1 = 0;
if (x140_interval < 1.f && x140_interval > 0.f)
{
zeus::CVector2f tmp = zeus::CVector2f(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight()) / x138_tileSize;
frame1 = (frame0 + 1) % int(tmp.x * tmp.y);
if (x148_fadeDuration == 0.f)
blur1 = 1.f;
else
blur1 = std::min(std::fmod(x144_frameTimer, 1.f) / x148_fadeDuration, 1.f);
blur0 = 1.f - blur1;
}
// Alpha blend
DoDrawImagePane(color * zeus::CColor(0.f, 0.5f), *xb8_tex0Tok, frame0, 1.f, true, filters.m_darkenerQuad);
if (x150_flashFactor > 0.f)
{
// Additive blend
zeus::CColor color2 = xa8_color2;
color2.a = x150_flashFactor;
DoDrawImagePane(color2, *xb8_tex0Tok, frame0, blur0, false, filters.m_flashQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color2, *xb8_tex0Tok, frame1, blur1, false, filters.m_flashQuad[1]);
}
switch (xac_drawFlags)
{
case EGuiModelDrawFlags::Shadeless:
case EGuiModelDrawFlags::Opaque:
// Opaque blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]);
break;
case EGuiModelDrawFlags::Alpha:
// Alpha blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]);
break;
case EGuiModelDrawFlags::Additive:
// Additive blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_addQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_addQuad[1]);
break;
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
// Alpha blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_alphaQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_alphaQuad[1]);
// Full additive blend
DoDrawImagePane(color, *xb8_tex0Tok, frame0, blur0, false, filters.m_addQuad[0]);
if (blur1 > 0.f)
DoDrawImagePane(color, *xb8_tex0Tok, frame1, blur1, false, filters.m_addQuad[1]);
break;
default: break;
}
}
bool CAuiImagePane::GetIsFinishedLoadingWidgetSpecific() const
{
return xb8_tex0Tok.IsLoaded();
}
void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp) void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp)
{ {
xc8_tex0 = tex; xc8_tex0 = tex;
@ -45,12 +201,12 @@ void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp)
xb8_tex0Tok = TLockedToken<CTexture>(); xb8_tex0Tok = TLockedToken<CTexture>();
} }
void CAuiImagePane::SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration) void CAuiImagePane::SetAnimationParms(const zeus::CVector2f& tileSize, float interval, float fadeDuration)
{ {
x138_ = vec; x138_tileSize = tileSize;
x140_interval = interval; x140_interval = interval;
x144_ = 0.f; x144_frameTimer = 0.f;
x148_duration = duration; x148_fadeDuration = fadeDuration;
} }
} }

View File

@ -3,6 +3,7 @@
#include "CGuiWidget.hpp" #include "CGuiWidget.hpp"
#include "CToken.hpp" #include "CToken.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
namespace urde namespace urde
{ {
@ -14,16 +15,27 @@ class CAuiImagePane : public CGuiWidget
TLockedToken<CTexture> xb8_tex0Tok; // Used to be optional TLockedToken<CTexture> xb8_tex0Tok; // Used to be optional
ResId xc8_tex0; ResId xc8_tex0;
ResId xcc_tex1; ResId xcc_tex1;
zeus::CVector2f xd0_; zeus::CVector2f xd0_uvBias0;
zeus::CVector2f xd8_; zeus::CVector2f xd8_uvBias1;
rstl::reserved_vector<zeus::CVector3f, 4> xe0_coords; rstl::reserved_vector<zeus::CVector3f, 4> xe0_coords;
rstl::reserved_vector<zeus::CVector2f, 4> x114_uvs; rstl::reserved_vector<zeus::CVector2f, 4> x114_uvs;
zeus::CVector2f x138_; zeus::CVector2f x138_tileSize;
float x140_interval = 0.f; float x140_interval = 0.f;
float x144_ = 0.f; float x144_frameTimer = 0.f;
float x148_duration = 0.f; float x148_fadeDuration = 0.f;
float x14c_deResFactor = 0.f; float x14c_deResFactor = 0.f;
float x150_alpha = 0.f; float x150_flashFactor = 0.f;
struct Filters
{
CTexturedQuadFilterAlpha m_darkenerQuad;
CTexturedQuadFilterAlpha m_flashQuad[2];
CTexturedQuadFilterAlpha m_alphaQuad[2];
CTexturedQuadFilterAlpha m_addQuad[2];
Filters(TLockedToken<CTexture>& tex);
};
std::experimental::optional<Filters> m_filters;
void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex,
int frame, float blurAmt, bool noBlur, CTexturedQuadFilterAlpha& quad) const;
public: public:
CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId, CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId,
rstl::reserved_vector<zeus::CVector3f, 4>&& coords, rstl::reserved_vector<zeus::CVector3f, 4>&& coords,
@ -31,10 +43,13 @@ public:
FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); } FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); }
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
void Update(float dt);
void Draw(const CGuiWidgetDrawParms& params) const;
bool GetIsFinishedLoadingWidgetSpecific() const;
void SetTextureID0(ResId tex, CSimplePool* sp); void SetTextureID0(ResId tex, CSimplePool* sp);
void SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration); void SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration);
void SetDeResFactor(float d) { x14c_deResFactor = d; } void SetDeResFactor(float d) { x14c_deResFactor = d; }
void SetAlpha(float t) { x150_alpha = t; } void SetFlashFactor(float t) { x150_flashFactor = t; }
}; };
} }

View File

@ -79,6 +79,8 @@ CScanDisplay::CScanDisplay(const CGuiFrame& selHud)
: xa0_selHud(selHud) : xa0_selHud(selHud)
{ {
x0_dataDot = g_SimplePool->GetObj("TXTR_DataDot"); x0_dataDot = g_SimplePool->GetObj("TXTR_DataDot");
for (int i=0 ; i<4 ; ++i)
xbc_dataDots.emplace_back(x0_dataDot);
} }
void CScanDisplay::ProcessInput(const CFinalInput& input) void CScanDisplay::ProcessInput(const CFinalInput& input)
@ -242,7 +244,7 @@ void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo,
bucket.x14_interval, bucket.x18_fadeDuration); bucket.x14_interval, bucket.x18_fadeDuration);
} }
state.second->SetTextureID0(bucket.x0_texture, g_SimplePool); state.second->SetTextureID0(bucket.x0_texture, g_SimplePool);
state.second->SetAlpha(0.f); state.second->SetFlashFactor(0.f);
if (scanTime >= GetDownloadStartTime(i)) if (scanTime >= GetDownloadStartTime(i))
x170_paneStates[i].first = 0.f; x170_paneStates[i].first = 0.f;
else else
@ -301,12 +303,7 @@ void CScanDisplay::SetScanMessageTypeEffect(CGuiTextPane* pane, bool type)
void CScanDisplay::Update(float dt, float scanningTime) void CScanDisplay::Update(float dt, float scanningTime)
{ {
if (xc_state == EScanState::Inactive) if (xc_state == EScanState::Inactive)
{
x0_dataDot.Unlock();
return; return;
}
x0_dataDot.Lock();
bool active = false; bool active = false;
if (xc_state == EScanState::Done) if (xc_state == EScanState::Done)
@ -379,7 +376,7 @@ void CScanDisplay::Update(float dt, float scanningTime)
tmp = 1.f - (x170_paneStates[i].first - g_tweakGui->GetScanPaneFadeOutTime()) / g_tweakGui->GetScanPaneFadeInTime(); tmp = 1.f - (x170_paneStates[i].first - g_tweakGui->GetScanPaneFadeOutTime()) / g_tweakGui->GetScanPaneFadeInTime();
else else
tmp = x170_paneStates[i].first / g_tweakGui->GetScanPaneFadeOutTime(); tmp = x170_paneStates[i].first / g_tweakGui->GetScanPaneFadeOutTime();
x170_paneStates[i].second->SetAlpha(tmp * g_tweakGui->GetScanPaneFadeAlpha() * x1a8_bodyAlpha); x170_paneStates[i].second->SetFlashFactor(tmp * g_tweakGui->GetScanPaneFlashFactor() * x1a8_bodyAlpha);
} }
float alphaMul = ((xc_state == EScanState::Downloading) ? GetDownloadFraction(i, scanningTime) : 1.f) * x1a8_bodyAlpha; float alphaMul = ((xc_state == EScanState::Downloading) ? GetDownloadFraction(i, scanningTime) : 1.f) * x1a8_bodyAlpha;
zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor(); zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor();
@ -426,8 +423,8 @@ void CScanDisplay::Update(float dt, float scanningTime)
if (tmp == 0.f) if (tmp == 0.f)
{ {
float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude(); float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude();
float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Min() : g_tweakGui->GetScanDataDotDuration1Min(); float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMin() : g_tweakGui->GetScanDataDotSeekDurationMin();
float durMax = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Max() : g_tweakGui->GetScanDataDotDuration1Max(); float durMax = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMax() : g_tweakGui->GetScanDataDotSeekDurationMax();
zeus::CVector2f vec(dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().x : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand), zeus::CVector2f vec(dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().x : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand),
dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().y : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand)); dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().y : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand));
dot.StartTransitionTo(vec, (durMax - durMin) * (rand() / float(RAND_MAX)) + durMin); dot.StartTransitionTo(vec, (durMax - durMin) * (rand() / float(RAND_MAX)) + durMin);

View File

@ -244,7 +244,7 @@ void CLogBookScreen::UpdateBodyImagesAndText()
bucket.x14_interval, bucket.x18_fadeDuration); bucket.x14_interval, bucket.x18_fadeDuration);
} }
pane->SetTextureID0(bucket.x0_texture, g_SimplePool); pane->SetTextureID0(bucket.x0_texture, g_SimplePool);
pane->SetAlpha(0.f); pane->SetFlashFactor(0.f);
} }
x260_26_exitTextScroll = false; x260_26_exitTextScroll = false;