Skip to content

Instantly share code, notes, and snippets.

@WiggleWizard
Last active May 4, 2020 15:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WiggleWizard/05d3c50fc634f3b1d36c770ad74a250c to your computer and use it in GitHub Desktop.
Save WiggleWizard/05d3c50fc634f3b1d36c770ad74a250c to your computer and use it in GitHub Desktop.
PSX shader for Godot
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