Stylized Toon Shader

Stylized Toon Shader
Publisher: Game Prompts LLC

Gallery

Mac OS, Unity 6 (6000.0.40f1), Augment Agent (v0.404.1), VS Code v1.99.1

Description

Stylized Toon Shader (URP). How to use: copy/paste the prompt "prompt1" into Augment's Chat (Agent mode) extension in VS Code For your Unity project

Prompts

prompt1
When you use terminal - make sure to use current project's directory, most likely the directory by default is not the project's directory, so switch to it before creating any folders and files. Create a high-quality, URP-compatible toon shader for Unity that achieves a clean anime/cartoon look with advanced stylization features, have smooth shading. The shader should be named "FGP_ToonShader" and placed in the Assets/Shaders/FGP folder. Shader Structure Requirements 1 Create a complete shader with the following structure: ◦ Main shader file with Properties, SubShader, and Pass definitions ◦ Separate include file for the shader functions and HLSL code ◦ Multi-pass setup (main lighting, outline, shadow caster, depth only, depth normals) 2 The shader should include these organized property groups: ◦ Base texture with color tinting ◦ Normal map support for detailed surface information ◦ Emission map for self-illuminating areas ◦ Shadow parameters (threshold, smoothness, color, strength) ◦ Specular control (intensity, smoothness, color, threshold) ◦ Rim lighting (threshold, smoothness, color, intensity, light-based option) ◦ Matcap overlay (texture, intensity, blend mode) ◦ Outline system (width, color, screen-space option) ◦ Advanced rendering settings (cull mode, ZWrite, ZTest, blend modes) 3 Implement the following passes: ◦ ForwardLit (main rendering pass) ◦ Outline pass using vertex extrusion with screen-space option ◦ ShadowCaster (for shadow mapping) ◦ DepthOnly (for depth prepass) ◦ DepthNormals (for effects like SSAO) Technical Requirements 1 Implement proper URP compatibility: ◦ Include correct URP shader libraries with absolute include paths ◦ Set up proper Tags for RenderPipeline and LightMode ◦ Configure appropriate multi_compile pragmas for shadows, fog, and VR ◦ Support for MainLight and additional lights ◦ Light probe support for ambient lighting 2 Set up proper SRP Batching and performance optimizations: ◦ Define a CBUFFER with all material properties ◦ Ensure all properties are correctly defined in both Properties block and CBUFFER ◦ GPU Instancing support ◦ Implement custom ShadowCaster, DepthOnly, and DepthNormals passes instead of directly including URP's built-in pass files ◦ Efficient texture sampling 3 Implement VR compatibility: ◦ Include necessary macros for Single-Pass Instanced rendering Visual Features 1 Implement cel-shaded lighting: ◦ Sharp transitions between light and shadow using EasyToonRamp function ◦ Customizable threshold and smoothness for the transition edge ◦ Support for main directional light and real-time shadows ◦ Shadow color and strength control for artistic flexibility 2 Add specular highlights: ◦ Modified Blinn-Phong with toon-style cutoff ◦ Controllable threshold, smoothness, color, and intensity ◦ Light-dependent specular that only appears in lit areas 3 Create rim lighting effect: ◦ View-angle based rim lighting with customizable parameters ◦ Customizable threshold, smoothness, color, and intensity ◦ HDR color control for the rim ◦ Option for lighting-dependent rim effect (only visible in lit areas) 4 Include advanced stylization features: ◦ Normal map support while maintaining stylized look ◦ Emission map for self-illuminating areas ◦ Matcap overlay with additive and multiply blend modes ◦ Screen-space and object-space outline options Implementation Details 1 Use helper functions for the toon lighting transitions: ◦ Implement EasyToonRamp function for clean transitions ◦ Create reusable lighting functions for diffuse, specular, and rim effects ◦ Optimize outline pass with screen-space and object-space options 2 Structure the code with clear sections: ◦ CBUFFER definitions ◦ Input/output structs ◦ Helper functions ◦ Main shader functions (Vertex, Fragment, etc.) ◦ IMPORTANT: Do NOT redefine textures that are already defined in URP's SurfaceInput.hlsl (_BaseMap, _BumpMap, _EmissionMap) 3 Create a custom shader GUI with polished UI: ◦ Implement FGP_ToonShaderGUI.cs in the Editor folder ◦ Create a visually appealing UI with clean design (no background rectangles for section headers) ◦ Organize properties into logical sections with styled headers ◦ Use boxed sections with proper spacing for better readability ◦ Include a main shader header with title and white text on colored background ◦ Add helpful tooltips for all properties ◦ Implement proper keyword toggling for features ◦ Add spacing between sections for better organization ◦ Include render queue and instancing controls at the bottom Output Provide the complete shader implementation as three files: 1 The main shader file (FGP_ToonShader.shader) 2 The include file (FGP_ToonShaderPass.hlsl) 3 The custom editor script (Editor/FGP_ToonShaderGUI.cs) All files should be fully functional in Unity URP projects with no errors or warnings. Important Implementation Notes 1 For ShadowCaster, DepthOnly, and DepthNormals passes, implement custom passes instead of directly including URP's built-in pass files: - Do NOT use "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" - Do NOT use "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" - Do NOT use "Packages/com.unity.render-pipelines.universal/Shaders/DepthNormalsPass.hlsl" - Instead, implement custom vertex and fragment functions for these passes to avoid compatibility issues 2 For the ShadowCaster pass: • Use URP's built-in ApplyShadowBias function directly in your ShadowCaster pass • DO NOT create your own ApplyShadowBias function as it will conflict with URP's built-in function • If you need custom shadow bias behavior, create a function with a different name (e.g., ApplyCustomShadowBias) - Include the necessary pragma directive for punctual light shadows: #pragma multi_compile_fragment _ _CASTING_PUNCTUAL_LIGHT_SHADOW - Implement a custom GetShadowPositionHClip function that handles both directional and punctual light shadows • When handling punctual light shadows, access _LightPosition as _LightPosition.xyz - IMPORTANT: Do NOT define custom shadow bias variables like _ShadowBias or _ShadowNormalBias as they conflict with URP's built-in variables - Instead, implement a simple shadow bias calculation directly in the GetShadowPositionHClip function - Make sure to use defined(_CASTING_PUNCTUAL_LIGHT_SHADOW) instead of just _CASTING_PUNCTUAL_LIGHT_SHADOW in preprocessor directives 3 For the DepthNormals pass: - Implement a custom fragment function that outputs normalized world-space normals - Handle normal mapping properly in this pass 4 IMPORTANT: Avoid defining any variables that might conflict with URP's built-in variables, especially: - _ShadowBias, _ShadowNormalBias - Any texture samplers already defined in SurfaceInput.hlsl 5 Ensure proper CBUFFER setup for SRP Batching in all passes 6 Use proper namespace for the custom GUI script (FGP.Shaders) 7 Implement proper keyword toggling in both shader and GUI script 8 For normal map and emission features, use texture presence and color intensity to toggle keywords rather than separate toggle properties 9 In the custom GUI script, handle null properties gracefully by checking if they exist before using them 10 Make sure property names in the GUI script exactly match those in the shader 11 Create a polished UI with custom styling: - Add a main shader header with white text on colored background - Do NOT use background rectangles for section headers (use standard Unity foldouts instead) - Use box containers for property groups - Add proper spacing between sections and properties - Include render queue and instancing controls at the bottom Other notes: • Create all folders and files inside project's "Assets" folder. Create folder "Shaders" in "Assets" folder (if does not exist), create folder "FGP" inside "Shaders" folder (if does not exist), name the created shader "FGP_ToonShader" and put into that "FGP" folder. • Do not create sample scenes to demonstrate the shader. • Do not create Readme files

Generated Sample

While AI can offer great flexibility and possibilities, results may vary from the expected output. Download this verified sample to see a working example of what can be achieved.

Download Generated Sample(7.7 KB)
We use cookies and similar technologies to analyze traffic and improve your experience. Select "Accept" to enable analytics or "Decline" to opt out.Learn more