Not logged inOpenClonk Forum
Up Topic General / Feedback and Ideas / Pixelshader Support
- - By Simsi [de] Date 2009-05-03 19:17
Well, I don't know if this idea has been posted before yet, if yes, any Admin can delete this Thread.

I don't know very much about Shader (How to write them, etc.) but maybe a Glow or Bloom shader makes clonk looking better ;). It would be quite nice if someone would implement this in OC.

Another idea, which has also something to do with shaders (I think so):
An object which has an Displacement texture, which will "displace the screen". Heres an example to see what I mean:
The Displacement-texture is like a Heightmap for an glasplate which is over the screen, and so the screen will be distorted.
It would be a nice effect for Hazard or Fantasy things.
Parent - - By Carli [de] Date 2009-05-04 08:36
I also made this suggestion (http://forum.openclonk.org/topic_show.pl?tid=20) to use shaders in landscape drawing, but it was a problem of compatibility and also of the used graphics API.
I think we should wait until the developers have enough time to care about such stuff. (I myself can not take part of coding in OC because it's closed source yet.)
Parent - - By henry [de] Date 2009-05-04 13:26
OpenClonk should use CG-Shaders.  : )
Parent - - By Carli [de] Date 2009-05-04 13:43
But why don't you use GLSL? It is mor comfortable and i have some implementation of shader loaders and example 2d shaders.
Parent - - By henry [de] Date 2009-05-04 13:46
OpenClonk will support OpenGL and DirectX.
GLSL only works for OpenGL.

(In my game project I am using GLSL too. :D)
Parent - - By Carli [de] Date 2009-05-04 14:05
wasn't there a discussion to remove directX support?
Parent - By henry [de] Date 2009-05-04 14:26
MClonk is a open source freak. -.-
Afaik there will be DirectX support. -> OGRE-Engine?
Parent - By Isilkor Date 2009-05-04 14:47
Yes, and that proposal was unanimously struck down.
Reply
Parent - - By Newton [es] Date 2009-05-04 09:31 Edited 2009-05-04 16:18
Ideas about bloom and pixelshaders in general  have been around for some time now. The issue is more to find someone who can implement it.

Additionally, the main problem here is that e.g. the displacement texture for a pixel-based landscape would have to be a second texture for the entire landscape since I think to generate it per-frame is too expensive. This would consume (too) much memory. The same applies for any other landscape-wide texture for shaders.
(The link is just made with POV-Ray and only to illustrate my idea)
Parent - By Simsi [de] Date 2009-05-04 12:38
I think you missunderstood me with the displacementmap.
I thought about a "displacementmap for the screen", like when you see through a glassball or a lens.
Parent - - By Carli [de] Date 2009-05-04 13:22

>The issue is more to find someone who can implement it.


Why don't you ask me?
(see Techdemo, link above)

the one_light.avi does not work (only a few KB)
Parent - By Zapper [de] Date 2009-05-04 15:13

>Why don't you ask me?


Well, feel free to fool around with the code in any way you want once it is open source :)
Parent - By Newton [es] Date 2009-05-04 16:14
The video is DivX MS-MPEG-4 Version 3, you should be able to play it. I can even under linux :P
Parent - By Caesar [de] Date 2009-05-05 13:54
WMP fails.
Parent - By henry [de] Date 2009-05-04 22:16 Edited 2009-05-05 12:52
Wow, looks great! O_o *impressed*

[edit]
I implemented a Shader-Manager and a PostProcessing-System (GLSL) for my game.
It shouldn't be a problem to convert the code to CG. :)

*screenshot*
Parent - - By Cani [de] Date 2009-05-04 23:08

> The issue is more to find someone who can implement it.


I think we first have to decide whether we use directX, openGl or both. Both would make it quite annoying to write shades since you'd always need two versions of them. There is a tool by AMD that can convert between those. I did not try it yet. (http://sourceforge.net/projects/hlsl2glsl)
I used to write some shaders in HLSL for a project. So if I had a look at the hopefully soon released source code, I might be willing to implement it.

Just because I'm interested in:
What did you use to model the landscape in POV-ray? A heightfiled?
Parent - - By Newton [es] Date 2009-05-04 23:31
If you or Carli know how to write shaders and would like to develop them for OC, I'd find that great!

Yes, I used a heightfield. The source is here.
Parent - - By Carli [de] Date 2009-05-05 13:53
can you put the video on yt pls?

i am writing this shader and it looks interesting (i could make a radial zoom f.e.)
Parent - - By Newton [es] Date 2009-05-05 20:47
VLC should be able to play that video. I don't really want to upload it to youtube.
Parent - - By Carli [de] Date 2009-05-06 15:05 Edited 2009-05-06 15:19
i didn't want to download VLC so i uploaded the videos.
http://www.youtube.com/watch?v=_qMtmsCvfCo
http://www.youtube.com/watch?v=V3SDcJ1MytM
Parent - - By Nachtfalter [de] Date 2009-05-06 15:43
You also can watch it with QT, if you have installed the codecs.
Reply
Parent - By Cani [de] Date 2009-05-06 19:06
WMP also works if you have the codec
Parent - - By Carli [de] Date 2009-05-05 15:17 Edited 2009-05-05 15:38
This Techdemo raytraces a landscape and generates shadows (no aa implemented)

Needs gwX to run (used gwX graphics Engine for rendering shaders)

I hereby license the following file(s) under the CC-by license
(c) Carli
Attachment: Techdemo.zip (974k)
Parent - - By Newton [es] Date 2009-05-05 20:58
Unfortunately for both tech demos I get "Zugriffsverletzung bei Adresse 0045BC1B in Modul 'gwX.exe'. Lesen von Adresse 0000001C"

But anyway, the screenshots looks quite cool. Can you explain more in detail how it works?
Parent - - By Carli [de] Date 2009-05-06 15:02 Edited 2009-05-06 15:04
it is a raytracing algorithm checking a line of 32 pixels on the heightmap from the clonk to this landscape pixel. When a solid pixel is found, this pixel will be shadowed, else it would be lighted.
This shader works with unrolled iterations for downwards compatibility.
The shadowmap is not antialiased and it uses bias which means it generates oversized pixels. But it can be improved when you are interested in.

The "Zugriffsverletzung" may cause an old engine. Maybe you can try and find out why it does not work (i'm sorry for this bug - what for a system do you have and did you use setup? It would work on an older engine, maybe since rev5).
Parent - - By Newton [es] Date 2009-05-06 19:35

>This shader works with unrolled iterations for downwards compatibility.


Ah this explains why the shader looks so weird.

Considering the possibility of multiple light sources and the fact that for every (oversized) pixel one has to do a pathfree check to the light source it sounds far too expensive. Actually I think the Clonk landscape would be a classical case for bump or normal mapping - a flat surface which has a rough surface (tunnels and such) that is approximated by a bumpmap texture. However, this doesn't include self-shadowing. I think I once read an article about new technologies where self-shadowing with normal-mappy-stuff would be possible but I don't know how expensive this is.

How would it look like if the brightness of one pixel is calculated like L = D * A where D is the brightness of the light source depending on the distance to it and A is the direction of the normal of this pixel relative to the light (if it points to the light source its 1, if it is 90° its 0). So without cast shadows, just shading.
Parent - - By Carli [de] Date 2009-05-07 12:46 Edited 2009-05-07 12:48
Then we have to generate a normalmap (i was not able to copy your povray example 'cause i had no normals for the landscape - and i was too lazy to generate them from the heightmap)
Parent - By Simsi [de] Date 2009-05-07 21:03
I could generate Normalmaps =) from heightmaps or from my brain, too.
Parent - - By Carli [de] Date 2009-05-07 12:47 Edited 2009-05-07 15:06
Now I continued my work on this Shader so it also enables embossing.

Watch at http://www.youtube.com/watch?v=hnvuIm7MgoE
Attachment: Techdemo.zip (975k)
Parent - By K-Pone [de] Date 2009-05-07 20:23
This looks great
Parent - - By Carli [de] Date 2009-05-05 15:41
it's quite easy to rewrite a glsl shader in cg. (just read some tutorials.)
But I think as an OpenSourceProject (muhahaa the source isn't open) we should use OpenGL because DX takes no advantages towards GL
Parent - By Newton [es] Date 2009-05-05 21:02
Possibly there are even some converters out there. But as Isilkor pointed out, to use CG in the first place might be a better idea.
Parent - - By Caesar [de] Date 2009-05-06 13:21
Hm. What happens, when you use more contrast? Something like LoS?
Parent - - By Newton [es] Date 2009-05-06 14:33
You can modify the povray script any way you like. There are some parameters which you can freely adjust Actually, I don't know that you are talking about - what is LOS?
Parent - By Caesar [de] Date 2009-05-06 17:36
Line of sight.
Parent - - By Clonkonaut [de] Date 2009-05-04 23:58

> I think we first have to decide


There's nothing to decide. When someone writes the shaders for ogl, we'll have ogl support and when someone writes the shaders for dx, we'll have dx support.
Reply
Parent - - By Isilkor Date 2009-05-05 08:58
And if someone writes the shaders in Cg instead, we'll even have both! Whee!
Reply
Parent - By henry [de] Date 2009-05-05 12:44
Exactly what I am talking about all the time. -.-
No one listens to me. :C
Parent - - By Cani [de] Date 2009-05-06 19:09
That would be some kind of a decision.
Parent - By Clonkonaut [de] Date 2009-05-07 13:27
No, it isn't. In this way we just wait for what people are willingly to code and not saying "we don't want you to code this or that".
Reply
Parent - By Newton [es] Date 2009-06-05 19:34 Edited 2009-06-05 19:41
Here some test maps if someone wants to try to implement lightning and shaders for normal & reflection maps. The normal map is actually not really good but it is not possible to create a better one with the from-photo-method. For a really good one, one would have to render the surface according to the texture and then render to normal map... but its just some test material anyway.

License: CC-BY 3.0
Attachment: red.zip (402k)
Up Topic General / Feedback and Ideas / Pixelshader Support

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill