feat: better cmake support (#21)
* feat: CMakeSettings.json * chore: remove visual studio stuff chore: move .clang-format to main directory * feat: new file structure, easier to implement as a submodule within existing projects * chore: we actually include some code now... * chore: remove prebuilt libraries (oops) * feat: new shader building script using cmake * chore: add debug postfix specifier * fix: forgot that windows builds use 4J_Render_PC for the render library * fix: didn't add the output directory (where shaders are saved to) to the include directories of 4J_Render
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
:: legacy shader building code
|
||||
@echo off
|
||||
|
||||
set OUT=../
|
||||
set OPT=/O3 /nologo
|
||||
|
||||
for /d %%i in ("C:\Program Files (x86)\Windows Kits\10\bin\10.*") do set FXC="%%i\x64\fxc.exe"
|
||||
|
||||
if not defined FXC echo FXC not found && exit /b 1
|
||||
if not exist %OUT% mkdir %OUT%
|
||||
|
||||
%FXC% %OPT% /T vs_4_0 /E main /D COMPRESSED /Fh %OUT%/VS_Compressed.h /Vn g_main_VS_Compressed main_VS.hlsl
|
||||
%FXC% %OPT% /T vs_4_0 /E main /Fh %OUT%/VS_PF3_TF2_CB4_NB4_XW1.h /Vn g_main_VS_PF3_TF2_CB4_NB4_XW1 main_VS.hlsl
|
||||
%FXC% %OPT% /T vs_4_0 /E main /D LIGHTING /Fh %OUT%/VS_PF3_TF2_CB4_NB4_XW1_LIGHTING.h /Vn g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING main_VS.hlsl
|
||||
%FXC% %OPT% /T vs_4_0 /E main /D TEXGEN /Fh %OUT%/VS_PF3_TF2_CB4_NB4_XW1_TEXGEN.h /Vn g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN main_VS.hlsl
|
||||
%FXC% %OPT% /T vs_4_0 /E VS_ScreenSpace /Fh %OUT%/VS_ScreenSpace.h /Vn g_main_VS_ScreenSpace screen_VS.hlsl
|
||||
%FXC% %OPT% /T vs_4_0 /E VS_ScreenClear /Fh %OUT%/VS_ScreenClear.h /Vn g_main_VS_ScreenClear screen_VS.hlsl
|
||||
%FXC% %OPT% /T ps_4_0 /E main /Fh %OUT%/PS_Standard.h /Vn g_main_PS_Standard main_PS.hlsl
|
||||
%FXC% %OPT% /T ps_4_0 /E main /D TEXTURE_PROJECTION /Fh %OUT%/PS_TextureProjection.h /Vn g_main_PS_TextureProjection main_PS.hlsl
|
||||
%FXC% %OPT% /T ps_4_0 /E main /D FORCE_LOD /Fh %OUT%/PS_ForceLOD.h /Vn g_main_PS_ForceLOD main_PS.hlsl
|
||||
%FXC% %OPT% /T ps_4_0 /E PS_ScreenSpace /Fh %OUT%/PS_ScreenSpace.h /Vn g_main_PS_ScreenSpace screen_PS.hlsl
|
||||
%FXC% %OPT% /T ps_4_0 /E PS_ScreenClear /Fh %OUT%/PS_ScreenClear.h /Vn g_main_PS_ScreenClear screen_PS.hlsl
|
||||
@@ -0,0 +1,52 @@
|
||||
# new shader build system
|
||||
|
||||
find_program(FXC_COMPILER NAMES fxc
|
||||
HINTS
|
||||
"C:/Program Files (x86)/Windows Kits/10/bin/*/x64"
|
||||
"C:/Program Files (x86)/Windows Kits/8.1/bin/x64"
|
||||
)
|
||||
|
||||
if(NOT FXC_COMPILER)
|
||||
message(FATAL_ERROR "Could not find 'fxc.exe', please make sure you have the Windows SDK installed or this file is available in this directory.")
|
||||
endif()
|
||||
|
||||
set(SHADER_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/inc")
|
||||
|
||||
function(compile_hlsl)
|
||||
set(options)
|
||||
set(argDescriptor SOURCE PROFILE ENTRY OUT_HEADER VAR_NAME)
|
||||
set(defDescriptor DEFINES)
|
||||
cmake_parse_arguments(ARG "${options}" "${argDescriptor}" "${defDescriptor}" ${ARGN})
|
||||
|
||||
set(OUT_FILE "${SHADER_OUT_DIR}/${ARG_OUT_HEADER}")
|
||||
|
||||
set(FXC_DEFINES "")
|
||||
foreach(DEF ${ARG_DEFINES})
|
||||
list(APPEND FXC_DEFINES "/D" "${DEF}")
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${OUT_FILE}"
|
||||
# should probably disable optimizations and enable debug flags when building in debug mode, but i don't care enough to do that right now BUAHAHAHA
|
||||
COMMAND ${FXC_COMPILER} /O3 /nologo /T ${ARG_PROFILE} /E ${ARG_ENTRY} ${FXC_DEFINES} /Fh "${OUT_FILE}" /Vn ${ARG_VAR_NAME} "${CMAKE_CURRENT_LIST_DIR}/${ARG_SOURCE}"
|
||||
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/${ARG_SOURCE}"
|
||||
COMMENT "Compiling shader: '${ARG_SOURCE}' into '${ARG_OUT_HEADER}'"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# send the generated paths to the parent scope
|
||||
set(GENERATED_SHADER_HEADERS ${GENERATED_SHADER_HEADERS} "${OUT_FILE}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
compile_hlsl(SOURCE main_VS.hlsl PROFILE vs_4_0 ENTRY main OUT_HEADER VS_Compressed.h VAR_NAME g_main_VS_Compressed DEFINES COMPRESSED)
|
||||
compile_hlsl(SOURCE main_VS.hlsl PROFILE vs_4_0 ENTRY main OUT_HEADER VS_PF3_TF2_CB4_NB4_XW1.h VAR_NAME g_main_VS_PF3_TF2_CB4_NB4_XW1)
|
||||
compile_hlsl(SOURCE main_VS.hlsl PROFILE vs_4_0 ENTRY main OUT_HEADER VS_PF3_TF2_CB4_NB4_XW1_LIGHTING.h VAR_NAME g_main_VS_PF3_TF2_CB4_NB4_XW1_LIGHTING DEFINES LIGHTING)
|
||||
compile_hlsl(SOURCE main_VS.hlsl PROFILE vs_4_0 ENTRY main OUT_HEADER VS_PF3_TF2_CB4_NB4_XW1_TEXGEN.h VAR_NAME g_main_VS_PF3_TF2_CB4_NB4_XW1_TEXGEN DEFINES TEXGEN)
|
||||
compile_hlsl(SOURCE screen_VS.hlsl PROFILE vs_4_0 ENTRY VS_ScreenSpace OUT_HEADER VS_ScreenSpace.h VAR_NAME g_main_VS_ScreenSpace)
|
||||
compile_hlsl(SOURCE screen_VS.hlsl PROFILE vs_4_0 ENTRY VS_ScreenClear OUT_HEADER VS_ScreenClear.h VAR_NAME g_main_VS_ScreenClear)
|
||||
|
||||
compile_hlsl(SOURCE main_PS.hlsl PROFILE ps_4_0 ENTRY main OUT_HEADER PS_Standard.h VAR_NAME g_main_PS_Standard)
|
||||
compile_hlsl(SOURCE main_PS.hlsl PROFILE ps_4_0 ENTRY main OUT_HEADER PS_TextureProjection.h VAR_NAME g_main_PS_TextureProjection DEFINES TEXTURE_PROJECTION)
|
||||
compile_hlsl(SOURCE main_PS.hlsl PROFILE ps_4_0 ENTRY main OUT_HEADER PS_ForceLOD.h VAR_NAME g_main_PS_ForceLOD DEFINES FORCE_LOD)
|
||||
compile_hlsl(SOURCE screen_PS.hlsl PROFILE ps_4_0 ENTRY PS_ScreenSpace OUT_HEADER PS_ScreenSpace.h VAR_NAME g_main_PS_ScreenSpace)
|
||||
compile_hlsl(SOURCE screen_PS.hlsl PROFILE ps_4_0 ENTRY PS_ScreenClear OUT_HEADER PS_ScreenClear.h VAR_NAME g_main_PS_ScreenClear)
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Patoke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
cbuffer diffuse : register(b0)
|
||||
{
|
||||
float4 diffuse_colour;
|
||||
};
|
||||
cbuffer fog : register(b1)
|
||||
{
|
||||
float4 fog_colour;
|
||||
};
|
||||
cbuffer alphaTest : register(b3)
|
||||
{
|
||||
float4 alphaTestRef;
|
||||
};
|
||||
|
||||
#ifdef FORCE_LOD
|
||||
cbuffer forcedLOD : register(b5)
|
||||
{
|
||||
float4 forcedLod;
|
||||
};
|
||||
#endif
|
||||
|
||||
SamplerState diffuse_sampler_s : register(s0);
|
||||
Texture2D<float4> diffuse_texture : register(t0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float4 colour : COLOR0;
|
||||
linear centroid float4 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main(PS_INPUT input) : SV_TARGET
|
||||
{
|
||||
float2 uv = input.texcoord.xy;
|
||||
|
||||
#ifdef TEXTURE_PROJECTION
|
||||
uv /= input.texcoord.w;
|
||||
#endif
|
||||
|
||||
#ifdef FORCE_LOD
|
||||
float4 texel = diffuse_texture.SampleLevel(
|
||||
diffuse_sampler_s,
|
||||
uv,
|
||||
forcedLod.x);
|
||||
#else
|
||||
float4 texel =
|
||||
(uv.x > 1.0f)
|
||||
? diffuse_texture.SampleLevel(diffuse_sampler_s, uv, 0)
|
||||
: diffuse_texture.Sample(diffuse_sampler_s, uv);
|
||||
#endif
|
||||
|
||||
float4 colour = texel * diffuse_colour;
|
||||
colour.a *= input.colour.a;
|
||||
|
||||
if (colour.a < alphaTestRef.w)
|
||||
discard;
|
||||
|
||||
float3 shaded = colour.rgb * input.colour.rgb;
|
||||
float3 fogged = lerp(fog_colour.rgb, shaded, input.texcoord.z);
|
||||
|
||||
return float4(fogged, colour.a);
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Patoke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef COMPRESSED
|
||||
|
||||
cbuffer positionTransformWV : register(b0)
|
||||
{
|
||||
float4x4 matWorldView;
|
||||
};
|
||||
cbuffer positionTransformWV2 : register(b1)
|
||||
{
|
||||
float4x4 matWorldView2;
|
||||
};
|
||||
cbuffer positionTransformProj : register(b2)
|
||||
{
|
||||
float4x4 matProjection;
|
||||
};
|
||||
cbuffer textureTransform : register(b3)
|
||||
{
|
||||
float4x4 matUV;
|
||||
};
|
||||
cbuffer textureUV2 : register(b4)
|
||||
{
|
||||
float4 vecUVT2;
|
||||
};
|
||||
cbuffer fog : register(b5)
|
||||
{
|
||||
float4 vecFog;
|
||||
};
|
||||
|
||||
#ifdef LIGHTING
|
||||
cbuffer lighting : register(b6)
|
||||
{
|
||||
float3 vecLight0;
|
||||
float3 vecLight1;
|
||||
float4 vecLight0Col;
|
||||
float4 vecLight1Col;
|
||||
float4 vecLightAmbientCol;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef TEXGEN
|
||||
cbuffer texgen : register(b7)
|
||||
{
|
||||
float4x4 matTexGenView;
|
||||
float4x4 matTexGenObj;
|
||||
};
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
cbuffer positionTransformWV : register(b0)
|
||||
{
|
||||
float4x4 matWorldView;
|
||||
};
|
||||
cbuffer positionTransformProj : register(b2)
|
||||
{
|
||||
float4x4 matProjection;
|
||||
};
|
||||
cbuffer textureUV2 : register(b4)
|
||||
{
|
||||
float4 vecUVT2;
|
||||
};
|
||||
cbuffer fog : register(b5)
|
||||
{
|
||||
float4 vecFog;
|
||||
};
|
||||
cbuffer positionTransform2 : register(b8)
|
||||
{
|
||||
float4 vecWV2Trans;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
SamplerState light_sampler_s : register(s0);
|
||||
Texture2D<float4> light_texture : register(t0);
|
||||
|
||||
#ifndef COMPRESSED
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 position : POSITION0;
|
||||
float4 colour : COLOR0;
|
||||
float3 normal : NORMAL0;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
int2 lightMapCoord : TEXCOORD1;
|
||||
};
|
||||
#else
|
||||
struct VS_INPUT
|
||||
{
|
||||
int4 position : POSITION0;
|
||||
int4 texCoord : TEXCOORD0;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float4 colour : COLOR0;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
float CalcFogFactor(float4 vecFog, float viewZ)
|
||||
{
|
||||
float fogLinear = saturate(vecFog.y * (vecFog.x + viewZ));
|
||||
float fogExp = min(1.0f, exp2(1.44269502f * vecFog.x * viewZ));
|
||||
float f = (vecFog.z == 2) ? fogExp : 1.0f;
|
||||
return (vecFog.z == 1) ? fogLinear : f;
|
||||
|
||||
}
|
||||
|
||||
VS_OUTPUT main(VS_INPUT input)
|
||||
{
|
||||
VS_OUTPUT output;
|
||||
|
||||
#ifndef COMPRESSED
|
||||
|
||||
float4 skinnedPos = mul(matWorldView2, input.position);
|
||||
float4 cameraPos = mul(matWorldView, skinnedPos);
|
||||
output.position = mul(matProjection, cameraPos);
|
||||
|
||||
float2 lightUV = frac(max(vecUVT2.xy, float2(input.lightMapCoord) * 0.00390625f));
|
||||
float4 lightSample = light_texture.SampleLevel(light_sampler_s, lightUV, 0);
|
||||
lightSample.w = 1.0f;
|
||||
|
||||
#ifdef LIGHTING
|
||||
float3 skinNormal = mul((float3x3)matWorldView2, input.normal);
|
||||
float3 viewNormal = normalize(mul((float3x3)matWorldView, skinNormal));
|
||||
|
||||
float diffuse0 = max(0.0f, dot(vecLight0, viewNormal));
|
||||
float diffuse1 = max(0.0f, dot(vecLight1, viewNormal));
|
||||
float4 litColour = saturate(vecLightAmbientCol + diffuse0 * vecLight0Col + diffuse1 * vecLight1Col);
|
||||
|
||||
output.colour.xyz = litColour.xyz * (input.colour.wzy * lightSample.xyz);
|
||||
output.colour.w = litColour.w;
|
||||
#else
|
||||
output.colour = input.colour.wzyx * lightSample;
|
||||
#endif
|
||||
|
||||
#ifdef TEXGEN
|
||||
float4 texGenCoords = mul(matTexGenView, cameraPos) + mul(matTexGenObj, input.position);
|
||||
output.texCoord.xy = float2(dot(matUV[0], texGenCoords), dot(matUV[1], texGenCoords));
|
||||
output.texCoord.w = dot(matUV[3], texGenCoords);
|
||||
#else
|
||||
output.texCoord.xy = float2(dot(matUV[0], input.texCoord), dot(matUV[1], input.texCoord));
|
||||
output.texCoord.w = 1.0f;
|
||||
#endif
|
||||
|
||||
output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z);
|
||||
|
||||
#else // COMPRESSED
|
||||
|
||||
float4 pos;
|
||||
pos.xyz = float3((int3)input.position.xyz) * 0.0009765625f + vecWV2Trans.xyz;
|
||||
pos.w = 1.0f;
|
||||
|
||||
int packedColor = (int)input.position.w + 32768;
|
||||
float3 color = frac(packedColor * float3(1.52587891e-05f, 0.00048828125f, 0.03125f));
|
||||
|
||||
float4 cameraPos = mul(matWorldView, pos);
|
||||
output.position = mul(matProjection, cameraPos);
|
||||
|
||||
float4 uvs = float4((int4)input.texCoord.zwxy) * float4(0.00390625f, 0.00390625f, 0.000122070312f, 0.000122070312f);
|
||||
float2 lightUV = frac(max(vecUVT2.xy, uvs.xy));
|
||||
float4 lightSample = light_texture.SampleLevel(light_sampler_s, lightUV, 0);
|
||||
|
||||
output.colour.xyz = lightSample.xyz * color;
|
||||
output.colour.w = 1.0f;
|
||||
output.texCoord.xy = uvs.zw;
|
||||
output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z);
|
||||
output.texCoord.w = 1.0f;
|
||||
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Patoke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
cbuffer cbuff : register(b4)
|
||||
{
|
||||
float4 clearColour;
|
||||
};
|
||||
|
||||
SamplerState screen_sampler_s : register(s0);
|
||||
Texture2D<float4> screen_texture : register(t0);
|
||||
|
||||
float4 PS_ScreenSpace(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET
|
||||
{
|
||||
return screen_texture.Sample(screen_sampler_s, texcoord);
|
||||
}
|
||||
|
||||
float4 PS_ScreenClear(float4 position : SV_POSITION) : SV_TARGET
|
||||
{
|
||||
return clearColour;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Patoke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
cbuffer screenspace_constants : register(b9)
|
||||
{
|
||||
float4 v_scaleoffset;
|
||||
};
|
||||
|
||||
void VS_ScreenSpace(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION, out float2 texcoord : TEXCOORD0)
|
||||
{
|
||||
float2 corner = float2(
|
||||
(vertex_id << 1) & 2,
|
||||
vertex_id & 2
|
||||
);
|
||||
|
||||
position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1);
|
||||
texcoord = corner * 0.5 * v_scaleoffset.zw + v_scaleoffset.xy;
|
||||
}
|
||||
|
||||
void VS_ScreenClear(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION)
|
||||
{
|
||||
float2 corner = float2(
|
||||
(vertex_id << 1) & 2,
|
||||
vertex_id & 2
|
||||
);
|
||||
|
||||
position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user