Giter VIP home page Giter VIP logo

flexibletoonshadergd-4.0's Introduction

Flexible Toon Shader for the Godot Engine

Table of contents

Features

 🤸Flexibility through parameters like number of cuts/bands, steepness, and wrap
 🎨 Supports custom color ramps
 🌈 Affected by the colors of light sources and ambient light in the scene
 💡 Allows for multiple light sources
 ⛱️ Supports shadows and attenuation
 ✨ Visual extras like specular reflections and rim lighting
 🖼️ Supports textures for albedo and specular

New:
 ✏️ Experimental toon hatching shader (available as a separate material)

Installation

Godot Asset Library

The shader is available in the Godot Asset Library directly from the editor.

Download from GitHub

Simply download the repository contents and drop the addons folder in your project root. You can find the toon shader material at addons/flexible_toon_shader/FlexibleToonMaterial.tres. The (experimental) toon hatching shader material is located at addons/flexible_toon_shader/HatchToonMaterial.tres.

Note: The repository contains an example scene at addons/flexible_toon_shader/example. You can remove this folder if you want to keep the install size small.

Settings

The following shader parameters are available:

  • albedo

Base color of the mesh.

  • albedo_texture

Use a texture for the base color (will be multiplied with albedo).

  • clamp_diffuse_to_max

When using multiple light sources, instead of adding every light, the diffuse color will use only the brightest light. This can make a scene with multiple light sources look more consistent (see below).

Example with clamp_diffuse_to_max enabled (left) and disabled (right).

  • cuts

The number of cuts used for toon shading. Set to 1 for "classical" toon shading with a single hard border.

  • wrap

Adds a bias to the calculation for diffuse shading, essentially moving the halfway point between the lit and dark sides of an object.

Shading of an object with wrap set to 0 (left) and 0.4 (right). Note that the position of the light is the same in both cases.

  • steepness

Controls how steep the transition from lit to dark areas should be, essentially shrinking the widths of all bands. (Has no effect when cuts is set to 1).

  • use_attenuation

Allows objects to cast shadows on the mesh. Also needed for proper attenuation when using OmniLight nodes in your scene.

Note: ATTENUATION parameter was changed from Vector to Float in Godot 4. I'm not sure if I ported correctly, please check :). You might need to set wrap to a slightly negative value (e.g. -0.1) for this to work properly.

  • use_specular

Adds a specular reflection blob based on Blinn-Phong shading.

  • specular_strength

Brightness of the specular blob. Does not change its size.

  • specular_shininess

Controls the size of the specular blob. Larger values will result in a smaller blob.

  • specular_map

Use a texture for specular reflection. This will be multiplied with the specular result so bright areas will be more reflective than dark areas.

  • use_rim

Enables simple rim lighting.

  • rim_width

Controls the width of the rim. Note that smaller values will result in a larger rim.

  • rim_color

Custom color of the rim effect to blend with the light color. The alpha component controls the brightness of the rim.

  • use_ramp

Use a custom ramp texture for coloring each band.

Note: If you're sampling from a texture with a discrete palette of colors, make sure to adjust the cuts parameter accordingly.

Ambient light, light color and parameters like albedo will affect the output color of the ramp. If you want to preserve the colors exactly as they are, make sure to either disable all ambient light sources or uncomment render_mode ambient_light_disabled in the shader file and make sure all lights in your scene are white.

  • ramp

(Horizontal) texture used for the color ramp. Godot's built-in GradientTexture can be used.

Toon Hatching Shader

The toon hatching shader is similar to the main toon shader but takes an additional single rectangular texture input. This pattern is then repeated to create a (cross) hatching effect.

The shader is available as a separate material at addons/flexible_toon_shader/HatchToonMaterial.tres.

Troubleshooting

use_attenuation looks weird/too bright.

You may need to set wrap to a slightly negative value, e.g. -0.1.

My color ramp doesn't look like the texture.

If you use a pixelated texture as the palette for the color ramp, make sure you import it with Repeat and Filter disabled. Also make sure no ambient light or light colors are changing the colors of the object. You can also switch between triplanar mapping and UVs with the flag use_triplanar.

License

This repository is licensed under the MIT license.

The Godot Engine Logo is used in the example scene:

Godot Engine Logo Copyright (c) 2017 Andrea Calabró

This work is licensed under a Creative Commons Attribution 4.0 International License (CC-BY-4.0 International) https://creativecommons.org/licenses/by/4.0/.

Godot Engine icons are used in the example scene. The Godot Engine is licensed under the MIT license.

flexibletoonshadergd-4.0's People

Contributors

captainproton42 avatar atzuk4451 avatar

Stargazers

 avatar IggyTheMad avatar Cat Cigarette avatar Rapuška avatar Todd Kuebler avatar Ivan Garusov avatar Bugbeard (Simen) avatar McAwl avatar  avatar  avatar Yura Ilyaev avatar  avatar Joey Nelson avatar Polluted Mind avatar  avatar  avatar  avatar yauoiyi avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.