-
Notifications
You must be signed in to change notification settings - Fork 4
7. Screen space shaders
theproadam edited this page Apr 8, 2020
·
1 revision
Just like the fragment shader which outputs a pointer to the pixels that it will set, the screen space shader works in the same way. However, the screen space shader also outputs the X and Y pixel positions.
unsafe void ScreenSpacePass(byte* BGR, int posX, int posY)
{
BGR[0] = 255; //Blue
BGR[1] = 255; //Green
BGR[2] = 255; //Red
}
Please don't exceed BGR[3]
. Doing so may cause crashes. BGR[3]
controls alpha, however currently renderXF ignores alpha values.
Once the shader code is ready, just create a instance of the shader class linked with your shader code method.
Shader ScreenSpaceShader = new Shader(ScreenSpacePass);
To use a created screen space shader, just select it with SelectShader()
, and then use the Pass()
function:
GL.SelectShader(ScreenSpaceShader);
GL.Pass();
- Initializing the renderer
- Setting the transform data
- Blitting and clearing the viewport
- Initializing a vertex buffer
- Creating a shader
- Drawing an object
- Screen space shaders
- Blitting bitmaps
- Loading a texture
- Creating a framebuffer
- Displaying a texture