Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by deraggi · Sep 12, 2016 at 07:47 AM · lightning

How to keep an object always full lighted with custom shader?

I have a mesh which I do not want to be affected by the lightning of the scene. It just should always be fully illuminated.

I am using a third-party shader and have no knowledge of shader scripting. Is there any chance I can achieve this without having to mess with the shader?

Thanks!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AurimasBlazulionis · Sep 12, 2016 at 09:03 AM

This question contains the answer you are looking for. Basically you need to put #pragma surface surf NoLighting where all other pragma are. Then, you will also need to put Lighting Off after subshader.

Comment
Add comment · Share
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
avatar image
0

Answer by deraggi · Sep 13, 2016 at 12:49 PM

Thanks a lot for yor response @TheDiamondPlay.

However I have no clue on how to deal with shader coding.

Could you let me know what exactly I need to put where?

Thanks a lot!!

 // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
 
 // Shader created with Shader Forge v1.02 
 // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
 // Note: Manually altering this data may prevent you from opening it in Shader Forge
 /*SF_DATA;ver:1.02;sub:START;pass:START;ps:flbk:,lico:1,lgpr:1,nrmq:1,limd:1,uamb:True,mssp:True,lmpd:False,lprd:False,rprd:False,enco:False,frtr:True,vitr:True,dbil:False,rmgx:True,rpth:0,hqsc:True,hqlp:False,tesm:0,blpr:0,bsrc:0,bdst:1,culm:0,dpts:2,wrdp:True,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0,f2p0:False;n:type:ShaderForge.SFN_Final,id:8237,x:32797,y:32698,varname:node_8237,prsc:2|diff-8178-RGB,olwid-6341-OUT,olcol-9688-RGB;n:type:ShaderForge.SFN_Tex2d,id:8178,x:32342,y:32718,ptovrint:False,ptlb:Main Tex,ptin:_MainTex,varname:node_8178,prsc:2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Color,id:9688,x:32299,y:33129,ptovrint:False,ptlb:Outline Color,ptin:_OutlineColor,varname:node_9688,prsc:2,glob:False,c1:0.08823532,c2:0.08823532,c3:0.08823532,c4:1;n:type:ShaderForge.SFN_ValueProperty,id:6341,x:32348,y:32987,ptovrint:False,ptlb:Outline Width,ptin:_OutlineWidth,varname:node_6341,prsc:2,glob:False,v1:0.1;proporder:8178-9688-6341;pass:END;sub:END;*/
 
 Shader "Shader Forge/Outline Diffuse" {
     Properties {
         _MainTex ("Main Tex", 2D) = "white" {}
         _OutlineColor ("Outline Color", Color) = (0.08823532,0.08823532,0.08823532,1)
         _OutlineWidth ("Outline Width", Float ) = 0.1
     }
     SubShader {
         Tags {
             "RenderType"="Opaque"
         }    
 
         Pass {
             Name "Outline"
             Tags {
             }
             Cull Front
             
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #include "UnityCG.cginc"
             #pragma fragmentoption ARB_precision_hint_fastest
             #pragma multi_compile_shadowcaster
             #pragma exclude_renderers xbox360 ps3 flash d3d11_9x 
             #pragma target 3.0
 
             uniform float4 _OutlineColor;
             uniform float _OutlineWidth;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
             };
             struct VertexOutput {
                 float4 pos : SV_POSITION;
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o;
                 o.pos = mul(UNITY_MATRIX_MVP, float4(v.vertex.xyz + v.normal*_OutlineWidth,1));
                 return o;
             }
             fixed4 frag(VertexOutput i) : COLOR {
 /////// Vectors:
                 return fixed4(_OutlineColor.rgb,0);
             }
             ENDCG
         }
         Pass {
             Name "ForwardBase"
             Tags {
                 "LightMode"="ForwardBase"
             }
             
             
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #define UNITY_PASS_FORWARDBASE
             #include "UnityCG.cginc"
             #include "AutoLight.cginc"
             #pragma multi_compile_fwdbase_fullshadows
             #pragma exclude_renderers xbox360 ps3 flash d3d11_9x 
             #pragma target 3.0
             
             uniform float4 _LightColor0;
             uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float2 texcoord0 : TEXCOORD0;
             };
             struct VertexOutput {
                 float4 pos : SV_POSITION;
                 float2 uv0 : TEXCOORD0;
                 float4 posWorld : TEXCOORD1;
                 float3 normalDir : TEXCOORD2;
                 LIGHTING_COORDS(3,4)
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o;
                 o.uv0 = v.texcoord0;
                 o.normalDir = mul(unity_ObjectToWorld, float4(v.normal,0)).xyz;
                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
                 float3 lightColor = _LightColor0.rgb;
                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                 TRANSFER_VERTEX_TO_FRAGMENT(o)
                 return o;
             }
             fixed4 frag(VertexOutput i) : COLOR {
                 i.normalDir = normalize(i.normalDir);
 /////// Vectors:
                 float3 normalDirection = i.normalDir;
                 float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
                 float3 lightColor = _LightColor0.rgb;
 ////// Lighting:
                 float attenuation = LIGHT_ATTENUATION(i);
                 float3 attenColor = attenuation * _LightColor0.xyz;
 /////// Diffuse:
                 float NdotL = max(0.0,dot( normalDirection, lightDirection ));
                 float3 indirectDiffuse = float3(0,0,0);
                 float3 directDiffuse = max( 0.0, NdotL) * attenColor;
                 indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
                 float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
                 float3 diffuse = (directDiffuse + indirectDiffuse) * _MainTex_var.rgb;
 /// Final Color:
                 float3 finalColor = diffuse;
                 return fixed4(finalColor,1);
             }
             ENDCG
         }
         Pass {
             Name "ForwardAdd"
             Tags {
                 "LightMode"="ForwardAdd"
             }
             Blend One One
             
             
             Fog { Color (0,0,0,0) }
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #define UNITY_PASS_FORWARDADD
             #include "UnityCG.cginc"
             #include "AutoLight.cginc"
             #pragma multi_compile_fwdadd_fullshadows
             #pragma exclude_renderers xbox360 ps3 flash d3d11_9x 
             #pragma target 3.0
             uniform float4 _LightColor0;
             uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
             struct VertexInput {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float2 texcoord0 : TEXCOORD0;
             };
             struct VertexOutput {
                 float4 pos : SV_POSITION;
                 float2 uv0 : TEXCOORD0;
                 float4 posWorld : TEXCOORD1;
                 float3 normalDir : TEXCOORD2;
                 LIGHTING_COORDS(3,4)
             };
             VertexOutput vert (VertexInput v) {
                 VertexOutput o;
                 o.uv0 = v.texcoord0;
                 o.normalDir = mul(unity_ObjectToWorld, float4(v.normal,0)).xyz;
                 o.posWorld = mul(unity_ObjectToWorld, v.vertex);
                 float3 lightColor = _LightColor0.rgb;
                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                 TRANSFER_VERTEX_TO_FRAGMENT(o)
                 return o;
             }
             fixed4 frag(VertexOutput i) : COLOR{
                 i.normalDir = normalize(i.normalDir);
             /////// Vectors:
                             float3 normalDirection = i.normalDir;
                             float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
                             float3 lightColor = _LightColor0.rgb;
                             ////// Lighting:
                                             float attenuation = LIGHT_ATTENUATION(i);
                                             float3 attenColor = attenuation * _LightColor0.xyz;
                                             /////// Diffuse:
                                                             float NdotL = max(0.0,dot(normalDirection, lightDirection));
                                                             float3 directDiffuse = max(0.0, NdotL) * attenColor;
                                                             float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
                                                             float3 diffuse = directDiffuse * _MainTex_var.rgb;
                                                             /// Final Color:
                                                                             float3 finalColor = diffuse;
                                                                             return fixed4(finalColor * 1,0);
             }
             ENDCG
         }
     }
     
     FallBack "Diffuse"
     CustomEditor "ShaderForgeMaterialInspector"
 }
 
Comment
Add comment · Share
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

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

68 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Is RenderSettings.ambientIntensity changeable through a script? 3 Answers

Shadows passing through objects, why? 4 Answers

Cube has no shadow? HELP? 0 Answers

Disable directional light with trigger 0 Answers

Ambient Intensity doesn't work in my scene - Help please! 0 Answers


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