Last active
May 4, 2020 15:34
-
-
Save WiggleWizard/05d3c50fc634f3b1d36c770ad74a250c to your computer and use it in GitHub Desktop.
PSX shader for Godot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type spatial; | |
render_mode skip_vertex_transform, unshaded; | |
//Albedo texture | |
uniform sampler2D albedoTex : hint_albedo; | |
//Geometric resolution for vert snap | |
uniform float snapRes = 15.0; | |
//vec4 for UV recalculation | |
varying vec4 vertCoord; | |
void vertex() { | |
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; | |
VERTEX.xyz = floor(VERTEX.xyz * snapRes) / snapRes; | |
vertCoord = vec4(UV * VERTEX.z, VERTEX.z, 0); | |
} | |
void fragment() { | |
ALBEDO = texture(albedoTex, vertCoord.xy / vertCoord.z).rgb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment