Преглед изворни кода

Fixing a shader so it works on both OpenGL and Vulkan

BearishSun пре 9 година
родитељ
комит
10ec5d4767
1 измењених фајлова са 10 додато и 4 уклоњено
  1. 10 4
      Data/Raw/Engine/Includes/DeferredPointLightPass.bslinc

+ 10 - 4
Data/Raw/Engine/Includes/DeferredPointLightPass.bslinc

@@ -175,12 +175,18 @@ Technique
 					float angleTan = tan(angle);
 					float angleTan = tan(angle);
 					float height = radius / angleTan;
 					float height = radius / angleTan;
 		
 		
+					#ifdef VULKAN
+						uint vertexIdx = gl_VertexIndex;
+					#else
+						uint vertexIdx = gl_VertexID;
+					#endif
+		
 					uint sphereStartIdx = numSides * numSlices;
 					uint sphereStartIdx = numSides * numSlices;
 					// Cone vertices
 					// Cone vertices
-					if (gl_VertexIndex < sphereStartIdx)
+					if (vertexIdx < sphereStartIdx)
 					{
 					{
-						uint sliceIdx = gl_VertexIndex / numSides;
-						uint sideIdx = gl_VertexIndex % numSides;
+						uint sliceIdx = vertexIdx / numSides;
+						uint sideIdx = vertexIdx % numSides;
 
 
 						float curAngle = float(sideIdx) * 2 * PI / float(numSides);
 						float curAngle = float(sideIdx) * 2 * PI / float(numSides);
 						float sliceOffset = height * sliceIdx / float(numSlices - 1);
 						float sliceOffset = height * sliceIdx / float(numSlices - 1);
@@ -192,7 +198,7 @@ Technique
 					}
 					}
 					else // Sphere cap vertices
 					else // Sphere cap vertices
 					{
 					{
-						uint sphereVertexIdx = gl_VertexIndex - sphereStartIdx;
+						uint sphereVertexIdx = vertexIdx - sphereStartIdx;
 						uint sliceIdx = sphereVertexIdx / numSides;
 						uint sliceIdx = sphereVertexIdx / numSides;
 						uint sideIdx = sphereVertexIdx % numSides;
 						uint sideIdx = sphereVertexIdx % numSides;