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 / Set Blend Mapping On + Lights

Author
Message
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 14:55 Edited at: 22nd Jul 2011 15:18
I currently am forced to use "Blend Mapping On" for an object in my program, so I can change the object's texture at runtime. Using "texture object" will not work, as the texture does not appear.

However, if I use "blend mapping on", lights do not affect the object at all. I've tried setting all of the object's material properties (ambience, diffuse, etc.) to no avail.

Anyone else get blend mapping on + lights to work?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 16:29
Quote: "Anyone else get blend mapping on + lights to work?"


Yes. You just need to use the correct blend mode. In your case try using mode 4 instead of 2. Mode 4 blends the texture with the current state of the surface whereas mode 2 only uses the texture so you lost the diffuse lighting which is used to initialise the blending operations.
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 16:35
Thank you for the quick reply, Green Gandalf.

Ok, it partially works. However, I need to replace the current texture that is applied to the mesh. Instead, it blends it. It partially appears correct (shaded at a darker level) but its still blended with the prior texture before it.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 16:42
Ah! I hadn't noticed you'd used stage 1. Sounds like the existing texture on stage 0 is being used as well. These things are easier to fix properly with a suitable sample model and media to work on.

Try changing the stage to 0 and let me know what happens.
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 16:47 Edited at: 22nd Jul 2011 17:07
I will certainly try this. The documentation isn't too clear, or I'm kinda an idiot, one of the two. I'll will try this. Unfortunately, I've tried so many combos I forgot which ones I've done which on heh.

EDIT: Setting it to texture stage 0 and with blend mode 4 causes nothing to show up. I'll try other flags...

EDIT2: Stage 8 gives me this, which appears lit correctly but sadly causes wonderful bleedthrough to the skybox. However, it is lit correctly, unlike other blend modes I've tried that are much brighter.

Attached a pic of what I'm getting right now as well.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 17:12
Quote: "Setting it to texture stage 0 and with blend mode 4 causes nothing to show up."


That's weird. But what do you mean by "nothing"? Do you mean everything shows up black, or white, or something else?

Before you started trying to change things do you know which textures are applied to which stages, and how many sets of UV coordinates there are?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 17:16 Edited at: 22nd Jul 2011 17:17
No idea Green Gandalf. The mesh is being loaded through Apex Now's CSM importer. My guess is that there is the possibility of the regular texture + lightmap texture to be dealt with, but I don't have a lightmap texture for that object.

Is there anyway I can remove all texture information from the mesh besides UV coordinates? The UV's appear correctly - its just that the blending isn't cooperating at all

EDIT, by nothing I mean nothing appears. There is no visible texture applied to the mesh at all (that I see)
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 17:30
Quote: "nothing appears"


You must see something. Just the blue backdrop, perhaps?

I think I need to work on the model and media themselves.

I know there is something strange when models have different materials applied to different polygons within a limb. Such models display correctly in DBPro but you can't change the texturing in the usual way. Perhaps that is related to your problem?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 17:31
Also, I was thinking - even though this will be a pain in the butt - couldn't I iterate through each vertex of the original mesh ("MeshA") and store the UV coordinates for each vertex? And then create a new mesh ("MeshB") with those exact same UV coordinates?

Wouldn't that get rid of any blend mappings that I have but may not be aware of in the original mesh? Right now I'm setting layers 0-15 to 'off' with no texture to no avail

This would be easier if Apex Now fixed the bug in his importer allowing you to change textures..... =(
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 17:36
Well, I do see something - the other objects in the map. Those appear and render fine. But depending on the blend mode of the object, it either
a) appears at full-brightness w/o alpha
b) appears at full-brightness w/ alpha
c) appears at full-brightness w/ alpha, causing z-depth rendering issues
d) appears at light-influenced brightness w/ alpha, causing z-depth rendering issues
e) nothing appears at all, besides other group scenery



And I do appreciate the help so far Green Gandolf. I've noticed you're quite the go-to man, so I am thankful for the help. Do you have cartography shop at all for CSM files?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 17:37
Why not just use the make mesh from object and make object commands? That should make a copy without the textures.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 17:40
Quote: "Do you have cartography shop at all for CSM files?"


I do but haven't had much success with it . However it's a long time since I looked at it. Perhaps it's time for another look?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 18:06
Nope. Creating a mesh from the object and then back vice-versa doesn't work. Same problems as before; i can only see the object really if its opaque, or using set mapping on.... something. and then it doesn't work correctly?

In theory, couldn't I loop through all of the vertexes, store them, and make a new mesh from scratch? Inconvenient yes, but eh.... or, I could use external meshes, but I'd rather keep everything self-contained aarg
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 18:29
Could you make a simple object with the media and features you describe and post it here? It's a bit hard trying to guess what sort of object you have.

I've just dusted off my copy of CS4 and experimented a bit. However it really would help to have the same kind of object that you are working on.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 19:29 Edited at: 22nd Jul 2011 19:40
Just a thought: does your object have normals? If it doesn't then it will only react to ambient light and the default ambient setting will darken the object. I've just tested a few simple objects exported by CS4 and they don't have normals by default. Haven't checked yet to see whether you can add them. Just about to investigate.

Edit On my copy of CS4 it looks as if all lighting is by a lightmap so the objects won't need normals. That could be part of your problem. If you're using more than one material per object then that will cause problems for both the DBPro texture object and blend mapping commands with or without normals.
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 19:39
Ok! Cool. I'll send over my media files to ya in just a bit. Just had to run some errands.

Though, I was thinking about it as well - what would happen if I imported a mesh into Cartography Shop and then saved it? I'm making objects from scratch, but making them outside in a different editor, loading them in CS, and then saving them (hopefully with normals) would be better than loading them into a separate file
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 20:13 Edited at: 22nd Jul 2011 20:20
Hey Green Gandalf, in the end, I don't want these particular objects to be multi-textured with lightmaps. They're just simple planes that have just one texture/material on them - period - and that's all I want.

Planes covered with one texture, with an alpha channel that lights up when darkened via a hardware light.

-Jeff
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 20:24
OK. It should be possible to see what the problem is and solve it. I'll check your stuff later this evening.

By the way I've found this link which may help you. I'm testing it now. See Lost In Thought's post in this thread:

CS4, lighting, normals, etc
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 22nd Jul 2011 20:49
Thanks Green Gandalf!
Anyway, here on this end I discovered IanM's plugin that allows you to specify blend modes for objects as well. I've been able to get it so that I can update the mesh's texture with 'texture object' command, but anytime I try to "set object transparency", the object disappears from the screen.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 22:11 Edited at: 22nd Jul 2011 22:26
I've got your email and zip file. Thanks.

However, I have a problem loading your CSM file. For some reason CS4 can't find the images. However, they are all there. Is there an option in CS4 that needs to be set? This is the first time I've used it for some time so I'm probably missing something obvious. Is CS4 expecting your image folders to be in a particular place? I've just got them in the same folder as your CSM file which I've placed in my Maps folder. I'm using Vista 64 bit in case that's relevant. [Actually I didn't know I had it installed on this machine. ]

Edit Never mind. I figured it out. Your image folders needed to be in the CS Textures folder. Can probably make progress now.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jul 2011 23:21 Edited at: 22nd Jul 2011 23:21
OK. I've done some tests with your map and things seem to be working correctly. I'm using IanM's X file exporter for CS4 and that seems to be working well.

Perhaps you could remind me what you want to do with the "urban" image? The X file version of your map implements this as a separate limb placed slightly infront of the wall behind it so from a distance it looks like the image is painted on the wall. You can change that image in the usual way using texture limb (it happens to be limb 4 in DBPro - but just to keep us on our toes is "object 25" in the X file ). Here's a screenshot showing a new image "painted" on the wall. Is that the sort of thing you were trying to do? I haven't checked out the lightmapping yet.

anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 23rd Jul 2011 02:17 Edited at: 23rd Jul 2011 03:16
Yes, this is exactly what I am trying to do; replace one transparent image with another at runtime. Though unfortunately, I am using just Apex Nows CSM plugin, and that I cannot seem to get this to work with :/

EDIT: Is there anyway I can compare meshes and/or objects in DarkBasic? What if I loaded the map as both a CSM and .X... and performed these steps:

a) find which object ID's in the CSMs belong to graffiti
b) compare each object ID against each limb from the .X file
c) delete original object ID, re-use object ID with 'create object from limb command'
d) tada, this might just work.

How does this sound? Think its worth a shot?
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 23rd Jul 2011 09:13 Edited at: 23rd Jul 2011 09:41
PROBLEM SOLVED =) Thanks to the idea from Mr. Green Gandalf, I am using "two" maps for my level instead of just one. The main map data is stored in the .CSM file, whereas mesh information (with normals!) is stored in a .X file that I also export from Cartography Shop.

Through much research - and Mr Gandalf's note that the geometry from the CSM map is slightly farked when it comes to normal lights - I started looking for a solution to combine the two together.

STEPS


PREFACE:
* Use Apex Now's CSM Loader to grab the data from the CSM files
* Download IanM's Cartography Shop Export Plugin and install it

CSM INSTRUCTIONS:
* Decide which objects in your map should be dynamically lighted at runtime. You must attach a pivot entity to these meshes, as well as record a flag somewhere - that you will parse in your own methods later - in that pivot stating that the mesh will be replaced later
* Save the map to a CSM as you normally would.
* Save a copy of this map to a new file. Delete all objects that won't be dynamically lighted at runtime.
* Export this map as a Matrix1 .X file.

DB PRO INSTRUCTIONS:
*Load up the .X file somewhere. Make a new object from each limb. I put rediculously high numbers here to prevent object number collisions.

REM this number holds the initial X-file.
REM child limbs from this file will be held at n+1, or default starting at 1000000



*Load up your CSM map. Parse your entities, and this is where the real magic happens.



VIOLA! All of the meshes that are to be dynamically lighted are now loaded into the app, with the added benefit that you can still adjust them with the pivot entities - as you did update their offsets to match their originals. In addition, everything is cleaned up for you - you can use those same numbers, as items are deleted from memory as soon as they're used!

Once again, a BIG THANK YOU to Mr Green Gandalf for helping me with this~

EDIT: Uploaded a video showing replaced meshes being lit my a changing dynamic light
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jul 2011 21:59
Excellent! Well done.

You've encouraged me to have another look at CS4 and I've learnt something from it too. So good news all round.

Login to post a reply

Server time is: 2026-07-11 07:06:07
Your offset time is: 2026-07-11 07:06:07