Skip to content

Commit

Permalink
Psx_retro shader first commit
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
dsoft20 committed Aug 13, 2015
1 parent 1850ccf commit b40fac7
Show file tree
Hide file tree
Showing 48 changed files with 744 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Assets/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/tex001.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/tex001.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/tex002.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/tex002.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/tex003.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/tex003.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/tex004.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/tex004.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Shaders/Trasparent.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions Assets/Shaders/Trasparent/psx-trasparent-unlit.shader
@@ -0,0 +1,89 @@
Shader "psx/trasparent/unlit" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}
// ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
//AlphaTest Less .01
Cull Off
LOD 200

Pass {
Lighting On
CGPROGRAM


#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct v2f
{
fixed4 pos : SV_POSITION;
float4 color : COLOR0;
float4 colorFog : COLOR1;
float2 uv_MainTex : TEXCOORD0;
float3 normal : NORMAL;
};

float4 _MainTex_ST;
uniform half4 unity_FogStart;
uniform half4 unity_FogEnd;

v2f vert(appdata_full v)
{
v2f o;

//Vertex snapping
float4 snapToPixel = mul(UNITY_MATRIX_MVP,v.vertex);
float4 vertex = snapToPixel;
vertex.xyz = snapToPixel.xyz/snapToPixel.w;
vertex.x = round(160*vertex.x)/160;
vertex.y = round(120*vertex.y)/120;
vertex.xyz*=snapToPixel.w;
o.pos = vertex;

float distance =length(mul (UNITY_MATRIX_MV,v.vertex));

//Vertex color
o.color = v.color;

//Affine Texture Mapping
float4 affinePos = vertex;//vertex;
o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv_MainTex *= distance + (vertex.w*(UNITY_LIGHTMODEL_AMBIENT.a * 8)) / distance / 2;
o.normal = distance + (vertex.w*(UNITY_LIGHTMODEL_AMBIENT.a * 8)) / distance / 2;

//Fog
float4 fogColor = unity_FogColor;

float fogDensity = (unity_FogEnd-distance)/(unity_FogEnd-unity_FogStart);
o.normal.g = fogDensity;
o.normal.b = 1;
o.colorFog = fogColor;
o.colorFog.a = clamp(fogDensity,0,1);

//Cut out polygons
if (distance >= unity_FogStart.z + unity_FogColor.a * 255)
{
o.pos.w = 0;
}

return o;
}

sampler2D _MainTex;

float4 frag(v2f IN) : COLOR
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex/IN.normal.r)*IN.color;
float4 color = c*(IN.colorFog.a);
color.rgb += IN.colorFog.rgb*(1-IN.colorFog.a);
return color;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Assets/Shaders/Trasparent/psx-trasparent-unlit.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions Assets/Shaders/Trasparent/psx-trasparent-vertexlit.shader
@@ -0,0 +1,93 @@
Shader "psx/trasparent/vertexlit" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}
//ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
// AlphaTest Less .01
Cull Off
LOD 200

Pass {
Lighting On
CGPROGRAM


#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct v2f
{
fixed4 pos : SV_POSITION;
float4 color : COLOR0;
float4 colorFog : COLOR1;
float2 uv_MainTex : TEXCOORD0;
float3 normal : NORMAL;
};

float4 _MainTex_ST;
uniform half4 unity_FogStart;
uniform half4 unity_FogEnd;

v2f vert(appdata_full v)
{
v2f o;

//Vertex snapping
float4 snapToPixel = mul(UNITY_MATRIX_MVP,v.vertex);
float4 vertex = snapToPixel;
vertex.xyz = snapToPixel.xyz/snapToPixel.w;
vertex.x = round(160*vertex.x)/160;
vertex.y = round(120*vertex.y)/120;
vertex.xyz*=snapToPixel.w;
o.pos = vertex;

float distance = abs(_WorldSpaceCameraPos.z-snapToPixel.z);

//Vertex lighting
o.color = float4 (ShadeVertexLights(v.vertex, v.normal) * 2.0, 1.0);
o.color *= v.color;

//Affine Texture Mapping
float4 affinePos = vertex;//vertex;
o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv_MainTex *= distance + (vertex.w*(UNITY_LIGHTMODEL_AMBIENT.a * 8)) / distance / 2;
o.normal = distance + (vertex.w*(UNITY_LIGHTMODEL_AMBIENT.a * 8)) / distance / 2;

//Fog
float4 fogColor = unity_FogColor;
float fogDensity = (unity_FogEnd-distance)/(unity_FogEnd-unity_FogStart);
o.normal.g = fogDensity;
o.normal.b = 1;


o.colorFog = fogColor;
o.colorFog.a = clamp(fogDensity,0,1);

//Cut out polygons
if (distance >= unity_FogStart.z + unity_FogColor.a * 255)
{
o.pos.w = 0;
}

return o;
}

sampler2D _MainTex;

float4 frag(v2f IN) : COLOR
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex/IN.normal.r)*IN.color;
float4 color = float4(0,0,0,0);
color = c*(IN.colorFog.a);
color.rgb += IN.colorFog.rgb*(1-IN.colorFog.a);
color.a = c.a;
return color;
}
ENDCG
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions Assets/Shaders/psx-unlit.shader
@@ -0,0 +1,84 @@
Shader "psx/unlit" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200

Pass {
Lighting On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct v2f
{
fixed4 pos : SV_POSITION;
float4 color : COLOR0;
float4 colorFog : COLOR1;
float2 uv_MainTex : TEXCOORD0;
float3 normal : NORMAL;
};

float4 _MainTex_ST;
uniform half4 unity_FogStart;
uniform half4 unity_FogEnd;

v2f vert(appdata_full v)
{
v2f o;

//Vertex snapping
float4 snapToPixel = mul(UNITY_MATRIX_MVP,v.vertex);
float4 vertex = snapToPixel;
vertex.xyz = snapToPixel.xyz/snapToPixel.w;
vertex.x = round(160*vertex.x)/160;
vertex.y = round(120*vertex.y)/120;
vertex.xyz*=snapToPixel.w;
o.pos = vertex;

float distance =length(mul (UNITY_MATRIX_MV,v.vertex));

//Vertex Color
o.color = v.color*UNITY_LIGHTMODEL_AMBIENT;

//Affine Texture Mapping
float4 affinePos =vertex;
o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv_MainTex*=distance+(vertex.w*4)/distance/2;
o.normal= distance+(vertex.w*4)/distance/2;

//Fog
float4 fogColor = unity_FogColor;

float fogDensity = (unity_FogEnd-distance)/(unity_FogEnd-unity_FogStart);
o.normal.g = fogDensity;
o.normal.b = 1;

o.colorFog = fogColor;
o.colorFog.a = clamp(fogDensity,0,1);

//Cut out polygons
if (distance >= unity_FogStart.z + unity_FogColor.a * 255)
{
o.pos.w = 0;
}

return o;
}

sampler2D _MainTex;

float4 frag(v2f IN) : COLOR
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex/IN.normal.r)*IN.color;
float4 color = c*(IN.colorFog.a);
color.rgb += IN.colorFog.rgb*(1-IN.colorFog.a);
return color;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Assets/Shaders/psx-unlit.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b40fac7

Please sign in to comment.