Convert Figma logo to code with AI

Kink3d logokShading

Shading models for Unity’s Universal Render Pipeline.

1,001
125
1,001
8

Top Related Projects

Unity Graphics - Including Scriptable Render Pipeline

2,195

A collection of custom post processing effects for Unity

Post Processing Stack

Quick Overview

kShading is a Unity package that provides advanced shading features for Unity's Universal Render Pipeline (URP). It offers a collection of custom shaders and rendering techniques to enhance the visual quality of Unity projects, focusing on improved lighting, shadows, and material effects.

Pros

  • Enhances the visual quality of Unity projects using URP
  • Provides a variety of custom shaders and rendering techniques
  • Easy integration with existing Unity projects
  • Actively maintained and updated

Cons

  • Requires Unity's Universal Render Pipeline
  • May have a learning curve for developers new to custom shading
  • Could potentially impact performance on lower-end devices
  • Limited documentation compared to some other Unity packages

Code Examples

  1. Adding kShading to a material:
using UnityEngine;
using Kink3d.kShading;

public class ApplyKShading : MonoBehaviour
{
    void Start()
    {
        Renderer renderer = GetComponent<Renderer>();
        Material material = renderer.material;
        
        kShadingFeature kShading = material.EnableKeyword<kShadingFeature>();
        kShading.intensity = 0.5f;
    }
}
  1. Configuring kShading settings:
using UnityEngine;
using Kink3d.kShading;

[ExecuteInEditMode]
public class KShadingSettings : MonoBehaviour
{
    public float shadowIntensity = 0.8f;
    public Color rimColor = Color.white;

    void Update()
    {
        kShadingSettings.SetShadowIntensity(shadowIntensity);
        kShadingSettings.SetRimColor(rimColor);
    }
}
  1. Creating a custom kShading effect:
using UnityEngine;
using Kink3d.kShading;

[CreateAssetMenu(menuName = "kShading/Custom Effect")]
public class CustomKShadingEffect : kShadingEffectAsset
{
    public override void Apply(Material material)
    {
        material.SetFloat("_CustomIntensity", 1.0f);
        material.EnableKeyword("_CUSTOM_EFFECT");
    }
}

Getting Started

  1. Install the kShading package from the Unity Package Manager.
  2. Ensure your project is using the Universal Render Pipeline.
  3. Add kShading to your materials:
using UnityEngine;
using Kink3d.kShading;

public class SetupKShading : MonoBehaviour
{
    void Start()
    {
        Renderer[] renderers = FindObjectsOfType<Renderer>();
        foreach (Renderer renderer in renderers)
        {
            Material material = renderer.material;
            kShadingFeature kShading = material.EnableKeyword<kShadingFeature>();
            kShading.intensity = 1.0f;
            kShading.rimColor = Color.blue;
        }
    }
}
  1. Adjust kShading settings in your scripts or through the Unity Inspector to achieve the desired visual effects.

Competitor Comparisons

Unity Graphics - Including Scriptable Render Pipeline

Pros of Graphics

  • Comprehensive graphics package with a wide range of features and tools
  • Official Unity repository, ensuring compatibility and ongoing support
  • Extensive documentation and community resources

Cons of Graphics

  • Large codebase may be overwhelming for beginners or small projects
  • Potentially higher performance overhead due to its comprehensive nature
  • Steeper learning curve for advanced features

Code Comparison

kShading:

half4 LightingKShadingForward(SurfaceOutputStandard s, float3 viewDir, UnityGI gi)
{
    // Custom shading calculations
}

Graphics:

half4 LightingStandard(SurfaceOutputStandard s, float3 viewDir, UnityGI gi)
{
    // Standard Unity shading calculations
}

Summary

Graphics offers a more comprehensive solution with official support, while kShading provides a lightweight alternative focused on custom shading techniques. Graphics is better suited for large-scale projects requiring extensive graphics features, whereas kShading may be more appropriate for smaller projects or those needing specific shading optimizations. The code comparison shows that both repositories use similar function structures for shading calculations, but kShading likely implements custom techniques within its function body.

2,195

A collection of custom post processing effects for Unity

Pros of Kino

  • Broader scope, offering a variety of post-processing effects
  • More actively maintained with frequent updates
  • Larger community and more extensive documentation

Cons of Kino

  • Potentially higher performance overhead due to more complex effects
  • Steeper learning curve for beginners
  • May require more setup and configuration

Code Comparison

kShading:

half4 frag(v2f i) : SV_Target
{
    half4 col = tex2D(_MainTex, i.uv);
    col.rgb = ACESFilm(col.rgb);
    return col;
}

Kino:

half4 Fragment(VaryingsDefault i) : SV_Target
{
    float3 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).rgb;
    color = ApplyBloom(color, i.texcoord);
    return half4(color, 1);
}

Both repositories focus on enhancing Unity's rendering capabilities, but they differ in scope and complexity. kShading primarily deals with shading and color grading, while Kino offers a wider range of post-processing effects. Kino's broader feature set comes at the cost of increased complexity and potential performance impact. The code snippets demonstrate the difference in approach, with kShading focusing on color transformation and Kino implementing more advanced effects like bloom.

Post Processing Stack

Pros of PostProcessing

  • More comprehensive and feature-rich post-processing solution
  • Official support from Unity Technologies
  • Extensive documentation and community support

Cons of PostProcessing

  • Potentially higher performance overhead
  • More complex setup and configuration
  • May require more advanced knowledge to fully utilize

Code Comparison

kShading:

half4 FragmentProgram(Varyings input) : SV_Target
{
    half4 color = SampleAlbedoAlpha(input.uv);
    return color;
}

PostProcessing:

[System.Serializable]
public sealed class Bloom : PostProcessEffectSettings
{
    public FloatParameter intensity = new FloatParameter { value = 0.5f };
    public FloatParameter threshold = new FloatParameter { value = 1f };
    public FloatParameter softKnee = new FloatParameter { value = 0.5f };
}

The code snippets demonstrate the difference in complexity between the two projects. kShading focuses on simple, lightweight shading techniques, while PostProcessing offers more advanced and customizable effects.

kShading is a lightweight shading solution that prioritizes performance and simplicity. It's ideal for projects that require basic shading functionality without the overhead of a full post-processing stack.

PostProcessing, on the other hand, provides a comprehensive suite of post-processing effects, offering greater flexibility and visual enhancement options at the cost of increased complexity and potential performance impact.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

kShading

Shading models for Unity’s Universal Render Pipeline.

alt text An example of a scene using Lit Toon shading.

kShading is a package of shaders for Unity's Universal Render Pipeline. It includes:

  • Lit: A physically based shader that supports all default Universal surface properties as well as anisotropy, clear coat, sub-surface scattering and transmission.
  • Toon Lit: A cel style shader that supports all features of the Lit shader but uses a stepped physical approximation BSDF.

Refer to the Wiki for more information.

Instructions

  • Open your project manifest file (MyProject/Packages/manifest.json).
  • Add "com.kink3d.shading": "https://github.com/Kink3d/kShading.git" to the dependencies list.
  • Open or focus on Unity Editor to resolve packages.

Requirements

  • Unity 2019.3.0f3 or higher.