Solved! Go to Solution.
Solved by __ben__. Go to Solution.
Solved by __ben__. Go to Solution.
Is there a standard methodology for adding an HLSL shader? I followed the step by step, but it really only works with the example you gave, its not clear to me how I could take a shader from a library, like Nvidia's and add it to my project. Also, the syntax in the shader files given by stingray seems to be a little different in nature than HLSL code, mainly the #define parts. What syntactical changes would I need to make to standard HLSL code to make it compatible with Stingray?
This one is from SweetFX, its a toon shader
/*------------------------------------------------------------------------------ Cartoon ------------------------------------------------------------------------------*/ #ifndef CartoonEdgeSlope //for backwards compatiblity with settings preset from earlier versions of SweetFX #define CartoonEdgeSlope 1.5 #endif float4 CartoonPass( float4 colorInput, float2 Tex ) { float3 CoefLuma2 = float3(0.2126, 0.7152, 0.0722); //Values to calculate luma with float diff1 = dot(CoefLuma2,myTex2D(s0, Tex + pixel).rgb); diff1 = dot(float4(CoefLuma2,-1.0),float4(myTex2D(s0, Tex - pixel).rgb , diff1)); float diff2 = dot(CoefLuma2,myTex2D(s0, Tex +float2(pixel.x,-pixel.y)).rgb); diff2 = dot(float4(CoefLuma2,-1.0),float4(myTex2D(s0, Tex +float2(-pixel.x,pixel.y)).rgb , diff2)); float edge = dot(float2(diff1,diff2),float2(diff1,diff2)); colorInput.rgb = pow(edge,CartoonEdgeSlope) * -CartoonPower + colorInput.rgb; return saturate(colorInput); } float3 CartoonWrap(float4 position : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target { float4 color = myTex2D(s0, texcoord); color = CartoonPass(color,texcoord); #ifdef Shared_Piggyback_Cartoon color.rgb = SharedPass(texcoord, float4(color.rgbb)).rgb; #endif return color.rgb; }
One thing I did notice is that the entire shader would have to be contained in
toonShader = { }
or something similarly named, with these static references at the bottom
{ shader="toonShader" } { shader="toonShader" defines=["
CartoonEdgeSlope
"]}
While we didn't directly translate that shader, we have posted a tutorial on toon shaders:
http://forums.autodesk.com/t5/stingray/stingray-how-to-make-a-toon-cel-shader-video/td-p/6012196
This should help, please reply back to the linked thread with any questions.
Can't find what you're looking for? Ask the community or share your knowledge.