#Tracer Effect
1 messages · Page 1 of 1 (latest)
These are some tracers
I want to replicate this effect with a shader (I can't use gameobjects)
How do I go about it?
Specifically, I need help with the shader itself
I am currently rendering using Graphics.DrawMesh
Ok, based on this info alone, it doesn't change my reply, if you have a trace mesh already(for example, if you generate it at runtime), you just need to apply a shader to it. Any kind of shader would work really, but you probably want an unlit shader, so that the trace is not affected by lighting. I'd try the unity unlit one for starters, as I suggested.
The shader is the point!!!!!!!!!!!!!!!!!!1
@royal vigil
Trail renderers are no good, the variable length depending on the speed is a bad thing
A small mesh with bloom is problematic because eventually there won't even be one pixel to display for post processing
I need to create an effect as seen in the video, where bullets gradually fade out of view instead of instantly due to aliasing
https://www.youtube.com/watch?v=jdCfhhJpi9E
Do you understand how shaders work? Vertex shader runs for each vertex of a mesh, transforms the vertices position to clip space + some other transformation and passes them on. The GPU fills the screen space triangles with pixels and calls a pixel shader for each screen pixel in the visible triangle. That's super simplified, but the point is, you need something for the vertex shader to work with. It can't make things out of thin air. That's why you need a mesh of the trace. That or it has to be a full screen shader, a post processing effect basically.
In thia video there's probably more than just a shader involved. It's likely that they're employing some advanced anti aliasing techniques, like ssaa or something.
It is something already though
Current look
The problem
Well, how you rendering it? It's weird that a long shape mesh would render as a point like that. Unless it's rotated orthogonally to the camera.
Is the problem that it appears too small when far away?
For that exact problem I used a shader that extrudes the mesh (adds the normals to vertex positions) over distance to camera
What stops you from using Particle System? Every game source and engine I had a chance to touch used Particle System implementation, this is like battle proven solution. It does many things out of the box.
Since you are restricted to Graphics.DrawMesh, I would look into possibility to limit minimum size of the object either though mesh or shader itself, I would dig into particle system code and see how its done in Render tab.
I have not done this that way, sorry to be useless.
But.
With Particle System you can build physical bullets, or ray cast based. You can have a bullet mesh, or/with traces that keeps its minimal size on distance, as alternative you might have different particle blending half way through to display far tracer as more visible/simplified one. With visibility over distance you might replace it with simple glare texture.
I suggested particles or VFX Graph specifically for this purpose in the other thread that we already had
Particle System and VFX Graph particles already let you define min/max screen size, and then you'd just fade the color or alpha when it get far away
This is what I'm looking for
As an object
I'm demonstrating that the effect is much worse when you are facing towards the bullet
I don't want to use a particle system, it would be annoying to write the code for setting the positions and direction for every particle in the system, that is what I did the first time around
This is a thread about creating a shader for a small mesh to keep it visible as it gets further away
You use shader graph?
Add the vertex normals to the vertex position in the shader. This makes the mesh extrude outwards along its normals.
Get the distance to the camera and use that as a multiplier for the extrusion.
Not familiar with it, the creation of the shader is precisely what I need help with
Which one?
I dont use URP but probably URP > Unlit Shader Graph
Unlit?
Since it will just emit light it doesnt need to be lit
Right
Lit = receive lighting, shadows and such
@sly rock Well that's not right...
Thats the idea, just need a very small multiplier based on distance
Is the position input World space or Object space?
If you unplug it you will see
WORLD
Good
You missed the 'very small multiplier' part
Also your muliply should be before the addition, not after
You only need to multiply the normal with distance * some small number
Then add it to the position
Looks like it just tears the mesh apart
If you push out the normals you need to have a continuous mesh. No split edges. All shared vertex indices.
Otherwise u get that effect
Another thing to consider that I tend to forget how to do (but remember to do) is you need to account for the fov of the camera for scaling problems like this. When multiplying by the projection matrix iirc the value you need for accounting for it is often stored in the w of a transformed xyz(w).
@brittle forum @sly rock This kind of works
But the object likes to disappear before it's fully off screen and the scaling is really weird
You'll need to update the bounds of the object to reflect the increased scale.
It's getting culled
uhuh
Pretty sure.
how
This is a tricky one. The way you have it written it could almost be a c# script.
But the bounds are a cpu side thing
So you can't get them in a shader
It's J a problem with making things larger than they really are in shader
A solved problem with particles
You can still use meshes with particles too.
I'm not going to use a particle system
I recommend VFX Graph, not the PS
What is the VFX graph?
GPU particle simulation
See what I mean by weird scaling? It's not entirely uniform and is prone to weird angles
A more flexible system than PS since it can do anything with any kind of data you feed into it, not just with predefined modules
So fading particle color over distance can be done within it without shaders
Screen space scaling is an included operation
I'll look into it
Hell, I might be better off with a 2D texture rather than a mesh. I mean, look at this
It's not quite possible to tell which one that is
U still have the problem you're describing where it's not visible from the front
A 2D Texture will have to be made into a mesh to be rendered
That's tru too
A mesh with 2 tris
Rather than my 4
We'll see
Billboarding a stretched quad towards camera is tough to do manually, and tougher if it also needs to retain solid appearance frontally as hol mentions
Luckily VFX Graph has all kinds of billboarding options for quad particles
I used a more capsule-like mesh so it extrudes more uniformly
Not sure how this would work when viewed from behind/front
I wonder if frustum/distance culling is playing a part in what they describe as the "object disappearing"..?🤔
That's how you'd see it in real life though. If the trace is facing you, you'd only see a dot.🤷♂️
That is if they were visible in real life.
What?
Well, yeah. But it would still have bloom. The issue is not it being small, but bouncing in and out of being invisible due to aliasing
You'd be surprised, but normal bullets don't produce shiny traces as they fly through the air.
In real life*
I'm not twelve, I know this
Can you record a video demonstrating the issue?
I feel like it's less "aliasing" and more has to do with the shape of your mesh.
Is it just 1 long triangle?
cone
Hmm.. Okay. So can you record a video of what it looks like?
It's too abrupt
I dunno what you're looking for, small object get so small that it become < 1 pixel big
Yes, I just wanted to confirm I understand the issue correctly.
The fact that post processing is... post processing doesn't help the issue at all, so it's either blooming really bright or completely invisible
Well, what Osmal was suggesting should work. Although, I'd think what Spazi was suggesting is a more correct approach and provides more room for customization.
I will look into converting over to a VFX graph, good excuse to learn it anyway
If that doesnt work out, try the extrusion approach, you were very close to having it working. The mesh just needs to have a couple more vertices and no hard edges
Funny to hear the approach called incorrect when it solved this exact issue for me
Ofc the downside is having a few more vertices compared to a quad, but it probably wont make a difference
I dont remember running into any culling issues 🤔
In my experience you run into those always when scaling up a mesh in vertex stage
It'd be simpler to only scale down
Yeah it makes sense, I need to check again if its an issue
I can just... scale it outwards. Like from the cone's tip.