Search Unity

Projectors projecting too much

Discussion in 'Shaders' started by Qeen, Nov 3, 2009.

  1. Qeen

    Qeen

    Joined:
    Nov 2, 2009
    Posts:
    2
    Well, first of all Hi everyone here at Unity.

    We (a small group of students) are working on a project, and we are trying to use Unity (indie for now, maybe Pro if needed).

    Feel free to moderate if I posted in the wrong section; Also I searched the forum with a few keywords, and found some topics related to our problem, but the results were not that much helpful...

    I won't give too much details since our problem is quite simple.
    I took a few screen to illustrate it :


    So we are using a projector to fake some shadows (that moves with the character). We are not trying to make realistic shadows, we want to create a fake shadow that is independant from the lighting in the scene - that's why we use a projector.

    This is what Unity does :


    And this is what we would like to create :

    (of course, this image was made with photoshop :p)



    So, well...
    We know it's not just something to toggle in Unity;
    We are not asking for someone to show up and say "oh wait, I'll code everything for you for free", of course; our question is more like "Is it possible to do that with Unity ?" and some directions on how to do it.

    Btw we also tried with a spotlight and cookies instead of projectors, didn't work either.


    We are working on the trial Pro, so we have around 20days left to see if we are doing our project with Unity (Indie, but the school can buy a few Pro licenses if needed).


    Thanks in advance to any of you for your answers.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Personally I have no idea how you'd do something like that, but you might want to take a look at this; maybe it would suit your needs.

    --Eric
     
  3. ToreTank

    ToreTank

    Joined:
    Jun 23, 2008
    Posts:
    165
    As far as I can understand, you're going to need some depth info from the projector's point of view to accomplish that (some implementation of shadowmapping).

    Good news is that it's possible to do in Indie, bad news is that you're gonna have to write the shaders for it yourself.

    In Indie, you can render a shot from the projector's point of view and store the depth info to the backbuffer. This backbuffer is copied to a texture using Texture2D readpixels. I have recently played around with this, and it turns out it is fast enough for real-time stuff given that the resolution of the texture is somewhat sane. Here is a link to a basic shadowmapping implementation that _should_ work on Indie(no guarantees, note the "Test" in the name): http://www.terravision.no/~trondabu/unity/ShadowMapPackageTest.zip (Please note that this does not work correctly in the editor if the Aspect is set to anything else than "Free")

    I think you should be able to modify this to project your texture along with the depth info and only draw where the depth test doesn't fail.

    I checked out the link from Eric5h5, and it says it requires Pro, but the idea should be the same - you can probably alter this to use regular Texture2D and make it work on Indie (without actually having checked out the source, don't quote me on that).
     
  4. Qeen

    Qeen

    Joined:
    Nov 2, 2009
    Posts:
    2
    Well, thanks to both of you. :)
    We're conducting tests using the info you gave us, but since we're a bit busy, it'll take some time before we got some results...

    So anyway, thanks a lot, we'll let you know how it evolve. :)