Commits

philiplb  committed b276df2

Volume Rendering: added support for specular maps in the reference
shader

  • Participants
  • Parent commits 5a2b07e
  • Branches v1-9

Comments (0)

Files changed (2)

File Samples/Media/volumeTerrain/triplanarReference.program

 		param_named transitionSpeed float 2.0
 		param_named ambient float4 0.41 0.41 0.41 1.0
 	}
-	// Supported defines: -DLIGHTNORMALMAPPING -DLIGHT0 -DLIGHT1 -DLIGHT2 -DATTENUATION -DFOGLINEAR -DFOGEXPONENTIAL -DFOGEXPONENTIAL2
-	compile_arguments -DLIGHTNORMALMAPPING -DLIGHT0 -DLIGHT1
+	// Supported defines: -DLIGHTNORMALMAPPING -DUSESPECULARMAP -DLIGHT0 -DLIGHT1 -DLIGHT2 -DATTENUATION -DFOGLINEAR -DFOGEXPONENTIAL -DFOGEXPONENTIAL2
+	compile_arguments -DLIGHTNORMALMAPPING -DUSESPECULARMAP -DLIGHT0
 	entry_point main_triplanar_reference_fp
 	profiles ps_2_x arbfp1
 }
 		param_named transitionSpeed float 2.0
 		param_named ambient float4 0.41 0.41 0.41 1.0
 	}
-	// Supported defines: -DLIGHTNORMALMAPPING -DLIGHT0 -DLIGHT1 -DLIGHT2 -DATTENUATION -DFOGLINEAR -DFOGEXPONENTIAL -DFOGEXPONENTIAL2
-	compile_arguments -DLIGHT0 -DLIGHT1
+	// Supported defines: -DLIGHTNORMALMAPPING -DUSESPECULARMAP -DLIGHT0 -DLIGHT1 -DLIGHT2 -DATTENUATION -DFOGLINEAR -DFOGEXPONENTIAL -DFOGEXPONENTIAL2
+	compile_arguments -DUSESPECULARMAP -DLIGHT0
 	entry_point main_triplanar_reference_fp
 	profiles ps_2_x arbfp1
 }

File Samples/Media/volumeTerrain/triplanarReferencePS.cg

 	float3 normal2 = unitNormal;
 	#endif
 	
+	#if USESPECULARMAP
+	float specularExponent = textColour.a;
+	#else
+	float specularExponent = exponent;
+	#endif
+	
 	// Light
 	float4 lightContribution = float4(0, 0, 0, 0);
 	#if LIGHT0
 	float3 lightSpotDir02 = lightSpotDir0;
 	float3 lightDir02 = lightDir0;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, exponent, lightDir02, lightPosition0, lightDiffuse0, lightSpecular0, lightAttenuation0, lightSpotlight0, lightSpotDir02);
+	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir02, lightPosition0, lightDiffuse0, lightSpecular0, lightAttenuation0, lightSpotlight0, lightSpotDir02);
 	#endif
 	
 	#if LIGHT1
 	float3 lightSpotDir12 = lightSpotDir1;
 	float3 lightDir12 = lightDir1;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, exponent, lightDir12, lightPosition1, lightDiffuse1, lightSpecular1, lightAttenuation1, lightSpotlight1, lightSpotDir12);
+	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir12, lightPosition1, lightDiffuse1, lightSpecular1, lightAttenuation1, lightSpotlight1, lightSpotDir12);
 	#endif
 	
 	#if LIGHT2
 	float3 lightSpotDir22 = lightSpotDir2;
 	float3 lightDir22 = lightDir2;
 	#endif
-	lightContribution += doLighting(position, normal2, eyeDir2, exponent, lightDir22, lightPosition2, lightDiffuse2, lightSpecular2, lightAttenuation2, lightSpotlight2, lightSpotDir22);
+	lightContribution += doLighting(position, normal2, eyeDir2, specularExponent, lightDir22, lightPosition2, lightDiffuse2, lightSpecular2, lightAttenuation2, lightSpotlight2, lightSpotDir22);
 	#endif
 	
 	oColor = saturate(textColour * (lightContribution + ambient));