Sorry your browser is not supported!

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

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

DarkBASIC Professional Discussion / The Ultimate Shader Thread.

Author
Message
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 11th May 2004 04:13
Well assuming you have snarfed the bitmap and turned it into an image somehow:

Quote: "TEXTURE OBJECT Object Number, Stage Index, Image Number"


will let you assign an image as a texture to a specific texture stage. Texture stages are the means whereby multitexturing is implemented. I haven't played with them yet, so there may be other things you need to set up to get them working.

I don't think it's practical to go about doing it that way though. Retreiving the screen image and turning it into a texture is going to be very very slow.

E Unibus Plurum
Cpt Caveman
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 12th May 2004 04:32
Ideajuice: How easy would it be to add reflections of other objects into the POcean.fx shader. I found that if I make the slab.x ghosted and set the bumpmapping to not move at -0.05 it looks a little like the water in Far Cry. With reflection of the surrounding landscape/objects it may look very good.
Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 12th May 2004 04:51
Ideajuice, I've got it! Just add a pixel shader to your example, pass the z value through to the pixel shader and have the pixel shader render that value to the w position of the framebuffer. Then I can use those values in the next pass for shadow maps.

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 12th May 2004 05:23
Shaders only really know about the model you apply them to, and even then they only really know about the current vertex they are processing (or the current pixel for pixel shaders).

A vertex shader is handed one vertex at a time, as well as whatever arbitrary data you attach to each vertex by defining the inputs it will receive.. typically the various matrices representing the viewing position, screen projection matrix, various color components, surface normals, shininess etc.

They don't even really know about any lights in your scene unless you build a variable into the shader representing the light, and then pass the data in using something like set effect constant or hardcoding the position in the shader. You might notice that the ocean shader appears to have a light coming from nowhere even if you have no such light in your scene. The position of this non existent light is implicitly hardcoded into the pixel shader.

So to do what you are asking would mean that each shader for each object would have to be told the position of each other object in the scene as well as all of the lights, and even then.. it wouldn't really be able to render the other objects unless it could shade them with the other objects shader... you can see that it would be quite a mess.

There is an interesting technology demonstration in the nVidia effects composer SDK that implements a primitive form of ray tracing all within a shader, but when you examine it you see that the entire scene is coded into the shader file..



... not all that useful for a general purpose game, and this shader requires instructions that are only available on graphics hardware that implements Pixel Shader V3, so it's definitely not suitable for our use at this time.

The DirectX examples that do reflection mappings create a dynamic environment map (cube map or sphere map), and burn some cycles each frame rendering the scene from the position of an object you want to have a reflection on into textures. Since you need six textures to make a cube map, and since each object in the scene should really have it's own cube map since what it sees from it's position is unique, this can get pretty expensive.

For something like a dynamic sky that can be considered to be infinitely far away from anything of interest, you can get away with rendering one cube map once per frame, or you could even update only one of the six faces of the cube map each frame so that every six frames you get a new cubemap to use. This will not let you see a reflection of one car in another car up close, but it would give you a common sky and scenery to apply to all of the cars.

The ocean shader already uses a cube map to provide a semi convincing reflection... albeit a non dynamic one unrelated to your game. I am still poking around with the connection between DarkBasic textures and the textures loaded and used by shaders, but it should be possible to create that cube map on the fly and get the shader to use it instead of the one it loads itself.

I was hoping that there would be something like a 'set effect constant texture' command to replace the textures used by a shader selectively at runtime, but at some point I will be looking at the 'texture object' command variant that allows you to specify a texture stage index to see if this can be used for that purpose.

Perhaps Raven or Neophyte or one of the other DB veterans who have more insight than I into the specifics of DarkBasic shaders can provide some information on how to override specific textures used by a shader from within DarkBasic.

E Unibus Plurum
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 12th May 2004 05:57
@Eldar

Assuming that a shader deposits the Z information into the w (I assume you mean alpha) component of the framebuffer, how would you use that to implement your shading pass?

And I don't think shaders can actually read the framebuffer. They can only read textures that have been bound to a texture sampler. Alpha blending happens outside of the shader in the part of the pipeline that merges the results of the pixel shader(s) with what is on the screen.

From a book by Microsoft Press entitled "Direct X 9 Programmable Graphics Pipeline" (extremely useful but very thick reading)

Quote: "Frame buffer blending is always done by the fixed function pipeline, regardless of wether pixel processing part one is done with the fixed function pipeline or a programmable pixel shader. This is because the frame buffer blending, as well as alpha, stencil, depth testing and so on, occur in the block called pixel processing part 2. This functional block is still controlled by states set up in the fixed function pipeline."


Indeed.. if you implemented a multi pass pixel shader, the alpha component might not even be on the screen yet.. it might be in the pipeline computed from an earlier pass, waiting for the current pass to finish computing so the blended result can be written out to the framebuffer.

There is another catch. Even if you could read the w component from the framebuffer, it would only be 8 bits worth on a 32 bit screen, and on a 16 bit screen it would get mangled down to one bit.

By all means explain your idea further though. It sounds sneaky, and I like that.

E Unibus Plurum
Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 13th May 2004 03:52 Edited at: 13th May 2004 03:54
Ideajuice, check out the deffered rendering article on beyond3d.com(expecially pages 1 and 2). It shows what I mean(except for the fact that I will be doing it only for shadows not deffered rendering).

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 13th May 2004 09:29
My, my. I leave for a week and all of this gets posted in my absense. Where to begin...

@Eldar

And thanks for all the work you have put into this Neophyte, now I can finally use all shaders I have been coding in FX composer. Keep up the good work.

Thank you. I plan on continuing this series for little while longer before I take a break from it.

Oh, and with regards to Raven, don't let him intimidate you. He's all talk and no walk. If you check out his claims they more often than not turn out to be false. He's notorious for BSing.


@Raven

I ignored the comments from that user quite obviously as i simply ran down what the shader contained and didn't respond to what he said.

Why? Must you always puff out your chest and try to show off you so called knowledge all the time?

What goes on between me and Neo has very little to do with whatever technology story you wish to believe;

Yeah. Right. Did you ever notice that I only really argue with you when you post false info?

there are personal grudges here.

That stem from the fact that you lie constantly and make stuff up. If you quit pretending to know stuff that you don't we wouldn't have these tech disagreements.

I personally have begun to hate Neo just like i hated Simple ... and for almost identical reasons as well.
Guess time will tell if I am right about this use how I was about Simple, eh?


And those reasons are...?

It's amazing how much power an internet search engine appears to give people around here, and how much respect they get for using it.

The only amazing thing around here is how much respect can be gained by continually brandishing big words about.

Second Post:

Or perhaps even the guy who happened to the first to get them working before DirectX9 update was out, or who had the first custom shader working in DBP, or has helped numerous other people to get thier shaders sorted out.

But i guess the fact of who that is might've passed by some people in this thread.


Yes, that "fact" has passed over a lot of people's heads. I wonder who it could be?

Could it be the same guy who claimed vertex shader versions 1.2, 1.3, and 1.4 existed not once, but twice? Could it be the guy who claimed ATI had nothing to do with shaders and that their hardware didn't support them; running any shaders that came to it on the CPU? Could it be the guy who thought Cg by passed the 3D API's and accessed the graphics hardware directly(even though the Cg runtimes had names like cgGL and cgD3D9)? Could it be the same guy who claimed to be a developer's forum administrator for popular graphic's card company even though that forum didn't exist?

Nah. It couldn't be. I mean, you'd have to be a major idiot to make those kind of mistakes right?


@Ideajuice

Perhaps Raven or Neophyte or one of the other DB veterans who have more insight than I into the specifics of DarkBasic shaders can provide some information on how to override specific textures used by a shader from within DarkBasic.

I wouldn't count on Raven providing any usefull info anytime soon. However, I'll see what I can dig up.



From my brief tests I've concluded that all you need is the texture object command. Just texture the object using the texture object command just like you would do with a regular shader. Use the same index as the texture you want to swap out. You don't even need to reapply the effect. So it's child's play really to swap out textures.

On a side note:

Thanks for fielding people's questions while I was gone. Its nice to know that I have someone who is knowledgable about shaders that can help out when I'm not available.

Also, I'd like to thank you for inadvertantly bringing the book "Direct X 9 Programmable Graphics Pipeline" to my attention. I hadn't heard of that book until now and it sounds like it could serve as a usefull reference. I will see if I can get around to buying it later.
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 13th May 2004 14:28
@Neophyte

Thanks for taking the time to mess around with this. Texture object seems to work for the objects main texture, but it doesn't seem to work for replacing the environment map.

The ocean shader loads two textures.. an environment map, and another texture that is used to simulate the wave pattern.

If I load a different cube map in DB (using texture flag or not), and then try applying it to various stages of the shader using the extra stage index parameter, the only one that affects the model is index 0, and that completely replaces the ocean effect and flat textures the model with just one image from the cube map.

What I would really like to be able to do would be to selectively replace these subtextures with different ones on the fly, or somehow get a handle to the ones that were set up by DB for the shader, and then cram something else into them.

I hadn't really tried doing it until now since there are plenty of other things to play with, but you filled me with optimism so I gave it a quick try. It doesn't seem to just work though, although the description of the stage index paramater in the texture object command would seem to imply that it should:

Quote: "An additional texture stage index can be provided to the command to specify multi-textures directly, and is required when using shaders that take pixel data from secondary
textures."


There is also a note in the shader tech document that says this:

Quote: "Notice the textures are still being specified by the FX file. This is due to the last parameter in SET OBJECT EFFECT. To use the textures already existing for the object, you set this parameter to zero, like so:
"


While this sounds extremely encouraging, adding any flag to the end of the set object effect command produces a compile error stating that the set object effect command does not accept three parameters but only two :-(

I'm really glad you got me onto this though, because:



seems to actually work! It's just the 'set object effect' that doesn't take the extra parameter. 'set effect on' seems to accept it, and it is using a different cube map now.

Now if we just had a way to access and render into the faces of the cubemap at runtime, we would be all set.

I'd like to thank you for posting these shader articles. Your information on the semantics that DB uses to connect shader entities with DB entities was invaluable in getting them to work at all. Check out my post 'for the brave and/or stupid' in this forum for a hack you can perform on fX Composer that will let you use it to work with shaders in DB without having to convert the semantics back and forth all the time.

As far as my knowledge of shaders go, I am just learning about them, but I'm happy to share anything I find. The book I mentioned is indeed useful. It's ISBN is 0-7356-1653-1 if you want to try to find a copy.

And welcome back.

E Unibus Plurum
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 13th May 2004 15:19 Edited at: 13th May 2004 15:24
@Eldar

I gave that a quick skim, and it's bookmarked now.

If you download and look at the example code in that article(look at GBufferSingle.cpp), the technique is not using the actual frame buffer or screen to store the accumulated shadow mapping information. It is creating a render target (it's creating several render targets actually) with special properties that are never visible on the screen, rendering to those in earlier passes, and then using the information stored into them as a texture input for other passes.

DarkBasic is a little weak on allowing for this kind of control over rendering. The only thing you can do with DB is to 'set current bitmap', and then call sync to render, but again we are faced with the problem of how to make a shader accept a bitmap created by DB as a texture.

It would be nice if you could create a bitmap, and also have the same bitmap be a texture (i.e a DB image). There would be many other uses for that, but currently it seems that you have to perform a get image on the bitmap each time you want to update the texture, and this is very slow and impractical.

In addition, the image and bitmap creation commands in DB don't allow you to specify a specific format or color depth (a glaring oversight in my opinion). The technique described in this article requires a very uncommon image format which does not correspond to any normal screen format, so getting DB to even create a render target with the properties required is not really possible with the current command set.

E Unibus Plurum
Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 14th May 2004 03:13
Like my other ideas this probably won't work either, but here goes.... Is their anyway to use a DBPro bitmap(The regular 32 bit variety, That will be more than enough range for shadows) as a render target?

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Ideajuice
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Cyberspace.. out near the edge
Posted: 14th May 2004 05:39 Edited at: 14th May 2004 05:41
That is the easy part actually. When you call sync, all of your 3D stuff is drawn into the current bitmap, so setting any bitmap as a render target is actually trivial... set current bitmap followed by a sync is all you need to do.

Getting a DB bitmap to be used as a texture is tougher.

Another way to do something similar is to have a camera render into an image using the 'set camera to image' command. This is the 'approved' method of creating dynamic textures to map onto 3D objects in DB and it is very close to what is needed.

One problem with this method though, is that there seems to be no way to selectively 'sync' just that camera... when you sync.. all of the cameras render everything at the same time, so you could not for example set all the objects to use the depth shader, sync just one camera into it's image texture, and then set all your objects back to their normal shader or texture, and then call sync to render your main scene using just the main scenes camera.

There are ways around this, but none of them are pretty. One way would be to duplicate your entire scene so far away from the main scene that it is beyond the camera range. Drawing everything twice isn't the bad part.. for what you want to do you would have to draw twice no matter how you cut it, but the problem is the amount of additional memory to hold all of the stuff, and the amount of time it would take for your game code to update the positions of two sets of objects instead of one set.

I just went off and tried a bunch of things, and it really boils down to not being able to tell DB not to render the main camera and flip the back buffer into view. Even if you could just tell it not to flip the buffer, a lot of things would be possible.

As it is now, everything I try to do with extra cameras or rendering independent subscenes breaks because you can't shut off or delete the main camera, you can't prevent it from drawing the scene and flipping it into view when you call sync, and you can't even lock the backbuffer on it to keep it from doing these things.

They've made it really simple to do some very complex things, but they made it impossible to do something really simple.

[EDIT] All that would really be needed would be a 'sync camera_number'. Why that isn't there already is a complete mystery.

E Unibus Plurum
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 14th May 2004 09:20
@Ideajuice

Thanks for taking the time to mess around with this.

No problem.

Texture object seems to work for the objects main texture, but it doesn't seem to work for replacing the environment map.

I've noticed this problem before. I've been meaning to talk to lee about this but I keep forgeting.

It's just the 'set object effect' that doesn't take the extra parameter. 'set effect on' seems to accept it, and it is using a different cube map now.

Yeah, I forgot to mention that I only used one of those commands. I kind of forgot about the other one. Should have tested that.

I'd like to thank you for posting these shader articles. Your information on the semantics that DB uses to connect shader entities with DB entities was invaluable in getting them to work at all.

Thanks. Hopefully, my next tutorial will expose the real power of the .fx file and get a lot more people using them. I just have to clear up a few things with Microsoft first before I can get any further.

Check out my post 'for the brave and/or stupid' in this forum for a hack you can perform on fX Composer that will let you use it to work with shaders in DB without having to convert the semantics back and forth all the time.

I'll do that.

The book I mentioned is indeed useful. It's ISBN is 0-7356-1653-1 if you want to try to find a copy.

I've searched around and found a used copy that is going for a pretty cheap price. I'll see if I can get it.

And welcome back.

Thanks. I wish it could be under better circumstances though. I just recently had a death in the family so things have been a little rough lately. Its kept me away from the computer so progress on my projects(including these tutorials) has grinded to a halt. The funeral is over with now so things should be returning to normal I guess.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 16th May 2004 14:00
Hi there.

Neophyte just a question.

I've you had a look about a cartoon shader ?

That all

Kaji
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 16th May 2004 20:26
@KajiSan

"Neophyte just a question.

I've you had a look about a cartoon shader ?"

Yes. In fact, the second tutorial in my series deals with just that. I've even modified the existing cartoon shader that came with DBPro to accept a base texture as well.

The tutorial should be the 80th post in this thread.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 16th May 2004 21:29
This is perfect. Nice work man ...

Kaji
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 17th May 2004 12:42
Neophyte, is making the cartoon model to interact with many lights possible?

Kaji
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 17th May 2004 19:38
@KajiSan

"This is perfect. Nice work man ..."

Thanks.

"Neophyte, is making the cartoon model to interact with many lights possible?"

Yes. But the shader would need to be rewritten though.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 17th May 2004 20:15
You mean that for each light, i have to add a light vector ( in the shader file ) ?? Is it possible to do this automatically ??
Cpt Caveman
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 17th May 2004 23:05
A shader that replicates the look of glass such as a window in a house, transparent and semi reflective. The reflective part would need to be a cubemap of the interior and exterior of the the house depending on whether you were inside or outside. Or can you do a shader that actually reflects the objects around it, as you couldnt really use cubemaps if you wanted to see your reflection in the window.
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 18th May 2004 00:08
@KajiSan

"You mean that for each light, i have to add a light vector ( in the shader file ) ?? "

You'd have to do much more than that. You'd probably have to modify the vertex shader. That could take some effort.

"Is it possible to do this automatically ?? "

Nope.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 18th May 2004 12:59
Oki, Thx.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 26th May 2004 12:14
Hi everybody

Question about cartoon Shading. Neophyte, It Seems there is a problem with edges detection... I've tryied to change the egde texture, to get an effect like like XIII, but nothing ( my model goes sometimes black, due to the distance between the camera and the model). So I think it can be a problem with the mipmaps of the edge image ...What's your opinion???

Thx

KajiSan
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 26th May 2004 22:55
Are you using the modified shader that I posted or the original shader that came with DBPro?

Also, could you post some code(and possibly media) to demostrate the problem?

It would help a lot.
KajiSan
20
Years of Service
User Offline
Joined: 5th Aug 2003
Location:
Posted: 28th May 2004 13:45
I'm using your modified shader, but there is no differences about the egdes.

The code is very simple, I've simply create a cube apply your shader without the light vector. The image for the edge is the one use in the db demo.

When you try this, there is edge detection, but a face color dependant of the camera position and orientation .Try to move the camera and rotate it....

Kaji
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 29th May 2004 06:44
"The code is very simple, I've simply create a cube apply your shader without the light vector."

Why didn't you apply the light vector?

"but a face color dependant of the camera position and orientation .Try to move the camera and rotate it...."

Err...yes, the edge detection is dependent on the camera. That's kind of the point.

I'm not sure what you mean here.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 30th May 2004 12:12 Edited at: 30th May 2004 12:21
Hey Ideajuice (or anyone who might know) im having trouble getting that ocean shader to work. Im using a plain I created in dbpro from a memblock, made up of 10x10 (in place of slab.x). I yanked the code for the shader and source exactly like you have it, but when I run the program I just get a boring old white plain. Nothing going on. Any ideas?

Btw neos light and toon shader tutorial programs worked just fine. Im using a GForce 4 ti 4200.

*edit* only thing i can think of is this one line
"Path: NVSDKCommonmediacgfx"
what the hell is that? All i have is the pocean.fx and my source. All I need right?

*edit again* ok its becoming more and more obvious as i read the fx file that i need some media. so im not a total dumbass . i guess after coming from neos two 'media less' tuts i didnt really think about it heh. anyway, where can i get the required files? im downloading the FX composer 1.1 right now but im on dialup so its taking forever...

All you need is zeal
nemsis
19
Years of Service
User Offline
Joined: 30th May 2004
Location:
Posted: 30th May 2004 17:11 Edited at: 30th May 2004 17:16
I´ve some problems with "bumplocallight.fx" of FX-Composer.



I´ve changed "ResourceName" into "Name" and I set the effect constants in DBPro.



Still it doesn´t work!

Anyone out there who can help me?
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 31st May 2004 04:50
@nemsis

Do you have the required media for the .fx file?

Looking at the shader I can see that it needs "default_color.dds", "default_bump_normal.dds", and "lightcubestar.dds". You'll need those in the same directory as your shader in order for it to work.
nemsis
19
Years of Service
User Offline
Joined: 30th May 2004
Location:
Posted: 31st May 2004 13:03
@Neophyte

OK! Got it!

This code works in DBPro:



You have to set the constants to matrix,vector,float or whatever. "set effect constant float" doesn´t work for a matrix or a vector. Sometimes I`m a bit slow on the uptake !
Final Epsilon
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: CA, USA
Posted: 31st May 2004 13:48
just curious: what does bumplocallight.fx do?
nemsis
19
Years of Service
User Offline
Joined: 30th May 2004
Location:
Posted: 31st May 2004 23:53
I´ve renamed this shader so I´m not sure which is the right one.

Here are some images: I think one of them is bumplocallight.fx.







nemsis
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 1st Jun 2004 04:36
For furture reference:

View = view
World = World
Projection = Projection
WorldView = worldview
WorldInverseTranspose = worldit
WorldViewInverseTranspose = worldviewit
ViewProjection = viewprojection
ViewInverseTranspose = viewit
WorldViewProjection = worldviewprojection

you can also use
eyeposition = current camera position
cameraposition = main (camera 0) position
time = time (same as fx shader)

Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 1st Jun 2004 08:57 Edited at: 1st Jun 2004 08:58
So im still trying to grasp this whole matrix concept. Does anyone know of a site that actually explains how/why a matrix is used for shaders? Its my understanding that a matrix is used to convert 3d object space into 'screen' space (like pixels on your screen, 800x600, ect..). Right? A picture showing how this conversion is done would really help a lot.

Also, on a more basic level, ive been wondering... Is the code in the shader file being run multiple times per loop/screen sync? Or does the code draw ALL pixels to the screen just after one run through the shader code?

Again, I wish I could find some REALLY basic tutorials/explanations on shaders. One with cartoon bunnies and big pictures would be nice. I think the problem is, most tutorials assume if youre working with shaders, youre working with DirectX or OpenGL, and you already have a pretty damn good understanding of this core stuff. However, people like us (those skilled in just DBP), might not know as much about DirectX as we should. Thus it seems very hard to find tutorials that are for 'shader newbs'.

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 1st Jun 2004 10:58
@Zeal

" Does anyone know of a site that actually explains how/why a matrix is used for shaders?"

Off the top of my head, no. I do know of a book though that does a very good job of explaining the various concepts and math behind them. The name of the book is "3D Math Primer for Graphics and Game Development". Its an excellent resource that makes all of this matrix and vector stuff really easy to understand. If you ever have the time or inclination, I'd suggest buying it. You won't regret it.
It is how I learned about all of this 3d math stuff.

"Its my understanding that a matrix is used to convert 3d object space into 'screen' space (like pixels on your screen, 800x600, ect..). Right?"

Correct, though there are much more spaces than screen space into which it can convert an object. Basically, the name of the matrix is what space it converts the vertexs of the model into. So a view matrix converts them into view space and a world martix converts them into world space, etc.(note: this is a bit of a simplified explaination. You can't just apply a matrix to a vert and get it into the space. Most of the time you have to apply them in a certain order to get them into the proper space. Notice that when world and view are in a matrix name view always comes after world? That's because view needs to be applied after world has been applied in order for it to be transformed into view space.)

" A picture showing how this conversion is done would really help a lot."

If you like pictures with your explainations, then you'll absolutely love the above mentioned book. There is almost a picture on every single page(minus the pages that have source code on them) to explain every concept no matter how mundane.

"Also, on a more basic level, ive been wondering... Is the code in the shader file being run multiple times per loop/screen sync? "

Yes. A vertex shader will operate on every single vertex that is fed to it so it gets run many times. A pixel(aka fragment) shader will operate on every single fragment that is passed to it.

"However, people like us (those skilled in just DBP), might not know as much about DirectX as we should. Thus it seems very hard to find tutorials that are for 'shader newbs'."

Yeah, I feel your pain. Its tough finding good material thats meant for absolute newbies. A lot of this stuff makes the assumption that you are familar with the graphics pipeline and how it works. I learned about this through another book called "Real Time Rendering Second edition". The best that I can offer is a link to its massive resource page.

http://www.realtimerendering.com/

A good start would be under Rendering Pipeline. There is a link that details the Direct3D rendering pipeline as well as the pipeline for OpenGL. I know its an extremely dense read and a bit much to a hit a beginner with, but it is all I can come up with for the time being. I haven't really had the time lately to spend on these forums.

If you need any more guidance from there hopefully I'll be able to return to this and scour through all of those links for some choice bits of information.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 1st Jun 2004 11:49
Thanks a ton neo, ill go look for that book asap. Think my loocal public library might carry it? How new is it? Ill be sure and check out that link too.

Thanks again for yer help! Keep up the good work this thread roxors! Youre my hero!

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 3rd Jun 2004 03:21
@Zeal

"How new is it?"

It came out in 2002 I believe.

@Raven

I'm sure you'll be pleased to know I've managed to confirm PS 1.4 support in the FX series. I found mention of PS 1.4 in the PDF titled Nvidia GPU programming Guide. Under Chapter 5.11 Summary, there is this paragraph:

Quote: "For many shaders, the best way to achieve maximum performance on the Geforce FX architecture may be to use a mixture of ps_1_* and ps_2_* shaders. For instance, for per-pixel lighting it may be faster to do the diffuse lighting term in ps_1_1, and the specular in another pass using a ps_1_4 or ps_2_0 shader."


However, mention of the Geforce 4300 and 4900 seems to be curiously lacking in Chapter 7 GPU Codename and Product Name list.

You can find the PDF here:

http://developer.nvidia.com/object/gpu_programming_guide.html

Enjoy.
Mucky Muck Ninja
20
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 4th Jun 2004 02:32
Could you help me use the Ocean FX in DBPRo? I just got a new card so i can use it now. I loaded the FX, and applied it to a cube, the waves work, but i can't get the actual shader to work. How do I make the Ocean Shader work?(im really really new to the shader and FX stuff, but not new to DBPRo)

Am I an Idiot...or is everyone else just really smart?
i am foonman305
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 7th Jun 2004 05:14 Edited at: 7th Jun 2004 05:19
Well ive been trying forever now and I just cant get the ocean.fx to work. I have the modified ocean.fx and dbpro source by Ideajuice. I have both media files "CloudyHillsCubemap2.dds" and "waves2.dds". All are in the same directory. I run the dbpro source and all I get is a white sphere, no movement, no textures, nothn.

*Note the fx shader and the source are in the same source file below, but you can still see them.

Thanks in advance for any help

BTW im using a Geforce 4 TI 4200

*Edit whops just noticed the shader uses ps 2.0. Im guessing my ti4200 doesnt support that? Well crap are there any other good 'water' effects out there that will work on my card?

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Jun 2004 07:37
@Zeal

"Well crap are there any other good 'water' effects out there that will work on my card?"

Preston posted one a while back. It can be found here:

http://darkbasicpro.thegamecreators.com/?m=forum_view&t=24922&b=2

The original that he posted used PS 2.0 but it could easily be changed to use PS 1.1. Try the download link that he posted later on in the thread instead of the one that he posted in the beginning. That one should contain the modified shader that will run on your hardware.
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Jun 2004 11:10
Some Good News Regarding My Next Tutorial:

For those of you who don't know, in writing my next tutorial I stumbled across some issues that I needed to resolve and I sent MS a question regarding them. Basically, one of their articles wasn't very clear on a topic and I asked for clarification.

I originally sent that email around May 13. I got an email about two weeks ago, May 24, that said that they were still working on the issue and thanked me for my patience.

Since it had been two weeks and I was getting impatient, I just recently sent them an email and I got a prompt response.

Quote: "Hello,

We apologize for the delay. We will be reforwarding your email for follow up.
Thank you for your patience."


Hopefully, that means I'll be getting a reply soon. I can't complete my tutorial without my questions being answered so I'm kind of stuck in a bind for the time being. But it looks like things are looking up and I may just be able to complete this very important tutorial(<-not an exaggeration) soon.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 7th Jun 2004 20:32 Edited at: 7th Jun 2004 21:35
Cant wait!

*edit Oh hey neo I got a question for you. Some files I got from the links you provided are given me trouble. I think perhaps they are using a profile thats too advanced for my vid card. Anyway, all of the example exe's I got from this site just crash as soon as I launch them. Can you get any to work?

http://www.shaderx.com/direct3d.net/index.html

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Jun 2004 22:55
I'll give a look later when I've got the time.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 7th Jun 2004 23:10
Well no need really, according to your first post GForce 4TI4200 only support up to like ps 1.3. The lowest profile in any of those examples is 1.4. So its my vid card. I realise now thats why 90% of the projects in Nvidia FX Composer dont work either. Damn I need a new vid card. What do you think of the GeForce FX 5200 256MB? They have em on price watch for 78 bucks.

All you need is zeal
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 8th Jun 2004 04:04
@Zeal

"What do you think of the GeForce FX 5200 256MB? They have em on price watch for 78 bucks."

If you are just going to use the card for development, I'd say go for it. It's the cheapest PS 2.0 capable card out there. However, if you plan on playing some games that use PS 2.0 then I'd think twice about that.

The performance for PS 2.0 and VS 2.0 on that card is horrible when it comes to actual games. Its fine for development because it will display the results of the shader in real time, but when you have a more graphically intense scene going on like in a real game then it starts to really become unplayable.

If you want, you could always check out Tom's hardware or Anandtech and see what they have to say when it comes to the price-to-perfomance ratio of this generations of cards.

Of course, I'm upgrading my Geforce 4 ti 4200 to a Geforce 6800 Ultra. But you probably aren't going to want to do that if price is an issue. Mine cost me around $550 for per-order.
Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 8th Jun 2004 04:16
Well I figured. From what ive read, the 5200 is like the 'mx' version, but it DOES support the more recent profiles. I know its not a high end card, but if im gonna spend any money id like to play some games on it too... do you think it will at least out perform my current AOpen GF4 TI 4200 128m?

All you need is zeal
Eldar
20
Years of Service
User Offline
Joined: 26th Nov 2003
Location:
Posted: 8th Jun 2004 05:09
Zeal, a Radeon 9600 would be a much better baragin for your money. If you look around you could probally find one cheap.

3.1 ghz Pentium 4
Geforce FX 5800 ultra @ 535/1300
DX 9
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 8th Jun 2004 14:00 Edited at: 8th Jun 2004 14:03
you should be able to easily pick up a 5200 Ultra for $80;
the under-performance of shaders on the 5200 is GROSELY exaggerated...

I have a 5200 (yes standard not ultra) at home; without tweaking I can run FarCry 640x480x32 and Angel of Darkness 800x600x32 at respectable framerates even on an 800MHz Duron machine; (25-30fps)
Both with standard graphics settings...

The 5200 will run Pixel 2.0 just as quickly as it will run Pixel 1.x provided one thing; the Shaders are identical.
What people seem to clearly forget is that Pixel 2.0 is capable of far more complexities and calculation depths; which means it is more taxing on ANY card if you use them.

[edit-]
i should add before someone tries to misquote and show me up here, is that developers using Shader 2.0 use these extra features which is WHY they are slower on all cards.

if you simply change the shader version and run it in dbp (using a HLSL effect) you'll see Zero speed difference; as the card is doing identical calculations.
[edit]

I've seen nothing in test to suggest to me that the gap of a Radeon is any different to the gap of an FX-Series

you could pickup a low-end 9600SE for around $80 (which performance wise is behind the 5200 Ultra) ... or you could go upto $120 and get yourself an FX 5700 which quite frankly is one of the best cards currently on the market.

Quote: "Well I figured. From what ive read, the 5200 is like the 'mx' version, but it DOES support the more recent profiles. I know its not a high end card, but if im gonna spend any money id like to play some games on it too... do you think it will at least out perform my current AOpen GF4 TI 4200 128m?"


5200 won't outperform the Ti 4200; The Geforce 4-Series speedwise are actually still capable of keeping up with the mid-range FX5600/R9600 cards. Only difference it is doesn't have Shader 2.0.
Same goes for the R8500; it can easily keep up speedwise with current cards, but it's featurewise that it lacks on.

Zeal
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: Colorado Springs, CO
Posted: 8th Jun 2004 23:26
Crap oh well looks like if I get a 5200 it will be just for development. Although for only 78 bucks on pricewatch I guess it will be worth it. Cant wait to get working in FX Composer...

All you need is zeal
Mr Anderson
20
Years of Service
User Offline
Joined: 14th Oct 2003
Location: NYC
Posted: 11th Jun 2004 03:47
Hey has anyone got an example of Normalmaps to make a low res model look High-res.

I saw one for BlitzBasic (w/ no src) and I figure it should be do-able in DarkBasic just as easy, no?

And depth-of-field.

IDIC (Infinite Diversity Infinite Combinations)
Neophyte
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 11th Jun 2004 04:36
There is a depth of field as well as a normal map example in the FX Composer app.

It can be found here:

http://developer.nvidia.com/object/fx_composer_home.html

Login to post a reply

Server time is: 2024-05-07 20:39:54
Your offset time is: 2024-05-07 20:39:54