Author Topic: Flashlight source code! -- How to make perspective projection? [B3D]  (Read 5504 times)

0 Members and 1 Guest are viewing this topic.

Offline Devils Child

  • C= 64
  • **
  • Posts: 66
  • Karma: 2
    • View Profile
hi!

i was working on a flashlight source a time ago and i discovered that tformpoint helps a lot. it helps me to project the flashlight texture.
the only problem is that the texture is projected parallel and not perspectively. parallel in this case means, that the flashlight spot will appear with the same size in every possible distance!!!
it's like the flashlight has a diameter of 2 meters and would project like a laser!!!

is there a way to project this whole thing perspectively?

http://fiser.aufserver4.hieriminternet.de/upload/files/Devils%20Child/Flashlight.zip (786.82 KB)

if you don't find out, you still have my source code which works almost well :)
thanks for ANY help!!:)
bye

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
The effect looks pretty good to me, K+ for posting the source too.

I guess that what you are after is something that emits out in a cone from the flashlight so that the beam is more concentrated when it hits something near to the light source and radiates out as it gets further away.

I was never a Blitzbasic 3D expert anyway but I'd guess that what you are after is similar to shadow volumes... I'm not even sure if that sort of technique couls be implimented in Blitz 3D.

I'd guess that Jim or Tetra or Stonemonkey would be your best bet here to come up with a solution for you.

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Devils Child

  • C= 64
  • **
  • Posts: 66
  • Karma: 2
    • View Profile
ok. maybe they read it and are thinking about it right now.
as far as i researched about this, it is kinda possible with matrices and a dx7 dll, but that would project ALL textures.
in fact i'm doing it with TFormPoint which converts the camera pos/rot and the vertex pos into an UV coord.

that's what i have to do in a cone shape...
oh, and another idea was to scale the flashlight spot for every vertex, but that causes that the flashlight looks like a heart or something like that...
« Last Edit: November 02, 2007 by Devils Child »

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
That looks really cool for blitz  8)
But resizing the light size gradually rather than instantly looks a bit wierd.

I've tried to figure it out, but the math needed is beyond me atm. I barely understand how that even works :D

I dont think scaling the light based on the distance to the vertex alone is going to work. As you said the projection is not subject to perspective, so the size of the light texture remains the same wherever its projected. I think scaling based on the distance to the vertex will work, as long as you use the same equation for perspective as blitz. The shearing you describe caused by doing that I think is to do with the same problem as non perspective correct texturing. I would imagin that something along those lines will produce the right result, but like I said the maths is beyond me atm :D

Sry I couldnt help any more than that.
Challenge Trophies Won:

Offline D. Acton

  • ZX 81
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
hi!

i was working on a
cheap flashlight source a time ago and i discovered that tformpoint helps a lot. it helps me to project the flashlight texture.
the only problem is that the texture is projected parallel and not perspectively. parallel in this case means, that the flashlight spot will appear with the same size in every possible distance!!!
it's like the flashlight has a diameter of 2 meters and would project like a laser!!!

is there a way to project this whole thing perspectively?

http://fiser.aufserver4.hieriminternet.de/upload/files/Devils%20Child/Flashlight.zip (786.82 KB)

if you don't find out, you still have my source code which works almost well :)
thanks for ANY help!!:)
bye


I am also having the same problem with this one. I also need some info on the topic.
« Last Edit: June 25, 2013 by D. Acton »

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
welcome to the forum D. Action

It seem the sever is gone as nothing last forever thought  but the best things you could do is email  Devils Child :)

All the best :)