Commits

philiplb committed 0382c99

Volume Rendering: proper use of the specular map

  • Participants
  • Parent commits 8194fda
  • Branches v1-9

Comments (0)

Files changed (1)

Samples/Media/volumeTerrain/triplanarReferencePS.cg

 	float3 normal,
 	float3 eyeDir,
 	float exponent,
+	float specularFactor,
 	float3 lightDir,
 	float4 lightPosition,
 	float4 lightDiffuse,
 			(lightSpotlight.x - lightSpotlight.y));
 	}
 	
-	return attenuation * spot * (lightDiffuse * lighting.y + lightSpecular * lighting.z);
+	return attenuation * spot * (lightDiffuse * lighting.y + specularFactor * lightSpecular * lighting.z);
 }
 
 void main_triplanar_reference_fp(
 	#endif
 	
     uniform float4x4 world,
-	#if !USESPECULARMAP
 	uniform float exponent,
-	#endif
 	uniform float texScale,
 	uniform float plateauSize,
 	uniform float transitionSpeed,
 	#endif
 	
 	#if USESPECULARMAP
-	float specularExponent = textColour.a;
+	float specularFactor = textColour.a;
 	#else
-	float specularExponent = exponent;
+	float specularFactor = 1.0;
 	#endif
 	
 	// Light
 	float3 lightSpotDir02 = lightSpotDir0;
 	float3 lightDir02 = lightDir0;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir02, lightPosition0, lightDiffuse0, lightSpecular0, lightAttenuation0, lightSpotlight0, lightSpotDir02);
+	lightContribution += doLighting(position, normal2, eyeDir2, exponent, specularFactor, lightDir02, lightPosition0, lightDiffuse0, lightSpecular0, lightAttenuation0, lightSpotlight0, lightSpotDir02);
 	#endif
 	
 	#if LIGHT1
 	float3 lightSpotDir12 = lightSpotDir1;
 	float3 lightDir12 = lightDir1;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir12, lightPosition1, lightDiffuse1, lightSpecular1, lightAttenuation1, lightSpotlight1, lightSpotDir12);
+	lightContribution += doLighting(position, normal2, eyeDir2, exponent, specularFactor, lightDir12, lightPosition1, lightDiffuse1, lightSpecular1, lightAttenuation1, lightSpotlight1, lightSpotDir12);
 	#endif
 	
 	#if LIGHT2
 	float3 lightSpotDir22 = lightSpotDir2;
 	float3 lightDir22 = lightDir2;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir22, lightPosition2, lightDiffuse2, lightSpecular2, lightAttenuation2, lightSpotlight2, lightSpotDir22);
+	lightContribution += doLighting(position, normal2, eyeDir2, exponent, specularFactor, lightDir22, lightPosition2, lightDiffuse2, lightSpecular2, lightAttenuation2, lightSpotlight2, lightSpotDir22);
 	#endif
 	
 	oColor = saturate(textColour * (lightContribution + ambient));