MX2 Shaders
Community Forums/Monkey2 Talk/MX2 Shaders
| ||
Has there been any more info on the shader support that MX2 will offer? I've never used shaders before but I remember reading something about 'one big shader' a while back which made me think it wasn't the standard way shaders are supported/implemented, but I can't find anything on it using the search now. Will it be pure GLSL or a custom language that MX2 will compile to GLSL? Any info appreciated! |
| ||
Anyone know anything about this? |
| ||
shaders are supported by mojo2 in monkeyx now, don't see why they won't be in monkey2 |
| ||
Yeah sorry should of clarified that I know they are supported, but where is any info on them and how to use them? |
| ||
There is really nobody in the entire community that has any info on shaders in Monkey/Monkey2? |
| ||
... just to start some conversation. I don't have any experience with shaders at all, but I read some posts about it. I think the shaders are part of Mojo2, so topics about that could be interesting. If you own a licence of Monkey X you also have Mojo2 in your Modules Folder. In that folder you can find examples how to use Mojo2 and shaders. And in the GameJam2015 ( linke in forum topic) there is a game called epicfox wich is using shaders and mojo2 as far as I know. So far my "knowledge". Maybe a starting point for some additional Pro information or at least some contradiction ;-) |
| ||
@rIKmAN: You're writing in GLSL and you're limited to fragment shaders. From there most things are fair game. The entry-point is custom and named 'shader', returning nothing ('void'). Like usual GLSL, you can declare 'uniform' variables that you can set through Mojo 2. In particular, you're probably interested in 'ColorTexture' and co. These are from the materials you use in your game. Basically, you make/load your images with a certain material. That material has a shader attached to it. The material feeds scalars ('Floats'), 'Vectors' ('Float[]' from what I remember) and textures (Represented using 'Texture' objects). Each entry you make in your material has a name attached to it that you assign whenever you set the value. The value stays the way it was until you change it. The best way to think about this is: Image -> Material -> Textures & Variables -> Shader (Can/should be shared with other materials, etc) The shader gets access to what you provide it, plus a few pre-defined variables. Everything that's there by default (Including the call to 'shader') is built into the fragment shader for you. You could do everything yourself theoretically, but that's not really what Mojo 2 is about. In general, you're going to need to look at the source for the shaders and the example. The example you're looking for is in the "bananas" sub-folder of the "mojo2" module. It's called "shadereffect" if I remember right. If you're interested, I wrote/ported a barrel distortion shader using Mojo 2. Just keep in mind that shaders need to be applied to 'Materials', so post-processing follows the same rules. That's just about all I've looked into so far. |
| ||
Thanks for the replies Phil and ImmutableOctet. @ImmutableOctet Mate that is brilliant and exactly the kind of info I was after, thank you so much! :) Where did you source this info in relation to Monkey, have I missed docs or some other info somewhere? |
| ||
@rIKmAN: Well, there's docs for 'mojo2', but I don't think they go into detail about GLSL. I just posted information I gathered from the times I used the language in hobby projects. Well, that and looking through the shaders and "mega shader" in the source code. Certain things like the material and texture relationships were actually very intuitive to learn, as I already used a few 3D solutions in the past. The system of passing variables through a material is a bit weird, but it makes sense when you usually share shader objects. |