├── README.md ├── psx cull_disabled.shader ├── psx.shader └── water_psx.shader /README.md: -------------------------------------------------------------------------------- 1 | # PS1-shaders-for-godot 2 | A collection of PS1 shaders for godot. 3 | 4 | This shaders are modified version of this shader: https://github.com/marmitoTH/godot-psx-shaders 5 | 6 | This were modified by me to solve specific problems in my projects. Specifically lighting issues, and create moving water. 7 | 8 | Have fun using this :) 9 | -------------------------------------------------------------------------------- /psx cull_disabled.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode skip_vertex_transform, diffuse_burley, cull_disabled; 3 | 4 | //Albedo texture 5 | uniform sampler2D albedoTex : hint_albedo; //Geometric resolution for vert sna[ 6 | uniform float snapRes = 8.0; 7 | uniform float roughness = 1.0; 8 | uniform float specular = 0.1; 9 | uniform vec2 uv_scale = vec2(1.0, 1.0); 10 | uniform vec2 uv_offset = vec2(.0, .0); 11 | //Controls the how much light it recieves 12 | uniform float light_intensity = 0.3; 13 | 14 | // For transparent textures 15 | uniform bool transparent = false; 16 | 17 | // cull mode disabled 18 | 19 | //vec4 for UV recalculation 20 | varying vec4 vertCoord; 21 | void vertex() { 22 | UV = UV * uv_scale + uv_offset; 23 | VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; 24 | VERTEX.xyz = floor(VERTEX.xyz * snapRes) / snapRes; 25 | vertCoord = vec4(UV * VERTEX.x, VERTEX.z, 0); 26 | } 27 | void fragment() { 28 | 29 | ROUGHNESS =roughness; 30 | SPECULAR = specular; 31 | ALBEDO = texture(albedoTex, UV).rgb; 32 | 33 | 34 | //Check if the texture is transparent 35 | if (transparent == true){ 36 | // alpha value less than user-specified threshold 0.0? 37 | if (texture(albedoTex, UV).a <= 0.0) 38 | 39 | { 40 | discard; // yes: discard this fragment 41 | } 42 | 43 | } 44 | 45 | 46 | } 47 | //QUICK FIX TO LIGHTING 48 | void light() 49 | { 50 | 51 | DIFFUSE_LIGHT = ALBEDO*LIGHT_COLOR*ATTENUATION*light_intensity; 52 | 53 | } -------------------------------------------------------------------------------- /psx.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode skip_vertex_transform, diffuse_burley; 3 | 4 | //Albedo texture 5 | uniform sampler2D albedoTex : hint_albedo; //Geometric resolution for vert sna[ 6 | uniform float snapRes = 8.0; 7 | uniform float roughness = 1.0; 8 | uniform float specular = 0.1; 9 | uniform vec2 uv_scale = vec2(1.0, 1.0); 10 | uniform vec2 uv_offset = vec2(.0, .0); 11 | //Controls the how much light it recieves 12 | uniform float light_intensity = 0.3; 13 | 14 | // For transparent textures 15 | uniform bool transparent = false; 16 | 17 | // cull mode disabled 18 | 19 | //vec4 for UV recalculation 20 | varying vec4 vertCoord; 21 | void vertex() { 22 | UV = UV * uv_scale + uv_offset; 23 | VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; 24 | VERTEX.xyz = floor(VERTEX.xyz * snapRes) / snapRes; 25 | vertCoord = vec4(UV * VERTEX.x, VERTEX.z, 0); 26 | } 27 | void fragment() { 28 | 29 | ROUGHNESS =roughness; 30 | SPECULAR = specular; 31 | ALBEDO = texture(albedoTex, UV).rgb; 32 | 33 | 34 | //Check if the texture is transparent 35 | if (transparent == true){ 36 | // alpha value less than user-specified threshold 0.0? 37 | if (texture(albedoTex, UV).a <= 0.0) 38 | 39 | { 40 | discard; // yes: discard this fragment 41 | } 42 | 43 | } 44 | 45 | 46 | } 47 | //QUICK FIX TO LIGHTING 48 | void light() 49 | { 50 | 51 | DIFFUSE_LIGHT = ALBEDO*LIGHT_COLOR*ATTENUATION*light_intensity; 52 | 53 | } -------------------------------------------------------------------------------- /water_psx.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode skip_vertex_transform, diffuse_burley, cull_disabled; 3 | 4 | //Albedo texture 5 | uniform sampler2D albedoTex : hint_albedo; //Geometric resolution for vert sna[ 6 | uniform float snapRes = 8.0; 7 | uniform float roughness = 1.0; 8 | uniform float specular = 0.1; 9 | uniform float apha = 0.8; 10 | uniform vec2 uv_scale = vec2(1.0, 1.0); 11 | uniform vec2 uv_offset = vec2(.0, .0); 12 | //How much light sources affect it 13 | uniform float light_intensity = 0.3; 14 | 15 | //Speed of flow: 1 is the standard, below 1 the flow is slower and above faster, negatives will meake it flow backwards 16 | uniform float Flow_speed = 1.0; 17 | // Speed of wave: how fast is the wave moving side by side, as before 1 is standard 18 | uniform float Wave_speed = 1.0; 19 | //vec4 for UV recalculation 20 | varying vec4 vertCoord; 21 | void vertex() { 22 | UV = UV * uv_scale + uv_offset; 23 | VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; 24 | VERTEX.xyz = floor(VERTEX.xyz * snapRes) / snapRes; 25 | vertCoord = vec4(UV * VERTEX.x, VERTEX.z, 0); 26 | } 27 | void fragment() { 28 | 29 | ROUGHNESS =roughness; 30 | SPECULAR = specular; 31 | 32 | //motion of water 33 | vec2 coord = UV * 1.0; 34 | //If you want more amplitud for the wave just change the 0.01 value 35 | vec2 motion = vec2(0.01*cos(Wave_speed * TIME), Flow_speed*TIME); 36 | 37 | ALBEDO = (texture(albedoTex, UV + motion).rgb); 38 | ALPHA = apha; 39 | 40 | 41 | } 42 | //QUICK FIX TO LIGHTING 43 | void light() 44 | { 45 | 46 | DIFFUSE_LIGHT = ALBEDO*LIGHT_COLOR*ATTENUATION*light_intensity; 47 | 48 | } --------------------------------------------------------------------------------