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 / a fx select texture on the distance from a point, example cam position

Author
Message
Ermes
22
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 18th Aug 2010 15:03
it is possible to have an effect selects texture stage depending on the distance from a point? or with a constant? exemple if a constant named "stage_n" is set to 3, object use texture stage 3, and so on.

i think it can be easy, but i haven't any idea how to code a fx file.

it can be done manually in dbpro, but retexturing objects reset too many other things like smoothing and it is slow.

any idea? thanks.

ogni scarafone è bello a mamma sua.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Aug 2010 18:52
Use a different technique for each texture (up to 8 I think) and use something like

set effect technique fxNum, "texture1"

or, use a single technique and use a series of if/else tests to select the right one.

The first would be easy to code and might be faster too. If you have a working shader for just one texture then the changes would be straightforward.
Ermes
22
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 19th Aug 2010 08:55
thanks but sounds like arabian to me.
maybe i'm a bit pretentious but i would like to see the code to how make it.... if it is possible.
thanks

ogni scarafone è bello a mamma sua.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Aug 2010 15:01
Quote: "but i would like to see the code to how make it.... if it is possible"


Here you are - complete project attached. Move the camera with the mouse and up/down keys. As the camera gets closer to the object the texture changes. This demo uses 4 textures but I'm sure you can work out the changes needed for more (you need to edit both the dba and fx files). I believe the maximum is 8 textures using this approach.

I don't know whether it is faster than re-texturing via the DBPro texture object command. My guess is "yes".
Ermes
22
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 19th Aug 2010 21:55 Edited at: 20th Aug 2010 01:48
oh you are very nice Green Gandalf, thank you a lot.
i've a debt with you. thanks again

edit: it is perfect, this piece of code must be in codebase section!!!

ogni scarafone è bello a mamma sua.
Ermes
22
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 20th Aug 2010 13:36 Edited at: 23rd Aug 2010 01:47
i've tested it, and there isn't any loss of time retexturing object with this effect.

maybe isn't so accurate like mipmapping via directx, but....

THIS IS MANUAL CONTROLLED MIPMAPPING

and it works. thanks to GREEN GANDALF.

ogni scarafone è bello a mamma sua.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Aug 2010 16:52
Quote: "THIS IS MANUAL CONTROLLED MIPMAPPING"


Good point. I'll try to remember that, it might be useful one day.
Ermes
22
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 23rd Aug 2010 01:47
yes, i'll use this in my next project.

ogni scarafone è bello a mamma sua.

Login to post a reply

Server time is: 2025-08-08 20:48:53
Your offset time is: 2025-08-08 20:48:53