The problem with transparency and 3d camera

0 favourites
From the Asset Store
A game with 3D terrain, realistic water and various 3D objects.
  • Colonel Justice I managed to use coordinates for sprites on the 2d layer. But I do not understand how to achieve the correct size of sprites. This method can be used for a coin in my case. Since the question arises how to move sprites if we constantly set their position.

    https://drive.google.com/file/d/1Z36JfxluwTB0vrWVDJi97Ko6H5HAkvq3/view?usp=sharing

    But even a coin I would like to animate (smooth movement up and down). Therefore, the ideal option would be for a coin or a flying ship that comes from the sky or whatever to be displayed correctly in 3d mode. And here is an example of a game in which i want to do this:

    Would you mind to share the c3p file shown on the GIF? (if you made this, off course). Thanks you :)

  • Hey

    Maybe my example will be helpful. No mesh needed! Rocket&pilot included :O

    https://rufson.itch.io/3d-to-2d-sprites

    I didn't know there was a function like: 3DCamera.CanvasToLayer...

    and I had to test it asap:) Thanks Colonel Justice

    For the costly square root I used fast(I think so) perpendicular distance math instead - I'dont remember where I found this formula but it works:

    set billboardSprite "A" variable to: (angle(CameraSprite.X,CameraSprite.Y,self.X,self.Y))-CameraSprite.angle

    then billboardSprite "B" variable to:

    distance(CameraSprite.X,CameraSprite.Y,self.X,self.Y)*cos(self.A)

    then set billboardSprite scale:

    abs(scale variable/(self.D+distance(CameraZ,0,self.ZElevation,0)^1.333))

  • rufson it looks cool! thank you)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It seems that the translation of the sprites position is not quite accurate and the sprites "walk" when moving the camera. Any thoughts on how to fix it?

  • Ups the events order is wrong, move "CAMERA" event group above "3Dto2D" group:

    like this:

  • rufson Yes it works thanks. I really liked your example and I was looking for the best optimization for it. Because I don't really like that all objects are in the same sprite. But the options I tried turned out to be worse than they are at the moment. Do you think there is a possibility of better optimization? Or leave the optimization at the same level, but put the objects in different sprites?

    And most importantly, do you have a formula for such a mode?

  • q3olegka

    Remove 1.333 from scale abs(180/(3Dbill.d+distance(camH,0,3Dbill.ZElevation,0))) for 45fov and should be fine, maybe not perfect but much better.

    Then you need also to adjust the 3Dshape sky height and camera H on mouse wheel.

    Optimization in this case depends on many factors, I made simple self picking distance variable without for each loop beacuse self is faster(and actualy is a loop too). When the distance is bigger than 0 then objects are at front of the camera then do tranformations etc But this is not the best solution when you have a lot of objects because engine must calculate every tick the distance for each sprite to compare them.

    If you want to have a lot of objects then you should consider to lock camera angle to avoid visible horizon (like in Don't Starve game) and then sort and transform only visible objects after picking them. You can pick those instances on 3D layer using square invisible sprite which follows camera but can't rotate with it(rotation will impact collision performance). 3D sprite that is in 3D layer and have 2D sprite in container should also have square collision shape like 4 corner only and can't rotate(this is the fastest picking on overlap event) Check out that post from page 1 to 2 that is exacly about this method: https://www.construct.net/en/forum/construct-3/general-discussion-7/picking-performance-132709

    Another method is to store objects in a Array and create them when camera or player is around and unload objects that are far away(many games do this). Then you can create very big worlds but this is more complex to achieve.

    You should then consider things like:

    - Storing static objects and its state variables for animation frame, life etc

    - to not create all of them from a array when needed in one tick(creating and destroing a lot of objects at once have performance impact)

    - Storing moving objects with variables and behaviours

    - And many more things that depend on the game design

    You can even instead of Array handle map cluster checking on which tilemap the player is and spawn objects designed for this biome and unload those far away.

    Good Luck!

  • I have another issue with transparency and 3D Objects, but only when I use the "Fog" effect.

    It seems that transparent objects prevent the fog to be shown behind them. As workaround I've created another layer without fog; I change the brightness of objects on this layer when I move the camera, but you can see that the light is not exactly the same as the objects on the "foggy" layers.

    You can find the issue in the "Foggy outbreak" template as well. Any way to fix it?

  • I have another issue with transparency and 3D Objects, but only when I use the "Fog" effect.

    This is a different issue to the one originally discussed in this thread. It's covered in the tutorial Using 3D in Construct under "Transparency and fog", and in the latest beta the "Foggy outbreak" project has been updated to work correctly.

  • > I have another issue with transparency and 3D Objects, but only when I use the "Fog" effect.

    This is a different issue to the one originally discussed in this thread. It's covered in the tutorial Using 3D in Construct under "Transparency and fog", and in the latest beta the "Foggy outbreak" project has been updated to work correctly.

    Thanks, I've updated my project following the tutorial and now the fog effect works fine on any objects

  • spokoinbli - how did you make the cylinder type shapes?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)