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.

Work in Progress / [STICKY] DX11 Plugin

Author
Message
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 13th Jun 2016 21:42
Any news is good news so long as it wasn't being cancelled! Thanks for the update
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Jun 2016 22:53
All the built in lighting and shader support is exciting keep it conning man!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 14th Jun 2016 08:05
Yup, some of us are relying on this plugin

One thing though Rudolpho - I wonder if you could decimate DBPro's DX9 reliance, that would be awesome. I'd have a go at it myself if I was much good with real C++.
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Jun 2016 10:52
Thanks guys!

Ortu wrote: "keep it conning man!"

Rudolpho - conning people since 2008!

Van B wrote: "I wonder if you could decimate DBPro's DX9 reliance, that would be awesome"

I have thought about this to and fro and it should certainly be possible. In theory all that should be needed is to remove some setup and shutdown code from DBProCore.dll and DarkExe (and naturally that no DX-reliant functions are called from your DBPro program).
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 19th Jun 2016 13:43
Maybe someday we can sell this on Steam? Except from AppGameKit I don't know of any other engine using BASIC.

This is probably a long shot, but I think if you put in some 'default' modern lighting system (like Advanced Lighting or Unity default lighting, global illumination, ect) , combined with easy BASIC, then people will come in droves.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Jun 2016 00:53
Maybe!
I also have some ideas about trying to extend the DarkBASIC language a bit, but that is still a ways off, so we will see what comes of it I suppose.

As for a default, complete lighting system, that is something I would like to do one day. It would require post-processing shaders and such though, which may be a bit complicated to add in as part of the default rendering pipeline, but I'm sure it should be possible to work out.
I can completely see how people would not want to have to write their own lighting system after messing around with all the problems it entails for the last months. Whether people would come in droves for it, well... one can always hope I guess
For now, the plan is to provide default "normal" single-pass lighting and shadow mapping in version 0.5. This could then be built upon in the future for things like bloom shading, volumetric particle lighting, ambient occlusion, etc., both by the eager DBPro user or perhaps eventually as an optional extension to the default lighting system included with the engine itself.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Jun 2016 11:22
Sounds good Rudolpho - shadow shading is something that eludes most people I think, would be great to have a standard system.

I was wondering how I should use pixelmaps and images though, hopefully you can point me in the right direction. I want to make adjustments to an image in realtime, it's textured onto a terrain, this is for RGBA texture masking. I can get it to do what I want to generate the image with a pixelmap, but then I'm a bit stuck on how I can update that. Deleting the image and re-creating from the pixelmap doesn't seem to do anything, I wonder if there's a way to just update the image without deleting it. Any advice you can give on how you'd do it would be appreciated.
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Jun 2016 13:07
Van B wrote: "I was wondering how I should use pixelmaps and images though, hopefully you can point me in the right direction."

Pixelmaps are a tool for manipulating an image in an RGBA8 format, reminiscient of DBPro's image memblocks.
As you have discovered there are currently no means of updating an image from a pixelmap, you can only create new images from them. This is an oversight on my part and I should add such updating functionality to them in the future. They may also receive an auto-convert functionality between various pixel formats instead of being locked to B8G8R8A8_UNORM as they currently are.
In any case, what you would do is indeed to recreate the image. You can keep and change the same pixelmap, so you don't have to recreate that one however. This is in fact how the engine's "labels" work behind the scenes so it is quite efficient even with the constant image deletions / recreations.
What I imagine you're missing is that after creating the new image you also have to reapply it to anything using it (DX11 SET OBJECT TEXTURE / DX11 SET SPRITE IMAGE / etc.). This is so because you are indeed creating a new image. Another implication of this is that you should delete the old image too, instead of just overwriting its address, or else you will leak memory and probably end up with a crash within seconds if you're doing the pixelmap -> image thing in every frame.

Van B wrote: "... I wonder if there's a way to just update the image without deleting it."

Indeed there is, though this is a bit more low level than the pixelmap approach.
Using DX11 LOCK IMAGE you can lock and update an image in-place. This furthermore allows you to only lock a subset of the image, such as a certain mip level or array slice, or indeed a rectangle that is smaller than the image itself.
After that you would call DX11 GET IMAGE PIXEL BUFFER POINTER to get a raw memory pointer into the pixel data of the image. You can use DX11 GET IMAGE PIXEL BUFFER SIZE, DX11 GET IMAGE PIXEL BUFFER WIDTH and DX11 GET IMAGE PIXEL BUFFER HEIGHT to query the accessible memory area. After that it is up to you to manipulate / read this memory as you see fit. What the data in the pixel buffer actually represents depends on the image's format (which can be checked using DX11 GET IMAGE FORMAT) and for some formats such as compressed ones or things like R10G10B10A2 or R16_FLOAT it would be a bit of a braintwister to set these accordingly, especially using DBPro. It certainly is possible though.
However, assuming you have a BGRA8_UNORM image, as you would if you created it from a pixelmap in the first place, the data layout is pretty straight forward. Every set of four bytes would be a new pixel, where the first byte is the blue channel, the second the green, the third the red and the fourth the alpha channel for that pixel. Once you're done editing the image you would simply unlock it (DX11 UNLOCK IMAGE) and the source image will be updated accordingly, without any need to reapply it to objects / limbs / sprites / what-have-you.

Finally there is a third option of using a render target image and updating it using shaders instead.
This could either be done through a pixel shader as a normal rendering operation, or using a compute shader, which would allow you to only write to certain pixels and also to read the previous pixel data already present in the image. Doing it this way offers the highest possible efficiency as no stalling communication between the CPU and GPU is required (image data is held in VRAM and has to be copied into RAM for access from the CPU when using pixelmaps or locking an image, and then back to VRAM again when done), however the tradeoff is that it is (usually) more complicated to set up as well.


Also thanks for the stickying of this thread, whoever did that! Most honorific
Though I've got to admit I got worried it had been deleted for a while there before finding it in green on the top of the thread list
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Jun 2016 13:29
Thanks

The image manipulation idea is interesting, that might be my best option in the long term, as I'd like to just load up the mask images and apply them when the terrain is not being edited. I think my main issue is that I've missed the re-texturing part with pixelmaps... I might have assumed the delete and re-create method wasn't working because I never noticed any slowdown. Lots of stuff for me to try - much appreciated!
The code is dark and full of errors
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Jul 2016 22:13
Thought I'd post a couple of screenshots of some foliage, lots of foliage, too much foliage - but I think it's pretty so...
The code is dark and full of errors

Attachments

Login to view attachments
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 21st Jul 2016 16:32
Wow.

What's the performance looking like?


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2016 17:14
Thanks! - Performance wise it's pretty good, not optimised yet, there's no distance culling, that'll be added soon. I get 50-55fps on average, my PC is reasonable but I only have a GTX660, patiently waiting on a 970 making its way to me.

It uses 32x32 objects, each with 5000 points, and theres no conditions so all points are used, so that's a 1024x1024 tile terrain with over 5m cross plain foliage points, and it gives a consistent 50fps on a 660. Once I add in distance occlusion I expect that FPS will rise nicely, and if I can tesselate the terrain then it'll jump up some more. The terrain will have 9 detail textures, with the 9th texture being a 3x axis, so X, Y and Z versions of a rock texture for example, to make it more organic... plus the textures will be arrays, so I'll probably add relief and normal mapping options.

I plan to have a tech demo in about a week, once I add terrain auto-texturing, sky, and water. The DX11 plugin is pretty damn awesome, I've wanted to have effective foliage in DBPro for so long!
The code is dark and full of errors
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2016 20:50 Edited at: 22nd Jul 2016 08:26
Added a distance occlusion of 150 terrain tiles and the fps is 85-90 now, if I reduce the density to 2500 (half) then the fps is only 7 or 8 more... so it appears that the denser foliage doesn't kill the fps too much, a 7% or 8% drop is worth it I think. I should really test it on my fresh win10 install though, this Win7 install is a bit crusty, might be slowing things down.

Edit: Fresh win10 install gives 110-150 fps, it's creeping up nicely
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Jul 2016 11:41
Most lush indeed, looking very nice Van!
It seems you've got the draw order sorted out nicely too.

I don't know how you're creating the foliage meshes, but an idea that may be of interest (if that isn't what you're doing already) would be to use a geometry shader running on a tessellated terrain mesh for building the foliage quads on the fly. This would have the added benefit that the density would be higher in the immediate area around the camera (assuming yo're using distance-based tessellation) and then dropping off to less and less further away. It would also make it easy to tweak the individual foliage instances based on the terrain at that specific point.

Van B wrote: "I plan to have a tech demo in about a week, once I add terrain auto-texturing, sky, and water. The DX11 plugin is pretty damn awesome, I've wanted to have effective foliage in DBPro for so long!"

Sounds really exciting, I'm looking forward to it!
And thanks for the appreciation
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Jul 2016 13:18
Ohh, that's an interesting idea, would probably look more organic than using an alpha fade. I still have a lot to learn about the tesselation stuff, I never thought about using it for the foliage.
The code is dark and full of errors
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Sep 2016 08:09
Damn tessellation is tricky, trying to make a water effect, I think I need to spend time learning the actual vertex formats.

But, terrain shader is working nice at least...
The code is dark and full of errors

Attachments

Login to view attachments
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 1st Sep 2016 22:00
Does look good, does each texture have is own detail map?

The 'green rock grass' effect can really spoil upclose a terrain that looks great from a distance.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Sep 2016 22:43
The terrain has 9 layers, with layer 9 including another 2 layers for X and Z mapping, used for rock textures to improve texturing on steep slopes. Each layer has a diffuse, normal, and coded texture with offset and specular info - but I've yet to refine that. It works well on really pebbly surfaces but I'm just using a quick normal map generator function for the time being. There is a colour map layer as well, but that's not used yet.
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Sep 2016 17:31
Looking really nice Van!
Is the foliage edge smoothed? Some parts of it looks like it is but I can't say for sure. I've been interested in that since a while as it seems to be a good compromise between z-ordering complexity with overlapping polygons and the blocky-looking alpha testing approach.

Van B wrote: "Damn tessellation is tricky, trying to make a water effect"

There should be a tessellation / displacement mapping example. You've probably already seen that though, and I admit it is a bit messy (and outright faulty with the pyramid object, though that's more because of it's sharp edges than the code) and could do with a revisitation.

Van B wrote: "I think I need to spend time learning the actual vertex formats"

Hm, what do you mean with vertex formats?
You can create those to hold any data you wish using DX11 CREATE VERTEX LAYOUT and DX11 ADD VERTEX LAYOUT ELEMENT. The format for the latter has to be given as one of the pixel data formats as that is what the shader side deals in, however you can just think of them as various vectors of different resolution. For example, DXGI_FORMAT_R32_FLOAT is a single (32-bit) floating point value; DXGI_FORMAT_R32G32_FLOAT is a two-float value (accessed as float2 from your shaders) and so on.
The _UNORM formats are specified as Unsigned integers on the CPU side, ie. in the actual vertex data, but on the GPU side they are reinterpreted as a normalized value in the 0..1 range. The standard colour format is DXGI_FORMAT_B8G8R8A8_UNORM - this is the standard 0xaarrggbb format, but to your shaders it appears as a float4 where 1.0 corresponds to a byte colour value of 255, 0.5 is 128 and so on.
Similarly the _UINT formats contains unsigned integers on both the CPU and GPU side, _SINT stands for Signed integer and the _TYPELESS formats are commonly used for pure data or "excess" such as an unused alpha channel.
The numbers in the formats designate the amount of bits allocated for each channel; you can for example have a 24-bit red channel ("X") and only 8 bits for the green ("Y").
There are also some other, more exotic formats, but I wouldn't worry too much about those for vertex data. They're mainly used for compressed pixel data or SRGB.



In other news I apologize for the lack of updates of late.
I have managed to get a job and as such am finding that I scarcely have time for more than eating, travelling back and forth and sleeping most days, so my (personal) programming hours are reduced to a weekend day here and there where I don't have to cut my grandmother's lawn or similar undertakings. I hope things will get better with time as I get more used to it, but the travelling time is admittedly quite bad (nice job though so I shouldn't complain).
In any case, I hope I will eventually manage to fix up the bugs in the lighting system (which at this point probably means a rewrite of the directional light code at least, and possibly half the point light effort as well) and get it to a releaseable state. After that I imagine things should get a bit easier as it can be put into smaller, more distinct pieces such as audio, physics, UI, hopefully VR and so on (or so I'm telling myself).
The initial idea of course was that the lighting system wouldn't be too huge an undertaking either, but it has prompted the implementation of tonnes of previously not considered side tracks such as shader libraries, mesh materials, different draw orders and so on. On top of that there has also been a lot of unrelated functionality put into version 0.5 such as gamepad / joystick / etc. support, extended image editing, texture sharing and various bug fixes, as well as some precompiler work.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Sep 2016 16:03
Thanks Rudolpho. I've enabled edge softening, and I think it does improve things but not when the sky is the backdrop, like the smothing works best over other foliage. It might make a difference when I add a sky effect, so it's not just rendering over the background.

I plan to mess around with the tesselation example, make a water test from that, then impliment that into what I have. I keep getting silent crashes, so I think I need to understand it all before trying to impliment it, I want to use it wherever I can, so the tesselation example will help I'm sure, but I'm getting old - this new tech takes time. Thanks for the explanation on the format stuff, I'm getting used to it.

Good news on the job too! - and take care of grandma - there's a lot in this plugin to keep us occupied already, but I do hope you get the time to add the features you've mentioned, lighting would be especially useful I think but really I have a use for everything!
The code is dark and full of errors
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Sep 2016 12:58
Splitting out that tessellation example helped a lot, was able to make a water source file to handle that stuff, got it showing reflection and refraction, so it's in a state now that I can start refining the shader.

For some reason though, when I create a camera, it's like the depth is inverted, like the Z depth acts really strange - not sure if I can fix that by specifying the FOV. For the time being, I'm just glad to have it rendering to the water mesh.
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 6th Sep 2016 08:38 Edited at: 6th Sep 2016 08:40
Thanks

Yes, the outlines sure look better with a less uniform background; hopefully a more detailed sky will help here. On the other hand there are situations where such foliage looks really square even in pretty recent AAA titles; I still find it a lot better than the Z fighting that tends to occur where quads overlap in a strict alpha blending scenario though.

Silent crashes are annoying to try to resolve indeed. I do think I have "most" normal errors reported by now though, so when this happens the first bet it probably to check your variables for spelling mistakes (ie. you're trying to use a resource but accidentally supplying the wrong variable name => DBPro sends a zero instead of a valid identifier). It can also happen sometimes where resources require additional setup before being used in a particular way; for example trying to retrieve a non-existant limb of an object will return 0, signifying there is no such limb, but then trying to use this with any limb accessing functions may cause a crash.

Happy to hear you got the tessellation working. As for things to keep occupied I technically have two "parts" of the upcoming version that could possibly be released on their own and that might be possible to finish sooner than the lighting system. We will see how that goes.

Van B wrote: "For some reason though, when I create a camera, it's like the depth is inverted, like the Z depth acts really strange - not sure if I can fix that by specifying the FOV."

Hm, how are you setting up the camera?
You can try using DX11 GET PROJECTION MATRIX() to see whether any element seems to be off in there. Also, all the built-in transformation functions assume a left-handed coordinate system (as do standard DBPro), but I doubt that would be the issue unless you're porting something from OpenGL or similar.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Sep 2016 12:17
The camera is just setup as a standard, nothing fancy, I will compare the matrices from the main camera and render cameras though, that should give me some clues - I should really learn more about that stuff anyway so this will give me the chance.
The code is dark and full of errors
Star Vitebsk
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: Belarus
Posted: 30th Sep 2016 14:41
when you can see the source code DX11 Plugin ?
VitebskStar@tut.by
icq: 157980031
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 30th Sep 2016 19:23
Awww, demo expired.
The code is dark and full of errors
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th Sep 2016 23:18
An extended demo build of version 0.4.7.5 can be downloaded from here.
This is just the updated dll file; simply replace your current one with this in the Compiler\plugins-user folder. The current download from the opening pages has also been updated to this extended version, but also includes all required files for a fresh installation.

Star Vitebsk wrote: "when you can see the source code DX11 Plugin ?"

I currently have no intentions of open sourcing the engine until such time that I will no longer be working on it myself.

By the way, did you ever sort that camera depth out Van?
Star Vitebsk
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: Belarus
Posted: 1st Oct 2016 11:29 Edited at: 1st Oct 2016 11:29
it is the most effective open-source projects.....
VitebskStar@tut.by
icq: 157980031
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Oct 2016 13:06
Star... Open source is fine if you don't mind working for free, I think Rudolpho deserves to make some cash with this and would be daft to go open source. You should spend some time with it and check out all the stuff it can do already, really I think that further development is best kept in his hands. There is a lot that people could contribute to it, like shaders and examples, I think that would be more beneficial.

I haven't gotten back to the camera render matrix stuff yet, refining some shaders and the tesselated water mostly right now. I need to sharpen my shader skills and get the water looking pretty so that the irregular camera renders are the only problem left.

Thanks for the extended version - very much appreciated
The code is dark and full of errors

Login to post a reply

Server time is: 2024-11-16 22:44:55
Your offset time is: 2024-11-16 22:44:55