Texture Only

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<shaderlab>" to "<syntaxhighlight lang="shaderlab">")
(fixed syntax highlight; ShaderLab is C-like and looks fine with C highlighting)
 
(6 intermediate revisions by 3 users not shown)
Line 9: Line 9:
  
 
Drag a single texture onto the material's only variable slot.
 
Drag a single texture onto the material's only variable slot.
 
You may need to change ''lowp vec2 uv'' to ''mediump vec2 uv'' or even ''highp vec2 uv'', if you are using heavy tiling.  If your UVs are all in the 0-1 space, the low precision should be fine, in my experience.  Unfortunately, there is currently no Editor emulation of the artifacts that can occur on the iOS device, with low precision UV calculation, so you'll have to build to know for sure – it will be immediately apparent, though.  (Precision hinting is an exclusive feature of OpenGL ES, at least as of March 2011, so don't hold your breath.)
 
 
 
[[Media:Texture Only.zip|Click here for a zip file that includes this shader.]]
 
  
 
==ShaderLab - Texture Only.shader==
 
==ShaderLab - Texture Only.shader==
<syntaxhighlight lang="shaderlab">Shader "Texture Only" {
+
<syntaxhighlight lang="c">Shader "Texture Only" {
  
 
Properties {
 
Properties {
Line 24: Line 19:
 
SubShader {Pass { // iPhone 3GS and later
 
SubShader {Pass { // iPhone 3GS and later
 
GLSLPROGRAM
 
GLSLPROGRAM
varying lowp vec2 uv;
+
varying mediump vec2 uv;
 
 
 
#ifdef VERTEX
 
#ifdef VERTEX
Line 46: Line 41:
 
}}
 
}}
 
   
 
   
}</shaderlab>
+
}</syntaxhighlight>

Latest revision as of 00:37, 1 December 2013

Author: Jessy

[edit] Description

This is a seriously simple shader. It just textures your model with a single map, exactly how you painted it. No lights, no tinting; it's your job to make it look good in a painting app, when you use this!  :-D

[edit] Usage

Drag a single texture onto the material's only variable slot.

[edit] ShaderLab - Texture Only.shader

Shader "Texture Only" {
 
Properties {
	_MainTex ("Texture", 2D) = ""
}
 
SubShader {Pass {	// iPhone 3GS and later
	GLSLPROGRAM
	varying mediump vec2 uv;
 
	#ifdef VERTEX
	void main() {
		gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
		uv = gl_MultiTexCoord0.xy;
	}
	#endif
 
	#ifdef FRAGMENT
	uniform lowp sampler2D _MainTex;
	void main() {
		gl_FragColor = texture2D(_MainTex, uv);
	}
	#endif		
	ENDGLSL
}}
 
SubShader {Pass {	// pre-3GS devices, including the September 2009 8GB iPod touch
	SetTexture[_MainTex]
}}
 
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox