GGeff
November 5, 2017, 7:04pm
1
When you draw to a destination which has a different scale ratio than your source scale ratio with Graphics.DrawTexture or directly with GL.Begin(GL.QUADS), it refuses to sample the entire texture. Drawing a quad with texture coords of x range 0 to 1 and y range 0 to 1 results in only a partial sampling of the set texture rather than a proper scaling.
PC Build w/ non power of 2 textures.
GGeff
November 5, 2017, 7:24pm
2
This is the shader being used for testing.
Shader "Custom/MyTrans2D"
{
Properties
{
_MainTex ("Texture", any) = "" {}
_Color("Tint", Color) = (1,1,1,1)
}
SubShader {
Tags { "ForceSupported" = "True" "RenderType"="Overlay" }
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
ZTest Always
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
fixed4 _Color;
uniform float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = 2.0f * v.color * _Color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
//if(i.vertex.x > 400 || i.vertex.y > 400)
// return (0,0,0,0);
return tex2D(_MainTex, i.texcoord) * i.color;
}
ENDCG
}
}
Fallback off
}