Shaders and other questions

Have a question, suggestion, or comment about Aleph One's features and functionality (Lua, MML, the engine itself, etc)? Post such topics here.

Shaders and other questions

Post Jan 3rd '19, 23:38

Is there any documentation for how to develop shaders for AlephOne? Or is a shader a universal thing, and there's nothing AlephOne specific about writing one? I really don't know much of anything about them.

The specific problem I'm looking for a solution to is give the player infravision, but also limit their view distance. Infravision seems to disable level lighting, so you can see forever. If I turn fog on, it kind of works but everything ends up super dark, even up close.

I guess first I should confirm there's no existing way to make fog work differently so that it doesn't have any effect up close, and then quickly drops to pitch black. Or is there a way to make infravision respect level lighting?

Assuming I knew how to write one, would it be possible to achieve this with a shader plugin? Can it detect when infravision is active?
User avatar

Wrkncacnter

Post Jan 4th '19, 02:26

The shaders are written in GLSL. What you are describing would be easy to implement, but it would depend on whether the shader can detect if infravision is on or not. What does A1 expose that you could infer from?

Here’s what the sprite shader has available:

uniform sampler2D texture0;
uniform float glow;
uniform float flare;
uniform float selfLuminosity;
varying vec3 viewDir;
varying vec4 vertexColor;
varying float FDxLOG2E;
varying float classicDepth;


One other approach is to still use fog, but change the shader such that the fog doesn’t start until some distance beyond the viewer. The wall and sprite shaders have all the info they need for that (the fragment depth is in gl_FragCoord.z).
User avatar

TrajansRow

Post Jan 4th '19, 02:36

TrajansRow wrote:One other approach is to still use fog, but change the shader such that the fog doesn’t start until some distance beyond the viewer. The wall and sprite shaders have all the info they need for that (the fragment depth is in gl_FragCoord.z).

This sounds ideal, since really, I don't need to know whether infravision is active or not. If it's not active, your view distance will be cut short anyway and you'd never even see the fog, due to the level lighting.

So now I guess I just need to see if I can learn GLSL enough to understand what you just said :P. Thanks for the response.
User avatar

Wrkncacnter

Post Jan 4th '19, 02:39

Try adding a constant to the result of exp2(FDxLOG2E * length(viewDir)) where the fogFactor is calculated. You will have to apply the adjustment to any shader that mixes the fog color with the fragColor.
User avatar

TrajansRow

Post Jan 4th '19, 03:35

Wow, this is amazing, thank you! I think this will not only make things look less weird, it will significantly help performance over the hack I was using before.
User avatar

Wrkncacnter


Return to Aleph One Discussion



Who is online

Users browsing this forum: No registered users