2019-09-25 03:25:59 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
2022-12-28 19:49:18 +00:00
|
|
|
Copyright (C) 2023 Gian 'myT' Schellenbaum
|
2019-09-25 03:25:59 +00:00
|
|
|
|
|
|
|
This file is part of Challenge Quake 3 (CNQ3).
|
|
|
|
|
|
|
|
Challenge Quake 3 is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
Challenge Quake 3 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
===========================================================================
|
|
|
|
*/
|
2022-12-28 19:49:18 +00:00
|
|
|
// post-processing: moves from gamma to linear space
|
2019-09-25 03:25:59 +00:00
|
|
|
|
|
|
|
|
2024-01-13 21:40:13 +00:00
|
|
|
#include "common.hlsli"
|
2024-01-14 21:43:20 +00:00
|
|
|
#include "fullscreen.hlsli"
|
2024-01-13 21:40:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
cbuffer RootConstants
|
|
|
|
{
|
|
|
|
uint textureIndex;
|
|
|
|
uint samplerIndex;
|
|
|
|
float gamma;
|
|
|
|
float invBrightness;
|
|
|
|
};
|
|
|
|
|
2022-12-28 19:49:18 +00:00
|
|
|
VOut vs(uint id : SV_VertexID)
|
2019-09-25 03:25:59 +00:00
|
|
|
{
|
|
|
|
VOut output;
|
2024-01-13 21:40:13 +00:00
|
|
|
output.position = FSTrianglePosFromVertexId(id);
|
|
|
|
output.texCoords = FSTriangleTCFromVertexId(id);
|
2019-09-25 03:25:59 +00:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2022-12-28 19:49:18 +00:00
|
|
|
// X3571: pow(f, e) won't work if f is negative
|
|
|
|
#pragma warning(disable : 3571)
|
|
|
|
|
|
|
|
float4 ps(VOut input) : SV_Target
|
2019-09-25 03:25:59 +00:00
|
|
|
{
|
2024-01-13 21:40:13 +00:00
|
|
|
Texture2D texture0 = ResourceDescriptorHeap[textureIndex];
|
|
|
|
SamplerState sampler0 = SamplerDescriptorHeap[samplerIndex];
|
2023-10-16 00:33:43 +00:00
|
|
|
float3 base = texture0.Sample(sampler0, input.texCoords).rgb;
|
2022-12-28 19:49:18 +00:00
|
|
|
float3 linearSpace = pow(base * invBrightness, gamma);
|
2024-01-13 21:40:13 +00:00
|
|
|
float4 result = float4(linearSpace, 1.0);
|
2019-09-25 03:25:59 +00:00
|
|
|
|
2024-01-13 21:40:13 +00:00
|
|
|
return result;
|
2019-09-25 03:25:59 +00:00
|
|
|
}
|