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
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 19th Oct 2006 00:06 Edited at: 29th Jul 2007 17:09
USE THIS THREAD TO POST ANY QUESTIONS ABOUT SHADERS

---------------------
-------------------------

This thread was originally started at the beginning of the nVidia competition, when we learnt that it would be marked heavily on use of shaders, and everyone realised they didn't have a clue how to write or use them.

Over the course of the competition, many of the community took the plunge and came up with a fairly decent knowledge of how to write shaders for use in DBPro.

This thread, therefore is fairly invaluable to anyway wanting gorgeous graphics in their game, hence its new home, at the top of the DBPro board.

It is probably the best place to ask questions if you are trying to learn - currently there is a fairly good tradition that people who have been helped to learn have stuck around to help others, it would be awesome if that could continue.

Enjoy!

-------------------------
---------------------


UPDATE.
-----------------
Some helpful info from GG on where to find good docs:
***************************************************
Three that I've found useful are:

1. "Programming Vertex and Pixel Shaders" by Wolfgang Engel. [He has written several other books that I haven't seen and has a website with a few tutorials.]

2. "Shaders for Game Programmers and Artists" by Sebastien St-Laurent.

3. "Microsoft DirectX9 Programmable Graphics Pipeline" by Kris Gray. [As is usual with Microsoft this book was better at convincing me that there was a lot I didn't know than actually telling me something I wanted to know. But it did explain some things I hadn't appreciated before.]

All three books come with CD demos, etc, but I haven't seen the CD for book 3 (it's a library copy and the CD has sprouted legs).

I particularly like the first two books and their demos. But I find "RenderMonkey", which I think both books use, a nightmare to use. However, RenderMonkey has some nice FX demos and, if you have the patience, you can rewrite the FX files for use in DBP.

FX Composer is a free shader resource which you might find useful.

I've also found some useful, but limited, HLSL tutorials using Google.
***************************************************************

Original Post:

OK, so I guess a lot of people are going to be in a position like me, where they really need/want to learn to write shaders for this competition.

I know there's going to be a tutorial in the next newsletter, but I guess that's going to be more getting them to work with DBPro than how to actually write them.

So any advice from anyone as to what tutorials to read?
Absolute beginner we're talking here.

I've got Render Monkey and I know C++ (the shader language is basically C isn't it?)

-= Out here in the fields, I fight for my meals =-
Image All
11
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 19th Oct 2006 03:05
I think shaders are made in Ye Olde Assembley >.> of which I know nothing about, thus I can't realy help much

WarGoat
12
Years of Service
User Offline
Joined: 19th Sep 2004
Location: Montreal
Posted: 19th Oct 2006 03:49
They can be written in C++, I think. Or you can use RenderMonkey or the NVIDIA Shader composer.


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Lukas W
13
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 19th Oct 2006 08:57
you can try this tutorial: http://vvvv.org/tiki-index.php?page=pixelshader_for_newbies
i may have a closer look at shader programming too. though at the moment Evolveds shaders and the DBPro Shadow shader is good enough for me.

Raven
12
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 19th Oct 2006 09:32
I'll try to explain them here a bit as tbh there aren't many decent online tutorials.

Alright we.. firstly I'd suggest using FX Composer for Shaders.
It fully supports any DirectX Shader Card, Shader Model 1.x / 2.x / 3.0 as well as supporting Software 1.1.
When you add to that functionality the ability to load, link and/or use up to 255 Shaders at any given time with a visual thumbnail of what they do and an option of adding them either as a Screen or Object Effect, then you have a fairly powerful tool.
You can also preview real-time, recompile quickly, change variables on-the-fly, view current samplers loaded / output.
Along with the main C-Style Coding Window.

All of which is customisable to your own preference. So you have a fairly powerful creation utility at your disposal. However another good point is that it provided help information on DXSAS1.0 Compliancy, something DBP now has meaning shaders theoretically can be used without any editing as well as exporting to be compatible with Ashli (so you can load/use in Maya/Max/XSI for model development means)

On the whole it makes shader development a damn sight easier, especially from a coding point of view.

Now I think I'll cover what DBP doesn't support.
Inline Functions : Useful technique used for creating samplers each time the function is called. While there is a way to do this, it is only supported by outputting the Shader as ASM, but DBP HLSL doesn't support this yet. To output ASM from FXComposer then click on Shader Perf and select your card.. Your card MUST support shaders to use Shader Perf. So those of you using it in Software 1.1 mode (like I am right now you can't access it).

Scripting : This can be useful for having shaders run slightly differently based on what is going on as well as controlling the function order better. Can increase performance and functionality under the right circumstances, but DBP doesn't support this and don't see why it ever will tbh as for most games it's pointless.

Shader 3 : Technically yes this is supported, but only the most basic implimentations that can revert back to 2.0.. so don't even bother using it. Again this is a feature that can be used with the ASM shaders, but the complexity of sorting out SM3 in ASM is honestly not worth the benifits over 2.0 HLSL. Only use that as a last resort.

There's a number of other things to look out for when making shaders for DBP, but I don't have a lot of time right now to explain them all. Mostly it's semantic stuff.

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 19th Oct 2006 20:31
Cheers everyone.

Raven's sold me FX Composer, I'll download it.

It sounds basically the same as Render Monkey but maybe a bit better.

-= Out here in the fields, I fight for my meals =-
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 19th Oct 2006 22:13
@Chris K

Yes, I agree with virtually everything Raven said, FX Composer is very good - definitely worth the wait while it downloads from NVIDIA. Also, it's MUCH easier to use than RenderMonkey (except that you have to write all the code yourself, but on the other hand, the shaders you will want here will be quite short really). Also, the FX files exported by RenderMonkey usually need editing before they work in DBP - but RenderMonkey does have some nice examples which you can adapt.

If you have questions, post them here and someone will probably help you. I will certainly try to help if I can. I think you get points for discussing your work here - so keep the questions coming.
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 19th Oct 2006 23:04 Edited at: 19th Oct 2006 23:05
Awesome.

There are some RenderMonkey example that I'm determined, eventually, to get into DBPro, but I'll be ecstatic to get anything that I've written working.

-------

I know what you mean about the wait. 11kb/s? What is this 2001?

-= Out here in the fields, I fight for my meals =-
WarGoat
12
Years of Service
User Offline
Joined: 19th Sep 2004
Location: Montreal
Posted: 19th Oct 2006 23:59
does the sample shader that are already here are 100% royalitie free?


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 20th Oct 2006 00:59
Those that I've posted on the main DBP board and the WIP/Ultimate Shader Pack certainly are - and I think most, if not all, in the Ultimate Shader Pack are too (but you'll have to check).
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 20th Oct 2006 21:33
Does a shader loaded into DBPro do anything for you?

For example, would it automatically set view_projection_matrix or whatever, to the right value, or do you essentially set all the shader's variables yourself?

-= Out here in the fields, I fight for my meals =-
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 20th Oct 2006 23:54
Quote: "For example, would it automatically set view_projection_matrix or whatever, to the right value, or do you essentially set all the shader's variables yourself?"


DBP passes various variables to the shader such as the worldviewprojection matrix and cameraposition as in the following snippet from one of my bump mapping shaders (see attached file for the complete code):

+ Code Snippet

I'm not sure what the complete list of such variables is. That's the sort of information that is hard to find.

One thing to note is that shaders produced in RenderMonkey often refer to the viewprojection matrix rather than the worldviewprojection matrix. You usually need the latter for use in DBP (and FX composer). There will be some other related changes as well.

The following variables, taken from the same shader, are variables you would usually want to vary in your DBP program:

+ Code Snippet

The values given are just default values used by the shader.

To change those values in DBP you would use commands such as set effect constant vector and set effect constant float.

Hope this helps.

Attachments

Login to view attachments
dab
12
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: You Temp Folder!
Posted: 21st Oct 2006 03:56 Edited at: 21st Oct 2006 03:59
Where are the shaders located?
Edit: The Download That is. I can't seem to find it in any of the Ultimate Shader Threads.

Edit2: Found it.
http://forum.thegamecreators.com/?m=forum_view&t=79849&b=8 (Thread)
http://cordierfr.free.fr/UltimateShaderPack1.0finale.zip (Shaders)

Uhh. I'm too lazy to fill this in right now. When I get the nvidia game further into working, I'll add a post to it.
WarGoat
12
Years of Service
User Offline
Joined: 19th Sep 2004
Location: Montreal
Posted: 21st Oct 2006 04:41
How can I have the fire sahder from the fx composer shader gallery. They say that the sample come with fx composer but there is no sample at all.


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Michael S
11
Years of Service
User Offline
Joined: 2nd Apr 2006
Location: Why do you ask?
Posted: 21st Oct 2006 04:52
What are shaders?

Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Oct 2006 12:57 Edited at: 21st Oct 2006 13:11
Basically a tiny little program that runs on an individual pixel (or vertex), to produce an effect.

They are written in a language specifically designed for GPU hardware, so they are incredibly fast at doing things that would take a long time on a CPU.

-----------

Thanks GG, helped a lot.

-= Out here in the fields, I fight for my meals =-
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Oct 2006 16:43 Edited at: 21st Oct 2006 16:47
In the Fresnel Water shader, what does the clipping do (set camera clip)? It appears to do nothing, is it just an optimisation?

-------

Oh wait I get it now.
It's so refraction camera only sees stuff below the water, and the reflection only sees stuff above the water.

-= Out here in the fields, I fight for my meals =-
Raven
12
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Oct 2006 17:00
Probably just an attempt at optimisation, as shaders work based on the screen-size. The smaller, the better they perform.

I mean you're no doubt going to expect more 3D work at 1280x720 than you would at 640x480, however let's say you have a normal mapped plane in the center of the screen that takes up 100x100px

With a 3D Texture, all it would do would be to stretch it across the surface meaning you end up with a blurred 1:1 at the higher resolution. A shader however will work in the additional pixel space making the normal mapping much better, and you'd end up with a 1:1 at 640x480 and 2:1.3 at 1280x720
Hopefully that makes sense.

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Oct 2006 17:36 Edited at: 21st Oct 2006 17:37
?

Umm, what?

I already figured it out. ^^^

I had nothing to do with what you said...
It just sets the draw distance, essentially, of the cameras.

-----------------

Is 1280x720 720p widescreen? ie. 360 standard?

-= Out here in the fields, I fight for my meals =-
Gamefreak
13
Years of Service
User Offline
Joined: 20th Jun 2004
Location: Cyberspace
Posted: 21st Oct 2006 18:16
Is there anyway to update my shader version, like to 2.0? My graphics card doesn't support a lot of the shaders in the pack.
MadrMan
11
Years of Service
User Offline
Joined: 17th Dec 2005
Location: 0x5AB63C
Posted: 21st Oct 2006 18:19
Nope there isn't.. its hardware so you'll have to buy a new graphic card or just stick to lower versions


Raven
12
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Oct 2006 18:45
Quote: "I had nothing to do with what you said...
It just sets the draw distance, essentially, of the cameras."


:shrugs: I was taking a guess, as I didn't have the USP to check.
Do now, and the Fresnel Shader looks like the NVIDIA ASM one converted to HLSL. Seems a very silly way of doing it as performance is being lost by letting DBP do aspects that should be internal to shaders. Still does the job I suppose.

Quote: "Is 1280x720 720p widescreen? ie. 360 standard?"


Something like that, yeah. It's a resolution that's been around before HD though

What I ment above is that the rendered pixels for the texture, on the first example it's 1:1 meaning 100x100px output, then it's stretched over the surface. For the shader example 640x480 is the original size so again it's 100x100px, yet 1280x720 is larger so the shader rather than doing it's 1:1 does a 2:1.3 (in relation to the screen ratio) so the texture ends up being 200x130px rather than stretching. So it's doing alot more work with the fill-rate but also on the gpu itself.

hense, smaller screen = higher performance.
This is also true when considering a shader like HDR or Bloom. Generally a way around it is to use a shader quad (shader created quad that sets the screen sampler size output) that way no matter the resolution the shader doesn't slow down... on the negative side no matter the resolution the shader output will always be the same, which can mean HDR might end up being a much lower quality aspect than say Normal Mapping.

Also a better solution for the Fresnel Water, or any Reflect/Refraction is to use the Shader itself to determine the clipping surface using an emissive level, which will allow anything above the water to be classed as something different to below. another (and tbh easier method) is to use a cubemap (or even single camera dp reflect vector from eye) passed by dbp for the reflection and use the scene itself for refraction.

Either method will provide much quicker and more impressive results. ^_^

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 21st Oct 2006 22:41
@sett (and anyone else interested)
Quote: "How can I have the fire sahder from the fx composer shader gallery. They say that the sample come with fx composer but there is no sample at all."


Here's a fire effect shader plus demo DBP program in a zip file you might like to try. You need a ps2 capable GFX card.

When you run the program, just press "2" to get the fire effect.

Let me know if you have questions or problems with this.

Attachments

Login to view attachments
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Oct 2006 22:50
Has anyone managed to get other shaders working with the Fresnel water?

I think it takes complete control of what goes into the backbuffer, basically.

I can't get HDR to work with it, and I think it's because of this.

The 'post' effects like HDR need to work on the image once it's had the water effects put in.

-= Out here in the fields, I fight for my meals =-
headcrab 53
11
Years of Service
User Offline
Joined: 14th Jul 2005
Location:
Posted: 21st Oct 2006 23:11 Edited at: 3rd Dec 2006 22:21
What's the Fresnel water?


Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 21st Oct 2006 23:30 Edited at: 22nd Oct 2006 00:03
Ummm, it's the Fresnel Water shader.

It's in the shader pack, called, wait for it, Fresnel Water.

---------------

I managed to get bloom working with the water.
It doesn't work on the actual water, which I kind of expected, but it still looks good on the rest of the enviroment

-= Out here in the fields, I fight for my meals =-
Turoid
13
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 26th Oct 2006 11:18
Hi guys,

I was playing around with the shader pack to see if I could manage working with shaders for the nvidia comp.
Now here, I made a plain and moved with the camera around it. As you can see in the far right corner it seems that it just dissapears when the camera comes close to it, but not in the other corners? I hope this is fixable actually.. I guess there's nothing wrong with the shader.

Click the download butten for the video.

Thanks

Attachments

Login to view attachments
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 26th Oct 2006 11:35
Had a quick look. I see what you mean. Will try to reproduce the problem myself (shouldn't take long). I suspect it's an object culling issue - but I'll check.

P.S. Thanks for posting here. It would be great if everyone else with competition related shader queries did that. Then everyone benefits.
Tinkergirl
13
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 26th Oct 2006 11:43
Did you make the plain in a modelling package, or is it a DB standard plain? Just, if it's a modelling package one, then I'd suspect that your pivot point is off centre, and DB only renders it when the centre point is close enough to the screen.

If it's a DB plain, then I'm afraid I don't know.

Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 26th Oct 2006 11:53
Sorry, couldn't reproduce your problem. The following code worked fine for me:

+ Code Snippet

I changed the shader slightly so it explicitly declares the textures - shouldn't be relevant to your problem though:

+ Code Snippet
Turoid
13
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 26th Oct 2006 12:47 Edited at: 26th Oct 2006 12:48
I used the inbuilt DB plain primitive, but I rotated it and fixed it's pivot.

[EDIT]
I tried making a new project with the same code and it seems that it works fine therE? ?? :S

Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 26th Oct 2006 15:16
Here's a simple reflection shader plus demo program people might like to play with. The cube map was made from images taken with cameras in another DBP application.

You can move around using the up/down keys and mouse to change direction.

Attachments

Login to view attachments
Cave Man
10
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 28th Oct 2006 01:06
Thats a nice shader.
I've got a question. What does the mul function do?

Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 28th Oct 2006 03:54
The mul function is used to multiply a vector by a matrix - often used in shaders to convert from one coordinate system to another. For example, position coordinates of a vertex are input to the vertex shader in object or model coordinates (the same ones you would see in a mesh in DBP. However, other things like camera position are passed in "world" coordinates, and to show things on the screen you need "view" coordinates (i.e. relative to the camera) and finally a "projection" to the screen coordinates. Hence shaders will often refer to 4x4 matrices such as WorldViewProjection which is a combined matrix giving the transformation of object coordinates to the screen, i.e. object -> world -> view -> screen projection.

Hence the following code snippet from my reflection shader is transforming input object coordinates into output screen coordinates. In the shader I have given the matrix WorldViewProjection the shorter name wvp for convenience.

+ Code Snippet

Hope this explains a bit.
dab
12
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: You Temp Folder!
Posted: 28th Oct 2006 12:24
@Green Gandalf
Your reflection shader doesn't do objects in the scene. Only the outside, cube.

Take heed, never take advantage of the things you need, never let your self be overcome by greed. Walk a strigh line, pick up your speed and try. Everyone deserves a piece of the pie By: Shaggy
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 28th Oct 2006 12:25
Yeah that's for speed. Not everyone has a computer fast enough for real time reflections, these are prerendered.

It looks very good for how cheap it is.

-= Out here in the fields, I fight for my meals =-
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 28th Oct 2006 14:26 Edited at: 28th Oct 2006 15:53
Quote: "Your reflection shader doesn't do objects in the scene. Only the outside, cube."


Yes, as Chris K says, that was done for speed. Real-time reflection rendering of the whole scene using set camera to image, etc, can slow things down enormously. Of course, you have to stop somewhere anyway - in a real-world version of my shader you would want a potentially unlimited sequence of reflections of one object in another. But how would you get that?

To get visually interesting effects and acceptable game speed you need to make a few compromises or approximations. I think several of the shaders in the Ultimate Shader Pack could do with reworking for speed with that in mind.

Quote: "Thats a nice shader."


Quote: "It looks very good for how cheap it is."


Thanks, guys. I'll keep posting simple shaders like that in case someone wants to use them.

[Edited typo.]
Cave Man
10
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 29th Oct 2006 05:12
Thanks Green Gandalf. Can you make a simple shader that just turns all the pixels one color so i can learn? Thanks.

Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 29th Oct 2006 12:02 Edited at: 29th Oct 2006 12:03
Here you go Cave Man:

Shader (save as MyFirstShader.fx):

+ Code Snippet

DBPro code:

+ Code Snippet

-= Out here in the fields, I fight for my meals =-
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 29th Oct 2006 13:23 Edited at: 1st Nov 2006 19:48
Quote: "Can you make a simple shader that just turns all the pixels one color so i can learn? Thanks."


Try the attached.

I'm going to add to this in response to questions on this thread - time permitting of course.

Thanks for the nudge - I've been meaning to do this for a while.

[Edit: someone beat me to it while I was tinkering with the code! Serves me right for being too fussy!]

[2nd Edit: Changed the name of the zip folder so it doesn't refer to "Tutorials". That will come later when I've added explanations and more examples. There's only one shader in there at the moment. More will follow.]

Attachments

Login to view attachments
Cave Man
10
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 29th Oct 2006 21:52
You guys are the best. I've got another question. What does pass in the technique do? Thanks for your time

Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 29th Oct 2006 21:56
Well a pass is when the shader acutally does something.

Think of it as 'run'.

It's called 'pass' because you can do it multiple times.
So you might have one pass where you do one thing and another where you do something else.

You'll notice that the Toon shader does two passes, one to make the edge, one to colour the object like a cartoon.

-= Out here in the fields, I fight for my meals =-
Cave Man
10
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 29th Oct 2006 22:59
Does it make a difference what you pass to pass?
(e.g.
pass p1)

Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 29th Oct 2006 23:18
No that's just it's name.

Call it whatever you want.

You'll notice in my code, it's called MyFirstPass

-= Out here in the fields, I fight for my meals =-
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 29th Oct 2006 23:22 Edited at: 29th Oct 2006 23:24
Quote: "Does it make a difference what you pass to pass?
(e.g.
pass p1)"


Not as far as I know. You can use any name you like: myfirstpass, mysecond pass, etc. Only doubt in my mind is whether they need to be different from names of passes in other techniques in the same shader.

Some applications (like RenderMonkey) use complicated naming conventions for pretty well everything. This has the advantage, I think, that shaders can be gradually built up from a set of smaller shaders in a development environment without causing naming conflicts. Fortunately we don't often need to worry about such things in the small-scale projects we are likely to use in DBP. The main disadvantage of RenderMonkey's naming conventions (for me anyway) is that it makes the code long and hard to read.

[Edit: Chris, you've done it again. Aren't you supposed to be busy with that cloud shader thing?
Chris K
13
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 30th Oct 2006 19:58
I prefer just sitting here clicking refresh just to make sure I get in there first with my lower quality, rushed anwser.

-= Out here in the fields, I fight for my meals =-
FROGGIE!
13
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 31st Oct 2006 16:21
Whats the difference between how HDR and bloom shaders work? and which is best to use?
Pulsar Coder
13
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 1st Nov 2006 04:34
Quote: "Whats the difference between how HDR and bloom shaders work? and which is best to use?"


http://en.wikipedia.org/wiki/Bloom_(shader_effect)

~Pulsar Coder
Green Gandalf
12
Years of Service
User Offline
Joined: 3rd Jan 2005
Location: Cornwall UK
Posted: 1st Nov 2006 09:54
That's a very useful and interesting article. Thank you.
Cave Man
10
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 1st Nov 2006 17:41
I looked at the rainbow shader. There's alot of functions i have no idea about. I noticed that the folder example shader you made said "Green Gandalf Tutorials". Next i think you should start explaining what certain functions do and how to use them.

But anyway, thanks again for that simple pixel shader you made. It helped alot!

Login to post a reply

Server time is: 2017-06-26 01:10:13
Your offset time is: 2017-06-26 01:10:13