Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Custom OC Silhouette Enhancement Shader ('Ghost-Shader')
- - By DaFatBrainbug [de] Date 2018-03-27 15:48
So while playing around with my edge detection shader (you can expect it soon), I came across this nice little effect I wanted to share.
Kinda looks like a ghost version of objects.
What it does can be read here in detail.
I could imagine this well as a special effect for powerups.

Attention: To get this effect working for a specific object, it needs the following line in the .material file:
scene_blend alpha_blend

The effect can be customized somewhat with 2 variables. The images below shows 2 different settings for those.
Also this can be added at runtime with AddFragmentShader. :)

This shader is not fine-tuned, I might do that at another point.
To install, attatch the code to your ObjectShader.glsl.

Obviously there are objects where the effect looks horrible. But for some it looks really nice.
I might develop this shader more when I work on my edge detection shader.

Have fun with it!



I hereby license the file silhouette_enhancement.txt under the CC-BY license
Attachment: silhouette_enhancement.txt - Silhouette Enhancement 0.1 (390B)
Reply
Parent - By Clonkonaut Date 2018-03-27 15:53
Hmm. I do have an idea where I could use this!
Reply
Parent - - By Maikel Date 2018-03-27 17:42
Is it possible to apply this to single objects somehow?
Parent - - By DaFatBrainbug Date 2018-03-27 19:23 Edited 2018-03-27 19:50
I don't think this is possible without a AddFragmentShader-Call that would target a specific object (or is there one?). So it's an engine-thing.

I got somewhat of a workaround for that:
If you add #ifndef OC_MESH --- #endif to the code, The effect will be limited to very few types. In a normal map this would apply mainly to rocks in the ground (so thats sprite-objects i think, excluding UI and sky)
Now...you need to add the scene_blend alpha_blend to the object you want to apply the shader to... and also have no other objects that require alpha-blending (cause they mustn't have the scene_blend alpha_blend)

But tbh, the #define category thing is kind of a mess and sometimes hard to understand :/

Edit: Or you could go the other way round and use #ifdef OC_MESH, there might bew fewer problems that way.
Reply
Parent - By Luchs Date 2018-03-27 19:44

>I don't think this is possible without a AddFragmentShader-Call that would target a specific object (or is there one?)


The shader programs are only compiled once (not sure whether they're shared between definitions). It may be possible to target specific objects using uniforms set from script, but this would also require a uniform with the object number or something like that.
Parent - - By Pyrit Date 2018-03-27 17:46
Damn tree leaves. (The one that I made, lol) Looking at them at a steep angle looks bad. Could we give tree leaves a material that is invisible when looking at a steep angle? Kind of like backface culling, but not necessarily looking at a face from behind, but a small angle. So that for example, the leaves I circled would be culled.
Parent - - By DaFatBrainbug Date 2018-03-27 19:27
I think for that you'd have to work with normals, and that would affect to many other model-parts.

Honestly, I had a small private rage at those trees already x)
The leaves cause many problems when I play with lighting.

Edit: However, trunk and branches are very good :)
Reply
Parent - - By Pyrit Date 2018-03-27 19:50
Couldn't an extra material be assigned to the leaves so that other model parts are not affected?

Nice shader effect btw. It looks inverted on the some leaves, b/c they don't have backface culling enabled. Otherwise halv of the leaves would be missing and it would not look so fluffy.
It could be modeled to look good from one side, but then the variety is missing.
Maybe we need another approach on modeling trees.
Parent - By DaFatBrainbug Date 2018-03-27 19:59

> Couldn't an extra material be assigned to the leaves so that other model parts are not affected?


That might work, but I don't understand materials well enough yet to say for sure.

>Maybe we need another approach on modeling trees.


The main problem is realy just the big planes with a sharp angle to the viewer. This also exists on some buildings.
The way they just end without being connected to anything is part of that.
Models would have to be smooth (i.e. like this)

>Nice shader effect btw


Thanks :3 This is my outline based on this shader.
Reply
Parent - - By DaFatBrainbug Date 2018-03-27 22:34
One example of this shader with very different values and sqrt instead of pow:
Reply
Parent - - By Caesar Date 2018-03-27 23:58
X-ray shader into the spirit world?
Parent - By DaFatBrainbug Date 2018-03-28 00:27
Hmm
Totengräber Twonky?
Reply
Parent - By Maikel Date 2018-03-28 09:32
X-ray Ice!
Parent - By Marky [de] Date 2018-03-28 19:01
Very cool!
Parent - By DaFatBrainbug Date 2018-03-28 20:04 Edited 2018-03-28 20:12
Here is the code for this one.
You can even change the color of the effect from white to whatever you like. Change it to black and you see how my outline will work.

I hereby license the file se2.txt under the CC-BY license
Attachment: se2.txt (595B)
Reply
Up Topic Development / Developer's Corner / Custom OC Silhouette Enhancement Shader ('Ghost-Shader')

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill