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 / Transparency Z-order Problem with grass

Author
Message
Jeremy2487
15
Years of Service
User Offline
Joined: 2nd Mar 2009
Location:
Posted: 2nd Mar 2009 19:52
Hello, I'm new to Dark SDK but I used DarkBasicPro quite a lot a few years back. Anyway, I downloaded the DarkGDK to try it out and I encounter what I believe to be a bug with transparency. I'm trying to create grass and I'm using the dbSetObjectTransparency command to allow the grass to be transparent. However from what I can see the DarkGDK draws objects based on the order they are created rather than the distance they are from the camera. This causes the grass to not be drawn correctly when a piece of grass that was created first is drawn in front of a piece that was created later. I found this bug in DarkBasicPro a long time ago and I find it kind of sad that it was never fixed and not only that but that it also managed to find its way into the DarkGDK. One work around that I knew of when I used DBP was to set the texture flag to 1 but this removes the mipmaps which makes my grass look like it was drawn with the MSPaint spray can tool. Anyway, I've seen screen shots on this forum of people who have created properly transparent grass without this problem so I'm wondering if someone could tell me how they did it.

P.S I'm using a PNG file so it should have its own alpha channel. so it's not a problem with that. also I tried creating my land object after the grass and that makes the problem occur with that also. I'll put some screen shots you so you can see

this looks correct
http://www.facebook.com/photo.php?pid=30486957&l=eb8a1&id=149001024
grass Z-order problem
http://www.facebook.com/photo.php?pid=30486958&l=41f30&id=149001024
also happens on the ground when it is created after the grass
http://www.facebook.com/photo.php?pid=30486959&l=3f7dc&id=149001024
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Mar 2009 20:04
Try setting the transparency type to 4 or 6:


I notice that it doesn't include all the information about this command in the help files
As you have DBPro, I'd suggest you install it, if only because the help files for DBPro are a little better the the GDK ones.

Jeremy2487
15
Years of Service
User Offline
Joined: 2nd Mar 2009
Location:
Posted: 2nd Mar 2009 23:12
tried that... sadly it didn't change anything... is there some other way i could get this to work like a shader maybe?
Jeremy2487
15
Years of Service
User Offline
Joined: 2nd Mar 2009
Location:
Posted: 3rd Mar 2009 04:21
DB Code:


Dark GDK Code:


the code above works fine in DarkBasic and not in Dark GDK
I have attached the image so people can see if this happens for them also.
Here is a photo of both:

http://www.facebook.com/photo.php?pid=30487164&l=d03a5&id=149001024

Attachments

Login to view attachments
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 3rd Mar 2009 13:09
Hi Jeremy2487,

I was also having transparency order problems like you have been explaining.
In the mean time I have been playing with another project but decided to see what your actual problem is, as I can not see a difference in the last 2 pictures of the grass.

I basically duplicated your code but made the middle grass texture red so I could clearly see what grass was overlapping what other one.

This is the code as modified.


A snapshot was taken and the order of the grass front to back was changed by changing to



Here are the 2 snapshots.


As you can see from my results the correct grass is always in front no matter what order the grass is created in.

I can not explain why this is working properly for me now, except that maybe I am using the latest DarkGDK that was very recently released, or else I may be using a different version of DirectX.

The problem is a little more complex than what it appears, but that bit of code does not demonstrate the problem. Maybe the problem only happens when one Instances the object or clones the objects .... must look into that.
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 3rd Mar 2009 13:31
Hell more problems.

Trying to make the back grass an Instance of the front grass the following happens.




The back grass is the instance grass.
It is reversed from left to right by some strange reason, and its color has become dark.
Looks like the "void dbInstanceObject ( int iObject, int iSource ) " function is also broken.
Jeremy2487
15
Years of Service
User Offline
Joined: 2nd Mar 2009
Location:
Posted: 3rd Mar 2009 17:39
My picture does show the problem though it is a little hard to see because it's a jpg... basically they are being drawn in the right order, but there are parts of the objects in the back that are not being drawn at all. if you flip the order of the objects in the code you'll see what i'm saying. also if back the camera of by 40-60 then it may show up better. I think what DarkGDK does it to render objects in order based on the texture they have. so objects w/ texture ID 1 are drawn first then 2,3 etc. this I think allows it to load one texture at a time for rendering rather than loading one texture- then unloading it- then loading at again when another object needs it. Now when two objects have the same texture it seems to draw them based on the order that they were created. Now I think what is happening is when an object is being drawn after an object that is in front of it the Dark GDK clips the parts of that object that should be obscured by the object in front of in and doesn't draw them. Now for non transparent objects this would be fine but with transparent objects you want to be able to see these parts that are being clipped through the object, but since they where never drawn it causes the behavior we are seeing. If you look closely at the last image you will see blue lines along the edge of the grass stems where the grass behind is not being drawn. it doesn't show up as well as in my first screen shots since the camera is very close to the grass. the effect seems to get worse at a distance and i think this is due to the mipmaps.

for your problem I think the instance command is making the object backwards possibly i wonder if you rotate it if it would look fine.



comment out the line of code to see what it should look like...

Image:
http://www.facebook.com/photo.php?pid=30487439&l=16d9d&id=149001024
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 3rd Mar 2009 23:18
I see what you are now talking about.

This code produces the problem as you describe:




Now using the advice that IanM suggested (transparency mode 4 or 6), at least for me the problem is gone. Here is the modified code:




Are you sure these modes do not work for you????

Login to post a reply

Server time is: 2024-09-30 19:22:10
Your offset time is: 2024-09-30 19:22:10