unsuccessful experimentation
This commit is contained in:
@@ -15,7 +15,8 @@ namespace Game
|
||||
{
|
||||
double Now = 0.0;
|
||||
double Delta = 0.0;
|
||||
uint32_t FrameCounter = 0;
|
||||
int64_t NowHP = 0;
|
||||
int64_t DeltaHP = 1000;
|
||||
int64_t StartTime = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,12 +68,6 @@ namespace Game
|
||||
void Level::Update()
|
||||
{
|
||||
PlayerData& player = GetInstance().Player;
|
||||
if (GetKeyPressedNow(ScanCode::R))
|
||||
{
|
||||
Cubes.Count = 0;
|
||||
Tests.Count = 0;
|
||||
Setup(GetShared().Game);
|
||||
}
|
||||
|
||||
float delta = GetInstance().Time.Delta;
|
||||
constexpr float moveSpeed = 10.0f;
|
||||
@@ -126,8 +120,8 @@ namespace Game
|
||||
EData.Transform.Position = {0.0f, -1.0f, 0.0f};
|
||||
EData.Transform.Scale = {100.0f, 1.0f, 100.0f};
|
||||
EData.TestColor[0] = 0.3f;
|
||||
EData.TestColor[1] = 0.4f;
|
||||
EData.TestColor[2] = 0.8f;
|
||||
EData.TestColor[1] = 0.325f;
|
||||
EData.TestColor[2] = 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Global.h"
|
||||
#include "Input.h"
|
||||
#include "Instance.h"
|
||||
#include "Log.h"
|
||||
#include "Setup.h"
|
||||
@@ -53,11 +54,21 @@ namespace Game
|
||||
|
||||
void Update()
|
||||
{
|
||||
++GetInstance().Time.FrameCounter;
|
||||
double newNow = (bx::getHPCounter() - GetInstance().Time.StartTime) / (double)(bx::getHPFrequency());
|
||||
GetInstance().Time.Delta = newNow - GetInstance().Time.Now;
|
||||
GetInstance().Time.Now = newNow;
|
||||
auto& inst = GetInstance();
|
||||
int64_t newNowHP = bx::getHPCounter() - GetInstance().Time.StartTime;
|
||||
inst.Time.DeltaHP = newNowHP - inst.Time.NowHP;
|
||||
inst.Time.NowHP = newNowHP;
|
||||
inst.Time.Now = (double)inst.Time.NowHP / bx::getHPFrequency();
|
||||
inst.Time.Delta = (double)inst.Time.DeltaHP / bx::getHPFrequency();
|
||||
GetShared().Window.PerfCounters[(int32_t)PerfCounterType::GameDelta].Write(inst.Time.DeltaHP,
|
||||
GetShared().Window.FrameCounter);
|
||||
|
||||
if (GetKeyPressedNow(ScanCode::R))
|
||||
{
|
||||
GetInstance().Size = 0;
|
||||
Shutdown();
|
||||
Setup(GetShared());
|
||||
}
|
||||
SetupInstance.Rendering.Update();
|
||||
|
||||
auto& win = GetShared().Window;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -290,10 +290,14 @@ namespace Game
|
||||
GetInstance().GameLevel.Cubes.Render(Models, Materials);
|
||||
GetInstance().GameLevel.Tests.Render(Models, Materials);
|
||||
|
||||
bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %.1f", GetInstance().Time.Now);
|
||||
bgfx::dbgTextPrintf(1, 2, 0x0F, "Frame: %u", GetInstance().Time.FrameCounter);
|
||||
bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %.1fs", GetInstance().Time.Now);
|
||||
bgfx::dbgTextPrintf(1,
|
||||
2,
|
||||
0x0F,
|
||||
"Window Events: %.3fms",
|
||||
GetShared().Window.PerfCounters[(int32_t)PerfCounterType::WindowEvents].GetMax());
|
||||
bgfx::dbgTextPrintf(
|
||||
1, 3, 0x0F, "Delta: %.3fms / %.0ffps", GetInstance().Time.Delta, 1.0 / GetInstance().Time.Delta);
|
||||
1, 3, 0x0F, "Delta: %.3fms", GetShared().Window.PerfCounters[(int32_t)PerfCounterType::GameDelta].GetMax());
|
||||
|
||||
bgfx::frame();
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ uniform vec4 u_testColor;
|
||||
float circle(vec2 uv, float radius)
|
||||
{
|
||||
float distSq = uv.x * uv.x + uv.y * uv.y;
|
||||
// float result = sqrt(distSq) / radius * 0.8;
|
||||
float result = sqrt(distSq) / radius;
|
||||
// return result < 0.5;
|
||||
return clamp(1.0 - result, 0.0, 1.0);
|
||||
// float clamped = clamp(1.0 - result, 0.0, 1.0);
|
||||
float clamped = clamp(1.5 - result, 0.0, 1.0);
|
||||
return clamped;
|
||||
}
|
||||
|
||||
float calcBrightness(vec3 lightPos, vec3 vertPos, vec3 normal)
|
||||
@@ -65,8 +67,9 @@ void main()
|
||||
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
||||
float brightness = calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal);
|
||||
// brightness = 1.0;
|
||||
// brightness = 0.1 + brightness * 0.9;
|
||||
// brightness = sin(u_time.x) * 0.5 + 0.5;
|
||||
|
||||
// Magic dot frequency calculation
|
||||
float baseScale = 2.0;
|
||||
float2 dx = ddx(v_uv0 * baseScale);
|
||||
float2 dy = ddy(v_uv0 * baseScale);
|
||||
@@ -78,24 +81,28 @@ void main()
|
||||
float discriminant = sqrt(discriminantSqr);
|
||||
float2 freq = sqrt(float2(qq + discriminant, qq - discriminant) / 2.0);
|
||||
|
||||
// Figuring out how many dots we want
|
||||
float spacing = freq.y * exp2(2.0);
|
||||
spacing = 1.0 / spacing;
|
||||
spacing *= brightness; // TODO: check reference to see how to calculate this!
|
||||
float spacingLog = max(log2(spacing), 0.0);
|
||||
int patternScaleLevel = floor(spacingLog);
|
||||
float patternFractional = spacingLog - patternScaleLevel;
|
||||
|
||||
vec2 uv = v_uv0 * exp2(patternScaleLevel);
|
||||
float dither = circles(uv, patternScaleLevel, patternFractional, brightness);
|
||||
|
||||
// Coloring
|
||||
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||
vec3 color = desaturate(texColor) * 0.01 + dither * texColor * 0.95;
|
||||
vec3 smoothColor = brightness * u_testColor.xyz;
|
||||
vec3 mixedColor = 0.1 * smoothColor + 0.9 * color;
|
||||
// gl_FragColor = vec4(mixedColor, 1.0);
|
||||
vec3 color;
|
||||
color.r = circles(uv, patternScaleLevel, patternFractional, brightness * texColor.r);
|
||||
color.g = circles(uv, patternScaleLevel, patternFractional, brightness * texColor.g);
|
||||
color.b = circles(uv, patternScaleLevel, patternFractional, brightness * texColor.b);
|
||||
// color = circles(uv, patternScaleLevel, patternFractional, brightness) * texColor;
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
// vec3 smoothColor = brightness * u_testColor.xyz;
|
||||
// gl_FragColor = brightness;
|
||||
// gl_FragColor = dither;
|
||||
// gl_FragColor = u_testColor;
|
||||
// gl_FragColor = texture2D(s_texColor, v_uv0);
|
||||
// gl_FragColor = vec4(texColor, 1.0);
|
||||
// gl_FragColor = vec4(v_normal, 1.0);
|
||||
// gl_FragColor = vec4(uv, 0.0, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user