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 / Projected textures... any way?

Author
Message
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 27th Aug 2004 01:35
Due a complete lack of any way to project textures in DBP, I thought an alternative might be to intersect multiple small textures to compose, say, a flashlight; a 4x4 grid of little lights that would sort of wrap around things they hit. Unfortunatly, there were complications; this looks like total crap. Does anyone here know alternatives?

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Aug 2004 04:29
I'm not sure I understand what you're trying to do.

"eureka" - Archimedes
Peter H
21
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 27th Aug 2004 05:26
yeah...same here

do you mean like how a projector projects a movie onto the wall?

"We make the worst games in the universe."
Preston C
22
Years of Service
User Offline
Joined: 16th May 2003
Location: Penn State University Park
Posted: 27th Aug 2004 05:56
@Phaelax & Peter: Basically it projects a texture from a certain point and it lands and wraps around any surface it comes in contact with. Here, have a little picture from Real Time Rendering to show this (please don't mind the quality, crap camera):

http://www.ppcdesigns.com/public/project.JPG

See how the texture is projected onto the tea pot and plane below it. Thats basically it.

@Mouse: Sorry, don't really know how to do it, just know what it is

Cheers,
Preston


Intel Celeron 1.3 Ghrz 512 MB Ram nVidia GeForce FX 5200 128MB
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Aug 2004 12:16
ooooo. it basically raytracing. I think I could do something like that with memblocks. The problem, however, is knowing which part of the texture on the model each ray passes through. If db supported multiple uv's, then i'd just add a second layer to the model rather than try and edit the pre-existing texture data.

"eureka" - Archimedes
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 27th Aug 2004 12:19
Yeah, Preston's got it ...

Phaelax-> I suppose... it's not a brand new technique or anything. It's used in Halo for headlights for example... hardly cutting edge on a GeForce 3 (Xbox). But DBP seems to totally lack any support for it. Oh well!

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 27th Aug 2004 17:50
If you had a memblock version of the mesh - and a simple flashlight texture, you could plain map from the camera view - like a *live* UV map. This uv map could be calculated from the 2D screen coords of the memblock mesh, you'd calculate the UV's and generate the mesh - then when you ghost it - it'd be sitting perfectly and would wrap around objects. IT WOULD texture on faces that would'nt need it - but if your behind the torch you'd never know. Perhaps this is something best done with a DLL plugin, that can generate the UV's and create the mesh etc quicker than the method we have now.


Van-B


Muhahahahaha.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 27th Aug 2004 23:22
That sounds plausible, but incredibly slow-- adjusting objects in memblock form is, if I remember correctly, incredibly slow. To make matters worse this would have to applied to every single static and active object that could recieve light. I don't think DBP could handle that .

Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 27th Aug 2004 23:29
Pretty sure Halo flashlights are done with shaders. Notice how bumpy/glossy the terrain looks under the light? Most likely a pixel shader+bump mapping.


Mussi
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 27th Aug 2004 23:41
Quote: "Pretty sure Halo flashlights are done with shaders. Notice how bumpy/glossy the terrain looks under the light? Most likely a pixel shader+bump mapping."


I don't think so, even doom3 uses this for their flash light .

I'm currently working on a collision plugin and I was planning to add this future .

I was thinking about creating a high poly object at runtime and modify the object each loop so it wraps arround the objects, unused polys would be turned away from the camera so DBP can cull them. Then calculating the uv co-ordinates isn't that hard.



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 27th Aug 2004 23:43
Odd, I thought Halo could run on non-shader supported cards. I was probably wrong though.

Still that's the kind of shaders DBP can't do... things that are universally applied to, well, everything. Like depth of field.



Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 28th Aug 2004 04:11
Halo runs on non shader cards, but you'll notice that the flashlight key does nothing. You press it and.. well.. no flashlight. Same goes for vehicle headlights.

You could always apply the same shader to every object, which would probably kill the computer.


Zokomoko
22
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 28th Aug 2004 04:17
well, you could "fake" it a little more.
if it's like an FPS, and the camera movement is limited (only behind the player).
you could make a plain, textured with a white circle glow, place it infront of the character until it collides with the objects infront of him, ghost and fade it.
I've not tested it, but it may work, or look really fake.
just an idea.

that would might give the illusion of a flash light, but not the example you gave with the tea pot.
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 28th Aug 2004 05:22
Wouldn't work at all because it's be obvious it was just a circular plain being pasted on whatever it hit-- it'd 'bounce' forward from the wall to an enemy if an enemy moved in its range for example, just one of many glitches. I tried that with nine images and it still looked like crap. Ohwell

Konrad-> I get it... cool.

DcZee
22
Years of Service
User Offline
Joined: 28th Apr 2003
Location:
Posted: 28th Aug 2004 09:15
Im not sure Im understanding what you are talking about here,..but wouldnt a simple light source pointed int he direction you want, provide the lighting effects you are looking for? Especially a spotlight, which is similar to flashlight and headlamps.
To actually project a texture onto another surface, is interesting but I dont see where you would use it. Without getting into reflective mapping and shaders,..hmmm tis possible. Could u not use a second camera then use that image from the camera to replace the target objects texturemap??
Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 28th Aug 2004 10:00
The goal is to mimic hardware lights without the heavy performance cost. Hardware lights (the built-in dbpro lights) are extremely costly to the system. The number of lights is also limited to 7, so what happens when 8 people turn on their flashlight?


Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 28th Aug 2004 11:07
Well, actually, although that is a reason, the primary one is that hardware lights don't look nearly as good. They're okay for global illumination; otherwise they suck. The lower the polycount count the more the light will look 'blocky' on objects, and since it's not projected, it goes right through one thing and lights up the objects behind it. Very bad indeed.

Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 28th Aug 2004 13:42
Yep, 1 reason why I don't use any hardware lights. I don't know enough about writing shaders to code a 'flashlight' pixel shader, so I wouldn't have any idea as to how well that would effect performance.

You could probably do it with some clever nuclear glory. Cast a ray for collision, then take the nearest vertices. Get the verts of the nearest 10ish polys and make a mesh from that. Of course that would only wrap light around the nearest object.


AciDucK
21
Years of Service
User Offline
Joined: 13th Aug 2003
Location:
Posted: 28th Aug 2004 23:45
In order to create a projector you have to use ray tracing. The problem is that there is only one game that is capable of ray tracing in real time ( http://www.gamershell.com/news/13500.html ). It is impossible to use real time ray tracing in dark basic.
The other way of doing this is creating a static projector. If you don't move the projector, you don't have to calculate its effect in real time. You calculate it during the loading time and the effect stays on during the game. I have worked out a general algorithm to do this:

Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 29th Aug 2004 01:02
That's interesting, but I don't follow how you say only one game is capable of ray tracing in real time... realtime dynamic lighting systems were featured in Deux Ex 2, Thief 3, and Doom 3, and are in the upcoming games Half-Life 2 and Unreal 3. And projectors have been in tons of games, Halo included.

Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 29th Aug 2004 01:14
Probably the best projected texture is the flashlight from Counterstrike. Which brings up a question. The light wraps around all the parts of the level, but if you shine it on a person, than only that person is lit up. So was it designed to 'highlight' people, or is it just projected textures based off the nearest verts?

Too much thinkage


Ninja Matt
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 29th Aug 2004 10:13 Edited at: 29th Aug 2004 10:15
No, that's not a projected texture, I don't think. Being based on the Quake engine, I'd guess that the light is actually done simply as a dynamic point light that is being positioned at the first obstruction of a line cast from the player, in the direction that the player is pointing. Usually, that obstruction is the wall that the player is pointing at but, as soon as an enemy appears in the middle of the flashlight, the point is shifted to a new position away from the wall and so no longer highlights it.

If you want a good flashlight effect, I'd say that the one seen in Splinter Cell: Pandora Tomorrow is a good one!

Still, projected textures are usually done with a shader that just alters an images texture coordinates based on the direction the projector is pointing in. Since DarkBasic can't do this so easily, you might just have to come up with your own system. You could perhaps just increase the amount of tiles in your grid, say to 8x8, or perhaps even make them into a single grid-like mesh that deforms to the environment. Failing that, you could always try using hundreds of 'circular' particles.

But, then again, none of these methods would be a great solution. Sorry I can't help more!
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 29th Aug 2004 12:41
S'ok. None of those work all that well with the kind of games I'm making, but they're all good ideas. It was just an idea I was working on so it's no huge loss.

JerBil
21
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 29th Aug 2004 12:57
I did notice DBP's Help file has a video card check
for projected textures. maybe a future version of DBP
will do more...-JerBil

PROJECTEDTEXTURES AVAILABLE
This command will return a value of one if the 3D device supports projected textures, otherwise zero.

SYNTAX
Return Integer=PROJECTEDTEXTURES AVAILABLE()

RELATED INFO
BASIC3D Commands Menu
Index
Powersoft
21
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 29th Aug 2004 19:06
could you use a memblock matrix the size of your flash lights scope. texture it white or whatever. then get the height of the points where you want to cast the light. modify the matrix to that height etc and position it


Scorched Turf --> Project Thread
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 29th Aug 2004 23:56
Well, that's a sound concept, but I visualize the light 'wrapping' weirdly around anyone it hits, and also slicing through said players because the various points didn't happen to be on their most portruding sections of geometry. Still, it might look okay... very good idea...

Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 30th Aug 2004 02:13
Does anyone know how it is really done? Like in commercial games? Not the actual code, but the concept.


kevil
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 30th Aug 2004 02:40
You should look into shadow mapping. That's what usually is done I think.

Kevil
Ninja Matt
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Lincolnshire, UK
Posted: 30th Aug 2004 03:55
DBPro being upgraded to support projected textures would certainly make my life easier in the future! Fingers crossed...
Mussi
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 30th Aug 2004 08:18
I'll have a trow at this, I'll post my progress in this thread.



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
Neophyte
22
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 30th Aug 2004 09:23
@Konrad

" Does anyone know how it is really done? Like in commercial games? Not the actual code, but the concept."

Yes, actually. I know exactly what he means and how to accomplish it more or less. It can be done via shaders and I was working on just such a shader, but I never actually finished it.

I'm positive that given enough time I could write a shader that would run on the most basic of shader capable hardware and achieve the desired effect.

It wouldn't be easy though. I remember running into some trouble writing the shader before other proirites got in the way and I had to shelf it.

Here is a link that explains the process for anyone who is curious:

http://www.sgi.com/products/software/opengl/advanced98/notes/node49.html
Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 30th Aug 2004 10:49
Hey thanks Neophyte .

Sparda
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location: Pacifica
Posted: 30th Aug 2004 11:55
Thanks Neophyte

I guess it's time to learn shaders


JerBil
21
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 30th Aug 2004 15:00
nVidia has a shader developer available for free,
but it's a 100 meg dl. Still, looks interesting -JerBil

http://developer.nvidia.com/object/fx_composer_home.html#2

Login to post a reply

Server time is: 2025-06-04 19:22:58
Your offset time is: 2025-06-04 19:22:58