Skip to content

eldskald/godot4-cel-shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godot 4 Complete Cel Shader

This project is a demo of my Cel Shader for Godot 4. This is a continuation of this project, the old version of this shader for Godot 3. Feel free to mess around with it and study!

godotshaders.com link

Youtube video

Instructions

You need to put everything on the src folder on your project, on the same folder. Then, go to Project Settings > Shader Globals and set the following:

sampler2D diffuse_curve
float specular_smoothness = 0.05
float fresnel_smoothness = 0.05
float outline_width = 4
color outline_color = black

These values are the ones that made this screenshot you're seeing, but feel free to mess around with these values.

The diffuse_curve texture must also be set. You can put a texture you already have or you can use Godot's built in GradientTexture1D or CurveTexture types, but you must save them as resources or else the engine won't be able to load them the next time you open Godot. The one I used for this demo is this one saved from a GradientTexture1D resource, so you can use this one to get a scene looking exactly like the one in the demo. I explain its functionality more in detail on the previous video.

Base Materials

Whenever you want a material with one of the additional features, make a copy of cel-shader-base.gdshader and change the defines.

This is how the defines look on cel-shader-base.gdshader. For each feature you want, change the 0 to 1 and the additional uniforms should show up on the material. You must have the includes folder on the same directory as the your modified copy. You can see the demo as an example.

Lastly, you can watch the Youtube video for more information on how the base functions work and how to set it up.

Outlines

Make another material with the outline.gdshader shader. Put this material on the next_pass property of the material.

Changelog

  • April 24, 2023
    Add diffuse_curve global shader parameter (Thanks to Urakaroo).

  • Nov 7, 2023
    Fix mountain shadows.

  • Nov 2, 2023
    Fix broken material dependencies.

  • Sep 19, 2023
    Fix the SPECULAR_AMOUNT variable name being already used.

  • Apr 24, 2023
    Add the outlines code to the source and add instructions on how to set them up.

  • Apr 12, 2023
    Update shadow settings (Thanks to Dustin Jablonski).

  • Apr 7, 2023
    Initial release.

License

All code is licensed under the MIT license.

Credits

Shader, demo and assets by me, Rafael Bordoni. The skybox shader is this one, by axilirate. The fog shader is this one, by alghost.

About

Complete cel shader for Godot 4

Resources

License

Stars

Watchers

Forks