View difference between Paste ID: jgaZbQCR and q6zV3hWK
SHOW: | | - or go back to the newest paste.
1
void ShaderGenPrinterGLSL::printPixelShaderOutputStruct( Stream& stream, const MaterialFeatureData &featureData )
2
{
3
	// Determine the number of output targets we need
4
	U32 numMRTs = 0;
5
	for (U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++)
6
	{
7
		const FeatureInfo &info = FEATUREMGR->getAt(i);
8
		if (featureData.features.hasFeature(*info.type))
9
			numMRTs |= info.feature->getOutputTargets(featureData);
10
	}
11
12-
	WRITESTR("layout(location = 0) out vec4 col;\r\n");
12+
	WRITESTR("layout(location = 0) out vec4 OUT_FragColor0;\r\n");
13
	for (U32 i = 1; i < 4; i++)
14
	{
15-
		if (numMRTs & 1 << i)
15+
		if (numMRTs & 1 << i) {
16-
			WRITESTR(avar("layout(location = %d) out vec4 col%d;\r\n", i, i));
16+
			WRITESTR(avar("layout(location = %d) out vec4 OUT_FragColor%d;\r\n", i, i));
17
			extraRTs[i - 1] = true;
18
		}
19
	}
20
	WRITESTR("\r\n");
21
	WRITESTR("\r\n");
22
}
23
24
void ShaderGenPrinterGLSL::printPixelShaderCloser( Stream& stream )
25-
}
25+
26
	WRITESTR("   OUT_FragColor0 = col;\r\n");
27
	for (U32 i = 1; i < 4; i++)
28
	{
29
		if (extraRTs[i - 1])
30
			WRITESTR(avar("   OUT_FragColor%d = col%d;\r\n", i, i));
31
	}
32
33
   WRITESTR("}\r\n");
34
}
35
36
37
//In the header file
38
class ShaderGenPrinterGLSL : public ShaderGenPrinter
39
{
40
	bool extraRTs[3];
41
42
public:
43
	ShaderGenPrinterGLSL() { for (int i = 0; i < 3; i++) extraRTs[i] = false; }
44
45
   // ShaderGenPrinter
46
   virtual void printShaderHeader(Stream& stream);
47
   virtual void printMainComment(Stream& stream);
48
   virtual void printVertexShaderCloser(Stream& stream);
49
   virtual void printPixelShaderOutputStruct(Stream& stream, const MaterialFeatureData &featureData);
50
   virtual void printPixelShaderCloser(Stream& stream);
51
   virtual void printLine(Stream& stream, const String& line);
52
};