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.

DarkBASIC Professional Discussion / Grass/flowers movement

Author
Message
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 23rd Mar 2015 18:42
I am trying to make a bit of movement to some of the grass/flowers I have made with plant life (included in dbpro).
For some weird reason, when I apply the shader "tree.fx" (but even if I apply leaf or leaf Billboard.fx, taken from one of the evolved examples), the transparent texture become all black (I don't mean all the quads to be black, just the part of the flowers is black, so the transparency is working but the pixels who needs to be shown are all black).
If I apply the same shader to trees made with "tree it" (evolved program) everything works fine, so what can cause this texture problem?
Textures are all .dds dxt5, and without applying the shader the grass/flowers are rendered correctly
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 25th Mar 2015 21:27 Edited at: 25th Mar 2015 21:29
This is the shader I am using (attached), if someone wants to do some tests just make a plane for example and texture it with a transparent texture, for some reason after applying the effect the pixels drawn for the non transparent part (like a leaf for example) are turned to black, so the shape of the leaf for example is still there and it moves, but the pixels of the leaf are all black.

This does not happen with the trees made with "tree it" (evolved program)
PS: The leaf.fx is an evolved shader too i think

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 26th Mar 2015 01:22
The shader uses alpha clipping (see the clip function call in the pixel shader) instead of blending. Basically, if the sampled texture texel has an alpha value of 0.25 or less it will not render the pixel at all. If the alpha value is above that it will however forcefully set the rendered alpha value to 1 (full opaqueness) on the line returning the output colour of the pixel shader.

Your results are most likely dependent on your textures so if you would post those though that would help

Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 26th Mar 2015 01:58
The problem is not the transparency enabled/disabled for a certain pixel, it works fine, but the part non transparent (the flowers for example) are all turned to black.

Here is the code I am using



I have also attached one of the textures (seems that they are not the problem as I have tried several)

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 26th Mar 2015 05:56 Edited at: 26th Mar 2015 06:03
That shader requires the object to have diffuse color data which is not present in the default object FVF format. Here is a version of your demo which adds vertex diffuse colors to the object's FVF, then sets each vertex to full white.



Ive also attached a version of the shader with the diffuse color code removed in case you don't want/need it. With this shader your original demo works as expected.

Attachments

Login to view attachments
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 26th Mar 2015 07:03
It works, but the texture seems to be way darker, if I try with my flowers ingame is even more noticeable as you keep getting far from them.
It seems also that from 1 angle it get more lights, but from the opposite side of the quads it is darker
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 26th Mar 2015 07:47
The shader uses its own ambient + directional lighting to illuminate the object. For a full-bright apperance, try changing the "LightColor" and "Ambient" float3 values within the tweaks section to:


If that produces the appearance you are after let me know and I will post a version of the shader without the lighting calculations.
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 26th Mar 2015 09:48
Thank you very much! Your help has been very helpfull!
And another problem has been fixed! Yuhuu!

I have only noticed that applying this effect to all of the flowers eat a good part of the fps (from 63 to 53 fps rendering the whole outside scene), one of the reason is that i have 132800 triangles of flowers (I know it's a lot).
Will this effect be less heavy if I will use dark impostors for the flowers? (I am planning to buy it)
Otherwise I will make an option to enable/disable the animation on the vegetation, so that older computers can disable it and gain some fps (I am planning to make plenty of options for this, antialiasing, anisotropic filtering, mesh detail, texture quality and a lot of other stuff)
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 26th Mar 2015 10:18 Edited at: 27th Mar 2015 07:24
Glad it worked, here is a version of the shader which does not use vertex diffuse colors or directional lighting which should increase performance a little.

Quote: "Will this effect be less heavy if I will use dark impostors for the flowers? (I am planning to buy it)"

I don't believe so. dark imposters is more aimed towards rendering distant objects which shouldn't really use this kind of effect, and when I last checked it didn't support shaders.



Just a side note: these shaders do not require DBPro transparency to be enabled so you may be able to gain a little performance by [Edited] replacing the "set object 1,1,1,0" line with "set object cull 1,0" in your demo.

Attachments

Login to view attachments
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 26th Mar 2015 18:47 Edited at: 26th Mar 2015 19:08
I thought the performance decrease was proportional to the number of polygons of the objects that are using the effect, this because when I have enabled the same effect on aprox the same amount of trees, but lower poly than the flowers (actually 2 effects because they use a tree.fx as well), the fps decrease is just a couple of fps, while enabling it on the flowers the decrease is by 10 (Always based position a camera in the same point to render the Whole outside scene).

About dark imposters it's a shame that it doesn't support shaders, in this case will be useless for me and I could build something myself to increase the performance, like LODs for the flowers, but doing this I would have to change the flower from "instanced" to "cloned", so I don't know if the fps gain will be eaten again by this change.

(PS: when i tried a few days ago to make LODs keeping the instanced objects the game crashes as soon as I come close the the flowers, so changing them to clones it's a must)

Edit: I do not know for what reason, but making a test today eats just like 3 fps, and 2 fps with the shader without lighting, very strange
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 26th Mar 2015 20:14 Edited at: 26th Mar 2015 20:20
Another thing, I am attaching one of the textures that evolved uses for the Leaves, I really do not understand what type of transaprency is, i mean, i know that transparency can be set to black pixels (defaults) or some textures use them as White, but this kind of textures don't use a specific color, so I don't know how could the program knows which part need to be transparent.
I need the black transarency instead rgb(0,0,0) because if I disable the leaf effect (using it as a option for the gamer to save fps) the leaf looks bad, transparency is not working well (using set object 1,1,1,1).

How can i turn the transparency of the texture to black as normal so the command set object 1,1,1,1 will works fine?

PS: the trees exported from "tree it" (evolved program) seem also to have some parameter of transparency (like ghost object on, the more the distance the more it disappear too), for example, if i disable the leaf effect and use only set object 1,1,1,1 , not only the transparency is not perfect (I can see the quad boundaries), but I can also see the water through them, even if between the Leaves and the water there is a pavement

Attachments

Login to view attachments
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 27th Mar 2015 04:22 Edited at: 27th Mar 2015 06:41
Quote: "I thought the performance decrease was proportional to the number of polygons of the objects that are using the effect"
It is but there are other factors to consider; The size of the object on screen (the number of pixels to render), texture resolution, limb count, draw calls/passes (,etc...) can all make quite a difference. [Edit] Un-welded objects also seem to render faster than objects with indexed vertexdata.


Quote: "I could build something myself to increase the performance, like LODs for the flowers, but doing this I would have to change the flower from "instanced" to "cloned", so I don't know if the fps gain will be eaten again by this change."
Instanced objects render faster than cloned objects and can be created/deleted in real-time. I've written several LOD systems using instanced objects without issue so there must be something specific to your project which is causing the crash.


Quote: "I really do not understand what type of transaprency is, i mean, i know that transparency can be set to black pixels (defaults) or some textures use them as White, but this kind of textures don't use a specific color, so I don't know how could the program knows which part need to be transparent."
Transparency actually uses values stored within each pixel's alpha channel, and some exporters/formats give the option to retain color values for transparent pixels. Im not sure how these images were created, but I think the reason for retaining color values for the transparent portions is to combat mipmapping at large distances.

Quote: "I need the black transarency instead rgb(0,0,0) because if I disable the leaf effect (using it as a option for the gamer to save fps) the leaf looks bad, transparency is not working well (using set object 1,1,1,1).
"
Try changing the transparency mode to 2 or higher.
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Mar 2015 06:51
About the crash, it only happened when I have attempted to add LODs on the 1st flower (reference one), all the instanced one should be the same as the 1st one, but as soon as I was coming close to a flower the game crashed (so it's surely something related to the LOD, removing the LOD give me no problems).

About the transparency, the only ones working are transparency mode 4 and 6, but there i Always the problem that they disappear with the distance, disabling mipmapping fix the issue but makes them looks really bad, too sharp.
There is a main issue too which with the transparency, the trunk disappear (do you remember when i talked to you about the ghost object on similar thing? Well that program "tree it" exports these trees with this weird transparency thing, even if I load them on 3ds max after converting it to a proper format, there is has the same "ghost object on property")
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 27th Mar 2015 07:23
Quote: "so it's surely something related to the LOD, removing the LOD give me no problems"
How are handling the LOD?


Ive never used TreeIT so cant help much without an example to fiddle with (hint-hint), but here is a stripped-down version of the shader which may work for your low-quality mode (does not include animation).

Ive also re-uploaded the "leaf NoLight.fx" shader a few posts up, it still had a few unneeded instructions lingering around.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-04 15:52:32
Your offset time is: 2024-05-04 15:52:32