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 / [STICKY] Learning to write Shaders

Author
Message
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Mar 2007 10:40
Onwards!

To five hundred.

-= Out here in the fields, I fight for my meals =-
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 13th Mar 2007 00:28 Edited at: 13th Mar 2007 01:28




All this does is texture an object(for now) but it will have two textures. One top layer which will conatin an alpha channel. The alpha is going to be for transparnt parts and the bottom layer is going to scroll under the top layer. It compiles so is this the right format for a shader? Any pointers?

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 13th Mar 2007 01:50 Edited at: 13th Mar 2007 02:31



I think I understand how to setup the varibles and textures in dark shader now. The next step is to figure out how to use the varibles to make the shader do something.

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Mar 2007 01:51
Looks like a good start. Watch this space.
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 14th Mar 2007 03:17
@ Green Gandalf

I am glad to here that. I was also thinking if I had a plain that was divided like a 10x10 matrics and have vertices move up in Y by a varible (one at at time though). The shader randomly pick a vertex, moves it and then moves it back.Then repeate. You get the Idea.That may be a little advance for me for now but with a thread like this and guys like you helping I will be able to do it. Be warn I am going to ask alot of questions here. Dont give me teh codez

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
Tim Will Hack
17
Years of Service
User Offline
Joined: 20th Dec 2006
Location:
Posted: 14th Mar 2007 21:01 Edited at: 14th Mar 2007 21:16
Hey guys,

I'm trying to figure out how to use a timer in a shader similar to how I use it in dbp.

I would basically like to setup something in the shader that takes a value of 1 to start a transition that will blend 2 textures over 2 seconds.

1. So I called the var "starttrans" as float in the shader

2. In DBP I set it to 1 when the spacekey is pressed and send it to the shader. In the shader, if starttrans = 1 then it starts the transition using the timers.

3. I have a 'float Timer : Time' in my shader (which according to fx composer its the actual timer value in realtime (under properties)

4. I also have a variable called float StartTimer = 0

5. In "PSOutput PShader(PSInput In, PSOutput Out)" I check if StartTimer = 0 if it does then I set it equal to Timer.

6. In "PSOutput PShader(PSInput In, PSOutput Out)" I constantly check to see if Timer - StartTimer > 2.0, however its like they are always equal, almost like StartTimer always equals 0 when it enters the call.

Any ideas? All I can think of is that I'm not really modifying the global variables, that its modifying a local var, however there are none declared, and I name it differently it errors due to me not declaring the variable.

One last question. Is there any way to view the values of the variables debugging wise for a shader? I've tried 'PERFORM CHECKLIST FOR EFFECT VALUES' but the 'checklist value a' command seems to be returning junk.

I hope I make sense. I'm still pretty new to writing shaders so any help is very much appreciated.


Check out my new website - http://www.madcents.com/
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Mar 2007 15:18
@Tim Will Hack

Here's a very simple demo of two ways of using a timer in a shader.

The first shader uses a variable "seconds" declared with the "Time" semantic in the shader:



The second uses DBP to pass the value of "seconds" to the shader. You can use either method - the first is slightly simpler:



The demo dba code I used was:



I don't think you can assume the timer starts from zero in either method.

But you CAN initialise the timer with the second method if you change the loop to:



This will force the right hand object to start from red.

Hope this helps.
Tim Will Hack
17
Years of Service
User Offline
Joined: 20th Dec 2006
Location:
Posted: 15th Mar 2007 16:07 Edited at: 15th Mar 2007 21:33
Thanks Green Gandalf, you are always the best!

One of my questions though is can I do it all in the shader? I'm having trouble under say the following example, setting the global variable equal to something and having it stay after the call:



Thanks again!

EDIT:

Basically I have a bunch of objects that use a 'fading in' technique. I don't want to keep track of the timers in db, i'd rather just have db tell the shader - 'Ok start' and have the shader keep track of its own timers. Maybe this isn't possible?

EDIT#2:

I know that timers never start at 0 (except I think at midnight). I usually take a starting timer, and then do 'timer() - starttimer' which would give me the seconds since I started it. I am still curious how you set global variables to new values.

SUPER EDIT#3:

I've sent in the timer/1000 in db for a starting point in the shader, and it works! I have a 10x10 set of objects that all have there own effect applied to them so they are all differing timewise for there own fades.

Thanks Gandalf


Check out my new website - http://www.madcents.com/
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Mar 2007 21:38
As far as I know you cannot rely on any variables in a shader persisting till the next call and you can't have global variables - except those which are passed by the application via semantics like "WorldViewProjection", "CameraPosition" and "Time", or via your own "tweakables" such as "seconds" in my second shader example.

The safe way to do what you want is to keep track of separate timers in DBP and pass the values to the shader.

Once you've done that you can do what you like with the timer inside your shader (within reason of course ).

If I think of another way I'll let you know.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Mar 2007 21:48
@dononeton

Just catching up with your query.

Quote: "The shader randomly pick a vertex, moves it and then moves it back.Then repeate."


Shaders can't "pick a vertex" - they get given a vertex to process (and you cannot easily see which vertex it is processing). So, if you bear that in mind you might be able to come up with something.

You've set yourself quite a task - but something along those lines is possible I'm sure.

Quote: "Dont give me teh codez"


I will do my best.

But I hope YOU give US the code when you've got it all sorted.
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 17th Mar 2007 16:01
The black part is going to be the crust texture and the yellow and orange is going to be the scrolling texture. Texture made in PhotoShop

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB

Attachments

Login to view attachments
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 10th Apr 2007 11:53
EVOLVED said this few pages back:

Quote: "heres my attempt at a depth of field shader > http://www.vector3r.com/DepthOfField.zip , but trust me it'll be such a pain in the ass to get working in game unless you have some shader knowledge.
"


I'd like to download that shader but his website seems to be offline, does someone have that shader evolved made? I'd like to experiment with it Thanks

I am awesome and always right.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 11th Apr 2007 01:05
Quote: "does someone have that shader evolved made"


Done (I hope ). See your thread on the main DBP list.
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 11th Apr 2007 10:23
Yup, got it, thanks a lot mate!

I am awesome and always right.
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 26th Apr 2007 02:16 Edited at: 26th Apr 2007 06:24
Noo! This thread can't die!


I need the shaders. Do you have anymore Green Gandalf?

EDIT:

Oh, and I also need some help. EVOLVED's soft shadow shader doesn't work well for me.
Here are the bugs:

The screen flashing slightly when I look at the light source.
It looks like it's pasting an image of what the main camera's seeing onto the shadowed object. But blured and dim.

Any ideas? I have a GeForce 6200 and it's worked on all his other shaders, and yours too, Green Gandalf.

...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd May 2007 22:27
Quote: "Noo! This thread can't die!"


Let's hope not.

Quote: "I need the shaders. Do you have anymore Green Gandalf?"


One day, I will put them all together in a single package ...

Quote: "Oh, and I also need some help. EVOLVED's soft shadow shader doesn't work well for me.
Here are the bugs:

The screen flashing slightly when I look at the light source.
It looks like it's pasting an image of what the main camera's seeing onto the shadowed object. But blured and dim.

Any ideas?"


Can you be specific about the code and media - and which version of DBP you are using?
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 1st Jun 2007 13:19
I have pixel shader version 1.3, does anyone have a normal mapping shader i can use that does what the ones in doom 3 do?

using multiple textures, one for the diffuse map, one for the normals, one for the bump, one for the specular and one for glow?

I can extract these from doom 3 but dont know the hlsl syntax so i cant figure out how to modify them to work with dbpro, let alone be allowed to legally.

Also, is there a help file i can download with hlsl syntax listed so i can figure out where to even begin?
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 3rd Jun 2007 02:44
There's a bump mappping and normal mapping example in the Ultimate Shader Pack.

They'll work in PS1.3 they're not complicated.

-= Out here in the fields, I fight for my meals =-
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 3rd Jun 2007 03:19
I have that, but the only one that will work doesn't do the specular shading the right way, it only supports a gray scale specular map, the alpha map of the normals texture. I want one that will use a separate specmap with color so that the materials dont just reflect white, and it also doesnt support a glow map. I knwo these things arent super tasking because they are everywhere.

The other examples in the ultimate shader pack require pixel model 1.4, and i dont know how to convert them to 1.3 compatible.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jun 2007 14:00
Quote: "They'll work in PS1.3 they're not complicated."


I'd be interested in seeing one that works with the extra features that Indecom is requesting.

I've tried adapting some of my bump-mapping shaders for PS1.3 along the lines that Indecom wants but keep hitting various instruction/register count limitations.

I think it would be quicker and cheaper to invest in a PS2 GFX card than to struggle with PS1.3.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 3rd Jun 2007 20:39
I know it seems like i am asking alot and i am sorry if this is too much hassle. I just have no clue what the hlsl syntax means. i am used to things that can be read and understood without needing much guidance.

I have doom 3 and prey and they both work fine on my 1.3 card, and i know how to extract the shaders from each, but they wont work with dbpro right away, and would require some altering to have any effect. This is something that i know nothing about. If anyone wants to take a look at these shaders to learn from or try to tweak into working with dbpro, with the exception that they are only going to be used for learning and not production, reply me and i will email them to you.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jun 2007 21:16
Quote: "If anyone wants to take a look at these shaders to learn from or try to tweak into working with dbpro, with the exception that they are only going to be used for learning and not production, reply me and i will email them to you."


I'd be happy to have a look on that basis - can't guarantee success though.

Quote: "I just have no clue what the hlsl syntax means. i am used to things that can be read and understood without needing much guidance"


I can sympathise with that - I was in much the same position not very long ago.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 5th Jun 2007 04:49
Thanks for your interest, i am trying to dig it up now.

I have a question tho, in the normal-specular shader, number 17 in the objects-lighting section, would it be difficult to add an ambient light value so the lights dont just fade to black? So i can still see some texture even when not directly lit?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jun 2007 13:11
Quote: "in the normal-specular shader, number 17 in the objects-lighting section, would it be difficult to add an ambient light value so the lights dont just fade to black"


Yes and no. If it was written in HLSL the changes would be very easy to apply. If we are talking about the same shader, it is written in asm which is much harder to get into (for me and probably most other people anyway) - but it could be done.

Personally, it would be much easier to write a new one from scratch in HLSL. However, I have a normal bumpmapping shader somewhere which allows for both specular reflection and ambient lighting - but it only uses one light source at present. If you're interested I'll try to find the link - it was posted on the main DBP list on someone else's thread which was probably about normal mapping around Sept 2006. A search should find it.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 5th Jun 2007 21:19
That sounds good, I know of a way to get multiple lights from a one light shader, i just hope its compatible with my card.

Also, i got 3dsmax 9 recently and will look into making shaders with that.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jun 2007 23:22
Here's the link:

http://forum.thegamecreators.com/?m=forum_view&t=88873&b=1

The demo is contained in one of my posts on 12 Sept 2006.

Let me know how you get on.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 6th Jun 2007 00:48
Well, thanks but the shaders of yours dont work with my card, i just get a white texture with a static ambient level unresponsive to the lights position.

Thanks for trying tho.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2007 01:36
Sorry - I forgot you needed PS1.3.

(Stupid thing is that I'd already tried to force my shader into PS1.3 for you - and failed! Looks like it's not just my PC that's got a memory fault. )

If I come across anything useful I'll let you know.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 6th Jun 2007 01:39
Hehe, yeah, my card is a picky little turd. I found that the inbuilt realtime renderer for 3dsmax supports normal maps, diffuse, specular and even environment/cubemaps. The only problem is that exporting that shader only exports to a higher pixel shader than the one that is displayed in the viewpoint. So, yeah, i think i may be screwed for some time.
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 6th Jun 2007 08:40 Edited at: 6th Jun 2007 08:50
Quote: "Can you be specific about the code and media - and which version of DBP you are using? "


Sure. I have DBPro V. 1.063

I'll post the code and media in a minute, when I find it.

EDIT:

.zip attached.

...

Attachments

Login to view attachments
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 6th Jun 2007 09:00 Edited at: 6th Jun 2007 09:00
Here's an image of the problemo:



It looks much worse live. That black 'shadow' and the weird lighting on the wall flash when I move the camera. The shader still accomplishes what it's supposed to, though, excluding bugs.

...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2007 14:04
@Indecom

Quote: "So, yeah, i think i may be screwed for some time."


Possibly not - I think I've overlooked something very simple. Won't know for sure till later when I get home from work. (Can't test it here.)

@Benji

I'll check your code out at the same time (more or less ).
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 6th Jun 2007 22:15
that would be cool if it managed to work. Thanks for the helps.
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 7th Jun 2007 01:02
Quote: "@Benji

I'll check your code out at the same time (more or less ). "


I'm in no rush. Anytime within this month is fine with me.

Thanks.

...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Jun 2007 01:16
Indecom

I've now got a working VS1.1+PS1.3 shader working which provides normal bumpmapping plus ambient lighting and specular reflection.

The shader isn't perfect - I had to make some compromises along the way to fit into the instruction count limit (only 12 allowed in the pixel shader), but it is a start.

Curiously the shader won't compile in DarkShader but runs nicely in both DBP and FX Composer. I'll have to raise that with TGC. I'll post the code tomorrow when I've cleaned my demo code properly.

In the meantime here's a screenshot of it working.

Benji

Thanks for the extension - Indecom's PS1.3 query took longer than I thought.

Attachments

Login to view attachments
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 7th Jun 2007 08:47 Edited at: 7th Jun 2007 11:15
Hey, thanks for getting that to work! I cant wait for the demo! I will use the crap out of that!

Does that use a specular map or an alpha channel?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2007 01:26
@Indecom

Here's the demo - pressing 1, 2 or 3 gives different effects (3 gives you the PS1.3 normal mapping).

The code for the specular reflection is frankly a hack and I'd like to see it improved. Also, if you look closely at the demo for option 3 you'll notice that the bumpmapping/specular reflection isn't always correct. I don't know the reason for that yet - but at least we have something to build on.

The shader is a two pass shader which is the main way of getting around instruction count limits - especially necessary for the earlier PS versions. This is precisely what I told someone else in another thread - but for some obscure reason it took me several days to think of that solution in this case.

I've included some other images and normal maps so you can play with the code a bit. Also, you can change the light and specular colours - but the demo doesn't let you do that yet (changing the demo dba code is easy enough though).

It may be possible to use effect states to get similar effects in the shader - but I haven't tried yet (relevant documentation is hard to find).

Attachments

Login to view attachments
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 8th Jun 2007 01:38
cool, thanks, i will give this the biggest look over ever. If it works well, i will probably use this a lot in my next project.
Irradic
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 8th Jun 2007 01:42
@Green Gandalf

I could use your help once you have attended to the other inquiries.

I have edited the Skin shader from Nvidia's FX Composer in order to make it work in DBPro.
Basically it works fine but I have issues in implemented my needed lighting system. The shader in it's original state has 1 light source without range/fall off.

Now this is what I need help with...I'm using Evolved's 6 lights Normal Map shader for the environment. In order to make the skin shader react to the lights in the same matter as it would with the normal map shader, it needs an identical light setup.
Now I don't have a problem in editing the extra light passes in, but I can't get the lightrange working.
I would really appreciate if you could help me out.

I attached a clean version of the skin shader and Evolved's NM shader.

Thanks !

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2007 02:19
@Benji

Just downloaded and tested your demo. I see what you mean - there's obviously a big problem with it. My immediate thought is that it's an object/camera/culling/positioning issue - but won't know for sure till I delve into the code.

I had similar problems with some of my full-screen shaders with U6.6b - but this was because Lee re-instated some earlier object culling functionality. Once I realised that was the problem the solution was easy. Could be a similar problem here - depends which upgrade the demo was built with.

I'll get back as soon as I've done some checks.

[But EVOLVED probably already knows the answer. ]
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 8th Jun 2007 03:30
I love the speed of your normal mapping shader, but i run into a problem, just look at my included screenshot. the object has zero normal mapping on the side that faces the light, and blotches of light on the sade facing away, kinda weird looking.

I do like the progress though, sorry i cant be satisfied, not your fault. Wouldnt blame you if you left it the way it is.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2007 20:27
Quote: "but i run into a problem, just look at my included screenshot"


That's what I meant when I said there was a problem with the shader. The cube in the demo shows the same problem if you wait for the correct face to be displayed - not quite sure what the cause is for the moment. I've had similar problems, though not so obvious, with other shaders. I'll have another look at the DarkShader demos to see if they have the same problem.

In my original PS2 bumpmapping shaders I included some extra code to stop backfaces getting light - I didn't include that here because of the instruction count limits. However there is a bit of slack in the first pass so I might be able to do something about it.

Thanks for the feedback.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 8th Jun 2007 21:56
yeah, no problems. I will probably just stick to the one in the shader pack for now. Although this one is nice, just needs more work.

Thanks for your help though.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2007 22:34
Indecom

See if this revised version is any better. It still has the problem of light showing on the back of the object - but the other problem should be solved now. Let me know how you get on.

Attachments

Login to view attachments
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 8th Jun 2007 23:59 Edited at: 9th Jun 2007 00:02
It is much better, as you can see in the screenshot. I have a question though, does this only work faceted like in my screenshot, or is it my model thats not smooth blended?

Its getting much better though. I am sure that by the time this is finalized, it will be a great asset to the lower ended community.

Also, i am curious, currently your specularity is based on a single value, would it be possible to , from withing dbpro, do a render of the specular alone and a render of the model with only the spec map applied and subtract that from the specularity render, to give the illusion of specular occlusion?

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2007 00:33
Quote: "It is much better, as you can see in the screenshot. "


Good, looks like we're making progress. You have Paul Johnston to thank for that - he pointed out a feature of PS1.3 TEXCOORD variables that I had overlooked.

I don't think the faceting has anything to do with the shader - it's more likely to be something to do with the normals of your object. Can you print them out for one of the facets?

Quote: "currently your specularity is based on a single value"


It's made up of two components: the specular level and the specular colour as in the following line of the FX file:



The specular level is a float which is calculated from the amount of reflection of the light source from the surface.

The specular colour can be any colour you choose in DBP. At the moment that's just various shades of grey as in the following lines of the dba demo file:



If you wanted the specular reflection to be green you could just use:



Specular reflection is not satisfactorily handled in the present version of the shader - but your suggestion of doing a separate render for specular level alone might be the answer. There would probably be a serious performance hit but it's certainly worth a try. That approach would free up some instruction slots and enable me to improve the specular reflection. I'll give it a go as soon as I can.

Quote: "and subtract that from the specularity render, to give the illusion of specular occlusion"


Not sure what you mean by this.

[By the way, I'm quite happy doing this. It's a good way of getting to grips with PS1.3 which I haven't used before. Fortunately, most of the relevant shader code is much the same.]
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 9th Jun 2007 00:44 Edited at: 9th Jun 2007 00:44
Okay, cools.

what i meant by specular occlusion is that you have your render of the object specularity alone, then you have a render of the same object from the same viewpoint at the same location with no lighting, and with the specularity map as its texture rendered to another texture. You take the spec mapped render and subtract that from the specular render and you should end up with what looks like an object that has specularity based on the specularity map, similar to what is attached, all done using only dbpro code.

(ps, the attached image is sloppy, did in like, 30 seconds, just to give an idea of what i mean.)

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2007 01:26
Thanks for that picture - I think it explained exactly what you want. But it isn't subtraction - because white subtracted from white would give you black. I think you mean "multiplied by" or "blended".

If I've understood you correctly, the idea is to have two maps - a normal map for bumpiness and a specular map for shinyness. The latter would then be combined with my specular calculation to give the final specular result. To do that in PS1.3 I think you definitely need a separate render to image which is then combined with the specular map in a separate render of the scene.

Quote: "all done using only dbpro code."


Not sure how you could do that without using a shader to do the normal mapping etc - or are you just referring to the final maps which can just be blended together (incidentally my experiments with this in a different context suggest the shader is just as fast ).


It's a very interesting idea - I'll definitely give it a go but not tonight.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 9th Jun 2007 01:51
yeah, when ever, i am still learning dbpro myself. i had the classic, so this is pretty similar. But yeah, use the shader for the normals and specular then blend them somehow with the seperate specmap render.

I would try myself, but i am still learning the ropes.
Benji
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: Mount Doom
Posted: 10th Jun 2007 00:29
@ Green Gandalf

Thanks for testing it. At least I know it's not my graphics card.

And yeah, whenever you can try to fix the shader would be great.

...

Login to post a reply

Server time is: 2024-11-24 21:25:19
Your offset time is: 2024-11-24 21:25:19