Horde3D
http://horde3d.org/forums/

Would you be my shader buddy?
http://horde3d.org/forums/viewtopic.php?f=1&t=446
Page 1 of 1

Author:  SpOOky [ 24.07.2008, 18:35 ]
Post subject:  Would you be my shader buddy?

Hi,

I need a couple of GLSL shaders for a personal project that are beyond my capabilities; I would pursue learning how to write shaders on my own,
but the time frame I have does not allow that.

Therefor I have to ask for help. The shaders I need are quite simple from what I've researched. I need a per-pixel refraction, glow, and a specular-mapping one;
integrating these with the normal mapping and skinning ones that come with Horde3D.

Can you help me with this?

Thanks! :)

Author:  DarkAngel [ 25.07.2008, 02:28 ]
Post subject:  Re: Would you be my shader buddy?

Specular maps are pretty easy to add in. I'm at work ATM, so I haven't tested this... but I think this is all you need to do to add a spec/gloss layer to the parallax mapping shader:

In the deferred version (ATTRIBPASS) and forward version (LIGHTING)
Change this:
vec3 albedo = texture2D( tex0, texCoords.st ).rgb;
To this:
vec4 colours = texture2D( tex0, texCoords.st ).rgba;
vec3 albedo = colours.rgb;

In the deferred version only (ATTRIBPASS)
Change this:
setSpecMask( 0.3 );
To this:
setSpecMask( colours.a );

In the forward version only (LIGHTING)
Change this:
gl_FragColor.rgb = calcPhongSpotLight( newPos, normalize( normal ), albedo, 0.3, 16.0, -vsPos.z, 0.3 );
To this:
gl_FragColor.rgb = calcPhongSpotLight( newPos, normalize( normal ), albedo, colours.a, 16.0, -vsPos.z, 0.3 );

Now you just need to edit your main texture in a tool like Photoshop or Paint.NET that supports alpha channels, and the alpha represents how matt or gloss the pixel is. White = glossy, black = matt.

Attachment:
gloss_map_result.jpg
gloss_map_result.jpg [ 108.44 KiB | Viewed 27723 times ]


If you're interested in the theory behind real-time glow/bloom, check out this article:
http://www.gamasutra.com/features/20040 ... es_pfv.htm
I've implemented the technique from this article in Half-Life before, and I'll be sure to let you know if I get it working in Horde. Don't hold your breath for me though :wink:

Author:  SpOOky [ 25.07.2008, 02:38 ]
Post subject:  Re: Would you be my shader buddy?

Thanks m8. I actually thought that this will be the the hardest to implement :) I will deffinetly check that article.
One down, two more to go.

Author:  DarkAngel [ 05.08.2008, 08:18 ]
Post subject:  Re: Would you be my shader buddy?

Hey SpOOky, I'm having another go at these shaders because I feel like brushing up on my GLSL :wink:

What kind of pipeline are you using (forward, HDR, deferred)? (So that I know which one to devote my time to first)

Author:  SpOOky [ 05.08.2008, 09:34 ]
Post subject:  Re: Would you be my shader buddy?

Atm I am using deferred, but i intend to switch asap to HDR for the final incarnation of the application. So the answer is HDR.

Author:  DarkAngel [ 06.08.2008, 11:48 ]
Post subject:  Re: Would you be my shader buddy?

I've got glow working now - I'll write up my results in the wiki soon.
Attachment:
glow_map_result.jpg
glow_map_result.jpg [ 68.83 KiB | Viewed 27719 times ]


BTW I've also added a wiki page describing the specular mapping technique.

Author:  Volker [ 06.08.2008, 12:13 ]
Post subject:  Re: Would you be my shader buddy?

Much kudos to all the wiki writers. I really like those articles! Even if they are only short and describing only some special techique they are a great source for problem solving! Keep it up!

Author:  speeder [ 07.08.2008, 04:52 ]
Post subject:  Re: Would you be my shader buddy?

I noticed that Horde3D shaders are quite... Huh... Bloated?

I mean, they are plainly huge, with all those includes and calculations, there are no way to make them more simple?

It is because altough it is really beautyfull, the things crawl on my machine (GeForce 8600, runs the Knight thing at 20 fps...)

My own game, that is just about 10 objects on-screen (each with 20 polygons), run at 30 FPS or something like that...

EDIT: How I profile horde to know what shader is eating the speed? (I noticed that horde do the things in several passes)

Author:  DarkAngel [ 07.08.2008, 06:27 ]
Post subject:  Re: Would you be my shader buddy?

speeder wrote:
It is because altough it is really beautyfull, the things crawl on my machine (GeForce 8600, runs the Knight thing at 20 fps...)
My GeForce 7800 runs the knight demo at over 120 fps!!!
Try updating your graphics drivers to the latest version.

speeder wrote:
EDIT: How I profile horde to know what shader is eating the speed? (I noticed that horde do the things in several passes)
Edit your shaders one at a time so that they don't do any calculation except for the bare minimum work. If this drastically improves the fps then you've found the culprit.

A bare minimum pixel shader might look like:
Code:
void main( void )
{
   gl_FragColor.rgb = vec3(0,1,0);
}
And a minimal vertex shader might look like:
Code:
uniform    mat4 worldMat;
void main( void )
{
   vec4 pos = worldMat * gl_Vertex;
   gl_Position = gl_ModelViewProjectionMatrix * pos;
}

Author:  DarkAngel [ 07.08.2008, 10:15 ]
Post subject:  Re: Would you be my shader buddy?

DarkAngel wrote:
I've got glow working now - I'll write up my results in the wiki soon.
I'm too busy to finish writing the wiki page on glow at the moment, so I just dumped all my shader code on there for now ;)
It shows how to make a glowing version of the parallax shader, and how to modify the skinning material to work with the glow effect (but not glow itself).

Author:  SpOOky [ 07.08.2008, 10:39 ]
Post subject:  Re: Would you be my shader buddy?

Thank you DarkAngel! This does not only help me to meet my deadline but also being included in the wiki can help numerous other users with their projects or learning as well :)

Author:  Thista [ 20.09.2010, 09:31 ]
Post subject:  Re: Would you be my shader buddy?

Well... my first post in the Horde3D forum... hi!

I'm not very used yet to shaders (especially not how Horde3D implements them) and I'm trying to get the glow shader example working.
Anyone able to post the material and shader for glow shader on this forum? :)

Thanks in advance,

Thista

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/