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 / Water Shader(Evolved's) - reflecting / refracting above below water

Author
Message
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 15th Jun 2009 17:45 Edited at: 26th Jul 2009 05:57
Hey All...

Ive been playing around with shaders lately in DarkGDK and have noticed that there seems to be a fair amount of users who have alot of trouble getting shaders to work, and while there are ALOT of great tutorials and resources here in these forums, the vast majority of it is aimed either at actual Shader development/programming, or using them with DarkBasic Pro.

To that end, I decided that while I was playing with various shaders, and converting alot of the DBpro code to C++ for my own uses, I would throw together a few examples of working shaders in DarkGDK that people can butcher, copy/paste and hopefully find some use for.

I'll stick them in this thread as I finish them, along with screenies, so you can see what they look like.

The first cab off the rank is something that I had some trouble getting right initially : Water. Specifically, water that showed real-time reflections and refractions, from both above and below the surface.

The actual Shader, and initial DarkBasic Pro code, were written by Evolved, and can still be downloaded at his website at : http://evolveduk.googlepages.com/Index.html

I simply translated it to C++, making a few small alterations to the logic of the code and the superficial parts, such as window positioning, camera control etc. The code is laid out in a procedural format, there are no objects or classes and nothing more complex than prototyped functions(its not laid out in an overly efficient manner, just a simple one). The code is also commented the whole way through so it's logic can be easily followed.

The attached ZIP file has all the code, media and the shader file required to compile amd run. Simply add main.cpp and main.h to a new DarkGDK Game project(replacing the existing files of course), and put the folders FX and media, inside the project's directory.(ZIP is about 1.75mb in size packed, 3.5mb unpacked)

Hope this is some help to someone out there

Here are the screenies of the water as it looked on my pc..
(core 2 e8400, 2gig ddr2, nvidia 9800)

Above Water Level:




Below Water Level:




EDIT : Please Note that ALL the .EXE files that come with the examples in this thread have been compiled with DarkGDK 7.3 using Visual Studio Professional C++ SP1. If another version of DarkGDK was used to compile with, I will mention it in the example's post. All of the Screen Captures in this thread posted by me were captued at the example's resolution(1024x768x32 or 1280x1024x32 usually) and reduced to 640x480 by my file hoster so they arent too big.

CREDITS : Please not that all of the original code, both DBPro and HLSL, were not written by me, all I have done it port code from one language to another, all credit belongs to the original authors and the programs are still structured in the same way as in their original forms, as closely as is possible in C++. Also, besides just the people who's code and shaders are here, I have used a whole heap of tips and tricks that I have picked up from various people in these forums over time, I only think its fair that there is a list of those people here, as I wouldnt be able to do what im doing without them.. :

*The Game Creators - without DarkGDK and DBPro and all the other great products these guys give us, none of this would be here.
*Evolved - The majority of the object shaders here were originally written by Evolved, and he deserves a whole heap of thanx for making available to us all of the excellent shader work he has done.
*Green Gandalf - I have a bunch of shader examples that I am learning from written by GG, and I have learned quite a few little tips and tricks to using shaders properly from reading through Green Gandalfs code and posts here on the forum, I dont think I would know half of what I do if we didnt have Green Gandalf helping us all.
*Jason P Sage - I use some of the classes from from Jason's JGC library(the v2 one) now and then and I have learnt alot from them, there is also a few small "helper" functions in my code that are largely inspired by Jason's own.
*Dark Coder - His signature says it all.. I have learnt alot from dark coder's examples and posts on these forums plus he is always willing to offer advice and help put you on the right path to get things done properly and efficiently.
*IanM - I remember basing the very first version of my OO wrapper for DarkGDK(which I use myself, and pull some functions from here and there for examples) on a DarkSDK Framework tutorial that IanM wrote many years ago. Its evolved since then into its own entity, but I owe alot of that to things that IanM had got me thinking about.

There are many more people here in these forums whom I have learnt alot of what I see as invaluable knowledge from. So I would like to thank everybody who contributes code snippets, tutorials, examples, media and also their time helping others in these forums.

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 15th Jun 2009 20:58
Thank you very much for this initiative! It will be very useful.
Indecom
17
Years of Service
User Offline
Joined: 23rd May 2007
Location:
Posted: 16th Jun 2009 08:45
I've been doing just this same thing for the past week, unfortunately not to evolved's shaders. This is fantastic, i was thinking of converting this one first but you beat me to it! lol
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 17th Jun 2009 11:10
EVOLVED'S Soft Shader/Normal Map Example in DarkGDK C++


Here is the next one, with some screenies... intructions are as in the first post, new project, add main.cpp and main.h .. put folders "media" and "FX" in the project folder.

These softshadows look really nice i think, especially with the mapping.

Hope it helps someone

Plain Light :


Red Light :


Spinning Texture Mapped Light :


If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 17th Jun 2009 20:26
Nice work.

Shame you didn't have a working EXE file in the file set also.
Well I guess I will have to reinstall DarkGDK back onto this machine and see what the FPS are like.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 18th Jun 2009 00:13
Hey sybdob, Here are the 2 EXEs(with media) for the 2 examples I have done so far

If they have any probs let me know, i just knocked em out real quick, they run on my pc ok, not tested anywhere else.

ZIP file is about 2.5mb unpacked about 6mb-ish

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 18th Jun 2009 06:47
Damn .... I hate you! You have got me all exited about shaders again.

I was primarily interested in the water shader sample.
It is giving a little over 50FPS running full screen at 1600x1200. (ATI HD4550 video card)

My intent is to eventually model a very simple ocean shader (without transparency, without reflection, without refraction). Something that I can apply over an area of viewdistance 300KM.(of course it should run on relatively low end video cards).
It will have to wait a little, until I finish my interface code to the "Fmod" sound library.

Thanks for providing the files. Much appreciated.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 18th Jun 2009 06:54
EVOLVED's Glass Shader Example in DarkGDK C++

Here is a nice example of a Glass shader, reflecting and refracting. Its actually a "trick" if you look closely, you will be able to see that the objects arent really transparent at all, it is most apparent with ghosting(G) turned on in the demo. The effect is achieved by careful use of shaders and looks quite nice without being too taxing on your system.

This attachment has "main.cpp" "main.h" aswell as the "media" and "FX" folders, but I have also included the Executable so you can see the shader working.
The file is 2.44mb Zipped and 6.04mb unpacked


Glass Sphere :


Glass Teapot :


Glass Twisty Shape :


Ghosted Glass Pyramid :


If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 18th Jun 2009 06:58 Edited at: 18th Jun 2009 07:47
@sydbod

No worries Im glad its got you interested again lol

Nothin makes that next blockbuster LOOK more like a blockbuster than a little spit and polish

Also, if you play around with the placement of the syncs in most of the examples, or replace the entire syncing system with fastsync and syncmasking you could squeeze a few more fps out im sure... the examples are not coded with optimization in mind, just functionality lol

Good Luck

If it ain't broke.... DONT FIX IT !!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 18th Jun 2009 07:46
EVOLVED's Simple "Toon" Shader for Objects

This is a very simple and short "Toon" shader, again from evolved.
If you are looking to add a different look to your program, this might be what you need

Attachment has as usual "main.cpp" "main.h" the "data" and "Effect" folders and the Executable the screenies were taken from.

Screenshots :




If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 18th Jun 2009 09:20
omg this thread is beastly. For me, I copy over the dbp code but it just doesn't work for some reason, thanks a bunch for this


Your signature has been erased by a mod
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 18th Jun 2009 21:02 Edited at: 18th Jun 2009 21:03
Very cool, except the toon shader doesn't work for me. I load it up and the head is just black, and the sphere is white.

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 19th Jun 2009 00:20 Edited at: 19th Jun 2009 00:23
@heyufool1 :

Did you extract the ZIP folder from attachment completely ? it sounds like its not finding some of the media...

Either that or you Graphics card doesnt support the shader version.
Its an old PS/VS 1.1 shader, I have read somewhere around that some of the newer graphics cards dont support the older shader versions properly anymore, I dont know the truth of that though, i havent realy looked into it, just what ive read in various forums.

Also, That EXE was compiled under VS2008 pro edition, with the March2009 DirectX SDK and DarkGDK 7.3 (not sure if that would make a difference for you, but it seems to be running on other people's pc's... ill have a look to make sure its not something i did in the linker, ill repost the attachment if it is)

EDIT : One more thought.. I compressed that zip file with an archiver called "IZarc" .. its a freeware version of Winzip, and support all archive formats that ive tried so far, zip, arc, rar, 7z, zoo, cab etc...anyway, depending on how you extracted the archive and what with, that may have affected the media in it aswell. Some archivers can corrupt if they cant read the file properly.

If it ain't broke.... DONT FIX IT !!!
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 19th Jun 2009 02:39 Edited at: 19th Jun 2009 02:39
Well I did extract the zip completely, and your other examples worked so assuming you used the same archiver that shouldn't be the problem, so I'll look into the shader version. Thanks!

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 19th Jun 2009 03:15
ok, if the other ones work ok on your system im sorry i really cant think of what might be the cause

I used exactly the same setting for all of the examples when they were compiled(they are even in the same solution).
The only variable that I can think could cause it would the shader itself, and your hardware/software.. although I personally dont know enough about shader language to be able to help, perhaps if you were to edit the .FX file and change in the techniques section at the bottom, the type of compiler...

make it compile it as a vs2.0 shader instead of the 1.1.. Again, not knowing shader language very well I dont know if that would work or not, I have changed it on my end, but it doesnt seem to affect it in anyway, it all still works..

The code i think could be changed is in the toon.fx file in the "effects" folder... I have included an attachment with the chaged toon.fx file, as i said it made no difference on my system or my 2 test pc's(my daughter's and my file server lol) it all worked the same as before.

FROM :



TO :


The toon shader is in its current form compiling only a vertex shader at version 1.1..

In my other examples, looking at the .fx files, most of them are ps/vs2.0, although there is a couple, skybox.fx for example, that use ps/vs1.0. So maybe its not the shader itself but perhaps the way your graphics card is interacting with it ? What card are you using at the moment ? Ill have a look around and see if i can find anything relating to shader behaviour on it that might explain.

On another note, I think that GDK has a built in toon shader command aswell .... dbSetCartoonShadingOn() ... I dont know how to use it, but maybe you could play with that and see if it works, if you are intersted in the effect...

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 19th Jun 2009 05:10
I think it's a problem with my graphics card. Because on the dbSetCartoonShadingOn() function in the user manual it says:
Quote: "Your video card must have the ability to create this hardware effect."
So, because I set the the function up correctly and it still didn't work, it's probably just because of my graphics card. Thanks for your help, i'll try to update my graphics card or something.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 24th Jul 2009 11:11
great thread with lots of useful examples! keep them rolling in pls!!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 24th Jul 2009 11:17
What techniques are you interested in bjadams ?

I think most of the "basic" object shader effects have been covered in the above examples, shadows, water, glass, normals, bump, cublic lighting etc..

If you can give me an idea of what you are looking for ill see if i can find an example or 2 of it for you in GDK

If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 24th Jul 2009 17:29
Deferred lighting ^_^


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 24th Jul 2009 19:14
ok, I have a bunch of examples from evolved's website for deferred lighting in dbpro, there are 4 or 5 examples tied into a central function set which is quite large so it'll take me a bit to get it ported over to cpp(taking a quick look, in dbpro there is a just over 2500 lines to port, so maybe a couple days depending on my time).

Ill post it back here when im done.

If it ain't broke.... DONT FIX IT !!!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 24th Jul 2009 22:41
there was a FUR shader in one of the ultimate shader packs for dbpro. don't remember if it was done by green gandalf or evolved though. would be nice to see it working in dgdk
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 24th Jul 2009 23:11
OMG IF YOU DO THAT I WILL <3 YOU FOREVER !! <3 <3 That has been +1 to dbpro for ages, they could make their game looks amazing really easily. I can't wait for it


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Jul 2009 04:10
@prasoc .. I'm working on it, havent come across anything yet that I dont think will work with GDK, but I do need to re-arrange the code slightly for C++ here and there and test it once it's done to make sure i havent goofed anything lol. It is a large example set.


@bjadams - I have the vertex fur example here with a bunch of others, ill get to work on porting it over to GDK for you aswell, it doesnt look to complex so shouldnt take too long.

I think I might have a look at the multi-pass lighting example aswell once im done with this one. Anyway, one thing at a time, ill keep you posted on how it's going

But, while im working on that, here is something to have a look at that I think looks pretty cool, even though its not shader based. A 3D object(plane) based animated fire decal illusion.. It's one of Lee Bamber's snippets from DarkSource and is really smart for something so simple, it could be adapted to have some lights flickering around it and smoke particles quite easily, and because its 3D you can place it where you want it in you scene.

Screeny :


Here is the code :



Attachment contains all the media, a compiled and working .EXE and the source code file that you can add to a project. Have Fun

If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Jul 2009 06:17
EVOLVED's Vertex Fur Shader in DarkGDK C++ Example

I personally dont really like the look of this effect, but thats just my opinion, perhaps it could be made to look more realistic by tweaking some of the shader's variables..

anyway, as requested here is an example of using the vertex fur shader in DarkGDK...

As usual, the attachment has a compiled .EXE, all the media and the source code file.

Screenies :




If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 25th Jul 2009 10:18
WOW! Fur works! amazing stuff!!!! You're a miracle genius Mista!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Jul 2009 11:49 Edited at: 25th Jul 2009 12:04
Thank you for the compliment, Im glad you like the example.. but really, its not my work.

I just ported a bunch of Evolved's code from DBPro to C++, it's still structured his way and he deserves all the credit for writing it.

Aswell as the shader itself which I didnt touch, as Im not very good with HLSL atm, I can muddle my way through an FX file and understand what is doing what, but writing my own is a little beyond me at the moment im still cutting and pasting other people's code and learning, and I need to spend some time and learn the language itself properly(its on the todo list lol).

So thanx to Evolved and anybody else whose shaders are here in these examples.

EDIT : I'll compile a list of names of everybody whose code and media, both DBPro and Shader, that I've used and I'll stick it in the first post when I have the time. At the moment though, I think the only person who's shaders are here is Evolved.

Im also still working on the Deferred Shading examples, I had to go back through and restructure the code a little more than I thought as it's using DBPro's dynamic arrays, so I decided to use my own class for emulating that functionality to make porting it as easy as possible, and to keep the code as close to its dbpro counterpart in structure as I can.

EDIT 2 : Sorry for the multiple edits, I just remembered though and thought that I had better mention it to prasoc.. the deferred lighting examples use some functionality that is included in DarkBasic Pro by default, but not DarkGDK, for dynamic cube mapping(the command is "make dynamic cube map"). So far, Ive found in the DarkGDK DarkShader library, functions that seem to do the same thing, but I havent tested it yet, other than to see if it works on its own(which it does).. So, depending on if it works or not, there is the chance that I may have to remove or "gimp" some of the kind of shading such as cube mapping.

If it ain't broke.... DONT FIX IT !!!
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 25th Jul 2009 13:20
Mista, great contribution

This thread is an useful resource for anyone starting with DGDK shaders. It gives an starting point, and it will save many time for many people. Keep on the good work
Apple Slicer
16
Years of Service
User Offline
Joined: 14th Nov 2008
Location: Oregon, in the rain...
Posted: 26th Jul 2009 00:42 Edited at: 26th Jul 2009 00:43
Wow. This is astounding work. I love your examples so far...maybe get that bloom shader of evolved working?

I know that there is an example of bloom included with dgdk, but I cant seem to make it so that the camera can move, and the bloom shader still work along with movement.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 03:52
@apple slicer,,, No worries.. Ill have a look at putting up some full screen shaders when im done with the current one im working on(deferred shading), so far they have been mostly object shaders, so some full screen ones would be nice.

Thanx for the suggestion, if there are any other examples that you want, feel free to make requests.

If it ain't broke.... DONT FIX IT !!!
Apple Slicer
16
Years of Service
User Offline
Joined: 14th Nov 2008
Location: Oregon, in the rain...
Posted: 26th Jul 2009 04:02 Edited at: 26th Jul 2009 04:34
You're a genius.

Thanks. I cant wait to see the deferred shading too.

EDIT: Parallax?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 05:21
@Apple Slicer.. Bloom and a Parallax Mapping example are on the list.

The deferred shading examples though are going to take me a couple more days that I originally thought, there are a few commands missing from GDK that it's using so Im working on emulating in GDK to get it to work..

The commands so far that it uses that I know dont work or are missing from GDK include :

dbRenderDynamicCubeMap()(need DarkShader in GDK for this one but it still doesnt work, causes an exception error) - not sure if its needed but I dont know a work around for this one yet.. so ill probably have to disable it.
dbGetObjectEffect() - can emulate this one by keeping track of which object has which effect applied to it using an array of custom types..painful way to do it, but it will work.
dbCameraExist() - just a missing forward decleration - works when you add it's decleration.
dbGet3DMathsExist() - another missing forward decleration, works when you add it.

Im sure ill probably come accross others, im only around 1/3 of the way through the main function library so far(around 1000 lines ported, but not tested), I had to inject a custom template array/list class into it to manage the arrays in the way that I wanted to as they are dynamic(and filled with user types) and while I could have just pre-allocated a constant array thats not very efficient and efficiency is something that will be needed after looking at what this library is actually doing lol.

If it ain't broke.... DONT FIX IT !!!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 07:13
EVOLVED's Parallax Mapping Shader Example

Here is an example of Parallax Mapping on objects. I think it looks quite nice, although im not sure if the screenshots do it justice as there is a "glossy" effect on the objects that moves with the light in the program and makes it look nicer..

Anyway, attachment contains .EXE compiled and working(with GDK 7.3), all the media and Shader files and the source code file.

Here are the Screenies of the program running :







If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 10:12
@ Any Forum Moderators who happen to pass through,

While im thinking of it, if there is a FORUM MODERATOR reading this, when you have the time, would you please be able to rename this thread something a little more general than what it is currently titled.

I was thinking something along the lines of : "DarkGDK Shader and Effect Examples"

This will allow more people to find it I think and its not really in relation to only water, I apologise for the silly original naming, I wasnt thinking at the time.

If it ain't broke.... DONT FIX IT !!!
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 26th Jul 2009 17:19 Edited at: 26th Jul 2009 17:21
Something that has been giving me sleepless nights wondering how this is done.

In another game library that I am playing with, it has a water shader that is endless.

http://i16.photobucket.com/albums/b49/sydbod/Sample1.jpg

That water is visible up to 300KM in that view (the camera frustum was set to 300KM for this snapshot).

One can move the camera upwards and get a full working ocean as far as one wants to see.

How the hell does one create an endless ocean like that (yes it has moving waves, reflection, refraction....etc.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 18:56 Edited at: 26th Jul 2009 19:00
@sydbod - Here is a screeny of a terrain system that I am working on, includes water, trees and other environmental effects.. all of the terrain/water meshes are made from memblocks and are welded vert meshes. The water is using Evolved Fresnel Water shader and is setup to allow above/below water to be displayed properly, it reflects and refracts.

There are almost 2.1million poly's onscreen in that pic and its only the beginning of what the system can handle(thats produced from a 1024x1024 heightmap) - although at that extreme range(I increased the cam range to 180,000 to get it all in the screeny lol) it does hurt the FPS..

To give you an idea of the scale, the entire water is made up of 4 large objects, each around 20k poly's.. the exact size for each water tile is around 40,000 dbpro units sq(10000x10000 - each made up of 100 quads per tile with 10 units per quad - maths may be off, its late lol).

To answer your question, there are a number of tricks that are used to render large scenes like the one in your picture above. They may increase the scale of the object and reduce the scale of the texture, to enable them to show more without bogging down the system, there could be a LOD system as part of their water mesh, reducing it's poly count the further from the camera that it is, although most likely a combination of various tricks and techniques would be used.



If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 26th Jul 2009 21:55
It doesn't matter if you "gimp" the effect, cubemaps are for reflections are they not, which isn't too important for the overall feel of the differed lighting too much


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Jul 2009 23:56
yep you are right as far as I know, the only "gimping" so far will involve teh dynamic cube maps.

Although there are quite a few commands that are missing from GDK that this library is using so im kind of working on multiple workarounds aswell.. almost 3/4 with the code port, then just gotta make sure it works.

If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 00:09
You have more patience that me, ALOT more


Your signature has been erased by a mod
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 27th Jul 2009 09:44
i have darkshader, but i was always confused about the additional commands it offers. it should have some easy fullscreen camera commands but i never found the right way to use them.

so does the darkshader lib for gdk contain all the commands of the dbpro counterpart?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 09:49 Edited at: 27th Jul 2009 10:34
Here is the listing of the DarkShader header file for DarkGDK :

ShaderData.h :



The only command in there that I havent gotten to work is :

dbRenderDynamicCubeMap - whenever any program includes that call, it crashes as soon as it reaches it... Although, Im using a very old version of the library(I havent purchased it yet, plans for that in the next couple of weeks sometime, saving pennies atm and using a mates copy as he no longer does any programming)


EDIT : Im not 100% sure, but reading through the "Advanced Shaders" tutorial that comes with DarkGDK, its states that the "shaderdata.h" file comes with DarkGDK, rather than darkshader, so perhaps the library is already present in GDK without having to have darkshader ?? Ill do some more experiements and post bak if i find anything solid.

EDIT EDIT : I have now confirmed that the shaderdata.h and shaderdata.lib files that are required by DarkShader shaders are included with the DarkGDK by default, so purchasing DarkShader isnt required unless you want the IDE. Im not sure of whether or not the purchased version of DarkShader is inline with the DarkGDK version of the library, I assume it would be though. I did some basic testing and the functionality is the same, also the dbRenderDynamicCubeMap command still crashes

Also, it seems that darkphysics is not compatible with shaderdata.h, I havent tested dakrAI or any other plugins that I have. When you include calls to both "dbShaderDataStart()" and "dbPhyStart()" the program will not link, the error is a multiply defined symbol in one of the 2 libraries, shaderdata.lib or darkphysics.lib - the symbol is g_DeleteObject

If it ain't broke.... DONT FIX IT !!!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 27th Jul 2009 17:47
maybe they just included a cut down version free with gdk.
or maybe darkshader is now included, just like the cloth & particles addon for dbpro.

can someone confirm pls?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Jul 2009 18:01 Edited at: 27th Jul 2009 18:22
I think I have solved the set effect constant vector element...

It had to do with me mis-understanding what the command does lol

It isnt for setting a single element of a vector in the shader....

It is for setting an ARRAY ELEMENT inside the shader, apparently DarkShader shaders use an array to represent multiple lights, each array element holds a float4.. and is of the type float4(each of the array elements is a vector4 in GDK terms) - the arrays in this lib are made up of 3 arrays, one 5 elements long, one 9 and one 16 elements long.

So my idea for emulating the command went out the window when i figured out how the command was acutally working lol, BUT after a little digging through GDK internals, I think I have found a way to access the shader array with GDK pointers... something like :



I need to do some more experimenting, as some of the flags that can be set internally seem to work and be automatically updated on a sync and others arent. I believe that I should be able to set the object mask properties this way aswell, as I have seen acouple of "mask" named flags in there.

Lets keep the fingers crossed that I can pull it off, I really want to get the deferred shading working for GDK.

The last thought I had, was kind of a "fall-back" incase the above ideas dont work out, and that involves re-writing the shaders unfortunately, to not use array of lights, and just store multiple vectors, but I would need to hit up the old HLSL books first lol

EDIT : Ive looked through the shaders that are using arrays, and they actually look quite simple to modify to not use an array, the way it is being called in the shader is in a for loop, so all i need to do is to replace the actual arrays with named float4's and write out the for loop manually, then I should be able to set them manually from inside GDK, although a bit of indexing is going to be needed I think to change the library to a different system... ill keep you posted

If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 20:07
Parts of dgdk are so broken


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 29th Jul 2009 04:43
Hey all, just a quick update on the Deferred Shader Library, Im stil working on it...

The code port from DBPro to C++ is complete as Ive said before, and it is now working, from a point of view of having all the little typos that I introduced fixed. It compiles and runs without any problems so far..

What is working so far is :

*Addding objects and lights and shaders and whatever else you need to the system
*Object Masking is sorted, I managed to get it working by accessing and setting the objects internal properties to make it mask, how I assume the dbpro command, Set Object Mask, works itself.
*The camera masking systems and syncing system is sorted and 99% working, I need to test a couple of things to make sure that its doing what its told, but so far its syncing however many cameras you give it and whatever render targets they have and masking them all properly, the testing programs in using are running at the full sync rate, with 14 images, 6 camera 3 effects and close to 3000lines of code all syncing and masking properly(I think, again, gotta test to make sure)


Ok, so the things im still working on :

*Get Object Effect and Set Effect Constant Vector Element -
These 2 commands are being used together to get an array of vectors from an object, and to set one of the elements of that array and send it back to the shader. Im currently taking a crash course in DirectX shader manipulation as im going to need to access the shader directly from the object's internals properties to be able to get at the effect's arrays.. Once I have that sorted I think I should be able to write up a function that allows me to set the array by element(by getting the whole array, changing what needs changing and sending it all back, using the ID3DXBaseEffect::GetVectorArray method and its set counterpart. - I can get at those commands from inside the GDK object via it's internals, using :



I havent tested it enough to know if its working or not though.

I also have a fallback plan incase it turns out that I cant use those internals for whatever reason, but it involves re-writing i think 4 or 5 shaders(only the ones that are using the light arrays) to not use light arrays, after looking at the shaders, its wouldnt be a hard task to do at all, they are only being used in a for loop inside the shader and incremented through, so I could re-write them to be iterated through manually and all individually named, that way I could just use the normal dbSetEffectConstantVector command. Doing it that way and re-writing the shaders is something that I dont want to have to do though as its pretty much defeating the advantage of using arrays in the shader in the first place, not to meantion its alot of extra work that I dont really need to do lol.

*TESTING - yep, Im not going to post this one up here until im completely sure that its working properly. There are alot of places where memory leaks could occur if I dont add in some safety checking, like if a function was passed an invalid value that is used inside it to obtain a pointer to something, I have no error checking at the moment to ensure that everything is used as it should be, and alot of places where the code is still pretty messy from the port, so I have to tidy it up aswell. The code is almost 3000 lines long for just the function library after the port to DarkGDK and C++, and its going to be a little longer when i finally get the shader array thing working one way or another. Becuase it is so long, I just want to spend whatever extra time I need to, to make sure its a bug free initially as I can, then when its used and little issues are discovered, it should be easier to fix them.

And also, If anybody is after any examples of using a particular type of shader or something along those lines in DarkGDK, feel free to ask here in this thread and ill put something together for you as soon as I can.

If it ain't broke.... DONT FIX IT !!!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 29th Jul 2009 12:12
Omg you're working like a madman! OVER 3000 lines?!?! Sorry for putting so much work on your shoulders, but it sounds like you are coming along nicely with it.


Your signature has been erased by a mod
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 11th Aug 2009 07:58 Edited at: 11th Aug 2009 08:28
BLOOM Effect Example

Hey All, just wanted to let you know that I am still working on porting the Deferred Shading library, had to spend my time on some other stuff for the past couple of weeks, but its still on the project list and mostly working, just ironing out some bugs with the masking and making sure that all the arrays are working properly.

Anyway, I remembered awhile bak someone was asking for an example of using Bloom, well I tracked a nice easy one DBPro one down, its part of the DarkSource examples, well, it was originally...

As usual, attachment contains the Source .cpp file, a compiled working EXE(GDK7.3) and it also contains the 3 .FX files to make bloom work, there is no other media, its all render targets

Here is a screeny, it shows just how simple the technique is :



Have Fun... I'll post some more as soon as I get the time to finish them off.. might be a little while though, man's gotta eat, and so does my 10yr old daughter lol Little busy with work atm is what I mean

EDIT : forgot the archive, sorry, here it is lol

Here is an alternative version of the code that demonstrates how to use OBJECT MASKING WITH SHADERS ... I basically replaced all of the show/hide object commands by masking the objects correctly.... doing it this way makes it ALOT easier to setup large shader scenes...



If it ain't broke.... DONT FIX IT !!!

Attachments

Login to view attachments
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 11th Aug 2009 08:28
Wow. So they released those librarys without testing them for cross compatability first...

if(enemy == Amnzero) runAway();
Amnzero->WebSite = L"http://neovance.com/";
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 11th Aug 2009 08:58
Sorry, Amnzero which libs do you mean ?

If it ain't broke.... DONT FIX IT !!!
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 11th Aug 2009 09:11 Edited at: 11th Aug 2009 09:12
Dark Shader and Dark Physics?

Quote: "Also, it seems that darkphysics is not compatible with shaderdata.h, I havent tested dakrAI or any other plugins that I have. When you include calls to both "dbShaderDataStart()" and "dbPhyStart()" the program will not link, the error is a multiply defined symbol in one of the 2 libraries, shaderdata.lib or darkphysics.lib - the symbol is g_DeleteObject"


if(enemy == Amnzero) runAway();
Amnzero->WebSite = L"http://neovance.com/";
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 11th Aug 2009 10:52
Oh sorry yes, that error seems to be a problem with a number of TGC plugins working together...

DarkPhysics didnt used to like DarkAI the same way, now it doesnt... But if you try to use DarkAI and Advanced Terrain you will also get that multiply defined symbol error with the same g_DeleteObject symbol.... I also think the shaderdata and DarkPhysics error has been fixed, but I havent actually tested that one. (DarkAI and DarkPhysics seem to be the 2 main offenders with the multiply defined symbol errors lol)

I think the problem may be because TGC havent stuck their various libs into proper namespaces, so they have to deal with name clashes like that, but they do fix things, just takes em awhile sometimes lol

If its something that you would like to see fixed sooner rather than later, I think emailing support might be a good idea, I have always had a good response from them, might take a couple days sometimes for a response, but they let you know whats happening at least.

If it ain't broke.... DONT FIX IT !!!

Login to post a reply

Server time is: 2024-11-19 18:06:25
Your offset time is: 2024-11-19 18:06:25