Horde3D

Next-Generation Graphics Engine
It is currently 27.11.2024, 03:58

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: 24.07.2008, 18:35 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
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! :)

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 25.07.2008, 02:28 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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 21292 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:


Last edited by DarkAngel on 06.08.2008, 11:36, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 25.07.2008, 02:38 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
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.

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 05.08.2008, 08:18 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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)


Top
 Profile  
Reply with quote  
PostPosted: 05.08.2008, 09:34 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
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.

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 06.08.2008, 11:48 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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 21288 times ]


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


Top
 Profile  
Reply with quote  
PostPosted: 06.08.2008, 12:13 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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!


Top
 Profile  
Reply with quote  
PostPosted: 07.08.2008, 04:52 
Offline

Joined: 05.07.2008, 21:12
Posts: 26
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)


Top
 Profile  
Reply with quote  
PostPosted: 07.08.2008, 06:27 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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;
}


Last edited by DarkAngel on 07.08.2008, 10:21, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: 07.08.2008, 10:15 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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).


Top
 Profile  
Reply with quote  
PostPosted: 07.08.2008, 10:39 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
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 :)

_________________
Paul


Top
 Profile  
Reply with quote  
PostPosted: 20.09.2010, 09:31 
Offline

Joined: 20.09.2010, 09:22
Posts: 1
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group