Changeset 1338 for trunk/orbital/mesh.h
 Timestamp:
 May 4, 2012, 1:00:30 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/mesh.h
r1332 r1338 91 91 "void main(void)" 92 92 "{" 93 /* Global shit */ 94 " float alpha_mul = 1.0f;" 95 96 /* Ambient: global constant */ 93 /* Material properties */ 94 " vec3 specular_reflect = vec3(0.8, 0.75, 0.4);" 95 " float specular_power = 60.f;" 96 97 /* World properties */ 97 98 " float ambient_mul = 0.5f;" 98 99 /* Diffuse: the level should decide of these values */ 100 " vec3 diffuse_dir = normalize(vec3(0.7, 0.7, 0.4));" 101 " vec4 frontColor = vec4(1.0, 1.0, 1.0, 1.0);" 102 " vec4 backColor = vec4(0.3, 0.2, 0.0, 1.0);" 103 104 " vec3 world_normal = normalize(in_NormalMat * in_Normal);" 105 " float d = dot(world_normal, diffuse_dir);" 106 " vec2 diffuse_mul = max(vec2(d, d), 0.0);" 107 " diffuse_mul[0] = min(diffuse_mul[0] + ambient_mul, 1.0);" 108 109 /* Specular: global settings */ 110 " vec4 spec_col = vec4(0.8, 0.75, 0.4, 1.0);" 111 " vec3 spec_dir = normalize(vec3(0.3, 0.3, 1.8));" 112 " float spec_exp = 60.f;" 113 114 " float spec_mul = max(dot(world_normal, spec_dir), 0.0);" 115 " spec_mul = clamp(pow(spec_mul, spec_exp), 0.0, 1.0);" 116 117 118 " vec4 tmpColor = frontColor * in_Color;" 119 " pass_Color = clamp(diffuse_mul[0] * tmpColor" 120 " + diffuse_mul[1] * backColor" 121 " + spec_mul * spec_col, 0.0, 1.0);" 122 " pass_Color.a *= alpha_mul;" 123 124 " vec4 viewPosition = in_ModelView * vec4(in_Vertex, 1.0);" 125 " gl_Position = in_Proj * viewPosition;" 99 " vec3 light_dir = normalize(vec3(0.3, 0.3, 0.7));" 100 " vec3 ambient_color = vec3(0.25, 0.2, 0.35);" 101 " vec3 diffuse_color = vec3(1.0, 1.0, 0.6);" 102 " vec3 specular_color = vec3(1.0, 1.0, 0.6);" 103 104 " vec3 tnorm = normalize(in_NormalMat * in_Normal);" 105 " vec4 eye = in_ModelView * vec4(in_Vertex, 1.0);" 106 107 " vec3 s = light_dir;" /* normalize(eye  lightpos); */ 108 " vec3 v = normalize(eye.xyz);" 109 " vec3 r = reflect(s, tnorm);" 110 111 " vec3 ambient = ambient_color;" 112 " float sdotn = max(dot(s, tnorm), 0.0);" 113 " vec3 diffuse = diffuse_color * sdotn;" 114 " vec3 specular = vec3(0.0);" 115 " if (sdotn > 0.0)" 116 " specular = specular_color * specular_reflect" 117 " * pow(max(dot(r, v), 0.0), specular_power);" 118 " vec3 light = ambient + diffuse + specular;" 119 120 " pass_Color = in_Color * vec4(light, 1.0);" 121 " gl_Position = in_Proj * eye;" 126 122 "}", 127 123 … … 142 138 " out float4 pass_Color : COLOR)" 143 139 "{" 144 " float alpha_mul = 1.0f;" 140 " float3 specular_reflect = float3(0.8, 0.75, 0.4);" 141 " float specular_power = 60.f;" 145 142 " float ambient_mul = 0.5f;" 146 " float3 diffuse_dir = normalize(float3(0.7, 0.7, 0.4));"147 " float 4 frontColor = float4(1.0, 1.0, 1.0, 1.0);"148 " float 4 backColor = float4(0.3, 0.2, 0.0, 1.0);"149 " float3 world_normal = normalize(mul(in_NormalMat, in_Normal));"150 " float d = dot(world_normal, diffuse_dir);"151 " float 2 diffuse_mul = max(float2(d, d), 0.0);"152 " diffuse_mul[0] = min(diffuse_mul[0] + ambient_mul, 1.0);"153 " float 4 spec_col = float4(0.8, 0.85, 0.4, 1.0);"154 " float3 spec_dir = normalize(float3(0.7, 0.7, 0.4));"155 " float spec_exp = 60.0f;"156 " float s pec_mul = max(dot(world_normal, spec_dir), 0.0);"157 " spec_mul = saturate(pow(spec_mul, spec_exp));"158 " float 4 tmpColor = frontColor * in_Color;"159 " pass_Color = saturate(diffuse_mul[0] * tmpColor"160 " + diffuse_mul[1] * backColor"161 " + spec_mul * spec_col);"162 " pass_Color.a *= alpha_mul;"163 " float4 viewPosition = mul(in_ModelView, float4(in_Vertex, 1.0));"164 " out_Position = mul(in_Proj, viewPosition);"143 " float3 light_dir = normalize(float3(0.3, 0.3, 0.7));" 144 " float3 ambient_color = float3(0.25, 0.2, 0.35);" 145 " float3 diffuse_color = float3(1.0, 1.0, 0.6);" 146 " float3 specular_color = float3(1.0, 1.0, 0.6);" 147 " float3 tnorm = normalize(mul(in_NormalMat, in_Normal));" 148 " float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0));" 149 " float3 s = light_dir;" 150 " float3 v = normalize(eye.xyz);" 151 " float3 r = reflect(s, tnorm);" 152 " float3 ambient = ambient_color;" 153 " float sdotn = max(dot(s, tnorm), 0.0);" 154 " float3 diffuse = diffuse_color * sdotn;" 155 " float3 specular = float3(0.0);" 156 " if (sdotn > 0.0)" 157 " specular = specular_color * specular_reflect" 158 " * pow(max(dot(r, v), 0.0), specular_power);" 159 " float3 light = ambient + diffuse + specular;" 160 " pass_Color = in_Color * float4(light, 1.0);" 161 " out_Position = mul(in_Proj, eye);" 165 162 "}", 166 163
Note: See TracChangeset
for help on using the changeset viewer.