Hello there, I’m having a bit of an issue with drawing to the screen. So far I’m drawing a procedural mesh with one point in my main thread to activate the shader, grabbing it in the vertex shader and passing it to my fragment shader where I have a loop to do my main work.
Can anyone explain whether or not you can write to the screen with this method in HLSL, and how I might go about doing it? Right now it doesn’t colour any pixels regardless of screen space, and it doesn’t appear as though it gets called at all; I’ve been under the impression that fragment shaders loop through all pixels on the screen, and not just the ones that are coloured, but the examples I find from Unity and elsewhere seem to rely on preexisting points and geometries.
I would have thought that the following HLSL would colour the entire screen red, considering it’s mentioned everywhere that fragment shaders are called once per pixel on the screen, and I’m calling the shader with a single point by drawing a procedural mesh with one point.
Thanks in advance!
struct Vert
{
float4 pos : SV_POSITION;
float4 colour : COLOR;
};
Vert VertFunction()
{
Vert vert;
vert.pos = float4(0,0,0,0);
vert.colour = float4(0,0,0,0);
return vert;
}
float4 FragFunction(float4 sp : SV_POSITION) : SV_TARGET
{
return float4(1,0,0,1); //red colour
}