I found some nice shaders online. So I thought I'd create a sample project in orx and play a bit. However, no matter which shader I pick, I always end up with an empty black screen.Tried different shader versions... Surely I must be doing something wrong. Please help!
1) Create a sample project with "init" command.
2) Assign a shader to "Object". E.g. This one: http://glslsandbox.com/e#58544.0
3) Run it. Screen is black
I have tried setting the texture to "pixel" and a size etc. Nothing helps. Ideas?
Have you gone through the shader examples on the wiki?
There are other shader tutorials there as well.
In any case, you need to adapt the shader you found on glslandbox (I also recommend checking shadertoy.com as a source of inspiration):
gl_FragCoord, which uses screen space coordinates (even on a viewport, where it would work, you could still stick with
In your case, that would give us something like:
You can now attach this shader to an object or a viewport.
Thanks! The use of gl_TexCoord certainly fixed some of my headache I got it working for a viewport, now trying to get my "pixel" object to render this.
This "resolution" parameter is found in most samples online. It's not available out-of-the-box in orx? I see you hard-coded it to (1.0, 1.0). Should I derive this from the frustum width/height or object size?
These tricks should indeed be part of the orx documentation. E.g. "If you encounter gl_Fragcoord in some shader..."
My pleasure. It should be working as-is in both cases.
You're looking at very specific setups, such as glslsandbox, whose goal is to use fullscreen shaders and nothing else and have thus hardcoded a few parameters like
resolution. Those are not standard GLSL. If you look at shadertoy, for example, the available hardcoded options will be slightly different but still relevant in the case of fullscreen shaders.
Now if you're going to use shaders in a different context, like in a game engine such as orx, those hardcoded parameters will never exist, as they are not relevant anymore (they only apply to the case of a fullscreen single quad rendering), and it will be your responsibility to add whichever parameters your situation requires.
Actually most game engines will only accept HLSL shaders, not GLSL ones, and some will even use their own intermediate representation, like godot.
Those are not tricks nor are they specific to orx: they're standard GLSL built-in variables. We assume users know how to use GLSL and the difference between
gl_TexCoord, for example, as this knowledge isn't specific to orx itself.
The only differences between regular GLSL shaders and orx ones are how the uniform variables are declared, through the config system, and a couple of extra built-in variables in the case of textures. Those parts should all be covered in the wiki. Everything else is plain standard GLSL.
To go back to
gl_TexCoord, those are standard GLSL built-ins. You can learn about them in any GLSL documentation or tutorials but here's a quick breakdown:
gl_FragCoordis the coordinates of your fragment, in screen space, in pixels. That's why you need to know the resolution in order to normalize it and know in which part of the screen you are.
gl_TexCoordis your primary texture coordinate coming out of the fixed vertex shader used by orx, for both viewports and objects. Texture coordinates, often called UVs, are always normalized, so you don't need to know about the resolution to use it, even for a quad covering the full screen.
The info above has been used in the following tutorial series to help new users get something simple going: https://wiki.orx-project.org/en/tutorials/shaders/getting_started_with_shaders