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 / Apply Texture by Texture Name

Author
Message
punkyb
7
Years of Service
User Offline
Joined: 8th Sep 2016
Playing: PC and Android Games
Posted: 14th Nov 2016 17:11
While checking out Advanced Lighting, I was surprised to see it could apply texture based on material name. I just found out that you can read material names like this

limb texture name (objectNum,limbNumb)

What I can't still figure out is how does DBPro and AL does this. I'm still not that familiar on how texturing works and AL code is kind of confusing so I was wondering if someone already has an idea on how to do this.

My setup would be having models with a single limb but with different textures.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Nov 2016 20:04
The .X file format can store material data such as texture file names. It is likely reading this similarly to reading limb/bone names.

Be aware though that if a margaritas texture is referenced in the object file, dbpro will automatically load a new copy of that image when the object loads.

This can affect load times and memory usage, particularly if you are just going to apply a different texture anyway.

I generally export objects without texture info to avoid reloading the same image, or unnecessary images again and again


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
punkyb
7
Years of Service
User Offline
Joined: 8th Sep 2016
Playing: PC and Android Games
Posted: 15th Nov 2016 00:37 Edited at: 15th Nov 2016 00:43
Thanks Ortu. Actually my problem here is related with Advanced Lighting and ImageBlocks, like WickedX suggested. Using imageblocks you save your images like a regular path and open it at the start of the program.

The problem here is when using Material Load in AL, only materials with a single limb is read properly and it's kind of confusing. I did test my imageblock with a reiteration loop like..



Only works if the model is single limb, it does not get applied on multitexture model using imageblock :/ but it works if I don't use it.

I was hoping and appreciate your response as I know you are also an AL user. Maybe you could shed some light as to what is going on..
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Nov 2016 01:23 Edited at: 15th Nov 2016 01:29
In Advanced Lighting a material file is a set of shaders with textures to apply to texture stages of the objects or limbs. For an object that may have a single limb using multiple texture stages, you need to use the texture stage parameter of the function - Limb Texture Name(Object Number, Limb Number, Texture Stage).

Hope this makes sense.
punkyb
7
Years of Service
User Offline
Joined: 8th Sep 2016
Playing: PC and Android Games
Posted: 15th Nov 2016 01:54 Edited at: 15th Nov 2016 01:58
Quote: "In Advanced Lighting a material file is a set of shaders with textures to apply to texture stages of the objects or limbs. For an object that may have a single limb using multiple texture stages, you need to use the texture stage parameter of the function - Limb Texture Name(Object Number, Limb Number, Texture Stage).

Hope this makes sense."


Thanks WickedX for the info. Apparently as I have mentioned, it works with the textures normally in the right path extracted but with using imageblocks, it looks like it does not recognize the path in the imageblock as a regular path as I would have expected.

Loading the image inside the imageblock without using AL, it seems to work..



Anyway, it's not that a big of an issue but if you guys have some workaround I'd appreciate it. I'll just have to worry about this next time.

Thanks guys.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Nov 2016 02:07
If AL needs to access image files the imageblock should be opened and left open until the program exits. File paths should work fine using imageblocks.
punkyb
7
Years of Service
User Offline
Joined: 8th Sep 2016
Playing: PC and Android Games
Posted: 15th Nov 2016 02:56 Edited at: 15th Nov 2016 03:01
That's technically what I did but a bit short. I'm closing it after I loaded all assets and before my main loop. The weird thing as I was reporting here is it only works with models with single limb or texture material models.

Anyway I'll do more test on this, thanks again.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Nov 2016 17:04
I haven't taken the time to dig into the AL material system to be honest. I just rely on a file naming structure to apply maps to the proper texture stages based on a specified base name.

I'll tell my framework to apply texture "brick01" using a given shader, say normalmap_clip, and it will append "_d.dds" etc and load "brick01_d.dds" to stage 0, "brick01_n.dds" to stage 1, "brick01_s.dds" to stage 2 via texture object.

This also lets me easily inject minor variations of diffuse textures (alternate colors etc) while reusing the base normal and specular files. "brick01_a_d.dds" "brick01_b_d.dds" a significant variation would require a different spec and normal and become "brick02", and when needed, I can parse the file name down to extract info from it. This becomes important for how I manage character and equipment assets.

I also haven't really done much with multi textured limbs, I guess I usually just break different materials into separate objects. Maybe I ran into similar issues with multi texture limbs initially and this was a work around, can't say that I recall exactly why I went with this approach.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
punkyb
7
Years of Service
User Offline
Joined: 8th Sep 2016
Playing: PC and Android Games
Posted: 17th Nov 2016 04:21
Quote: "I'll tell my framework to apply texture "brick01" using a given shader, say normalmap_clip, and it will append "_d.dds" etc and load "brick01_d.dds" to stage 0, "brick01_n.dds" to stage 1, "brick01_s.dds" to stage 2 via texture object. "


Thanks Ortu. Actually, I did the same thing and got this also working as it is much easier and it seems the standard on most game dev workflow today.

Login to post a reply

Server time is: 2024-04-26 20:05:42
Your offset time is: 2024-04-26 20:05:42