Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / The Ultimate Shader Thread.

Author
Message
Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 11th Jun 2004 18:59 Edited at: 11th Jun 2004 18:59
Well, one of the hardest things I've found about creating vertex and pixel shaders is figuring out exactly how to make an effect work. I got a lot of help from the RacorX tutorial (http://www.shaderx.com/direct3d.net/tutorials/shader/shader1.html is one place it's hosted) which explains what each line of shader code does as well as describe some of the ideas behind different lighting models. Of course, it's all in ASM, so it's not for everyone. I personally prefer ASM to HLSL, so I loved it!

Anyway, I was just wondering, let's say I want to create a Halo/Predator cloaking effect that gives a glass-like visual distortion of the area, and I want to apply the effect to Walter. Would I be right in saying that you should first render the scene without Walter in it, then apply this texture to Walter in a second pass? Or, would there be a way of doing this in a single pass? Or is this just completely wrong?

Also, thanks for the tutorials Neophyte! My shaders would still be stuck in FX Composer and RenderMonkey if it wasn't for your help!
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 12th Jun 2004 03:06
Hi all,

Just like to know if a Glow Shader has been made for Db.

Thx
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 12th Jun 2004 21:13
@Ninja Matt

"Anyway, I was just wondering, let's say I want to create a Halo/Predator cloaking effect that gives a glass-like visual distortion of the area, and I want to apply the effect to Walter. Would I be right in saying that you should first render the scene without Walter in it, then apply this texture to Walter in a second pass? Or, would there be a way of doing this in a single pass? Or is this just completely wrong?"

I think you'll need only 1 pass but I'm not sure. You could probably do it by modifiying the "Mr Wiggle" shader that comes with FX Composer to fade out model by slowly modifying the Alpha value through a constant. In that case, I'm pretty sure that you would only need one pass.

However, if you want to have a shimmering edge effect like the Predator has you might need two passes. I don't know though. I've never tried it before. You could probably just get away with one by making the model slightly less transparent at the edges.

Probably could achieve that through some kind of edge detection algorithm like cartoon shaders use. You could probably detect the edge and mod the alpha based on that. Afterwards, you could display the model in a "Mr Wiggle" style so the alpha fade isn't entirely even; giving it that blurred kind of look.

If that method doesn't give decent results there is always a combo of cubemaps and a reflection/refraction shader. I'm sure you could mod one of those shaders to warp the results near the edges.

The only serious drawback to that is that you will need a cubemap of your enviroment to pull it off. Those can get pretty big when you start to accumlate them. Fortunately, you could probably just pre-compute the cube-maps for your levels and reuse some cubemaps as long as you are in the general vicinity.

Given the nature of the Predator cloaking effect I think you could get away with it. It is suppose to be hard to see after all so minor graphical glitches can be overlooked.

Failing even that, all I can think of that is even close to that is a combo of a depth of field shader and the alpha cranked all the way up. For that you would probably need two passes though. I'm not sure though since Depth of Field shaders can't be run on my hardware. My poor Geforce 4 ti 4200 is a little overwhelmed.

"Also, thanks for the tutorials Neophyte!"

Your welcome.

@KajiSan

"Just like to know if a Glow Shader has been made for Db."

There hasn't been any that have been made specifically for DBPro but there are Glow shaders that you can get to work.

This one right here came with the DX 9 sdk and will run on any shader capable hardware. You'll have to set the constants for it though, but that shouldn't be a problem thanks to my tuts.

KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 13th Jun 2004 00:16
Yes Thanks for your tuts, you're a god man
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 16th Jun 2004 14:05
Hi,

It's me . Is it possible to implement the HDRL lighting fx, i like this bloom effect. I have try to change all the constants...still don't work. I know i must do something with pass, but I haven't any knowledges about that.

Thx
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 17th Jun 2004 06:35
@KajiSan

Could you post the code for the shader you are using?
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 17th Jun 2004 10:16 Edited at: 17th Jun 2004 10:39
Worked velvety shader.



all is fine!
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 17th Jun 2004 10:17 Edited at: 17th Jun 2004 10:38
Worked hemisphere shader.



all is fine!
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 17th Jun 2004 16:12
@Neophyte

Well, I need a code
The technique used is "Bloom"....

I have made 2 matrix4 (one for the Projection and an other for the view), 2 vector4 (for the light position and light intensity), and a float for the bloom scale effect.

My model goes Black

Thx for answers..
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 18th Jun 2004 02:07
@KajiSan

I'm sorry if this has been asked before, but what graphics card do you have?
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 18th Jun 2004 02:34
@Neophyte

Ati Radeon 9700 Pro.....
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 18th Jun 2004 02:53
@KajiSan

DBPro is not currently capable of creating the bloom effect that comes with FX Composer. There are some things you need to create and access that we just can't do with DBPro currently.

Hopefully, when the shader commands are extended we'll get access to the needed commands.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 18th Jun 2004 02:59
@Neophyte

Ok

Thx a lot for your answers.
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 23rd Jun 2004 12:54
Update:

Well I've just recently re-emailed Microsoft about my earlier email I sent regarding some clarifications I needed for my tutorial.

This is the reply I got:
Quote: "Hello again and we apologize for any inconvenience this issue may have caused you.

We have followed-up your issue to the appropriate group and a response from them is likely forthcoming. We will get back to you as soon as we receive any updates from them.

Thanks for your patience and continued support."


So that makes about 1 and half months since I orignally emailed them some questions(I emailed them May 12). So it looks like my next tutorial will be delayed yet again until I can get a straight answer out of them.

Out of curiousity, has any one here emailed Microsoft's support team before? Is it usual for them to take this long responding? I've never emailed them before so I don't really know what to expect.

In all fairness though, they are usually remarkable prompt at returning a response to my emails(I got the above quote from a response that they sent in under an hour). They just haven't answered my questions that's all. I suppose I must have asked some pretty tough questions.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 23rd Jun 2004 14:21
Quote: "Out of curiousity, has any one here emailed Microsoft's support team before? Is it usual for them to take this long responding? I've never emailed them before so I don't really know what to expect. "


haha... yeah good luck with that, basically with microsoft unless they want to help you'll get the run around from thier support dept. who know bugger all.
If you were going to get a reasonable answer it would've come by now.

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 23rd Jun 2004 14:54 Edited at: 23rd Jun 2004 14:54
Quote: "Out of curiousity, has any one here emailed Microsoft's support team before? Is it usual for them to take this long responding? I've never emailed them before so I don't really know what to expect."

They take their time . Although 6 weeks is quite a long time. Usually it took 3-4 weeks when I had "not so common" questions. Sometimes you get a reply within a week. Apple's dev support wasn't much faster, however, their replies were longer.

Play Nice! Play Basic!
ALPHA ZERO PRODUCTIONS
20
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Mom ! I forgot where we live !
Posted: 23rd Jun 2004 18:48 Edited at: 23rd Jun 2004 18:53
hey Neophyte can u make the msglow.fx in fx composer work in dbp please ???
because i tried everything and it still did not work

Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 23rd Jun 2004 21:12
Noooo our umbilical has been cut! Dont let this thread die! We need more input neo! I got that 3d graphics primer book in the mail the other day. Gonna go start it now, and when im done reading it (heh) ill need more shader tuts!

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 24th Jun 2004 06:42
@ALPHA ZERO PRODUCTIONS

"because i tried everything and it still did not work"

A few questions:

1. What video card do you have?
2. What do you mean by "did not work"? Did you model turn black when you applied it? Or did nothing happen? What were the visual results of it not working?

@Zeal

" Dont let this thread die!"

I won't.

Its just that I really want to do something special with my next tutorial that will knock people's socks off and show the true power of the .fx file format.

I can write my next tutorial right now, but I just won't be able to include the stuff I wanted so it would come out rather uninteresting though still important. Hopefully, MS will eventually get back to me about the questions that I asked. I just don't think they'll do it anytime soon.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Jun 2004 07:09
Neo you ever thought of perhaps asking your question on here.
Whether you want to admit it or not, I do actually know one hell of alot about this stuff that I could no doubt answer (and no doubt in alot better detail and understanding than Microsoft would give you).

Or maybe you wanna just stay petty about things just like other users around here.

Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 24th Jun 2004 13:41
I seriously doubt that you could answer my question, Raven(though I was wondering when you'd ask). They aren't easy questions at all. Thank you for offering your assitance though.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Jun 2004 14:57
You never know unless you try.

aG Annihilator
19
Years of Service
User Offline
Joined: 20th Jun 2004
Location: UK
Posted: 24th Jun 2004 16:57
Quote: "I seriously doubt that you could answer my question, Raven(though I was wondering when you'd ask). They aren't easy questions at all. Thank you for offering your assitance though."


you guys should help each other out, even if he cant help you out its still usefull to get feedback from someone else

ya never know

------------------------
Annihilator of Annihilator Units
http://dynamic5.gamespy.com/~au
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Jun 2004 17:11
@Neophyte

Ask the question!!

I like a good laugh and I'm sure Ravens answer will provide one

ALPHA ZERO PRODUCTIONS
20
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Mom ! I forgot where we live !
Posted: 25th Jun 2004 01:40
i have a 16mb nvidia tnt2
and it says "cannot create vertex shader"

Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 25th Jun 2004 04:41 Edited at: 25th Jun 2004 04:42
Alpha, there is a reason your card "can't create vertex shader". Your card doesn't support shaders.

Neo, thanks for keeping this going(even if it isn't stickied anymore). Since Raven is making an atempt to be civil, you could at least try to do the same. If you post the question, at the worst it would be a few wasted minutes. And you never know, some one might be able to help you with it.

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 25th Jun 2004 07:15
@Eldar

" Since Raven is making an atempt to be civil, you could at least try to do the same."

I am being civil(notice how I said Thank You for him offering his assitance). I just don't want to reveal what exactly I'm working on because I want it to be a suprise. In all of the posts I've made regarding this topic I have never once given away what the subject matter of this tutorial is other than the fact that it has to do with the .fx file format. Never. I did that deliberately.

This isn't because its Raven that's offering. Even if it were someone else I'd still decline, because I want to keep this thing a secret until I'm ready to spring it. So it's nothing personal. I've just have had the goal of keeping this tutorial as a surprise every since I concieved of it.

It's going to be a really impressive peice of work when it's done. It will reveal the true power of the .fx file format and make effect files a lot more usefull in other people's eyes. But that's all I'm going to say on the matter.
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 25th Jun 2004 10:39 Edited at: 25th Jun 2004 10:41

It is Moscow shader from FX composer. Please, help me whit writing Dark basic code for corect work this shader.

all is fine!
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Jun 2004 12:22
Meh! I'm kinda past caring, i offered you declined. whatever

As for your Shader Alex, i'll have to take some time to recode the procedual texture as Lee still hasn't got them working for 5.4;
but i'm totally swaped for the next week, so I'll see about getting it done for next Friday.

Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 26th Jun 2004 06:07 Edited at: 26th Jun 2004 06:18
The moscow shader uses volume textures. I don't think Db supports them.

Quote: "" Since Raven is making an atempt to be civil, you could at least try to do the same."

I am being civil(notice how I said Thank You for him offering his assitance). I just don't want to reveal what exactly I'm working on because I want it to be a suprise. In all of the posts I've made regarding this topic I have never once given away what the subject matter of this tutorial is other than the fact that it has to do with the .fx file format. Never. I did that deliberately.

This isn't because its Raven that's offering. Even if it were someone else I'd still decline, because I want to keep this thing a secret until I'm ready to spring it. So it's nothing personal. I've just have had the goal of keeping this tutorial as a surprise every since I concieved of it.

It's going to be a really impressive peice of work when it's done. It will reveal the true power of the .fx file format and make effect files a lot more usefull in other people's eyes. But that's all I'm going to say on the matter. "
Didn't know it was a secret. Thanks again, for your work on this tutorial .

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Final Epsilon
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: CA, USA
Posted: 27th Jun 2004 18:29
mmm. Thanks for all your work. I'm just curious, when do you think that you'll have the information needed to finish writing the tutorial?
Final Epsilon
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: CA, USA
Posted: 30th Jun 2004 10:55
hm.... i just thought of an idea. Why dont we create some sort of "dbp shader repository" in which we have premodified shaders and example DBP source, all packaged in one little nifty zip file. Then we could have download links, each with a screenshot of the shader in action.

It'd be a great resource to the community, especially for those hard to modify shaders, and those really cool effects. I could host the files if you guys want to do it. I personally know very little about shaders, but i just thought it'd be nice to have such a resource when working on projects and such.

Oh well... just a thought. If it's stupid you guys can just like ignore me or something.
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 30th Jun 2004 19:06
Quote: "hm.... i just thought of an idea. Why dont we create some sort of "dbp shader repository" in which we have premodified shaders "

It is very nice idea!

all is fine!
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 30th Jun 2004 19:53
@Final Epsilon

"I'm just curious, when do you think that you'll have the information needed to finish writing the tutorial?"

I'm not sure. That's mostly up to Microsoft. However, I've just recently managed to figuare out a few important things for myself so I'm a lot closer to actually getting the tutorial done.

But there are still some issues that I need to get some clarity on.

Further, there is a shader competition going on and I'm thinking about entering. Since the deadline is August 1 I have about a month to hurry up and start working on my shader. To add to the pressure, I'll be going on vacation in a few weeks. So I'll be gone when the compo deadline occurs. So I really have less than a month to get my shader and a demo up and running. And they all have to be under 3mb in size!

I think it's a fairly safe bet that I won't be able to get this tutorial out for this month unfortunately. I'll probably be able to get it out next month given a little luck and some effort.

As for the DBPro shader repository we could start something like that using the codebase. It would be a little difficult to do for some shaders given the difficult file size limits(Some textures from FX Composer can't be compressed small enough to fit into the required limit let along a whole program with source included.)
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 30th Jun 2004 23:09
Quote: "As for the DBPro shader repository we could start something like that using the codebase. It would be a little difficult to do for some shaders given the difficult file size limits(Some textures from FX Composer can't be compressed small enough to fit into the required limit let along a whole program with source included.) "


There is no limit on the source length, convert the images to data statements.
Even so you could simply put in the text of the codebase entry

`// Requires *.DDS, *.TGA, Available In FX Composer //

Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 1st Jul 2004 08:05 Edited at: 1st Jul 2004 08:09
@Kajisan
A bloom lighting effect? Well, I've been fiddling around to make one that works in DB, and here's what I've got so far:



Currently, the shader works by using a seperate camera to render the scene to an image, preferably of size 128/128 or 256/256, and then using that image to texture a ghosted plain in front of the main camera. The shader will then blur the image and scale the colours to get a good glow. Also, you'll need to make sure that the second camera, used to capture the glow image, doesn't include the plain, otherwise it'll mess up. The way I did that was to position the plain three units in front of the main camera, then set the second camera's minimum view range to four units. Also, you have to remember to tell the shader to use the textures already applied to the object when you load it, otherwise it'll mess up.

I've included a modified version of the RoadTerrain program in the code box below, since that's what I use to test all my shaders out! To use it, you'll need to have this shader saved as "GlowTest2.fx" in the "RoadTerrain" folder, where the .dba file is stored. Then start a new project and paste the code below into it. If it doesn't work - kick me until I fix it!

You might also want to go into the shader itself and mess around with the "Scale for Glow" part, since that's what affects the final colour output the most.

@Clever People
Well, the above shader works, but it's shoddy. It's the bad result of a bad shader programmer! I wondered if you could help me improve it by imparting some of your knowledge?

Of course, the single best way to improve it would be to avoid the whole camera and plane malarky. It would be nice if more, if not all of this, could be encapsulated in the shader itself; but then, we're moving onto render targets, aren't we?

The other thing I'm worried about is the blur. As it stands, the blur is done through multitexturing and slightly perturbed UV coordinates for each texture. Then, it's a simple case of taking the average colour value of the textures for each pixel. The problem is, I'm getting eight sample points out of two passes, using four textures per pass (I'm not sure if I can use more...), which doesn't give a very smooth effect. Would it be at all possible to blur the texture horizontally, then send the resulting half-blurred texture into the next pass to blur it vertically? Effectively, I want to be able to squash the four textures of the first pass into a single texture, then use that texture four times to do the same thing in the next pass.

*EDIT*
Also, this is my first attempt at using multiple passes, so I'm still not entirely sure how it works. As far as I can tell, it pretty much just re-renders the object over the top of the original and relies on alpha-blending to combine them.

Whoah, I've rambled a bit - I'd better stop now! Thanks in advance!
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 1st Jul 2004 12:53
@Raven

"There is no limit on the source length, convert the images to data statements."

Sure. I'll give it a try next time.

"Even so you could simply put in the text of the codebase entry"

I believe that's what I did with one of mine.

@Ninja Matt

" It's the bad result of a bad shader programmer! "

I wouldn't say that. You did pretty good considering the limitations that DBPro places on us.

" It would be nice if more, if not all of this, could be encapsulated in the shader itself; but then, we're moving onto render targets, aren't we?"

Yup. I've been hounding lee and mike for support for render targets for quite some time. I think that eventually they will become a part of DBPro but I'm not too optimisitic about it happening anytime soon.

"Would it be at all possible to blur the texture horizontally, then send the resulting half-blurred texture into the next pass to blur it vertically?"

Yes. In fact, that's exactly how the pros do it. I think there are a few examples on the web that demostrate how to do that. I don't have any links on hand, but I'll see what I can come up with. However, internet access for me has been spotty at best lately. So I don't know if I'll be able to dig anything up anytime soon.

"As far as I can tell, it pretty much just re-renders the object over the top of the original and relies on alpha-blending to combine them."

Yeah, that's basically what they do. I can see you've been reading the DirectX SDK help files.

@Everyone

Well I just got a response from Microsoft(Yay!) they said they couldn't give me an example of what I wanted in a "non-convoluted way"(Boo!).

I'm composing my response right now. I'll see if I can use the information that I've gleaned so far and try rephrasing my questions so as to narrow the problem down more. Hopefully, they'll be able to help me figuare out some of the more specific problems I'm dealing with.

On an interesting side note:

They also said that as a result of my questions they'll be including some examples in the next SDK release that deal with my questions.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 1st Jul 2004 22:33
Ninja Matt, The shader isn't to shabby.
However for the way your doing it, there isn't a way (even in DirectX) to encapsulate all the data into the shader.

If you keep using PS 1.1 then, again no you can't do a single pass blur; Especially considering your doing this as an ASM not a HLSL based shader.
I'll have some time after I finish up some shaders for a level i'm working on (about an hr if all goes well), i'll see if i can't throw together a faster more flexible example of what you want.

Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 2nd Jul 2004 08:56
@Neophyte
Yeah, I've seen how the pros do the shader itself, since I've had a good look at some of the screen-space effects in FX Composer. The problem is that I can't for the life of me figure out what part of the code is 'baking' and then transfering the half-blurred texture! I scarcely know anything about HLSL and I'm not too familiar with the phase marker and dependent reads, so I'm a bit stumped at the moment.

I'll take your advice and have a quick scan over the 'net to see what I can dig up, but everything tends to be written in HLSL, so I've usually got to figure stuff out for myself.

Anyway, thanks for the help and tutorials! I'd never have got this far without you!

@Raven
"If you keep using PS 1.1 then"

Actually, I'm using VS 1.1 and PS 1.4. VS because I don't seem to need to use anything higher at the moment, and PS because the texture instructions of 1.0 - 1.3 confuse me too much!
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 2nd Jul 2004 09:47


have a tinker with that in FX Composer. it won't work atm, converting it over from my Cg version... always get mixxed up with the Samplers in HLSL though; in Cg you'd set them up in C.

but that's a full 1.1 with single pass; just uses multiple textures instead.

Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 2nd Jul 2004 12:18
Hmmm, that's pretty much what I'm doing already, but using four textures in one pass rather than eight textures in two passes. In fact, my two-pass shader started life as a single-pass, four-sample shader, but the blur left too many artifacts to be useful.

The only real difference is that you've defined the texture offsets in a tweakable, while I've defined them as a constant within the shader itself.

Also, I don't quite see how the non-advanced technique is going to work. As far as I can tell, each of the four samples is given the same offset, meaning that it won't blur it at all. Still, I don't know much about HLSL, so I could be wrong...
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 5th Jul 2004 15:57
Could anyone please help with writing the shader similar to that used in Doom3, combining glossmap, normal map and diffuse map? I only need one directional light source and ambient light (fortuntately I can manage adjusting the parameters). Use any textures, I'll also be able to change that DarkBasic code so that the shader would plug there would be greatly appreciated. Thanks a lot in advance to those who could help

all is fine!
Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 6th Jul 2004 07:38
I can give it a go. I've already written a basic shader that uses normal maps, so I should be able to work from there.

Although, I'm not too sure about the glossmap - it's basically an environment map, right? I haven't used cube or sphere mapping before, so it would be a learning experience to get something like that working!

Oh, and I've figured out how the two-pass blur works in the samples I was looking at. Unfortunately, it seems to be done with render targets - the first pass would blur horizontally and render the output to a target texture, which would then be used by the second pass to blur vertically. Are render targets completely out of the question, or only those that pass the texture to DarkBasic instead of to the next pass?
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 6th Jul 2004 08:25
Tweaking the pattern Matt allows you to alter how the samples are combined together. This can either give different effects, or it cand give you more control over the number of effects.

I know that it is essencially what your already using, basically what i wanted to do was give you the HLSL version so you could tweak it further; you add in a function for a blur pass you can do it in 2 with 1.1 and 1 with 2.0 as you can define the vector in 2.0 Tex2D.

A rendertarget actually isn't anything special; infact all it is technically is a camera attached to a texture. You can simply alter the rendering output to your needs, ie ZDepth Render, Alpha Render, etc... So techically speaking your already using a Render Target in your example.
Basically pass back what you render, to that camera then pass it back into the shader for the second pass. If you need specialised things then as you update the shader first alter your scene to render 1frame how you need it then change everything back.

It is effectively how i did an object mask effect a year ago with the backbuffer; if you want full access to render targets, let me know and i'll post up an explaination on how to acces them from dbp as is.

Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 7th Jul 2004 07:26 Edited at: 7th Jul 2004 07:36
@Raven
Thanks for the offer to help, but I'm fine at the moment. Actually, I don't plan to use the glow effect, or anything else that needs render targets in the game I'm working on. In fact, the most complex shader I'll be using is a combined bumpmap and depthmap shader for modelling realistic, 3D-looking debris and particle effects. I've already got one of each shader, but now I've just got to combine them. Should look pretty sw33t when it's done!

@Alexy
Well, it's only a quick attempt, and it might well be buggy, but I've had a go at your 'Doom III' shader:



Unfortunately, it's minus the gloss map that you asked for, but it does have specular bumpmapping to hopefully make up for that. As for tweaking, you can change the light direction by altering the lightDir float4 either by hand in the .FX file or by plugging it into a vector in DarkBasic. Also, you should be able to find the lines that point to textures up near the top too. The only other things you might want to change are the ambient colour, which can be found as a constant defined in the pixel shader, and the specular power. I'm not sure if it's the best way to do it, but the specular power is controlled by the four mul operations in the pixel shader - you won't be able to add any more, because I've hit the eight arithmetic instruction limit, but you can remove one or two of them to make the specular effect more pronounced.

I haven't had time to create a demo for you but, if you're having trouble getting it working, I'll knock one up for you. It shouldn't be too hard to make it work - all the non-tweakables are automatically set by DB.

I hope this is what you're looking for! If not, I can try to make a better one for you!
alexey vlasov
19
Years of Service
User Offline
Joined: 28th May 2004
Location:
Posted: 7th Jul 2004 16:29 Edited at: 7th Jul 2004 16:32
To Ninja Matt Diffuse texture don`t displayed
Glossmap texture is very need for best picture quwality.

P. s. Thanks for lot.

all is fine!
Ninja Matt
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 8th Jul 2004 01:25
But the bump texture and specular lighting work? That's a bit odd...

Although, if you really need the gloss map, I don't think I should be the one to make the shader for you - I still haven't gotten round to figuring out cubemaps, and my last attempt at using them was a bit of a failure.
Final Epsilon
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: CA, USA
Posted: 18th Jul 2004 08:20
hmmm... this was a useful thread, wonder why it died.

*bump*
Sam Cameron
20
Years of Service
User Offline
Joined: 26th Dec 2003
Location: 0,0,0 I\'m the center of the world !!!
Posted: 18th Jul 2004 08:51
do you want to see something really cool with shaders? try this:

http://www.virtools.com/downloads/vmo/head/Shaders_Demo.exe

when the users of darkbasic could use this technology? because I only see shaders from the original darkbasic software, but we can't use all the rest of the shaders of internet, that's stupid implementation and not very usefull only use 2 o 3 shaders when we have a directx 9.0 engine
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 19th Jul 2004 00:49
@SamCameron

"because I only see shaders from the original darkbasic software, but we can't use all the rest of the shaders of internet, that's stupid implementation and not very usefull only use 2 o 3 shaders when we have a directx 9.0 engine "

You obviously haven't looked at the second post in this thread. I've detailed how to get shaders working in DBPro. The only shaders you can't get to work right now are the ones that generate procedural textures. But they will eventually be added to DBPro.

I'm pretty sure that almost all of those shaders can be used by DBPro.

@Final Epsilon

"hmmm... this was a useful thread, wonder why it died."

I've been busy lately and haven't really gotten the time to post. On the bright side, I do have some good news regarding my next tutorial. I've managed to figuare out what I have to do in order to get the paticular effect working. Unfortunately, I need the vertex commands that are not "offically" in DBPro yet in order to achieve what I'm after.

I'd could probably use some known approximations, but that would limit the usefullness of what I'm trying to do and I don't want to do that. But I also don't want to delay this tutorial until patch 6 or whenever those vert manipulation commands are supposed to offically become apart of DBPro.

So it looks like I'm going to have to write the tutorial with the approximations and hope that that doesn't introduce too many unacceptable graphical glitches. Sometimes you just have to make do with what you have I guess.

Login to post a reply

Server time is: 2024-05-07 07:39:41
Your offset time is: 2024-05-07 07:39:41