mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 16:42:23 -07:00
test with srgba buffer, hack in srgb -> linear conversion in shader for
testing
This commit is contained in:
@@ -191,6 +191,7 @@ fp_init(void)
|
||||
//- rjf: make sharp-hinted rendering params
|
||||
{
|
||||
FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params);
|
||||
gamma = 1.f;
|
||||
FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params);
|
||||
if(fp_dwrite_state->dwrite2_is_supported)
|
||||
{
|
||||
@@ -219,6 +220,7 @@ fp_init(void)
|
||||
//- rjf: make sharp-unhinted rendering params
|
||||
{
|
||||
FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params);
|
||||
gamma = 1.f;
|
||||
FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params);
|
||||
if(fp_dwrite_state->dwrite2_is_supported)
|
||||
{
|
||||
@@ -247,6 +249,7 @@ fp_init(void)
|
||||
//- rjf: make smooth-hinted rendering params
|
||||
{
|
||||
FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params);
|
||||
gamma = 1.f;
|
||||
FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params);
|
||||
if(fp_dwrite_state->dwrite2_is_supported)
|
||||
{
|
||||
|
||||
@@ -83,6 +83,20 @@ str8_lit_comp(
|
||||
" return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float linear_from_srgb_f32(float x)\n"
|
||||
"{\n"
|
||||
" return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 linear_from_srgba(float4 v)\n"
|
||||
"{\n"
|
||||
" float4 result = float4(linear_from_srgb_f32(v.x),\n"
|
||||
" linear_from_srgb_f32(v.y),\n"
|
||||
" linear_from_srgb_f32(v.z),\n"
|
||||
" v.w);\n"
|
||||
" return result;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//- rjf: vertex shader\n"
|
||||
"\n"
|
||||
"Vertex2Pixel\n"
|
||||
@@ -122,11 +136,12 @@ str8_lit_comp(
|
||||
" cpu2vertex.corner_radii_px.w,\n"
|
||||
" cpu2vertex.corner_radii_px.z,\n"
|
||||
" };\n"
|
||||
" float4 src_color[] = {\n"
|
||||
" cpu2vertex.color01,\n"
|
||||
" cpu2vertex.color00,\n"
|
||||
" cpu2vertex.color11,\n"
|
||||
" cpu2vertex.color10,\n"
|
||||
" float4 src_color[] =\n"
|
||||
" {\n"
|
||||
" linear_from_srgba(cpu2vertex.color01),\n"
|
||||
" linear_from_srgba(cpu2vertex.color00),\n"
|
||||
" linear_from_srgba(cpu2vertex.color11),\n"
|
||||
" linear_from_srgba(cpu2vertex.color10),\n"
|
||||
" };\n"
|
||||
" float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,\n"
|
||||
" (cpu2vertex.vertex_id & 1) ? 0.f : 1.f);\n"
|
||||
@@ -164,6 +179,7 @@ str8_lit_comp(
|
||||
" if(vertex2pixel.omit_texture < 1)\n"
|
||||
" {\n"
|
||||
" albedo_sample = mul(main_t2d.Sample(main_sampler, vertex2pixel.texcoord_pct), texture_sample_channel_map);\n"
|
||||
" albedo_sample = linear_from_srgba(albedo_sample);\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // rjf: determine SDF sample position\n"
|
||||
|
||||
@@ -520,7 +520,7 @@ r_window_equip(OS_Handle handle)
|
||||
{
|
||||
swapchain_desc.Width = 0; // NOTE(rjf): use window width
|
||||
swapchain_desc.Height = 0; // NOTE(rjf): use window height
|
||||
swapchain_desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
swapchain_desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
swapchain_desc.Stereo = FALSE;
|
||||
swapchain_desc.SampleDesc.Count = 1;
|
||||
swapchain_desc.SampleDesc.Quality = 0;
|
||||
@@ -896,7 +896,7 @@ r_window_begin_frame(OS_Handle window, R_Handle window_equip)
|
||||
D3D11_TEXTURE2D_DESC color_desc = zero_struct;
|
||||
{
|
||||
wnd->framebuffer->lpVtbl->GetDesc(wnd->framebuffer, &color_desc);
|
||||
color_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
color_desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
color_desc.BindFlags = D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE;
|
||||
}
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtv_desc = zero_struct;
|
||||
@@ -906,7 +906,7 @@ r_window_begin_frame(OS_Handle window, R_Handle window_equip)
|
||||
}
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = zero_struct;
|
||||
{
|
||||
srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srv_desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srv_desc.Texture2D.MipLevels = -1;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,20 @@ float rect_sdf(float2 sample_pos, float2 rect_half_size, float r)
|
||||
return length(max(abs(sample_pos) - rect_half_size + r, 0.0)) - r;
|
||||
}
|
||||
|
||||
float linear_from_srgb_f32(float x)
|
||||
{
|
||||
return x < 0.0404482362771082 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
float4 linear_from_srgba(float4 v)
|
||||
{
|
||||
float4 result = float4(linear_from_srgb_f32(v.x),
|
||||
linear_from_srgb_f32(v.y),
|
||||
linear_from_srgb_f32(v.z),
|
||||
v.w);
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: vertex shader
|
||||
|
||||
Vertex2Pixel
|
||||
@@ -120,11 +134,12 @@ vs_main(CPU2Vertex cpu2vertex)
|
||||
cpu2vertex.corner_radii_px.w,
|
||||
cpu2vertex.corner_radii_px.z,
|
||||
};
|
||||
float4 src_color[] = {
|
||||
cpu2vertex.color01,
|
||||
cpu2vertex.color00,
|
||||
cpu2vertex.color11,
|
||||
cpu2vertex.color10,
|
||||
float4 src_color[] =
|
||||
{
|
||||
linear_from_srgba(cpu2vertex.color01),
|
||||
linear_from_srgba(cpu2vertex.color00),
|
||||
linear_from_srgba(cpu2vertex.color11),
|
||||
linear_from_srgba(cpu2vertex.color10),
|
||||
};
|
||||
float2 dst_verts_pct = float2((cpu2vertex.vertex_id >> 1) ? 1.f : 0.f,
|
||||
(cpu2vertex.vertex_id & 1) ? 0.f : 1.f);
|
||||
@@ -162,6 +177,7 @@ ps_main(Vertex2Pixel vertex2pixel) : SV_TARGET
|
||||
if(vertex2pixel.omit_texture < 1)
|
||||
{
|
||||
albedo_sample = mul(main_t2d.Sample(main_sampler, vertex2pixel.texcoord_pct), texture_sample_channel_map);
|
||||
albedo_sample = linear_from_srgba(albedo_sample);
|
||||
}
|
||||
|
||||
// rjf: determine SDF sample position
|
||||
|
||||
Reference in New Issue
Block a user