Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding a post processing plugin like "SweetFX"

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1051 Views, 7 Replies

Adding a post processing plugin like "SweetFX"

What's the methodology for adding an image post processing plugin like "SweetFX", would I need source code access?
7 REPLIES 7
Message 2 of 8
__ben__
in reply to: Anonymous

No, you don't need source code to implement your own shader post-processing effects! One of the advantages of Stingray's data-driven workflow is that even the per-frame rendering flow is controlled by configuration files. I've written a brief tutorial on this and will post it to a blog next week. In the meantime, take a look at these files: binaries\core\stingray_renderer\renderer.render_config Search for: { resource_generator="post_processing" profiling_scope="post_processing" } If you need to define another buffer in video memory for your effect, go to the "global resources" section and add a line similar to: { name="postfxdemo_scratch" type="render_target" depends_on="output_target" w_scale=1 h_scale=1 format="R8G8B8A8" } Shader source code can be found in core/stingray_renderer/shader_libraries. When testing out new ideas I'll usually add new shaders to development.shader_source. This is not anywhere near a complete set of instructions. I'll follow up later with a link to a video and/or blog post. Thanks, Ben
Message 3 of 8
Anonymous
in reply to: Anonymous

Awesome, please post a link in this thread when its ready!
Message 4 of 8
__ben__
in reply to: Anonymous

Our YouTube channel: https://www.youtube.com/channel/UC0fIe6XV1PjilADTei9JMOA The video is called "Stingray Render Config Tutorial." Please post back here if you have any questions after watching the video.
Message 5 of 8
Anonymous
in reply to: __ben__

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?

Message 6 of 8
__ben__
in reply to: Anonymous

Good question. I don't have a list of differences. If you post a relatively simple shader demonstrating the differences I'll take a look at it and note required changes.
Message 7 of 8
Anonymous
in reply to: __ben__

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
"]}

 

Message 8 of 8
__ben__
in reply to: Anonymous

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report