daily pastebin goal
4%
SHARE
TWEET

PS1 shader - Godot

CowThing Jun 27th, 2018 285 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type spatial;
  2. render_mode depth_draw_opaque, diffuse_lambert, specular_disabled, skip_vertex_transform;//, vertex_lighting;
  3.  
  4. uniform vec4 albedo : hint_color;
  5. uniform sampler2D texture_albedo : hint_albedo;
  6. uniform vec2 uv1_scale = vec2(1.0, 1.0);
  7. uniform vec2 uv1_offset = vec2(0.0, 0.0);
  8.  
  9. uniform float snap_scale = 10.0;
  10.  
  11. varying noperspective vec2 base_uv;
  12.  
  13. void vertex() {
  14.     VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
  15.     NORMAL = normalize((MODELVIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
  16.    
  17.     VERTEX = vec3(ivec3(VERTEX * snap_scale)) / snap_scale;
  18.    
  19.     UV = UV * uv1_scale + uv1_offset;
  20.     base_uv = UV;
  21. }
  22.  
  23. void fragment() {
  24.     vec4 albedo_tex = texture(texture_albedo, base_uv);
  25.     ALBEDO = albedo.rgb * albedo_tex.rgb * COLOR.rgb;
  26.    
  27.     METALLIC = 0.0;
  28.     SPECULAR = 0.0;
  29.     ROUGHNESS = 1.0;
  30. }
  31.  
  32. void light() {
  33.     float VdotN = dot(VIEW, NORMAL);
  34.     float cNdotL = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
  35.    
  36.     float shadow = step(0.1, cNdotL);
  37.     vec3 col = ALBEDO * LIGHT_COLOR * (1.0 / 3.14159);
  38.    
  39.     DIFFUSE_LIGHT += col * shadow;
  40.     DIFFUSE_LIGHT += col * step(0.8, 1.0 - VdotN) * (shadow * 0.8 + 0.2);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top