I am building a game where everything behind the player is greyed out as if it lives in a memory. But I don't know how I can achieve this effect. Is this where shaders are being used for?
Now I can create a SKLightNode to create the lighting and make it dark around the edges. But I like to field of view for the character to be 120 degrees. Everything outside of that angle should be greyed out.
Of course in the future I like the view to be blocked by obstacles but that is outside of the scope of this question.
A desaturation shader for SpriteKit can be found at my blog post on that subject. Note that this works in terms of an input texture, so you may need to adapt things to work on top of a tiled background. Also note that there is a new iOS 9 API to support capture of the output of a whole node, which may be useful to you in implementing this.
Related
In Unity is there a way to stop the camera rendering few objects or lets say far away objects so that it is more performant? I can achieve this with adjusting the far-clipping plane. But I also want the objects to be seen by camera. Such that the objects are visible in the scene but not rendered by the camera? This is specifically for VR purpose. Is there a way to achieve such an unusual thing?
If I understand correctly, you're asking for something to be visible but unrendered. This poses a conflicting problem, as rendering something is the process of making it visible.
Normally, you'd work with not rendering things outside of the viewport and LOD (level of detail).
LOD
Basically rendering things far away with low level of detail, making the game more performant. You can see how to set it up here: https://docs.unity3d.com/Manual/LevelOfDetail.html
Occlusion Culling
Culling is partly done by Unity, as can be read here: https://docs.unity3d.com/Manual/OcclusionCulling.html
There might be more answers than this, I'm not sure I fully understand what you wish and I am not a game designer by profession so my optimization skills are sub-par.
I'm new to shaders and with the new Shader Graph from Unity I'm trying to experiment and archive some effects that I have in mind for my games.
I want to get something like this:
https://imgur.com/vqy9y3H
I want a glow effect to go arround my object. In my case it's a square neon light, so it's simple I think.
What I have so far, experimenting and unifying different tutorials, effects, etc.:
https://imgur.com/aPW95S0
This is the current Shader Graph, i know its a mess and maybe there are useless nodes, etc.:
https://imgur.com/J3jzGE6
This is the tutorial I think it's the most accurate to what I need:
https://www.youtube.com/watch?v=UJUlGJS3QpY
Thanks in advance for any tip that help me find the correct path to archive the effect.
EDIT:
To make it clear, the real problem for me is the motion effect. I already setup the glow effect with post-processing and bloom. My problem is how to do the effect arround the object. In my case it's a neon tube, so it's easiest I think, as the effect can be on all the object but from the start of the tube to the end. As the tube is closed, it will start again from the begining almost at the same point. Hope it make it clear.
you can use post processing to get the effect your after, specifically bloom and tone mapping effects.
With post processing applied you just need to increase the color into HDR levels in your shader.
Applying a blur outside of post processing is actually extremely expensive and isn't really recommended unless there is absolutely no other option.
I'm having trouble figuring out how to light up large area(s) of sprites in Unity 2D. My previous knowledge on Unity's lighting is zero.
I first tried using a large amount of point lights and using the "Sprites/Diffuse" material, but about only five would actually render at a time, so I guess there's a limit on that.
Then I tried putting in an area light. That didn't do anything, so that's when I started doing research about baked lighting on sprites (and baked lighting in general). I found stuff like this but I couldn't get it to work either because it's outdated or because I don't know what I'm doing. Other answers I've come across seem to assume that the reader knows anything about lighting in Unity in the first place which, to be honest, I don't. Unity's documentation website had some information on it, but no tutorials that go into how to set up baked lighting.
I've tried a bunch of different combinations of materials (like using the "Standard" shader for the sprites instead of "Sprites/Diffuse", emission, ect.) and I enabled "Baked Global Illumination" in Lighting>Settings.
If baked lighting isn't possible on sprites (or isn't worth the trouble), what are the alternatives?
Edit: I made sure not to have the lights pointing the wrong direction, and I do realise that Unity2D is just like painting onto a piece of paper in Unity3D. I was able to get point lights to work, but only a few at a time. I don't need to do the entire screen at once, I need to do a large specific area at once.
some tips...
working with sprites your in 2d... when you add a light, switch to 3d mode, and rotate to make sure your light is pointed at your objects, and oriented so as not to be on the same plane, or level with them, as this will cast all the light behind them.
if your trying to light up everything on the screen(in camera) attach an area light to the camera at the cameras position, point it where the camera points, and then in the inspector on the right, you can change its variables. intensity, range, width, height etc.
Emissive Texture:
https://www.youtube.com/watch?v=oa6kW5HhRd4
For some reason, I never even thought about going into the asset store. I found this for free, and it looks like it will work: Light2D.
I am making a app which draws continuous lines like a snake using Unity and SKSpriteKit (Obj-C) in Xcode (I’m making 2 versions of the same app in both):
http://i.stack.imgur.com/qA1zk.png
http://i.stack.imgur.com/484kj.png
http:// i.stack.imgur.com/QTEkC.png (Apologies for the image posts. I can't post an image/more than 2 links)
If you’ve ever heard of a game called Curve Fever, what I’m doing here is quite similar to it. I’m controlling the direction of the end of the line with the arrowkeys, whilst the end of the line automatically moves forward every frame creating an image like the one above.
However, from the 3 screenshots above, it is quite obvious that my program isn’t very efficient - every frame, I add a circle sprite to the SKScene in the place where my moving sprite is, which is why, after a while, there are over 1000 nodes on the screen, and the energy impact/memory/cpu is very high… Not ideal.
So now I’m looking for better ways of drawing the line on the screen without drawing thousands of nodes.
A while ago, a friend talked to me about how he made a similar app in GameMaker (which I have no knowledge of how to use). When I asked him how he rendered the line, he said he created something called a “surface”, and when anything moved on that surface, the old position of the sprite would still stay there - which would create lines if a circle moved across the surface.
He was rather vague about this, and I tried to do some research later, but with no success. I couldn’t find anything relevant about continuous lines, surfaces and GameMaker, Xcode or Unity.
If someone could come up with a solution like my friend was talking about, for Xcode/Unity - preferably both (or if someone could tell me what he was talking about for GameMaker), then I’d be grateful, as this would optimise my game and reduce the severe lags I get after around 30 seconds.
Also, I’d be grateful if anyone could suggest alternative solutions to this, too.
I'm using GameMaker but I have no knowledge of Xcode or Unity. I can't help you directly but I can explain GameMaker surfaces.
Surfaces in GM are objects where you can draw on instead of directly drawing on the screen. Later you can draw the surface to the screen. The main advantage of it is that you can store a surface and for example draw it again in another tick, while the screen is redrawn in every tick, or that you can change it over time.
Surfaces are basically just bitmaps where you draw on. That means it wouldn't be hard to do the same in any other environment. Most other libraries/APIs call it canvas.
In your example you would draw one circle to the bitmap in each tick and then draw the whole bitmap to the screen.
A related topic is destructible terrain as it is discussed here: https://gamedev.stackexchange.com/questions/6721/implementing-a-2d-destructible-landscape-like-worms
I'm new to Lighting in 3D. Just started working with Unity3D. I was creating a sample for myself to test shadows and there is a problem.
As you can see that i have created two simple walls with two cubes. Also I have setup a directional light. Let's go the backside of the walls to view the problem
Technically the front wall should be blocking the shadow of the back wall. But it is not. I have painted a read line to show that where the shadow of front wall is overlapping the shadow of the other, meaning going all the was through the wall. Why is that happening. Help please...
set your shader to DIFFUSE. i have the same problem and solved this. my spotlight is passing thor
that is interesting indeed, i have used unity3d for 5 plus years and never seen or noticed this. however, this might seem like a weird request, could you set the ground and the two cubes to bumped diffuse and make sure the cubes are touching the ground.
Since the shader that is used might allow shadows to pass, secondly, could you go to player settings and check if you are using forward of differed rendering, since their lighting techniques are very different they might have different results.
but all in all, best guess is that the shader you are using allows shadows to pass.