Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Visual Shader Derive Z Node

An asset by Foyezes
The page banner background of a mountain and forest
Visual Shader Derive Z Node hero image

Quick Information

0 ratings
Visual Shader Derive Z Node icon image
Foyezes
Visual Shader Derive Z Node

Get the Z channel of a normal map from X & Y channels.

Supported Engine Version
4.2
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
2 months ago
Git URL
Issue URL

Godot Derive Z Node

Get the Z channel of a normal map from X & Y channels. This node only works in Godot 4.2 onwards. README image

Method

The node take X & Y as inputs and outputs the full normal map.

vec3 deriveZ(float x_in, float y_in){
        
        vec2 normalXY = vec2(x_in * 2.0 - 1.0, y_in * 2.0 - 1.0);
        
        float z = sqrt(max(1.0 - dot(normalXY, normalXY), 0.0));
        
        vec3 normal = vec3(normalXY.x, normalXY.y, z);
        
        return normal;
    }

By default the normalization is set to No. You can normalize the result by selecting Yes if you need.

Yes

=normalize(deriveZ(%s, %s)) * 0.5 + 0.5;

No

=deriveZ(%s, %s) * 0.5 + 0.5;

This implementation gives users the flexibility to choose whether they need normalization, which is useful since sometimes you might want to skip normalization for performance if you know your inputs are already normalized or if perfect unit vectors aren't required.

Installation

Extract the zip file and copy the folder to your project. You'll need to restart the editor for the node to appear in visual shader. Alternatively, you can make a new gdscript file and copy the code.

Get the Z channel of a normal map from X & Y channels.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Visual Shader Derive Z Node icon image
Foyezes
Visual Shader Derive Z Node

Get the Z channel of a normal map from X & Y channels.

Supported Engine Version
4.2
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
2 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers