0
\$\begingroup\$

In Unity Shaderlab shader, Is there any way to apply _Atten value?
Using surface shader, and vertex/fragment shader I can do it easily.
But, I didn't find any reference to do that in Shaderlab syntax.

Shader "Diffuse" {
    Properties {
        _Atten ("Light Attenuation Power", Float) = 1.0 // <= how to apply?
        _Color ("Main Color", Color)            = (1,1,1,1)
        _MainTex ("Base (RGB) Transparency (A)", 2D) = "" {}
    }
    SubShader {
        Pass {
            SetTexture[_MainTex]
            {
                  constantColor [_Color]
                combine texture * constant, texture * constant
            }
        }
    }
}

this makes syntax error.

constantColor [_Atten * _Color]
\$\endgroup\$
4
  • \$\begingroup\$ Are you initializing the _Atten property inside of your CG code? Is that the entirety of your Shader code? \$\endgroup\$ – jgallant Jun 30 '15 at 15:37
  • \$\begingroup\$ It's not CG, it's shaderlab Jon. So, it doesn't need to declare or initialize the variable. yes, it's the entire shader code. \$\endgroup\$ – Jinbom Heo Jul 1 '15 at 3:19
  • \$\begingroup\$ try [_Atten] * [_Color] \$\endgroup\$ – jgallant Jul 1 '15 at 11:35
  • \$\begingroup\$ tried [_Atten] * [_Color]. Parse error. T_T / _Atten * [_Color] also makes parse error. \$\endgroup\$ – Jinbom Heo Jul 2 '15 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.