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.

Dark GDK / Shaders for Dummies (I'm the dummy)

Author
Message
chiekku
16
Years of Service
User Offline
Joined: 23rd Apr 2008
Location:
Posted: 20th Sep 2010 04:49
I'm a long time user of DarkBasic, DarkBasic Pro, and recent user of Dark GDK. I'm not very good at it, but DB has been an enjoyable intro to game programming. I recently switched over from Pro to DGDK, since my classes at college deal with C/C++.

I'm new to shaders, and am having trouble using them in DGDK, more specifically what commands to use when. There seem to be a lot:

dbCreateVertexShaderFromFile
dbCreatePixelShaderFromFile
dbLoadEffect
etc...

I don't know which of these commands to use, basically. I don't have Dark Shader, so I need to use shaders without it. For starters, I downloaded some shaders from NVIDIA's library found at: http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html

In addition to not knowing which commands to use in GDK to apply shaders to objects or matrices, any progress I've made in applying a shader to an object has been met with DGDK crashing in the usual "has stopped working" fashion. From what little I understand about shaders, .DDS files are the textures, and the .fx or .cgfx files actually "shade" the .DDS textures. However, the game always crashes when I attempt to apply the shader effect (using "dbSetObjectEffect(51,52)").

Here's the code I've been trying to use that causes a crash:




If someone could enlighten me on the basics of applying shaders in DGDK without the use of Dark Shader, I would appreciate it. I'm not looking for tutorials on how to write shaders from scratch (yet), just how to take an already existing shader and apply it to a surface with the DGTK commands as simply as possible.

tl;dr -> how do I use a shader on an object in DGDK?
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 20th Sep 2010 22:44
That's alot easier to ask than it is to answer. The best thing I could recommend doing is going to http://www.evolved-software.com/shaders/shadowing
downloading the DarkGDK project files and learning from there. Not all shaders work the same, and some of them have specific ways you have to texture the objects, so it's not something easily answered in a forum post. Hope this helps.

The most BASIC thing I can tell you, is that every shader has certain perameters, called tweakables that can be adjusted with dbSetEffectValueFloat, and dbSetEffectValueVector, as well as certain techniques that you call to actually make the rendering happen with dbSetEffectTechnique. You can find all these values in the fx file by opening it in notepad. Some shaders also involve setting up multiple cameras and rendering the scene multiple times. It sounds complicated but if you study the source files above, you'll figure it out.

The other thing I can recommend is that you have to change all the 1_1 and 1_4's in the effect file to 2_0.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 21st Sep 2010 01:15 Edited at: 21st Sep 2010 01:16
Also check out this thread for a bunch of shaders (any non-shader code will be for DBPro, but the shaders should work in DGDK and the DBPro code shouldn't be too hard to understand anyway):

The Learning To Write Shaders Shader Archive.

Included in that thread is a link to the "Learning To Write Shaders" thread, where people post their questions about shaders. There are also shader demos posted in that thread, which are referenced in the archive thread.

I started my shader quest here:
http://knol.google.com/k/hlsl-shaders#.

Then I went to EVOLVED's site ([href]www.evolved-software.com[/href]) and started messing around with some of his fullscreen shaders, changing the colors and whatnot.


Guns, cinematics, stealth, items and more!
chiekku
16
Years of Service
User Offline
Joined: 23rd Apr 2008
Location:
Posted: 21st Sep 2010 08:17
Quote: "
The other thing I can recommend is that you have to change all the 1_1 and 1_4's in the effect file to 2_0.
"


That fixed it! From what I gather, that told the shader to render with Pixel Shader version 2 instead of 1.4. How did you know this would work?

Thank you

I'm very good at recursively doing things tomorrow.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 21st Sep 2010 13:25
Apart from all that's been said, your code approach is not bad, but it will never work. Have this changed:



To this,



All paths use double '\', not single '/'

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Sep 2010 21:10
@Morcilla
Forward slashes work fine on windows

[b]
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 22nd Sep 2010 11:11
Really?
Good to know, I take note

Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 23rd Sep 2010 00:04
@ chiekku

DarkGDK only supports shader version 2_0 and above so ANY shader has to be changed this way.
chiekku
16
Years of Service
User Offline
Joined: 23rd Apr 2008
Location:
Posted: 23rd Sep 2010 14:11
Quote: "
All paths use double '\', not single '/'
"


Yeah... '/' works just fine.

Quote: "
DarkGDK only supports shader version 2_0 and above
"


Does that mean DGDK supports geometry shaders and DX10?

I'm very good at recursively doing things tomorrow.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 23rd Sep 2010 15:19
DarkGDK is a directX 9 wrapper, not 10 nor 11, i dont think 10 or 11 shaders would work

Login to post a reply

Server time is: 2024-11-19 18:35:16
Your offset time is: 2024-11-19 18:35:16