Skip to content

Conversation

iwubcode
Copy link
Contributor

For simple shader code, you often can fit it in one file. However, it can be useful to organize code into different files. In order to do this, we need an include system.

This PR adds an include system. The end goal is to use this in custom draw shaders due to the complexity and reuse of some of the shader logic. I ultimately want to provide a bunch of Dolphin provided shader code for end users. However, in order to allow devs to test this (and possibly use it in some capacity), I've exposed this to the post processing system.

This works on all backends, though error reporting only works through backends that use glslang (DirectX, Vulkan, Metal).

Example:

#include "SubFolder/get_color.glsl"

void main()
{
	vec4 c0 = Sample();
	SetOutput(vec4(get_color().rg, c0.b, c0.a));
}

And in get_color.glsl:

vec3 get_color()
{
	return vec3(1, 0, 0);
}

The screen will tint a pink color!

One thing to note: the include system isn't as intelligent as C++'s include system. If you have the same file included in multiple places within a "web" of includes, you will get an error. A brief look online seems to indicate this is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant