README.md 1.53 KB
Newer Older
pcy's avatar
pcy committed
1
2
# FNAGLSL

pcy's avatar
pcy committed
3
4
Trying to hackily shoehorn GLSL shaders into FNA, while trying to comply with
the `Effect` API as much as possible. (Which isn't always working.)
pcy's avatar
pcy committed
5
6
7
8

## Does it work?

Kinda. Static shaders work. Passing vertex data is very hacky and brittle.
pcy's avatar
pcy committed
9
10
Uniforms seem to work, but aren't well-tested. Same goes for textures. Using
regular shaders interleaved w/ GLSL shader draw calls seems to work ok.
pcy's avatar
pcy committed
11

pcy's avatar
pcy committed
12
13
14
15
Also note that I only tested the code on Linux, with the FOSS drivers (Mesa).
So if you run Windows, OS X, or proprietary NVidia drivers, chances are high
something will break.

pcy's avatar
pcy committed
16
17
## How does this work?

pcy's avatar
pcy committed
18
No. Don't. Here be dragons.
pcy's avatar
pcy committed
19

pcy's avatar
pcy committed
20
21
22
23
24
25
26
## Are there things it can't do?

Yes:

* Passing this to a `SpriteBatch` will probably fail in a bad way (unlikely
  to be fixed).

pcy's avatar
pcy committed
27
28
## How can I use it?

pcy's avatar
pcy committed
29
30
31
You shouldn't if you want software that's stable, but, in case you really
want to:

pcy's avatar
pcy committed
32
33
34
35
36
37
38
39
40
```cs
var glsl = new GLSLEffect(GraphicsDevice, new Dictionary<GLSLPurpose, string>()
{
	{ GLSLPurpose.  VertexShader, "vertex shader here"   },
	{ GLSLPurpose.FragmentShader, "fragment shader here" },
});

// ...

pcy's avatar
pcy committed
41
42
glsl.Parameters["paramname"].SetValueT(xyz);

pcy's avatar
pcy committed
43
44
45
46
47
48
using (var bound = glsl.Bind())
{
	GraphicsDevice.DrawPrimitives(/*...*/);
}
```

pcy's avatar
pcy committed
49
50
NOTE: I'm ***NOT*** going to provide help with how to write shaders.

pcy's avatar
pcy committed
51
52
53
54
55
56
57
58
59
## License

```
Copyright (C) 2020 PoroCYon <porocyon@titandemo.org>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the LICENSE file for more details.
```