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 / [DarkGDK 2.0 Matrices & Shaders] Can you get this to work?

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Aug 2012 14:15 Edited at: 2nd Aug 2012 14:24
So I've been messing around with this for over a week now it seems.
This is a minimal example that is as close to a straight port of Fallout's Simple Shadow Shader tutorial as I can get. It makes use of a custom Matrix4 class since the built-in one simply wouldn't work.
However I just can't seem to get the proper result still (all that is rendered to the shadow map is the cube, which seems rather elongated at that).
Maybe it is that I've missed something after staring blind at these things for days and nights so I post my code here for anyone who feels up to it to investigate and try out.
---------------------------------------------------
main.cpp
The main source file.



MathWrapper.h
Just contains some typedefs to discern the internal DGDK Vector / Matrix structs from my own wrapper classes.



Matrix4.h
Wraps the underlying calls to the DirectX functions used by DarkBasic's 3D math functions. Also extends this by keeping an internal "standard" DBP matrix4 (referred to by ID). This is used when communicating with shaders.


Matrix4.cpp
While most member functions are inlined and present in Matrix4.h due to their simple wrapping nature, this file contains some functions that cannot be inlined due to cross references between Matrix4.h and Vector3.h as well as initiation of static fields.



The below file isn't really used in the example code but it is included by Matrix4.cpp so it's here for completeness. You can just outcomment the functions using it in Matrix4.cpp and everything should likely work.
Vector3.h





Now there are some additional dll functions required here. These are from DBProVectorsDebug.dll and Matrix1Util_32.dll. The latter must be manually included in your darkgdk.dll file by adding the following line to your (DarkGDK)/engine/libraries file (yes it has no file extension):
.
(Of course you must also drop the Matrix1Util_32.dll file in your (DarkGDK)/engine/plugins-user folder).
The functions wrappers are as follows and goes (I suggest, but you can place them whereever) at the bottom of your include/dgdk/core/dgdk-math.h and dgdk-math.cpp files:

[ADD TO] dgdk-math.h


[ADD TO] dgdk-math.cpp



EDIT: here's the shader source from Fallout's thread as well, refered to as SimpleShadow.dbs in my main.cpp file above:




Thanks for any help and fresh eyes,
Rudolpho


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-04-19 08:27:43
Your offset time is: 2024-04-19 08:27:43