Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sumeetkhobare · Apr 11, 2014 at 02:57 AM · lighting

Lighting disabled in shader, Enable Lighting

The global light seems to have no effect on GameObjects in my scene due to the shader i am using in their material.

here's the shader code:

 Shader "Outlined Toon Detail" {
 Properties {
  _Color ("Main Color ", Color) = (1,1,1,1)
  _OutlineColor ("Outline Color", Color) = (0,1,0,1)
  _Outline ("Outline width", Range(0.001,0.05)) = 0.01
  _ToonShade ("MatCap (RGB)", 2D) = "white" {}
  _MainTex ("MatCap (RGB)", 2D) = "black" {}
 }
 SubShader { 
  Tags { "RenderType"="Opaque" }
  UsePass "ToonDetail/BASE"
  Pass {
   Tags { "RenderType"="Opaque" }
   Cull Front
   Blend SrcAlpha OneMinusSrcAlpha
   ColorMask RGB
   Lighting On
 Program "vp" {
 SubProgram "opengl " {
 Bind "vertex" ATTR0
 Bind "normal" ATTR1
 Float 13 [_Outline]
 Vector 14 [_OutlineColor]
 "!!ARBvp1.0
 # 15 ALU
 PARAM c[15] = { program.local[0],
         state.matrix.modelview[0],
         state.matrix.projection,
         state.matrix.mvp,
         program.local[13..14] };
 TEMP R0;
 TEMP R1;
 DP3 R0.x, vertex.attrib[1], c[1];
 MUL R0.z, R0.x, c[5].x;
 DP3 R0.y, vertex.attrib[1], c[2];
 DP4 R0.x, vertex.attrib[0], c[11];
 MUL R0.w, R0.y, c[6].y;
 MUL R0.zw, R0, R0.x;
 DP4 R0.y, vertex.attrib[0], c[3];
 MUL R0.zw, R0, c[13].x;
 RCP R0.y, -R0.y;
 DP4 R1.x, vertex.attrib[0], c[9];
 DP4 R1.y, vertex.attrib[0], c[10];
 MAD result.position.xy, R0.zwzw, R0.y, R1;
 MOV result.color, c[14];
 DP4 result.position.w, vertex.attrib[0], c[12];
 MOV result.position.z, R0.x;
 END
 # 15 instructions, 2 R-regs
 "
 }
 SubProgram "d3d9 " {
 Bind "vertex" Vertex
 Bind "normal" Normal
 Matrix 0 [glstate_matrix_modelview0]
 Matrix 4 [glstate_matrix_projection]
 Matrix 8 [glstate_matrix_mvp]
 Float 12 [_Outline]
 Vector 13 [_OutlineColor]
 "vs_2_0
 ; 15 ALU
 dcl_position v0
 dcl_normal v1
 dp3 r0.x, v1, c0
 mul r0.z, r0.x, c4.x
 dp3 r0.y, v1, c1
 dp4 r0.x, v0, c10
 mul r0.w, r0.y, c5.y
 mul r0.zw, r0, r0.x
 dp4 r0.y, v0, c2
 mul r0.zw, r0, c12.x
 rcp r0.y, -r0.y
 dp4 r1.x, v0, c8
 dp4 r1.y, v0, c9
 mad oPos.xy, r0.zwzw, r0.y, r1
 mov oD0, c13
 dp4 oPos.w, v0, c11
 mov oPos.z, r0.x
 "
 }
 }
 Program "fp" {
 SubProgram "opengl " {
 "!!ARBfp1.0
 # 1 ALU, 0 TEX
 MOV result.color, fragment.color.primary;
 END
 # 1 instructions, 0 R-regs
 "
 }
 SubProgram "d3d9 " {
 "ps_2_0
 ; 1 ALU
 dcl v0
 mov_pp oC0, v0
 "
 }
 }
   SetTexture [_ToonShade] { combine primary }
  }
 }
 Fallback "Diffuse"
 }



And Another Shader:

 Shader "ToonDetail" {
     Properties {
          _Color ("Main Color ", Color) = (1,1,1,1)
          _ToonShade ("Shading Texture (RGBA)", 2D) = "white" {}
          _MainTex ("Detail(RGBA)", 2D) = "black" {}
     }
     SubShader { 
          Pass {
             Name "BASE"
             Fog { Mode Global }
             Program "vp" {
                 SubProgram "opengl " {
                     Bind "vertex" Vertex
                     Bind "normal" Normal
                     Bind "texcoord" TexCoord0
                     Vector 9 [_MainTex_ST]
                     "!!ARBvp1.0
                     # 8 ALU
                     PARAM c[10] = { { 0.5 },
                             state.matrix.mvp,
                             state.matrix.modelview[0].invtrans,
                             program.local[9] };
                     TEMP R0;
                     DP3 R0.x, vertex.normal, c[5];
                     DP3 R0.y, vertex.normal, c[6];
                     MAD result.texcoord[0].xy, vertex.texcoord[0], c[9], c[9].zwzw;
                     MAD result.texcoord[1].xy, R0, c[0].x, c[0].x;
                     DP4 result.position.w, vertex.position, c[4];
                     DP4 result.position.z, vertex.position, c[3];
                     DP4 result.position.y, vertex.position, c[2];
                     DP4 result.position.x, vertex.position, c[1];
                     END
                     # 8 instructions, 1 R-regs
                     "
                 }
                 SubProgram "d3d9 " {
                     Bind "vertex" Vertex
                     Bind "normal" Normal
                     Bind "texcoord" TexCoord0
                     Matrix 0 [glstate_matrix_mvp]
                     Matrix 4 [glstate_matrix_invtrans_modelview0]
                     Vector 8 [_MainTex_ST]
                     "vs_2_0
                     ; 8 ALU
                     def c9, 0.50000000, 0, 0, 0
                     dcl_position0 v0
                     dcl_normal0 v1
                     dcl_texcoord0 v2
                     dp3 r0.x, v1, c4
                     dp3 r0.y, v1, c5
                     mad oT0.xy, v2, c8, c8.zwzw
                     mad oT1.xy, r0, c9.x, c9.x
                     dp4 oPos.w, v0, c3
                     dp4 oPos.z, v0, c2
                     dp4 oPos.y, v0, c1
                     dp4 oPos.x, v0, c0
                     "
                 }
             }
             Program "fp" {
                 SubProgram "opengl " {
                     Vector 0 [_Color]
                     SetTexture 0 [_ToonShade] 2D
                     SetTexture 1 [_MainTex] 2D
                     "!!ARBfp1.0
                     OPTION ARB_precision_hint_fastest;
                     # 5 ALU, 2 TEX
                     PARAM c[2] = { program.local[0],
                             { 2 } };
                     TEMP R0;
                     TEMP R1;
                     TEX R0, fragment.texcoord[1], texture[0], 2D;
                     TEX R1, fragment.texcoord[0], texture[1], 2D;
                     MUL R0, R0, c[0];
                     MUL R0, R0, c[1].x;
                     MUL result.color, R0, R1;
                     END
                     # 5 instructions, 2 R-regs
                     "
                 }
                 SubProgram "d3d9 " {
                     Vector 0 [_Color]
                     SetTexture 0 [_ToonShade] 2D
                     SetTexture 1 [_MainTex] 2D
                     "ps_2_0
                     ; 4 ALU, 2 TEX
                     dcl_2d s0
                     dcl_2d s1
                     def c1, 2.00000000, 0, 0, 0
                     dcl t0.xy
                     dcl t1.xy
                     texld r1, t1, s0
                     texld r0, t0, s1
                     mul r1, r1, c0
                     mul r1, r1, c1.x
                     mul_pp r0, r1, r0
                     mov_pp oC0, r0
                     "
                 }
             }
          }
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Deffered Shading and MSAA 1 Answer

Lightmapping - Exclude object 1 Answer

Torchlight effect in 2D 3 Answers

Unassigned Reference Exception error? 4 Answers

Making a sprite totally dark without lighting 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges