- Home /
How to disable texture perspective correction?
Hi, I'm trying to disable(cancel) texture perspective correction, to simulate 90's game graphics. Does Unity engine has any option or any scripts way for this?
My purpose is simulation by like an early times polygon rough graphics.
SFMPE
I'm a newbie here. I just signed up. I also want to know more about this texture perspective correction. Thank you!
Answer by Philipp · Mar 10, 2013 at 09:37 AM
There's no option for that, but you can undo the perspective correction in a shader, like so:
Shader "Custom/AffineTexture" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct vertexInput {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float3 normal;
float2 uv : TEXCOORD0;
};
vertexOutput vert(vertexInput input) // vertex shader
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
output.normal = output.pos.xyz; // using normal because POSITION semantic isn't visible in fragment shader
output.uv = input.texcoord * output.normal.z;
return output;
}
float4 frag(vertexOutput input) : COLOR // fragment shader
{
return tex2D(_MainTex, input.uv/input.normal.z);
}
ENDCG
}
}
}
Great! I'm trying to acheive something like this for my hobby project. Do I apply this script to the camera, or to objects in the game world?
This did not work for me at first. The normal need " : NORMAL" to compile. Also, I had to switch to using w instead of z (for texture coord mul/div), but now it seem to work as expected.
keeps giving errors and I don't know what type of shader
Your answer
Follow this Question
Related Questions
Black Texture on Initial Load 1 Answer
Tracing in Unity3D 2 Answers
How can I prevent lights overlapping in intensity? 1 Answer
How to blend colors from two texture maps in VFX graph 1 Answer