+18
En revisión

Projector Tutorial

PixelNAUTS hace 9 años actualizado por Teddy Himple hace 7 años 13
Would anyone have any examples on how to use the Projection Parameters to make a shader work with Unity Projectors? I am using them as a decal type system and the shaders that come with Unity just dont cut it. Thanks!!
Doesn't have to be a full tutorial, just an image of the shader would be awesome!
I am also trying to achieve this effect because I would like to create a lava effect that can be animated by the shader, and I would like to make a texture projection to the world, does anyone has an example on Shader Forge on how to do this? Thank you all!
+1
Why this still an impossible mission in Shader Forge? :( .... if someone has achieved a shader projector using shader forge I need his help! Please share!!
+4
En revisión
Projection parameters are not for any projection they're specifically for the parameters of the projection of the camera. As for decal projection shaders - I'm not sure how you do that to be honest, so I'm not sure if it's possible in SF!
+4
If you have a look at ProjectorMultiply.shader and ProjectorLight.shader in the Effects standard asset bundle, they seem quite simple. I can't code shaders (because of SF ;) ), but to someone with your experience, it shouldn't be that hard to port them to SF. I really need that right now!
+5

I'm attempting the same:


what you need is:


uniform float4x4 _Projector;


(correctly naming a matrix property in SF works for this)


then within "vert" :


o.posProjector = mul(_Projector, v.vertex);


then within "frag" :


if (i.posProj.w <= 0.0) return float4(0,0,0,0); // behind projector, ignore

return tex2D(_MainTex, i.posProjector.xy / i.posProjector.w); // return decal


Generally the above would be used in conjunction with a falloff:


vert:

o..projClip = mul(_ProjectorClip, input.vertex);

frag:

float4 fallOff = tex2Dproj(_FalloffTex, i.projClip);


result:

return float4( tex2D(_MainTex, i.posProjector.xy / i.posProjector.w), fallOff.a );



I spent an hour trying to learn shader forge hoping it'd speed up this crazy projector I have to make. Kinda sad it seems impossible (currently).



[EDIT]


in my opinion the most important node (for this) that shader forge is missing is:


Geometry Data/Projector Position :: o.posProjector = mul(_Projector, v.vertex);




+2

mul() is the matrix multiply node, so it should work! Could you try it out?

+3

Apologies I'm still learning shader forge. How do I use "v.vertex" as an input to matrix multiplier? That's where I got stuck.

+4

It turns out it was just too much work & near impossible to get a projection shader working in Shader Forge, which is sad, but it doesn't mean Shader Forge didn't help me. In the end the best route was to create the shader, and then edit the output result manually and turn it into a projection shader by hand. I'm hoping it'll be supported some time in the future, but for now, at least, I managed to get my blood splatter projection shader working.


Tools: Allegorithmic Substance (procedural textures making random splat shapes in-game) -> Shader Forge base custom shader -> manually edited and turned into a projection shader


Result:

+3

For those curious about implementation.


Allegorithmic Substance:


Shader Forge Shader:

That UV on the left (feeding into the relay) is what needs to be replaced with projection UVs but I was unable to figure that part out using Shader Forge :(

Really sorry to revive this years-old thread, but I'm also looking to build a decal shader in Shader Forge.

Judging by those two comments below, your shader seems to work. So can you, or anyone, please reupload a screenshot that is actually readable so I may also try it out?

Hello Clive, I cannot thank you enough for making this great contribution, I had agreed with Joachim in providing a couple of shaders that already implemented this to have an example to start working on a node that could allow us to achieve this, but I have had enormous amounts of work with very close deadlines. Joachim was very comprehensive with this feature since is a thing that can empower SF shaders with such awesome realism.


If the code that you shared is all what is needed to build the projection shader this can really help Joachim to build it and published it in the next version or so, if there is new breakthrough, like the code that you manually programmed in the shader, please share with us to count with this so usefully feature in Shader Forge.


Thank you all!

+1

Ahhh, attempting to do the same thing! I'm making a spinning projection in Unity - works and shows up, but always appears at (0,0,0), despite where the prefab is in worldspace.


Thanks for any help!