Browse Source

Shader fixes for android.

Mark Sibly 7 years ago
parent
commit
b67dfab185

+ 2 - 0
modules/mojo3d/assets/shaders/imports/pbr.glsl

@@ -123,6 +123,7 @@ void emitPbrFragment( vec4 color,vec3 ambient,vec3 emissive,float metalness,floa
 	
 	
 	vec3 frag=(ambDiffuse + ambSpecular) * occlusion + emissive;
 	vec3 frag=(ambDiffuse + ambSpecular) * occlusion + emissive;
 	
 	
+#if MX2_DEFERREDRENDERER
 	//write ambient
 	//write ambient
 	gl_FragData[0]=vec4( min( frag,8.0 ),1.0 );
 	gl_FragData[0]=vec4( min( frag,8.0 ),1.0 );
 	
 	
@@ -131,6 +132,7 @@ void emitPbrFragment( vec4 color,vec3 ambient,vec3 emissive,float metalness,floa
 	
 	
 	//write normal/roughness
 	//write normal/roughness
 	gl_FragData[2]=vec4( normal * 0.5 + 0.5,roughness );
 	gl_FragData[2]=vec4( normal * 0.5 + 0.5,roughness );
+#endif
 }
 }
 
 
 #endif
 #endif

+ 15 - 2
modules/mojo3d/assets/shaders/imports/std.glsl

@@ -8,6 +8,19 @@
 #ifndef MX2_RENDERPASS
 #ifndef MX2_RENDERPASS
 #define MX2_RENDERPASS 0
 #define MX2_RENDERPASS 0
 #endif
 #endif
+
+#ifndef MX2_FORWARDRENDERER
+#define MX2_FORWARDRENDERER 0
+#endif
+
+#ifndef MX2_DEFERREDRENDERER
+#define MX2_DEFERREDRENDERER 0
+#endif
+
+#ifndef MX2_SRGBOUTPUT
+#define MX2_SRGBOUTPUT 0
+#endif
+
 #define MX2_PASSTYPE			((MX2_RENDERPASS & 3))
 #define MX2_PASSTYPE			((MX2_RENDERPASS & 3))
 #define MX2_LIGHTTYPE			((MX2_RENDERPASS & 12)>>2)
 #define MX2_LIGHTTYPE			((MX2_RENDERPASS & 12)>>2)
 #define MX2_SHADOWTYPE			((MX2_RENDERPASS & 16)>>4)
 #define MX2_SHADOWTYPE			((MX2_RENDERPASS & 16)>>4)
@@ -72,7 +85,7 @@ uniform mat4 r_InverseProjectionMatrix;
 uniform mat4 r_ProjectionMatrix;
 uniform mat4 r_ProjectionMatrix;
 uniform mat4 r_ViewMatrix;
 uniform mat4 r_ViewMatrix;
 
 
-// These available in deferred renderer!
+// These only available in deferred renderer!
 uniform sampler2D r_AccumBuffer;
 uniform sampler2D r_AccumBuffer;
 uniform sampler2D r_ColorBuffer;
 uniform sampler2D r_ColorBuffer;
 uniform sampler2D r_NormalBuffer;
 uniform sampler2D r_NormalBuffer;
@@ -366,7 +379,7 @@ vec3 sampleEnv( vec3 viewVec,float roughness ){
 
 
 void emitLinearFragment( vec4 color ){
 void emitLinearFragment( vec4 color ){
 
 
-#if defined( MX2_SRGBOUTPUT )
+#if MX2_SRGBOUTPUT
 	gl_FragColor=vec4( pow( color.rgb*color.a,vec3( 1.0/2.2 ) ),color.a );
 	gl_FragColor=vec4( pow( color.rgb*color.a,vec3( 1.0/2.2 ) ),color.a );
 #else
 #else
 	gl_FragColor=vec4( color.rgb*color.a,color.a );
 	gl_FragColor=vec4( color.rgb*color.a,color.a );