Seeking an actual example of a step shader with threshold
I'm an artist. I can 'code' a bit but only to the extent of getting the job done. I use visual-scripting and blueprints for absolutely everything I do.
I am attempting to get the 90 degree threshold Step Shader, used in Guilty Gear Xrd and Xrd Revelator going inside a UE4 project. I want to do this so I can practice more-so from the asset set-up perspective.
I've watched the GDC video enough to memorize it. I understand in full why the shader works but I don't know enough about HLSL to determine if they literally provided the code or not.
Here is the explanation they provided in the GDC video:
"Generic step(Threshold, dot(Light, Normal)) * Determine if a surface is lit or not.
If the surface Normal is facing the Light source, it is lit. If it is facing away more than 90dg (the threshold), it is not lit."
Am I to take this to mean that the 'code' is quite literally? "generic step(Threshold, dot(Light, Normal))"? If so does it need a semi-colon on the end of it? Example: "generic step(Threshold, dot(Light, Normal);"
How would I indicate the 90-degree threshold? Do I do that in the code? Or through a 'node' in the blueprint? both?
Quite literally all I am looking for is the proper syntax for an HLSL shader in which you indicate whether a surface normal is lit or not and whether or not the light source is head on, or more than 90 degrees away. Just as their explanation states it should work.
Alternatively, can this exact same thing be accomplished with a blueprint? Because I understand blueprints so I'm totally open to being given a few reference links.
I can handle every single aspect of the asset set up (vertex colors, etc) on my own. but I simply cannot understand HLSL and the supporting documentation does not serve to explain how multiple parts work together (it's not friendly to a non-programmer)
Thanks for taking the time to read this. Hopefully someone can provide guidance. Have an awesome day.
asked Jan 19 '18 at 02:53 AM in Rendering
I'm afraid you're not going to get very far without actually taking the time to learn how HLSL works and how all the parts fit together. You might want to try looking at example shaders (there are tons all over the internet) and checking out things like ShaderToy (https://www.shadertoy.com/).
To actually answer your question, the step function takes two values (y, x - note the order) and returns 1 if x is greater than or equal y, or 0 otherwise. It returns the same type as whatever x and y are (float, generally).
The dot product of vectors A and B returns the length of A times the length of B times the cosine of the angle between them (
I assume you'd rather implement this inside a material node graph than attempt to modify the underlying HLSL shaders. If you use the Unlit shading model, you can implement this "lighting model" yourself by using the following node graph, with the caveat that you must pass in the light vector yourself through a parameter:
Implementing a full cel-shaded lighting model that "just works" without you having to do a bunch of extra setup would involve actually adding a new shading model to the engine, but you might want to search for other examples, as I'm sure someone else has already done so.
Follow this question
Once you sign in you will be able to subscribe for any updates here