It might be stupid question, but I was looking for a long time for an answer and I can't find one for my DirectX 11 game engine. For example I have got two pixel shaders A and B and I don't want to repeat my code for gamma correction. So my idea was to move that to separate hlsl file and include them, but I don't know how to do that. When I was google that I was only able to find informations about .fx workflow, but I'm not using it. When I'm trying to make a new shader I always get an error, that my shaders need to have main function. How can I do this?
EDIT: As VTT suggested I will provide example. Let's say I have my uber_pixel_shader.hlsl like this:
#include "gamma_utils_shader.hlsl"
...
float4 main(PS_INPUT input) : SV_TARGET
{
...
finalColor = gammaCorrect(finalColor);
return float4(finalColor, Alpha);
}
And there is no method gammaCorrect in HLSL, so I want to include it from another file named gamma_utils_shader.hlsl. This file looks like this:
float3 gammaCorrect(float3 inputColor)
{
return pow(inputColor, 1.0f / 2.2f);
}
When I'm trying to compile this, the comipler is throwing an error "Error 3501 'main': entrypoint not found". And it's true, becase I don't have main method in this file, but I do not need one. How can I solve this in Visual Studio 2017?
gamma_utils_shader.hlsl
instead of just including it? – user7860670