more tooling
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
*.blend1
|
*.blend1
|
||||||
tools/remedy-session.rdbg
|
tools/remedy-session.rdbg
|
||||||
src/imgui.ini
|
src/imgui.ini
|
||||||
|
*.log
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ struct SharedDevData
|
|||||||
{
|
{
|
||||||
uint32_t ChangedShaderCount = 0;
|
uint32_t ChangedShaderCount = 0;
|
||||||
FileChangeNotification ChangedShaders[16];
|
FileChangeNotification ChangedShaders[16];
|
||||||
|
char ShaderLog[2048]{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameData
|
struct GameData
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <fileapi.h>
|
#include <fileapi.h>
|
||||||
|
#include <fstream>
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
#include <synchapi.h>
|
#include <synchapi.h>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -109,7 +110,17 @@ void FileChangeCheck(HANDLE dirHandle, FileChangeType changeType, const wchar_t*
|
|||||||
}
|
}
|
||||||
else if (changeType == FileChangeType::Shader)
|
else if (changeType == FileChangeType::Shader)
|
||||||
{
|
{
|
||||||
std::system("shadercompile.bat");
|
std::system("shadercompile.bat > shadercompile.log");
|
||||||
|
Sleep(1000);
|
||||||
|
std::ifstream shaderLogFile("shadercompile.log");
|
||||||
|
if (shaderLogFile.is_open())
|
||||||
|
{
|
||||||
|
shaderLogFile.seekg(0, std::ios::end);
|
||||||
|
uint32_t size = bx::min(BX_COUNTOF(Shared.Dev.ShaderLog), shaderLogFile.tellg());
|
||||||
|
shaderLogFile.seekg(0);
|
||||||
|
shaderLogFile.read(Shared.Dev.ShaderLog, size);
|
||||||
|
shaderLogFile.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (changeType == FileChangeType::CompiledShader)
|
else if (changeType == FileChangeType::CompiledShader)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,13 +29,21 @@ namespace Game
|
|||||||
bgfx::setIndexBuffer(currentModel.IndexBuffer);
|
bgfx::setIndexBuffer(currentModel.IndexBuffer);
|
||||||
bgfx::setState(currentMaterial.State);
|
bgfx::setState(currentMaterial.State);
|
||||||
|
|
||||||
float TimeValues[4]{0.0f};
|
float timeValues[4]{0.0f};
|
||||||
TimeValues[0] = GetInstance().Time.Now;
|
timeValues[0] = GetInstance().Time.Now;
|
||||||
|
|
||||||
|
float texInfo[4]{0.0f};
|
||||||
|
texInfo[0] = currentMaterial.Textures[0].Info.width;
|
||||||
|
texInfo[1] = currentMaterial.Textures[0].Info.height;
|
||||||
|
texInfo[2] = rendering.DitherTextures.DitherTexWH;
|
||||||
|
texInfo[3] = rendering.DitherTextures.DitherTexDepth;
|
||||||
|
|
||||||
bgfx::setTexture(0, currentMaterial.Textures[0].SamplerHandle, currentMaterial.Textures[0].Handle);
|
bgfx::setTexture(0, currentMaterial.Textures[0].SamplerHandle, currentMaterial.Textures[0].Handle);
|
||||||
bgfx::setTexture(1, rendering.DitherTextures.DitherSampler, rendering.DitherTextures.FinalTex);
|
bgfx::setTexture(1, rendering.DitherTextures.DitherSampler, rendering.DitherTextures.FinalTex);
|
||||||
bgfx::setTexture(2, rendering.DitherTextures.RampSampler, rendering.DitherTextures.RampTex);
|
bgfx::setTexture(2, rendering.DitherTextures.RampSampler, rendering.DitherTextures.RampTex);
|
||||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UTime], TimeValues);
|
bgfx::setUniform(currentMaterial.Uniforms[Material::UTime], timeValues);
|
||||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UDotColor], TestColor);
|
bgfx::setUniform(currentMaterial.Uniforms[Material::UDotColor], TestColor);
|
||||||
|
bgfx::setUniform(currentMaterial.Uniforms[Material::UTexInfo], texInfo);
|
||||||
|
|
||||||
bgfx::submit(currentMaterial.ViewID, currentMaterial.Shader);
|
bgfx::submit(currentMaterial.ViewID, currentMaterial.Shader);
|
||||||
}
|
}
|
||||||
@@ -189,7 +197,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
player.FreeflyCamTransform.UpdateMatrix();
|
player.FreeflyCamTransform.UpdateMatrix();
|
||||||
bgfx::setViewTransform(viewId, player.FreeflyCamTransform.M.M, proj);
|
bgfx::setViewTransform(viewId, player.FreeflyCamTransform.M.M, proj);
|
||||||
bgfx::dbgTextPrintf(1, 0, 0b1100, "NOCLIP");
|
// bgfx::dbgTextPrintf(1, 0, 0b1100, "NOCLIP");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -136,7 +136,6 @@ namespace Game
|
|||||||
|
|
||||||
const bgfx::Memory* mem =
|
const bgfx::Memory* mem =
|
||||||
bgfx::makeRef(data->data + imageContainer.m_offset, data->size - imageContainer.m_offset);
|
bgfx::makeRef(data->data + imageContainer.m_offset, data->size - imageContainer.m_offset);
|
||||||
// const bgfx::Memory* mem = bgfx::makeRef(imageContainer.m_data, imageContainer.m_size);
|
|
||||||
|
|
||||||
if (NULL != _info)
|
if (NULL != _info)
|
||||||
{
|
{
|
||||||
@@ -356,13 +355,13 @@ namespace Game
|
|||||||
{
|
{
|
||||||
Log("BGFX setup succeded!");
|
Log("BGFX setup succeded!");
|
||||||
}
|
}
|
||||||
bgfx::setDebug(BGFX_DEBUG_TEXT);
|
// bgfx::setDebug(BGFX_DEBUG_TEXT);
|
||||||
bgfx::setViewClear(MainViewID, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x3399FFff, 1.0f, 0);
|
bgfx::setViewClear(MainViewID, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x3399FFff, 1.0f, 0);
|
||||||
bgfx::setViewRect(MainViewID, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight);
|
bgfx::setViewRect(MainViewID, 0, 0, shared.Window.WindowWidth, shared.Window.WindowHeight);
|
||||||
|
|
||||||
DefaultSampler = bgfx::createUniform("s_texColor", bgfx::UniformType::Sampler);
|
DefaultSampler = bgfx::createUniform("s_texColor", bgfx::UniformType::Sampler);
|
||||||
Textures[0].Handle =
|
Textures[0].Handle = loadTexture(
|
||||||
loadTexture(bx::FilePath{"models/body.dds"}, BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE, 0, nullptr, nullptr);
|
bx::FilePath{"models/body.dds"}, BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE, 0, &Textures[0].Info, nullptr);
|
||||||
Textures[0].SamplerHandle = DefaultSampler;
|
Textures[0].SamplerHandle = DefaultSampler;
|
||||||
LoadModels(Models, ModelCount);
|
LoadModels(Models, ModelCount);
|
||||||
|
|
||||||
@@ -499,8 +498,10 @@ namespace Game
|
|||||||
}
|
}
|
||||||
if (isValid(DitherTextures.RampTex))
|
if (isValid(DitherTextures.RampTex))
|
||||||
{
|
{
|
||||||
ImGui::Image(DitherTextures.RampTex.idx, {BX_COUNTOF(DitherTextures.BrightnessRamp), 1});
|
ImGui::Image(DitherTextures.RampTex.idx, {BX_COUNTOF(DitherTextures.BrightnessRamp), 8});
|
||||||
}
|
}
|
||||||
|
ImGui::Text("Shader log:");
|
||||||
|
ImGui::TextWrapped("%s", GetShared().Dev.ShaderLog);
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@@ -508,12 +509,12 @@ namespace Game
|
|||||||
GetInstance().GameLevel.Update();
|
GetInstance().GameLevel.Update();
|
||||||
GetInstance().GameLevel.Render(MainViewID, Models, Materials);
|
GetInstance().GameLevel.Render(MainViewID, Models, Materials);
|
||||||
|
|
||||||
bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %.1fs", GetInstance().Time.Now);
|
// bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %.1fs", GetInstance().Time.Now);
|
||||||
for (int32_t i = 0; i < (int32_t)PerfCounterType::COUNT; ++i)
|
// for (int32_t i = 0; i < (int32_t)PerfCounterType::COUNT; ++i)
|
||||||
{
|
// {
|
||||||
bgfx::dbgTextPrintf(
|
// bgfx::dbgTextPrintf(
|
||||||
1, 2 + i, 0x0F, "%s Max: %.3fs", PerfCounterNames[i], shared.Window.PerfCounters[i].GetMax());
|
// 1, 2 + i, 0x0F, "%s Max: %.3fs", PerfCounterNames[i], shared.Window.PerfCounters[i].GetMax());
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Finish Frame
|
// Finish Frame
|
||||||
imguiEndFrame();
|
imguiEndFrame();
|
||||||
@@ -556,6 +557,7 @@ namespace Game
|
|||||||
BGFX_STATE_CULL_CCW | BGFX_STATE_MSAA;
|
BGFX_STATE_CULL_CCW | BGFX_STATE_MSAA;
|
||||||
mat.Uniforms[Material::UTime] = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
mat.Uniforms[Material::UTime] = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||||
mat.Uniforms[Material::UDotColor] = bgfx::createUniform("u_testColor", bgfx::UniformType::Vec4);
|
mat.Uniforms[Material::UDotColor] = bgfx::createUniform("u_testColor", bgfx::UniformType::Vec4);
|
||||||
|
mat.Uniforms[Material::UTexInfo] = bgfx::createUniform("u_texInfo", bgfx::UniformType::Vec4);
|
||||||
mat.Textures[0].Handle = tex;
|
mat.Textures[0].Handle = tex;
|
||||||
mat.Textures[0].SamplerHandle = sampler;
|
mat.Textures[0].SamplerHandle = sampler;
|
||||||
mat.ViewID = view;
|
mat.ViewID = view;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
bgfx::UniformHandle SamplerHandle;
|
bgfx::UniformHandle SamplerHandle;
|
||||||
bgfx::TextureHandle Handle;
|
bgfx::TextureHandle Handle;
|
||||||
|
bgfx::TextureInfo Info;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Model
|
struct Model
|
||||||
@@ -44,6 +45,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
UTime = 0,
|
UTime = 0,
|
||||||
UDotColor = 1,
|
UDotColor = 1,
|
||||||
|
UTexInfo = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
bgfx::ProgramHandle Shader;
|
bgfx::ProgramHandle Shader;
|
||||||
@@ -68,9 +70,9 @@ namespace Game
|
|||||||
struct DitherData
|
struct DitherData
|
||||||
{
|
{
|
||||||
static constexpr uint32_t BrightnessBucketCount = 256;
|
static constexpr uint32_t BrightnessBucketCount = 256;
|
||||||
Vec2 Points[1024];
|
Vec2 Points[4096];
|
||||||
uint32_t PointCount = 0;
|
uint32_t PointCount = 0;
|
||||||
Vec4 DitherTex[64 * 64 * 16];
|
Vec4 DitherTex[256 * 256 * 64];
|
||||||
uint32_t DitherTexWH = 0;
|
uint32_t DitherTexWH = 0;
|
||||||
uint32_t DitherTexDepth = 0;
|
uint32_t DitherTexDepth = 0;
|
||||||
int32_t BrightnessBuckets[BrightnessBucketCount];
|
int32_t BrightnessBuckets[BrightnessBucketCount];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ SAMPLER3D(s_ditherSampler, 1);
|
|||||||
SAMPLER2D(s_rampSampler, 2);
|
SAMPLER2D(s_rampSampler, 2);
|
||||||
uniform vec4 u_time;
|
uniform vec4 u_time;
|
||||||
uniform vec4 u_testColor;
|
uniform vec4 u_testColor;
|
||||||
|
uniform vec4 u_texInfo;
|
||||||
|
|
||||||
float calcBrightness(vec3 lightPos, vec3 vertPos, vec3 normal)
|
float calcBrightness(vec3 lightPos, vec3 vertPos, vec3 normal)
|
||||||
{
|
{
|
||||||
@@ -28,27 +29,14 @@ vec3 desaturate(vec3 color)
|
|||||||
return vec3_splat(dot(color, vec3(0.33, 0.34, 0.33)));
|
return vec3_splat(dot(color, vec3(0.33, 0.34, 0.33)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
float dither(float brightness, vec2 inputUv)
|
||||||
{
|
{
|
||||||
// setup
|
float globalScale = 8.0;
|
||||||
float globalScale = 6.0;
|
|
||||||
float testRadius = 30.0;
|
|
||||||
float testSpeed = 1.0;
|
|
||||||
vec3 testOffset = vec3(0.0, 0.0, 50.0);
|
|
||||||
float3 lightPos = vec3(sin(u_time.x * testSpeed) * testRadius, 5.0, cos(u_time.x * testSpeed) * testRadius);
|
|
||||||
vec2 inputUv = v_uv0;
|
|
||||||
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
|
||||||
|
|
||||||
// lighting
|
|
||||||
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
|
||||||
float brightness = lerp(0.5, 0.9, calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal));
|
|
||||||
// float brightness = 0.5;
|
|
||||||
// brightness = lerp(0.2, 1.0, sin(u_time.x) * 0.5 + 0.5);
|
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
float dotsPerSide = 2;
|
float xRes = u_texInfo.z;
|
||||||
|
float dotsPerSide = xRes / 16;
|
||||||
float dotsTotal = dotsPerSide * dotsPerSide;
|
float dotsTotal = dotsPerSide * dotsPerSide;
|
||||||
float xRes = 32;
|
|
||||||
float invXRes = 1 / xRes;
|
float invXRes = 1 / xRes;
|
||||||
float zRes = dotsTotal;
|
float zRes = dotsTotal;
|
||||||
float invZRes = 1 / zRes;
|
float invZRes = 1 / zRes;
|
||||||
@@ -70,6 +58,7 @@ void main()
|
|||||||
// Figuring out how many dots we want
|
// Figuring out how many dots we want
|
||||||
float scaleExp = exp2(globalScale);
|
float scaleExp = exp2(globalScale);
|
||||||
float spacing = freq.y * scaleExp;
|
float spacing = freq.y * scaleExp;
|
||||||
|
spacing *= dotsPerSide * 0.125;
|
||||||
|
|
||||||
float brightnessSpacingMultiplier = pow(brightnessCurve * 2 + 0.001, -(1 - 0.5));
|
float brightnessSpacingMultiplier = pow(brightnessCurve * 2 + 0.001, -(1 - 0.5));
|
||||||
// float brightnessSpacingMultiplier = 1;
|
// float brightnessSpacingMultiplier = 1;
|
||||||
@@ -87,14 +76,34 @@ void main()
|
|||||||
|
|
||||||
float pattern = texture3D(s_ditherSampler, vec3(uv, subLayer)).r;
|
float pattern = texture3D(s_ditherSampler, vec3(uv, subLayer)).r;
|
||||||
|
|
||||||
float contrast = 12 * scaleExp * brightnessSpacingMultiplier * 0.1;
|
float contrast = 8 * scaleExp * brightnessSpacingMultiplier * 0.1;
|
||||||
contrast *= pow(freq.y / freq.x, 1.0);
|
contrast *= pow(freq.y / freq.x, 1.0);
|
||||||
float baseVal = lerp(0.5, brightness, saturate(1.05 / (1 + contrast)));
|
float baseVal = lerp(0.5, brightness, saturate(1.05 / (1 + contrast)));
|
||||||
float threshold = 1 - brightnessCurve + 0.6;
|
float threshold = 1 - brightnessCurve + 0.6;
|
||||||
|
|
||||||
vec3 thresholds = threshold.xxx / texColor;
|
return saturate((pattern - threshold) * contrast + baseVal);
|
||||||
// vec3 finalColor = saturate((pattern - thresholds) * contrast + baseVal);
|
}
|
||||||
vec3 finalColor = saturate((pattern - thresholds) * contrast + baseVal);
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// setup
|
||||||
|
float testRadius = 30.0;
|
||||||
|
float testSpeed = 1.0;
|
||||||
|
vec3 testOffset = vec3(0.0, 0.0, 50.0);
|
||||||
|
float3 lightPos = vec3(sin(u_time.x * testSpeed) * testRadius, 5.0, cos(u_time.x * testSpeed) * testRadius);
|
||||||
|
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||||
|
|
||||||
|
// lighting
|
||||||
|
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
||||||
|
float brightness = lerp(0.5, 0.9, calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal));
|
||||||
|
// float brightness = 0.5;
|
||||||
|
// brightness = lerp(0.2, 1.0, sin(u_time.x) * 0.5 + 0.5);
|
||||||
|
|
||||||
|
float r = dither(brightness * texColor.r, v_uv0);
|
||||||
|
float g = dither(brightness * texColor.g, v_uv0);
|
||||||
|
float b = dither(brightness * texColor.b, v_uv0);
|
||||||
|
// float3 finalColor = vec3(r, g, b);
|
||||||
|
float3 finalColor = dither(brightness, v_uv0);
|
||||||
gl_FragColor = vec4(finalColor, 1.0);
|
gl_FragColor = vec4(finalColor, 1.0);
|
||||||
// gl_FragColor = vec4(finalColor * 0.8 + subLayer * 0.2, 1.0);
|
// gl_FragColor = vec4(finalColor * 0.8 + subLayer * 0.2, 1.0);
|
||||||
// gl_FragColor = vec4(finalColor * 0.8 + vec3(uv % 1, 0.0) * 0.2, 1.0);
|
// gl_FragColor = vec4(finalColor * 0.8 + vec3(uv % 1, 0.0) * 0.2, 1.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user