Texture Only

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<shaderlab>" to "<syntaxhighlight lang="shaderlab">")
m (Text replace - "</shaderlab>" to "</syntaxhighlight>")
Line 46: Line 46:
 
}}
 
}}
 
   
 
   
}</shaderlab>
+
}</syntaxhighlight>

Revision as of 21:56, 17 January 2012

Author: Jessy

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

Usage

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.)


Click here for a zip file that includes this shader.

ShaderLab - Texture Only.shader

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


Shader "Texture Only" {

Properties {
	_MainTex ("Texture", 2D) = ""
}

SubShader {Pass {	// iPhone 3GS and later
	GLSLPROGRAM
	varying lowp 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