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
EVOLVED
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: unknown
Posted: 16th Dec 2006 18:35
Quote: "I don't suppose you know of a way to remove a shader from an object do you?"


"set object effect obj,0" should work, the "set shading off" command dosnt seem to effect shaders.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 16th Dec 2006 18:57
Hey Evolved do you know how to zsort an object's vertexes, so they get passed to the shader from back to front?

This is for doing alpha right.

They need to be rendered back to front.

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Dec 2006 19:17
Quote: ""set object effect obj,0" should work"


Looks worth a test - now try finding that in the Help files...

Cheers EVOLVED!

Quote: "i.e set alpha in DBp at 50 = 0.5 in the shader"


I did wonder at that bit of the code.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 16th Dec 2006 22:28
Nevermind I managed to do it in the end.

Should have some nice videos to show by tomorrow night (depends how hellish Christmas shopping is)

-= Out here in the fields, I fight for my meals =-
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Dec 2006 11:45 Edited at: 17th Dec 2006 11:48
Turning off shaders is still proving to be a little irksome!

If I apply the Vertex Fur shader and turn it off using SET OBJECT EFFECT OBJ, 0 it will be removed. So far, so good. Now if I try to apply SET SPHERE MAPPING ON I get nothing. I can re-apply the fur shader but not sphere mapping.

I have taken Evolved's Vertex Fur shader demo and changed the code a little to demonstrate what I am talking about:



Press F to turn on the Fur shader
Press S to turn on sphere mapping
Press R to turn off shaders

Try this:
1. Turn on the fur shader(F), then remove it(R). Now reapply it (F). That seems to work.

2. Having done step 1. Now try to turn on Sphere mapping(S). It does nothing for me.

3. Stop the program and re-run it.

4. Turn on sphere mapping(S), this time it should work. Now remove it(R). For me it stay applied but becomes much brighter.

5. Apply Fur shader(F). That works fine. Remove it(R) and apply sphere map again(S) ... nothing!

It seems that neither of the two possible commands to remove shaders is doing it completey. The code tries to remove the shader with both the SET OBJECT EFFECT obj, 0 and the SET SHADING OFF obj commands but still nothing.

Any ideas? I really need to be able to swap shaders on objects.

Thanks

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Dec 2006 12:34
Quote: "Any ideas? I really need to be able to swap shaders on objects."


Why? Is there a reason why you don't keep multiple copies of your objects - in the same positions and rotating exactly the same way some with shaders, some without, etc. Then just show the ones you want on screen and hide the others at any given moment. That works for me.

I agree, though, that a clean swapping of the shaders would be nice.

Another solution (which I have used) is to put your shaders as different techniques in a single shader - and then just use "set effect technique" to swap the techniques. You generally need to have separate vertex and pixel shader code for each technique, e.g. "VShader1(VSInput1...etc)" and "VShader2(VSInput2...etc)" - although you can often re-use code. I can get a simple example for you tomorrow (Monday) but I'm sure you can fill in the details yourself.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Dec 2006 12:41 Edited at: 17th Dec 2006 12:42
Quote: "Why? Is there a reason why you don't keep multiple copies of your objects - in the same positions and rotating exactly the same way some with shaders, some without, etc. Then just show the ones you want on screen and hide the others at any given moment."


Yes there is a reason.

It is the method I have been employing but with 200 objects and 13 (at the moment) different shaders that makes 2600 objects that all need to be available at any one time. I know that my machine can handle that without any problems but I am trying to optimize everything so that it will run on even the lowest spec machine. So, if I can simply change an objects shader from one to another I am sure that will go a long way towards improving performance.

As for your second option of using multiple techniques, that sounds like a plausible work-around. The trouble is, I am making extensive use of the in-built sphere mapping and I don't know of an external sphere mapper. Nor do I know how to go about making one.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Dec 2006 12:51
Quote: "So, if I can simply change an objects shader from one to another I am sure that will go a long way towards improving performance."


Agreed.

Quote: "The trouble is, I am making extensive use of the in-built sphere mapping and I don't know of an external sphere mapper. Nor do I know how to go about making one."


Hmm. Can't remember off-hand what that does exactly - but a shader solution certainly ought to be possible. Is the reflection shader I posted a few weeks ago on this thread up to the task? No time to look into this now - and it'll probably have to join the queue. But I'm sure a "simple" solution is possible.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Dec 2006 13:39
I hadn't seen you reflection shader before. I have just found it now and I must say it looks great. It's almost cube mapping but without the six additional cameras. I found you fire shader too ... very nice.

Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 17th Dec 2006 21:01
You should just be able to call set object effect with a different shader number to switch shaders...

Then you just need one other copy which has the sphere mapping on...

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Dec 2006 23:20
Quote: "You should just be able to call set object effect with a different shader number to switch shaders"


Why didn't I suggest that? (Haven't tried it either, though. )

Quote: "The code tries to remove the shader with both the SET OBJECT EFFECT obj, 0 and the SET SHADING OFF obj commands but still nothing"


Strange. I've been using precisely the first of those two commands without trouble this evening - it restores standard texturing.

[More strangely, I'm sure I posted a reply similar to this earlier this evening - but I can't see it now. ]
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 18th Dec 2006 23:58
You would think that it would work but try the code a few posts up and you will see that it doesn't

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Dec 2006 16:54
@Scraggle

Do you mean this:



Will check your code when I get home. But just a thought for now. Your code contains the following:



Is that correct? In one line you are texturing object number 1, in the next line you are setting an effect on object number "object" - but "object" can presumably take other values.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 19th Dec 2006 17:13
yeah ... sorry that was a hangover from a previous attempt. I'm sure you can see how it is supposed to be

Slayer_2
17
Years of Service
User Offline
Joined: 18th Sep 2006
Location: Anywhere I feel like
Posted: 22nd Dec 2006 01:38
does this work in fpsc?

Elite OPS Terrorstrike a modern shooter check it out below

http://eliteops.piczo.com/?cr=6&rfm=y
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Dec 2006 10:58
Quote: "does this work in fpsc?"


No idea. What is "this"?
Slayer_2
17
Years of Service
User Offline
Joined: 18th Sep 2006
Location: Anywhere I feel like
Posted: 22nd Dec 2006 19:25
"<--- that means a quote if that is what you mean

Elite OPS Terrorstrike a modern shooter check it out below

http://eliteops.piczo.com/?cr=6&rfm=y
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Dec 2006 20:21
Quote: ""<--- that means a quote if that is what you mean
"


??

Quote: "You cannot be serious."


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Dec 2006 23:26 Edited at: 24th Dec 2006 18:09
@Peter H

Quote: "If you could work in the default (light 0) directional light, or just have it so you pass the shader a light position, that would be perfect. (whichever is easier)"


OK, here it is. It uses a single directional light source plus ambient light. You have to pass the light direction and light colour to the shader in the usual way.

Let me know if you need further explanations or instructions, or encounter any problems.

Edit: see my 24 December post for the latest version.
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 24th Dec 2006 00:07
thank you!

that does give them lighting, however, it's a lot harsher than the default light... so you end up with one side of the hog whitish, and the other pitch black... I fiddled around with the ambient colour in the shader code and the light colour (like 0.5, 0.5, 0.5) but either had to settle for almost all white, all black, or one side black and one side white (with some brown in the middle)

If you can't make it less harsh, that's ok... (i'll probably just go for no lighting on them in that case)

thank you though!

One man, one lawnmower, plenty of angry groundhogs.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Dec 2006 00:29 Edited at: 24th Dec 2006 00:34
Strange. Can you post some simple code and media which illustrates the problem so I can see for myself? I might then be able to see what the problem is and fix it.

Edit: Just a thought. Did you normalize the input light direction that you passed to the shader (the shader assumes it's been normalized)? If that's the problem I could add a line to the shader code - but it will be faster to do it in DBP.
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 24th Dec 2006 00:42 Edited at: 24th Dec 2006 00:43
sure! here's an example

the one on the left has no lighting
the one in the middle has the shader
the one on the right has default lighting

it assumes you have DBPro heh

One man, one lawnmower, plenty of angry groundhogs.

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: 24th Dec 2006 01:33 Edited at: 24th Dec 2006 18:05
Thanks. Just realised I didn't think through the ambient and diffuse lighting properly. Will sort it out tomorrow. In the meantime, don't forget you need to pass the light direction as well to compare with the default lighting - I think the default direction is straight down, i.e. (0, -1, 0). You need to add an extra value at the end to make up the vector4.

Edit: Here's the corrected version Hope it's OK. I include a demo program and media. The demo allows you to change the ambient level and the brightness of the glow. You can add extra code to the demo to change the default directional light direction and colour - the demo just uses the defaults set in the shader.

Have a good Xmas.

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Dec 2006 22:09
I have managed to get Green Gandalf's Fire shader into my game. The only downside to it is that there could potentially be around 50 objects all with the fire shader applied and whilst they look good, they are let down by the fact that they are all showing the same animation frame and 'blowing' in the same direction.

I want each object to display a different frame and for the fire to 'blow' against the direction of the objects movement.
The only way I can think of to achieve my objective is to load in a different shader for each object. That way I could certainly control the direction of the fire, still not sure about the animation frame though.

So, to save me creating 50 different copies of the shader and applying them to different objects, does anyone know if:
a) Creating different shaders for each object will allow me to have a different animation frame for each object?
b) Will doing so have an adverse affect on frame rate?
c) Is there a different (better) way to acheive my goal without having to create 50 shader files?

Thanks

Here is the fire in action:



Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Dec 2006 00:34
Quote: "I have managed to get Green Gandalf's Fire shader into my game."


Glad to see it in action.

Quote: "I want each object to display a different frame and for the fire to 'blow' against the direction of the objects movement.
The only way I can think of to achieve my objective is to load in a different shader for each object. That way I could certainly control the direction of the fire, still not sure about the animation frame though."


Yes, I think you need to load 50 copies of the same effect (do you really need 50?) and set the effect constants "scroll" and/or "perturb" for each one. That won't deal with the timing issue though (although differing "perturb" values might help). The best solution though is to add another tweakable effect constant, "offset" say, into the shader code, e.g. replace:



with



Then replace the following:



with



You would then just give different values for "offset" for each of the 50 effects. You might still notice that the 50 copies had the same time base.

I haven't tried the above so the suggestions come with a health warning.

And I don't know off hand what the fps implication would be - the DBP Help files suggest there would be a price to pay.

There are other solutions.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Dec 2006 15:38 Edited at: 30th Dec 2006 16:23
@Scraggle

I've just completed some experimenting with my fire effect shader and it seems that loading many copies of the effect and applying them to different objects does NOT have an obvious effect on performance. This means you should be able to change the "wind direction" easily by just using many copies of the effect.

To change the animation offsets you can use the method I suggested yesterday - or use the method illustrated in the attached demo file (see the new effect version "GGFire v2.fx"). In that new version I illustrate a way of passing different data to different objects - but using a single copy of the shader. The idea is to code your data as an image and apply the image as an extra texture stage. I have done that in the demo. However, since there seems to be no loss of performance with using several (even 50!) copies of the effect you will probably get better performance using the method I suggested yesterday (the extra texture look-up used in "GGFire v2.fx" comes at a price).

For the record, on my machine I get the following FPS rates with the attached demo:

1. one copy of original effect applied to many objects: 26-32.
2. one copy of revised effect applied to many objects: 24-27.
3. separate copies of original effect applied to objects: 26-32.
4. separate copies of revised effect applied to objects: 24-27.

And I still haven't tested the suggestion I made yesterday ...

Edit: corrected silly typo in demo program.

P.S. I sometimes get the images breaking up with lines on them when I move the mouse. Does anyone else see that? Not sure what the problem is yet.

2nd Edit: The problem was a zwrite problem - now disabled zwrite in the shaders (may need to remove that in some applications).

Attachments

Login to view attachments
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th Dec 2006 19:12
Thank you once again!

I had a quick play with the first option but my code exits silently when the shader is used. I haven't tried the second option yet and probably won't get chance until tomorrow when the little woman is at work.

I will let you know how it goes when I get chance to try it.

Thank you

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Dec 2006 22:54 Edited at: 30th Dec 2006 23:28
Which was "the first option" exactly? The one I didn't test? Just in case it was, I'll test it now.

Edit: OK, I've tested it now (with a small improvement) and it should be the solution to your problems. It is option 5 in the attached demo and the fx file is "GGFire v3.fx". It runs as fast as the original version whether or not I use multiple copies of the effect (on my machine anyway). Any problems just ask.

Attachments

Login to view attachments
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 2nd Jan 2007 15:45
whoa! i missed that you had updated the glow shader!

thanks for all your help, it looks great now



One man, one lawnmower, plenty of angry groundhogs.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jan 2007 17:24
Glad you like it. The hogs look good too.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 3rd Jan 2007 19:46
@Green Gandalf

Apologies for the late reply but I have only just had time to try your latest revision of the fire shader. I have inserted version 3 into my code and everything is working beautifully. Thank you once again

valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 4th Jan 2007 13:28
is it possible to get this shader to work?



I have tried converting it using the ultimate shader thread method and it still just shows white. What is the VIEWPORTPIXELSIZE semantic? Here is my code in db trying to convert it...



It is the fireball shader that comes with nvidia fx sdk thing. I have included the texture it ask for.

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: 5th Jan 2007 11:24
valleyman86

That shader uses a procedural texture, i.e. a texture which is generated using a function in the shader code itself. The texture would be set up when the effect is first applied - but unfortunately DBPro doesn't support such textures yet.

Procedural textures are often used with noise functions to generate things like wood, fire, clouds, etc. At the moment the code would need to be re-written to either use a pre-prepared noise texture (the faster option) or to do the noise calculations in the pixel shader. The fire shader I posted a couple of days ago uses a pre-prepared noise texture - but that is only a 2D noise texture whereas the shader you've quoted requires a 3D noise texture. The shader could be re-written to work with the 2D texture but it probably won't be so impressive. One of the long-standing projects on my list is to write some code to produce a 3D version of my 2D noise texture (but decent 3D textures tend to be big).

I think either FX Composer or RenderMonkey comes with a sample 3D noise texture but I haven't got it here. I'll try to remember to look for it when I get home on Sunday.

If I can find a more constructive suggestion I'll post back.
valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 5th Jan 2007 13:02
Well thats nice to know lol. Thanks a lot. So if I make it a 2d noise texture then it should work. I actually don't care I just want a cool fireball effect and this one looked good.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jan 2007 20:23
Quote: "So if I make it a 2d noise texture then it should work"


No. You'll need to make several other changes to the code first.
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 6th Jan 2007 02:29
I was wondering if you might be able to create or guide me in the correct direction to creating a couple of shaders. One that would look like magma and one that gave off a reflection similar to that of ice.


valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 6th Jan 2007 04:00
hmm darkbasic makes this so hard. You have to edit alot to get them to work. Im not sure how I figure out what darkbasic supports and what it does not. I have that tutorial. If I go and change everything like he does then change the texture would it work. Also what is wrong with vector3. I tried using it and when I try to access it I get a "does not exist" error. If I replace the vector3 with vector4 it works fine. Is there another way like using arrays?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jan 2007 12:33
Quote: "I was wondering if you might be able to create or guide me in the correct direction to creating a couple of shaders. One that would look like magma and one that gave off a reflection similar to that of ice."


I think RenderMonkey (which you can download for free) has all sorts of fire effect shaders (lava, fire, explosions, etc). Unfortunately they need to be modified for use in DBP - and the changes are not obvious unless you are used to writing shaders. I have a lava style shader that works in DBPro available at home so I'll look that out for you when I get back (next week some time).

I don't have any ideas about ice like reflection shaders for the moment.

Quote: "I have that tutorial. If I go and change everything like he does then change the texture would it work. Also what is wrong with vector3."


What tutorial are you talking about? I don't think there's anything wrong with vector3. Can you give the code to show us what you're doing? If you're referring to the vectors needed for passing vector constants to shaders I think they need to be vector4 (will check when I get home if you haven't sorted it out by then).

Quote: "If I replace the vector3 with vector4 it works fine."


Sounds like that's what you should be doing.
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 7th Jan 2007 01:31
Quote: "I have a lava style shader that works in DBPro available at home so I'll look that out for you when I get back (next week some time)."


OK That sounds cool. I really have no experience with shaders at all. I plan to learn eventually, but for now I need to work on my actual game. If you can thing of something for ice that'd be great, but I might just use the snow shader that comes in the ultimate shader pack.


headcrab 53
18
Years of Service
User Offline
Joined: 14th Jul 2005
Location:
Posted: 7th Jan 2007 02:29
@ Green Gandalf

Just wondering, what is the order of everyone you are going to help? The "queue" as you called it.

valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 7th Jan 2007 04:31
Well its a float3 in the shader using 3 inputs. That would be a vector3 correct. Vector4 is for 4inputs. And just take my code up there and instead of vector4 use vector3 (where it should be of course).

EX:
null = make vector4(4)
set vector4 4, 0, 0.01, 0, 0
set effect constant vector 1,"timeScale", 4

should be a vector3 but I get an error on the set effect constant command.

This is the tutorial i was talking about
http://forum.thegamecreators.com/?m=forum_view&t=49137&b=1
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2007 00:53
valleyman86

In shaders vectors can be float2, float3 or float4 - but in each case DBP has to pass a vector4. The extra entries are required by DBP but are just ignored by the shader - the shader just uses the first two, three or four components of the vector as appropriate.

A similar issue may arise with matrices - but I haven't used the DBP set effect constant matrix command so I can't advise you further on that yet.

headcrab 53

Quote: "Just wondering, what is the order of everyone you are going to help? The "queue" as you called it."


That is a very good question and I'm afraid I've been indulging myself over the Xmas/New Year period by concentrating on easy queries or queries that I found particularly interesting. I do this for fun too you know.

However, perhaps now is a good time to resurrect the "queue" and see who's still waiting. I'm finished for the day and will return to this tomorrow.
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 8th Jan 2007 04:55
@Green Gandalf

so far we are coming along nicely however there is something I could use your help with.
I'm still using the normal map shader you edited for me last time. My question is, how do I go about adding another texture stage, namely an alpha channel ? I have attached the shader so you can take a look at it when you find the time.
Thanks a lot.

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 Jan 2007 23:21 Edited at: 8th Jan 2007 23:57
OK. Time for an overdue update on that "queue". Looks like I wrote the following on 8th December (how time flies when you're enjoying yourself):

Quote: "So, new list is:

1. Terrorist Zero.
2. Irradic.
3. Seppuku Arts.
4. headcrab 53.
"


Terrorist Zero's query was finally solved thanks to Evolved.

Irradic seems to be making progress on his own but has a new query (see brief reply below).

I don't think Seppuku Arts or headcrab 32 have had any real help from me.

Various people, e.g Peter H and Scraggle have had some help in the interim - and I've promised to dig out a lava shader for Antidote (I'll look for one in a minute and edit this post if I find it).[Edit - see end of this post.]

Looks like I'd better see what I can do for Seppuku Arts and headcrab 32 after this.

@Irradic

A few quick comments for now. You asked:

Quote: "My question is, how do I go about adding another texture stage, namely an alpha channel ?"


At least two ways.

One method is to just add an alpha component to one of the existing textures (I use Paint DxTex.exe for that - if it's a simple alpha map) and modify the shader's code to use the alpha component (and that can be done in more than one way).

Another way is to just add an additional texture stage as you suggest. You would need to texture the object in the usual way in DBP, e.g. something like:


and then just add a new stage



In the shader you would add something like



after the other texture declarations. You will also need some code to read from the texture and to do something with it. I haven't got time to check now but there may be a limit of 4 or 8 textures that you can access in the shader. If you are already using 4 then you may have to use the first method. If you are using essentially greyscale light or alpha maps, etc, then these can be combined into a single texture by using "red" for the first map, "green" for the second, and so on (you can have up to 4 maps per texture that way). These would then be picked out in the shader and used appropriately.

Edit: Found the lava shader - you've got two for the price of one plus two demo programs

The best one is "GGLava05.fx" which uses a lava image supplied by Lee (you'll need to check with him to see if you can use that) - but the demo program "GG lava FX test.dbpro" uses a different lava image (I've included several for you to play with - and you can use your own, but it will need to be a "seamless" image). Let me know how you get on with these. The zip file is a bit big I'm afraid.

Attachments

Login to view attachments
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 9th Jan 2007 00:23 Edited at: 9th Jan 2007 00:24
yep, you've completely solved all my shader problems, thank you tons!

One man, one lawnmower, plenty of angry groundhogs.
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 9th Jan 2007 02:12 Edited at: 9th Jan 2007 02:38
Hey thanks for the lava shader. That'll be a big help! If you can find some kind of ice shader just let me know, until then help everyone else that you can.

[Edit] Just to be sure, I do have your permission to use the effect with the lava images you made correct?

[Edit^2] OK the shader is nice, but it seems to cause the framerate to rapidly decrease. I've put the shader on some lava bullets and the fps will start fine at just above 60. As I continue to shoot more bullets the fps will drop, but then once I stop shooting and the bullets are deleted the fps does not go back up. Why is this? And how can I fix it? My guess is that it has something to do with the way the object is deleted and it not getting rid of the shader or something.


valleyman86
17
Years of Service
User Offline
Joined: 15th Dec 2006
Location:
Posted: 9th Jan 2007 02:39
can I see the lava shader? I would like some kind of fire shader, water shader, and green shader. These can be the same shader just different colors. It does not have to be fire it can be a wavy look that goes over a pretextured model to make it look magical maybe. If you could put me on your list that would be great. Thanks.
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 9th Jan 2007 05:41
@Green Gandalf

Thanks a lot for the reply. The shader currently has 3 stages, base, normal map and a specular map. I find your first method interesting, adding an alpha component to an existing texture.
The base texture would have to be used for this since the normal map textures are using an alpha channel to control the specular strength\level. But I have no idea about the changes that I would have to make in the shader.
Thanks for our time ! cheers

Btw, I can't recall whose project it was but I saw someone using Evolveds shader together with a bloom\glow effect.
Was it coded into the original shader ? Or was an additional extra shader used ? I would be really thankful for some infos on that matter. Thanks !
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jan 2007 16:26
headcrab 32

Just been looking back in the posts and it seems you should probably get help next since Seppuku Arts had some help (not sure whether his queries were finally sorted out though).

Some time back you asked:

Quote: "How could I change one of the lights to a spot light in 3 of Evolved's 4 Lighting Shaders from the Ultimate Shader Pack? ((2) Normal Mapping SM1.4, (3) Normal Mapping SM2.0, and (4) Parallax Mapping SM2.0)"


Is that still your query? If so, I'll look at that next. I haven't got the code here to check - are those shaders the ones for up to 8 lights with several techniques? It might simplify matters a bit if you only need a few lights altogether. What do you need exactly? (Bear in mind that it is probably better to use lightmapping where possible for things like fixed lights.)
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jan 2007 16:48 Edited at: 10th Jan 2007 00:59
Antidote

Quote: "I do have your permission to use the effect with the lava images you made correct?"


Yes - but you need to know which images I made. I'll edit this post later with the details. You're all free to use any images or shaders that I created at the moment. An acknowledgement is all I ask.

[Edit: in that lava demo for Antidote both fx files and the seven png files were mine (and hence free for you to use). The other image files I'm not so sure. I think lava1.bmp and mud1.bmp came with DBP, lava_D.dds is a file Lee Bamber posted with a lava query of his some time ago and you'll have to check with him).]

Quote: "As I continue to shoot more bullets the fps will drop, but then once I stop shooting and the bullets are deleted the fps does not go back up. Why is this? And how can I fix it? My guess is that it has something to do with the way the object is deleted and it not getting rid of the shader or something."


Off-hand I don't know. It is possible it is a result of the object deletion problem rather than the shader. What happens to the fps when you just use textured bullets in the usual way? It is usually far better to re-use objects which are used for something like bullets - e.g. decide the max number you are likely to use in your scene at once and create them once at the beginning. Then use show/hide object as required.

valleyman86

Quote: "can I see the lava shader? I would like some kind of fire shader"


The lava shaders plus demos were posted a few posts back. I posted a fire shader earlier in this thread and also a revised one for Scraggle several posts back.

Irradic

Quote: "The shader currently has 3 stages, base, normal map and a specular map. I find your first method interesting, adding an alpha component to an existing texture."


Ok, I'll see what I can come up with - but don't expect instant results. I might be tied up with headcrab 32's query which looks messy. Have you got suitable media that I can use for testing, including an alpha map? I'll try to add it to the base texture. If it works I'll let you know the details.

Seppuku Arts

Did you get your shader queries sorted out?

Login to post a reply

Server time is: 2024-03-19 07:39:42
Your offset time is: 2024-03-19 07:39:42