Metallic sparkle effect in OpenGL ES? - iphone

I'm working on an Android and iPhone app. I'm rendering lots of smallish (about 32 pixels) billboards to the screen for a particle system and want to give a glitter-like sparkle to each billboard e.g. as the particles are falling, random ones will briefly light up and sparkle as they catch the light. Is there a simple way to achieve this effect? As a limitation, I cannot use pixel/vertex shaders.
I was thinking something along the lines of a giving each billboard metal-like lighting effect (although I'm not sure how to do this part) coupled with giving each billboard a random and constantly rotating normal with flat shading so that each billboard would randomly light up. I'm having trouble making it look nice.

Disclaimer: I don't know OpenGL, and I did't actually try anything I write below.
You can have another, 'brightly lit', texture and substitute it when normal is nearly at the 'shine' position.
Take a piece of metal and rotate it. Once the normal is close to 'full shine' position, the metal shines a bit brighter, and a muted reflex travels through it, with a bright flash in the middle, then it is dull again.
If you can, apply a second bright texture of a narrow 'reflex' band and move it through surface of the billboards that are in a near-shine position, shifting them accordingly to normal angle. When the normal is at the shine position (± epsilon), apply the 'full shine' texture.
Also, unless your plates fly in vacuum, there will be a halo due to atmosphere. Add a rectangle say 50% bigger than the plate right behind it, and apply to it a semi-transparent halo texture that becomes fully transparent closer to edges. You only need it at the fill shine moment.

Related

Unity - particle system material like this?

Im trying to copy this fire system https://realtimevfx.com/t/sketch-10-jordanov/4273/7 the smoke here especially:
https://www.youtube.com/watch?time_continue=2&v=Wwj3Y6ieTlI
So far not much luck, mainly because when I try to emulate the smoke by setting the material to a fade alpha, or even cutout alpha, the overlapping particles become this:
See, they overlap instead of being a solid stream. Is this not possible in Unity?
There's a few possibilities for this.
The texture you're using for your particle has the color fading to black on the RGB channels, instead of being pure white or blue and only having the alpha channel contain the circle pattern.
The shader being used is "pre-multiplying" the color by the alpha, giving a darker look around semitransparent overlaps.
The particles are being lit and thus differences in position can result in differences in lighting, breaking color/shading continuity.
If you use a Unity "Unlit" particle shader, there should be no visible overlaps, assuming you don't have the first issue. I'd recommend trying some of the other shader options available in the Particle section and Mobile>Particle section.

unity3d: Adding half-transparent video with shadows

I'm struggling with an issue that might seem a little bit awkward.
I have some black & white 2d animation (1440x1080px) that I'd like to be played in in a 3d environment in unity3d. Therefor I added a video player to a plane. Now comes the tricky part: I want to make the black areas of the video transparent while the white areas remain visible AND the white areas shall cast shadows on the surrounding. Using the particles shader "additive" does half of the job. But I just can't manage to let the video cast a shadow.
If it worked you would get some 2d "antagonist" (you can't interact with) that looks kind of 3d. Alternatively you could interprete it as some half materialzed holograph that casts shadows.
Is there any (simple) solution I just don't know?
Here some schematic drawing of what I would like to achieve, for better understanding.
The problem right now is: In contrast to my drawing, the desired shadow on the wall doesn't appear... :-/
So, I did never try this but you can maybe add a light in the scene just in front of the video player, that way the light will cast shadows.

How to get rid of "shadow teeth" in Unity?

I tried everything but nothing can affect this. The only thing is when I change shadow resolution to "low", it becomes more smooth (obviously), but still not the best. Those shadows also look better if angle of view is less acute. Quality settings are the best, light source is a spotlight. Material on those things uses standard shader. What do I do wrong?
Image is enlarged.
You...can't. :(
The problem is that the shadows being cast are essentially just a texture. And texture points (aka "pixels") are square. This shadow texture is then "cast" from the light source (think about the light as being a camera: every pixel that it can see that is an object, that becomes a "dark" pixel in the lightmap; its a bit more complicated than that, but not by much).
Your objects and light are definitely not square up from each other. And in fact, can never be as your cubes are rotated five to ten degrees from each other forming a curve. Which means that some edge, somewhere, is going to get jaggy. This also explains why changing the light's position and orientation to a different angle affects the result: those edges more closely (or less closely) align with where the lightmap pixels are.
You can try various settings, such as Stable Fit or higher quality shadows (this is really just "use a bigger texture" so those jaggies get smaller as the same volume is covered by more shadow-pixels) but fundamentally you're not going to get a better result.
Unless...
You use baked lighting. Open up the Lighting window (Window -> Lighting), set your lights as baked rather than forward/deferred (this means they will not be realtime and may not move or otherwise change) and then in the Lighting window, bake your lights.
This essentially creates a second texture that is wrapped around your objects and gives them shadows and the pixels line up differently and generally give smoother shadow edges when the object's faces align with the shadow-casting edge (such as your stacked cubes). The textures are also much larger than the runtime light textures because it doesn't have to be recomputed every frame (realtime lights are restricted so they don't consume gigabytes of video RAM).
Baking will take a while, let it do its thing.
Have you tried with Stable Fit (under Quality settings)?

How to create a non-perpendicular near clipping plane in Unity?

I have a need for setting up clipping planes that aren't perpendicular to the camera. Doing that for the far plane was easy: I just added a shader that clears the background.
I just can't figure out how to do the same for the near clipping plane. I've tried to think of solutions dealing with multiple shaders and planes, a special cutting shader, having multiple cameras for this or somehow storing the view as a texture, but those ideas are mostly imperfect even if they were implementable. What I basically need is a shader that would say "don't render anything that's in front of me". Is that possible? Can I eg. make a shader to make the passed pixels "final"?

How to achieve Terraria/Starbound 2d lighting?

I am making a 2d game in the perspective of Terraria/Starbound. I want the lighting to look similar to this:
Ive tried to get lighting like this by adding a material on all the sprites in my game and then giving them a sprite diffuse shader. Then I made a point light wherever I needed light. There where two problems with this though: 1) Where the light was most intense, it was draining the color of a sprite and made it lighter. 2) I noticed a big FPS drop (And I only had 1 point light!).
Is there any way of achieving lighting like this without having to write my own lighting engine? Ive search the asset store and Ive searched to see if unity has any way of handing 2D lighting from this angle but I have found nothing.
If I do have to write my own lighting engine, would that be to complex for someone who is relatively new to unity and has only had ~ 8 months experience?
Assume you are using tile map.
You need to have a field of view map, which can be achieved by reading this: http://www.redblobgames.com/articles/visibility/
Using such map, you know exactly the color tinting for each tile. Now, just blend the color to the SpriteRenderer of every tile on the map.
Somebody already created a line of sight plugin:
http://forum.unity3d.com/threads/light-of-sight-2d-dynamic-lighting-open-source.295968/
Here's my hacky solution on GitHub
There's 2 cameras.
Empty tiles on the tilemap are filled in with white blocks (only one camera renders this)
A gaussian blur is applied to the camera rendering the white blocks
Then, blend the two cameras, darkening everything not covered by the white blur.
You can adjust the "light" penetration by changing the white tile's sprite's Pixels Per Unit.