- Home /
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
Your answer

Follow this Question
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