Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MIT License
- Copyright (c) 2021 Amankumar "ACP" Chandubhai Parmar
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- shader_type spatial;
- render_mode cull_disabled, specular_schlick_ggx;
- uniform float rotation_point : hint_range(0, 1, 0.1) = 0.5;
- uniform float rotation_degrees : hint_range(-360, 360, 1) = 0;
- uniform float x_offset = 0;
- uniform float y_offset = 0;
- uniform float x_scale = 1;
- uniform float y_scale = 1;
- uniform float metalic : hint_range(0, 1, 0.01) = 0;
- uniform float specular : hint_range(0, 1, 0.01) = 0;
- uniform sampler2D texture_albedo : hint_albedo;
- uniform float albedo_strength : hint_range(-2, 2, 0.1) = 0;
- uniform sampler2D texture_roughness : hint_aniso;
- uniform float roughness_strength : hint_range(-2, 2, 0.1) = 0;
- uniform sampler2D texture_normal : hint_normal;
- uniform float normal_strength : hint_range(-2, 2, 0.1) = 0;
- void vertex() {
- // Output:0
- }
- // Rotate UV
- vec2 rotate(vec2 uv) {
- float x = ((uv.x - rotation_point) * cos(radians(rotation_degrees))) + ((uv.y - rotation_point) * sin(radians(rotation_degrees))) + rotation_point;
- float y = ((uv.y - rotation_point) * cos(radians(rotation_degrees))) - ((uv.x - rotation_point) * sin(radians(rotation_degrees))) + rotation_point;
- return vec2(x, y);
- }
- // Offset UV
- vec2 offset(vec2 uv) {
- float x = uv.x + x_offset;
- float y = uv.y + y_offset;
- return vec2(x, y);
- }
- // Scale UV
- vec2 scale(vec2 uv) {
- float x = uv.x * x_scale;
- float y = uv.y * y_scale;
- return vec2(x, y);
- }
- void fragment() {
- vec2 uv = UV;
- // Apply rotation
- uv = rotate(uv);
- // Apply offset
- uv = offset(uv);
- // Apply scale
- uv = scale(uv);
- // Output:0
- METALLIC = metalic;
- SPECULAR = specular;
- ALBEDO = texture(texture_albedo, uv).rgb;
- ROUGHNESS = texture(texture_roughness, uv).r;
- vec4 tex = texture(texture_normal, uv);
- NORMALMAP = vec3(tex.r, 1.0 - tex.g, 0.0);
- NORMALMAP_DEPTH = tex.b + normal_strength;
- }
- void light() {
- // Output:0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement