D3D problem

Discussions related to graphics (2D and 3D), animation and games programming
RichardRussell

Re: D3D problem

Post by RichardRussell »

Ric wrote: Wed 18 Mar 2020, 22:16can someone with a higher knowledge of D3D9 help with this aspect?
Michael Hutton is your man. I don't know whether he's currently active on the forum, but going back some years he was very much the expert in Direct3D 9 and wrote programs well beyond anything I understand, including shader programming.
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

Thank Richard,
I have heard Michael's name banded about before regarding D3D. I will put out a plea.

Regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

I have now successfully got d3d9 up and running NEARLY!
As DDRM pointed out order does matter and so to this end i have created a veretex_buffer with opaque colour objects, a vertex_buffer with transparent colour objects and one with opaque textured objects. When i run the code the scene does not quite raster properly as follows:-

1. If i just use the opaque colour and transparent colour buffers it appears to be working fine,
2. When i introduce the texture buffer the transparent object disappears and after one frame the opaque objects colour dims.

Infact if a combination of any two buffers are used the result is what you would expect.
I have put a second delay between each frame so point 2 can be observed, if you hold down the left mouse button (initially for 1 second) the scene can be rotated with the mouse to check if the transparency works.

The code is in "Object VIII - II"

https://1drv.ms/u/s!AqibHqCkE1VQ_DCMRiA ... W?e=kD57se

The code is set up to raster the opaque and transparent colour buffers, if you put a REM statement into line 1810 then all three buffers will be attempted to be rastered.

Can anyone help

Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
RichardRussell

Re: D3D problem

Post by RichardRussell »

Ric wrote: Wed 01 Apr 2020, 14:52 As DDRM pointed out order does matter
He was presumably referring to this Wiki article.
The code is in "Object VIII - II"
Unless Michael Hutton is around I fear there will be nobody here with sufficient experience of Direct3D9 to make sense of that code; certainly it goes way beyond my understanding. It's a shame that you weren't able to use D3D9LIB; what limitation(s) does that library have which makes it unsuitable?
Can anyone help
Are you sure that what you are trying to do is even (straightforwardly) possible? There may not be a unique object order which will result in the 'correct' rendering, particularly when the relative orientation of the objects, or the viewing direction, changes. In this circumstance you may need to split your object(s) into two or more parts, as described here, and even then there may be no simple solution.

The conclusion of that article is "If you have enough translucent surfaces moving around in a sufficiently complex manner, you will find it very hard to avoid errors with acceptable realtime algorithms" which is annoying but it's the way things are.
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

The code does not do anything that the D3D9LIB doesnt do yet, that is why i can not understand why is doesnt work. All i have done is produce 3 buffers with different qualities, I assume that if i ran these through the D3D9LIB it would work, but i want to fine tune the process a bit further down the line.
Whilst building my Object creating GUI I learnt a lot about how 3D works and built in a lot of features to take advantage of the individual processes. Order of types of face rastered is the most obvious one.
It is a shame that i can not easily translate this to d3d because the only thing i can not do with my GUI is make it go fast enough, even with full asm, if i could d3d would not be required, but if you want to write 3d games a graphics card of some sort is going to be required.
I have not given up and will keep trying. When sorted (which i will do) i will post the correct code.

Thanks again for the swift reply

Regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
RichardRussell

Re: D3D problem

Post by RichardRussell »

I tried to check your program with the Cross Reference utility, as that can be very useful for tracking down obscure faults, but it aborts when finding lines starting with \ that aren't continuation lines. :shock:
RichardRussell

Re: D3D problem

Post by RichardRussell »

Ric wrote: Wed 01 Apr 2020, 18:50 It is a shame that i can not easily translate this to d3d
If it's limitations in Direct3D that you're finding frustrating, don't forget that you have the option of using OpenGL instead; the Windows edition of BBC BASIC for SDL 2.0 uses OpenGL for all its rendering (2D and 3D). Direct3D and OpenGL are pretty similar in most respects, but if your particular concerns are obscure 'edge cases' it's possible that you might find that OpenGL is a better fit
RichardRussell

Re: D3D problem

Post by RichardRussell »

Ric wrote: Wed 01 Apr 2020, 18:50I assume that if i ran these through the D3D9LIB it would work
As confirmation of that (or not, depending on what you expected to see!) here is what I get when I render your three objects using D3D9LIB, using a program which is of course a fraction of the complexity of yours because the library is doing most of the work. The lighting is similar to yours, but not identical:

https://www.youtube.com/watch?v=OIB5Q7zsLbQ
i want to fine tune the process a bit further down the line.
Sure, but the way I would have approached it would be to get it going with D3D9LIB first, because that's so easy and will demonstrate the correctness of your models, textures, materials, lighting etc. and only then to tackle the fine tuning. If that means ditching the library at that stage so be it, but at least you have something working as the starting point.
RichardRussell

Re: D3D problem

Post by RichardRussell »

And just to demonstrate how using a library can easily achieve cross-platform compatibility, here's the same thing rendered in OpenGL (admittedly I did need a slight cheat to enable the specular reflection on the textured cube):

https://www.youtube.com/watch?v=lHgL10N_ksg
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: D3D problem

Post by Ric »

Thankyou Richard,
Could you supply the code for that please, because i do not know how using the library to create the 3 buffers with different attributes. That would probably change my approach to how i go about d3d.
Regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023