From 36769fd2fb3f05a170d35070b2ababb2a8d36c37 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Mon, 3 Aug 2015 21:04:53 +0200 Subject: [PATCH] backlog script update + font update + gass dither update --- WickedEngine/ditherHF.hlsli | 2 +- WickedEngine/grassL2GS.hlsl | 3 ++- WickedEngine/qGrassLDistGS.hlsl | 3 ++- WickedEngine/wiBackLog.cpp | 20 +++++++++++++++++--- WickedEngine/wiBackLog.h | 2 ++ WickedEngine/wiFont.h | 8 ++++---- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/WickedEngine/ditherHF.hlsli b/WickedEngine/ditherHF.hlsli index 8659bc8c9..90c6c0cf5 100644 --- a/WickedEngine/ditherHF.hlsli +++ b/WickedEngine/ditherHF.hlsli @@ -57,7 +57,7 @@ inline float ditherMask8(in float2 pixel) inline float dither(in float2 pixel) { - return ditherMask4(pixel); + return ditherMask8(pixel); } #endif //DITHER_HF diff --git a/WickedEngine/grassL2GS.hlsl b/WickedEngine/grassL2GS.hlsl index 108e9d1d5..cd53ef174 100644 --- a/WickedEngine/grassL2GS.hlsl +++ b/WickedEngine/grassL2GS.hlsl @@ -28,7 +28,8 @@ void main( for(uint i=0;i<1;++i){ float4 mod = pos + float4(cross(MOD[i], normal), 0); #ifdef GRASS_FADE_DITHER - const float fade = pow(saturate(distance(pos.xyz, eye.xyz) / drawdistance), 10); + static const float grassPopDistanceThreshold = 0.9f; + const float fade = pow(saturate(distance(pos.xyz, eye.xyz) / (drawdistance*grassPopDistanceThreshold)), 10); #else static const float fade = 0; #endif diff --git a/WickedEngine/qGrassLDistGS.hlsl b/WickedEngine/qGrassLDistGS.hlsl index d9addd069..1a5fe0086 100644 --- a/WickedEngine/qGrassLDistGS.hlsl +++ b/WickedEngine/qGrassLDistGS.hlsl @@ -35,7 +35,8 @@ void main( QGS_OUT element = (QGS_OUT)0; element.nor = normal; #ifdef GRASS_FADE_DITHER - element.fade = pow(saturate(distance(pos.xyz, eye.xyz) / drawdistance), 10); + static const float grassPopDistanceThreshold = 0.9f; + element.fade = pow(saturate(distance(pos.xyz, eye.xyz) / (drawdistance*grassPopDistanceThreshold)), 10); #endif element.tex=float2(rand%2?1:0,0); diff --git a/WickedEngine/wiBackLog.cpp b/WickedEngine/wiBackLog.cpp index 0592f7c5c..08d9d2849 100644 --- a/WickedEngine/wiBackLog.cpp +++ b/WickedEngine/wiBackLog.cpp @@ -16,7 +16,7 @@ int wiBackLog::scroll; stringstream wiBackLog::inputArea; int wiBackLog::historyPos=0; ID3D11ShaderResourceView* wiBackLog::backgroundTex = nullptr; - +float wiBackLog::fontSize = 0; void wiBackLog::Initialize(){ pos = (float)wiRenderer::RENDERHEIGHT; @@ -26,9 +26,11 @@ void wiBackLog::Initialize(){ inputArea=stringstream(""); const unsigned char colorData[] = { 0, 0, 43, 200, 43, 31, 141, 223 }; wiTextureHelper::CreateTexture(backgroundTex, colorData, 1, 2, 4); + fontSize = 0; wiLua::GetGlobal()->Register("backlog_clear", ClearLua); wiLua::GetGlobal()->Register("backlog_post", PostLua); + wiLua::GetGlobal()->Register("backlog_fontsize", FontSizeLua); } void wiBackLog::CleanUp(){ stream.clear(); @@ -60,8 +62,8 @@ void wiBackLog::Draw(){ fx.pos=XMFLOAT3(0,pos,0); fx.opacity = wiMath::Lerp(0, 1, pos / wiRenderer::RENDERHEIGHT); wiImage::Draw(backgroundTex, fx); - wiFont(getText(), wiFontProps(5, pos - wiRenderer::RENDERHEIGHT + 75 + scroll, 0, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8)).Draw(); - wiFont(inputArea.str().c_str(), wiFontProps(5, -(float)wiRenderer::RENDERHEIGHT + 10, 0, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8)).Draw(); + wiFont(getText(), wiFontProps(5, pos - wiRenderer::RENDERHEIGHT + 75 + scroll, fontSize, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8)).Draw(); + wiFont(inputArea.str().c_str(), wiFontProps(5, -(float)wiRenderer::RENDERHEIGHT + 10, fontSize, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8)).Draw(); //wiFont::Draw(wiBackLog::getText(), "01", XMFLOAT4(5, pos - wiRenderer::RENDERHEIGHT + 75 + scroll, 0, -8), "left", "bottom"); //wiFont::Draw(inputArea.str().c_str(), "01", XMFLOAT4(5, -(float)wiRenderer::RENDERHEIGHT + 10, 0, -8), "left", "bottom"); } @@ -164,3 +166,15 @@ int wiBackLog::PostLua(lua_State* L) //number of results return 0; } +int wiBackLog::FontSizeLua(lua_State* L) +{ + int argc = lua_gettop(L); + + if (argc > 0) + { + fontSize = lua_tointeger(L, 1); + } + + //number of results + return 0; +} diff --git a/WickedEngine/wiBackLog.h b/WickedEngine/wiBackLog.h index 0876db104..8272bc152 100644 --- a/WickedEngine/wiBackLog.h +++ b/WickedEngine/wiBackLog.h @@ -23,6 +23,7 @@ private: }; static State state; static ID3D11ShaderResourceView* backgroundTex; + static float fontSize; public: static void Initialize(); static void CleanUp(); @@ -50,6 +51,7 @@ public: static int ClearLua(lua_State* L); static int PostLua(lua_State* L); + static int FontSizeLua(lua_State* L); }; #endif diff --git a/WickedEngine/wiFont.h b/WickedEngine/wiFont.h index d7fb17c87..c022e2d28 100644 --- a/WickedEngine/wiFont.h +++ b/WickedEngine/wiFont.h @@ -18,14 +18,14 @@ enum wiFontAlign class wiFontProps { public: - int size; - int spacingX, spacingY; + float size; + float spacingX, spacingY; float posX, posY; wiFontAlign h_align, v_align; //zero-based properties: add or subtract from values - wiFontProps(float posX = 0, float posY = 0, int size = 0, wiFontAlign h_align = WIFALIGN_LEFT, wiFontAlign v_align = WIFALIGN_TOP - , int spacingX = 0, int spacingY = 0) + wiFontProps(float posX = 0, float posY = 0, float size = 0, wiFontAlign h_align = WIFALIGN_LEFT, wiFontAlign v_align = WIFALIGN_TOP + , float spacingX = 0, float spacingY = 0) :posX(posX), posY(posY), size(size), h_align(h_align), v_align(v_align), spacingX(spacingX), spacingY(spacingY) {} };