Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
Shader "FX/DoubleSidediffuseRimlight" { // These are the fields that will appear for this Material in the Inspector - see Unity doc at http://docs.unity3d.com/Documentation/Components/SL-Properties.html // The first part is the property's variable, eg. "_MainTex" - Naming your main texture "_MainTex" signals to Unity that this Shader should be included in Lightmap calculations // Using the standard Unity property names also lets Unity apply a fallback Shader if the user's hardware can't handle this one // The second part in brackets is the name of the property in the Inspector, eg. "Main Texture" - This can be anything you like. // The third part in brackets is the variable type, eg. "2D" declares it to be a texture file - // The fourth part is the property's default value, eg. "white {}" - Textures are generally given default values of white, gray or black Properties { _MainTex ("Main Texture", 2D) = "white" {} // This is the material's Texture property and we want it to be included in Lightmap calculations (especially LightProbes) _RimColor ("Rim Color", Color) = (0.26, 0.19, 0.16, 0.0) // This is the material's RimLight Color _RimPower ("Rim Power", float) = 3.0 // This is the material's RimLight strength. 0 will be maximum rimlighting... Rim power is generally exposed as a Range property type } // The SubShader is where the Shader calculations actually happen // IMPORTANT : Normally, surface shaders cannot include two passes, but we're going to use a sneaky trick to use two passes into this one SubShader { // This allows Unity to intelligently substitute this Shader when needed Tags { "RenderType"="Opaque" } LOD 200 // This lets Unity know it doesn't need to worry about the back of our object right now, because we can't see it Cull Back // The syntax that was use after "pragma" tells Unity what kind of shader this is and how it should be applied, eg. // This shader is a surface Shader of type Lambert, and we want Unity to approximate view direction to speed up calculations CGPROGRAM #pragma surface surf Lambert approxview //These match the shader properties uniform sampler2D _MainTex; uniform fixed4 _Color, _RimColor; uniform fixed _RimPower; // This contains the inputs to the surface function // Valid fields are listed at: http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaders.html struct Input { float2 uv_MainTex; float3 viewDir; // Since this is a RimLight Shader, we need to account for the Camera View Direction. This value accesses Unity's internal calculations float3 worldNormal; // Since this is a Mobile Shader, we want to try to avoid complex calculations. This value uses the Unity's world normals instead of the object normals }; // This is where we prepare the surcace for lighting by propagating a SurfaceOutput structure void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex); // Samples the texture o.Albedo = c.rgb; // Modulate by main colour o.Alpha = 1.0; // No alpha in this shader fixed rim = 1.0 - saturate(dot(normalize(IN.viewDir), IN.worldNormal)); // We calculate the dot product of the vertex and our view direction, and use it to calculate our rim light o.Emission = _RimColor.rgb * pow (rim, _RimPower); // We apply our rim light and place it in the Material's emmission value } ENDCG // This lets Unity know that we'll need the back of theobject now, but it can ignore the front... it we wanted, we could also say "off" and have it paint everything Cull Front // IMPORTANT : This is where this shader starts getting sneaky and weird // The "vertex" syntax at the end of the "pragma" line tells the shader we want to do some vertex calculations before we paint the texture, and that we'll put them in a function called "vert" CGPROGRAM #pragma surface surf Lambert approxview vertex:vert uniform sampler2D _MainTex; uniform fixed4 _Color, _RimColor; uniform fixed _RimPower; struct Input { float2 uv_MainTex; float3 viewDir; float3 worldNormal; }; // This is our vertex function, I'm going to break it down so you know what's happening // "inout" tells Unity we want to hijack a value. We're going to take it in, do something to it, and push it back out // "appdata_full" is the output of Unity's standard vertex calculations, if this wasn't a Surface Shader, we would have to do those ourselves // "out" tells Unity that we'll also be producing another value (this is actually pretty normal c syntax) // "Input" is the value structure we defined just above // We're calling it "o" void vert (inout appdata_full v, out Input o) { // Since Unity wouldn't normally worry about our Input structure before the surf function below, we ask Unity to prepare it for us now so we can access the vertex info UNITY_INITIALIZE_OUTPUT(Input, o); // Here, we simply switch the normals of the entire object, this will let Unity paint a texture on the back side of the planes (which are now front sides) v.normal = -v.normal; } void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D (_MainTex, IN.uv_MainTex); o.Albedo = c.rgb; o.Alpha = 1.0; fixed rim = 1.0 - saturate(dot(normalize(IN.viewDir), IN.worldNormal)); o.Emission = _RimColor.rgb * pow (rim, _RimPower); } ENDCG } FallBack "Mobile/Diffuse" }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
I made $15,000 in 2 days
CSS | 3 min ago | 0.23 KB
This summer smells like money
CSS | 5 min ago | 0.24 KB
API Glitch (Docs Leak)
CSS | 5 min ago | 0.24 KB
FB2600 User Handbook v0.91
1 hour ago | 6.06 KB
FB2600 Administrator & Moderator SOP
2 hours ago | 8.13 KB
Untitled
13 hours ago | 7.38 KB
c2l.puter.site
15 hours ago | 0.48 KB
Looksmaxxing
15 hours ago | 1.83 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!