Texture Only

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(ShaderLab - Texture Only.shader)
(fixed syntax highlight; ShaderLab is C-like and looks fine with C highlighting)
 
(12 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
Drag a single texture onto the material's only variable slot.
 
Drag a single texture onto the material's only variable slot.
  
 +
==ShaderLab - Texture Only.shader==
 +
<syntaxhighlight lang="c">Shader "Texture Only" {
  
[[Media:Texture Only.zip|Click here for a zip file that includes this shader.]]
 
 
==ShaderLab - Texture Only.shader==
 
<shaderlab>Shader "Texture Only"{
 
 
 
Properties {
 
Properties {
 
_MainTex ("Texture", 2D) = ""
 
_MainTex ("Texture", 2D) = ""
 
}
 
}
  
SubShader {
+
SubShader {Pass { // iPhone 3GS and later
Pass {SetTexture[_MainTex]}
+
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
 +
}}
  
}</shaderlab>
+
SubShader {Pass { // pre-3GS devices, including the September 2009 8GB iPod touch
 +
SetTexture[_MainTex]
 +
}}
 +
 +
}</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