orthographic camera?

kmgkmg Join Date: 2008-02-28 Member: 63758Members
does anybody know if this is possible in spark? obviously i want to try out comm with an orthographic camera. i managed to change the fov and height of the comm camera to try and simulate it, but of course i knew the draw distance would be too great. i'm pretty new to modding, anybody got ideas?

Comments

  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    I don't think there is a way to modify the perspective cam into an orthographic camera, would require modding I guess. But here's something @matso was working on to modify the view distance per area of a level http://forums.unknownworlds.com/discussion/130399/location-relevancy-get-around-max-relevancy-distance-by-location-based-relevancy
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    Yes there is and it doesn't really change anything.
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    SamusDroid wrote: »
    Yes there is and it doesn't really change anything.

    mmmmm do you mind clarifying?
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    I changed this while looking around in the code a while ago and it had no noticeable difference
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    you mean it just doesn't work at all? can you tell me what you changed?
  • matsomatso Master of Patches Join Date: 2002-11-05 Member: 7000Members, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Shadow, NS2 Community Developer
    I was just looking at the latest NSL replays, and its really annoying that relevancy works the same from a commander view as for normal players - if the action is high up on the overhead view and a bit low down, the 40m relevancy distance kicks in and things the spectator/commander SHOULD see disappears.

    The solution is quite simple - just check if the player uses an overhead view, grab the camera position and calculate if entities are inside the viewing volume.

    IIRC, you COULD do that from inside lua by using the "call back to lua for each entity when deciding if something is relevant" marker... which has an annoyingly high performance cost though.

    Cheap to do if you add that capability to the engine though - then you would just tell the engine "Hi! Use these camera parameters instead of distance for me, please*".


    * the please is NOT optional. Programs have feelings too...

  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    can you just up the max relevancy distance for the commander's entity or something?
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    @SamusDroid can you give me an idea what exactly you changed that i might play around with it?
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    It's literally one constant change. Search Perspective in code, it's the only place it's used, then find the constant for orthographic
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    thanks, i found what you're talking about. it sorta implies that the engine is probably capable of doing this maybe! if only there were a setCameraType method on CameraHolderMixin or something.
  • matsomatso Master of Patches Join Date: 2002-11-05 Member: 7000Members, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Shadow, NS2 Community Developer
    What you are looking for is RenderCamera.SetType() - docs/Render.json contains the details.
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    wow that looks like exactly what i need
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    You literally change
    camera:SetType(Camera.Perspective)
    to
    camera:SetType(Camera.Orthographic)
    and that's it
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    So I've been able to get the RenderCamera into orthographic mode using the following:
    gRenderCamera:SetType(RenderCamera.Type_Perspective)
    

    but of course this breaks a whole bunch of stuff! some of it makes perfect sense, like outlines are all busted presumably because they're done in a separate render pass using a separate RenderCamera, so I'm just going to ignore them for now. there's some other wacky junk, but the main problem is that I can't change the FOV at all!

    my understanding is that with an orthographic camera FOV simply changes the size of the viewing area. it's possible that spark just ignores orthographic FOV and uses some other property, but i don't know what it would be. does anybody have any ideas? basically in the screen below you'll see that the camera is zoomed in way too far, and basically I can't figure out how to adjust it. height does nothing (makes sense), FOV does nothing.
    lsVt7qb.jpghxRtVDi.jpg
  • RegnarebRegnareb Join Date: 2007-08-26 Member: 62008Members, NS2 Playtester
    It is normal, there is no 'Focal' variable when using an orthographic camera... an orthographic camera being a 2d projection of the 3d world, it wouldn't make sense to have a focal.
    Open a software like Maya for example, and change the focal of an orthographic camera, it will do nothing.

    The variable you are looking for is the Orthographic Width, I don't know how spark manages it though.
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    edited May 2014
    yeah i understand that. in some engines fov is used for what you're talking about. they're both just scalar values, and they do similar things. anyway, i tried that, among other things, and none of them worked.
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    @matso plz come to my rescue
  • matsomatso Master of Patches Join Date: 2002-11-05 Member: 7000Members, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Shadow, NS2 Community Developer
    I checked where ortographic mode is used in the engine (for generating overviews), and from what I can see, fov seems to be used in orthographic mode:
        RenderCamera* renderCamera = scene->CreateCamera();
        renderCamera->SetRenderMask(renderMask);
        renderCamera->SetFov( blockSize );
        renderCamera->SetType( RenderCamera::Type_Orthographic );
        renderCamera->SetCullingMode( RenderScene_CullingMode_Frustum );
        renderCamera->SetFarPlane( infinity );
    
    The rendering job is split into multible blocks for performance reasons, blocksize here is
    Real blockSize = blockSizeInPixels / pixelsPerMeter;
    
    ...and blockSizeInPixels is 32, so the camera will be moved around and renders a 32x32 m area of the map into whatever number of pixels in the bitmap that represents. That should mean that SetFov in orthographic mode should control the size of the rendered area ... but I'm not really an expert on this stuff.

    And yea, outlines are rendered in a separate stage.
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    so i've been working on this some more, and I have been able to get the FOV of the orthographic camera to change by calling SetFov on every UpdateRender event. now the main issue i'm having is lights. as you'll see in the screenshot below, it seems like all the lights which should be affecting the room are in this little cluster centered around the camera. the cluster follows the camera around and as i move around the map lights will pop into and out of the cluster as they go into and out of range of the camera. as you can see they are lighting materials appropriately, just for some reason they're not positioned and scaled correctly, and again they're following the camera for some reason.

    screenshot:
    RnMJSx4.jpg

    also here's a twitch video to further explain what exactly is happening

    and in case you ever wondered what topo would look like with an orthographic camera:
    YbpWrmm.jpg
  • kmgkmg Join Date: 2008-02-28 Member: 63758Members
    i'm thinking about just cranking up ambient lighting and disabling these lights somehow.
Sign In or Register to comment.