Branimir Karadžić 10 years ago
parent
commit
9ebcfab447
23 changed files with 40 additions and 32 deletions
  1. 2 2
      examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc
  2. 2 2
      examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc
  3. 3 1
      examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc
  4. 3 1
      examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc
  5. 14 12
      examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc
  6. 2 0
      examples/14-shadowvolumes/fs_shadowvolume_svside.sc
  7. 2 2
      examples/14-shadowvolumes/fs_shadowvolume_texture.sc
  8. 4 4
      examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc
  9. 8 8
      examples/14-shadowvolumes/shadowvolumes.cpp
  10. BIN
      examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin
  11. BIN
      examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin
  12. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin
  13. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin
  14. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin
  15. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin
  16. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin
  17. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin
  18. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_texture.bin
  19. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin
  20. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin
  21. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin
  22. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin
  23. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin

+ 2 - 2
examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc

@@ -15,7 +15,7 @@ uniform vec4 u_specular_shininess;
 uniform vec4 u_fog;
 uniform vec4 u_lightPosRadius;
 uniform vec4 u_lightRgbInnerR;
-SAMPLER2D(u_texStencil, 7);
+SAMPLER2D(s_texStencil, 1);
 
 #define u_ambientPass   u_params.x
 #define u_lightningPass u_params.y
@@ -68,7 +68,7 @@ void main()
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 
 	vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf;
-	vec4 texcolor = texture2D(u_texStencil, ndc);
+	vec4 texcolor = texture2D(s_texStencil, ndc);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	s *= u_useStencilTex;
 

+ 2 - 2
examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc

@@ -7,11 +7,11 @@ $input v_texcoord0
 
 #include "../common/common.sh"
 uniform vec4 u_color;
-SAMPLER2D(u_texColor, 0);
+SAMPLER2D(s_texColor, 0);
 
 void main()
 {
-	vec4 tcolor = toLinear(texture2D(u_texColor, v_texcoord0));
+	vec4 tcolor = toLinear(texture2D(s_texColor, v_texcoord0));
 
 	if (tcolor.x < 0.1) //OK for now.
 	{

+ 3 - 1
examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc

@@ -11,14 +11,16 @@ vec4 stencilColor(float _k)
 			  , float(abs(_k + 1.0) < 0.0001)/255.0
 			  , float(abs(_k - 2.0) < 0.0001)/255.0
 			  , float(abs(_k + 2.0) < 0.0001)/255.0
-			  ); 
+			  );
 }
 
 void main()
 {
 	float k = 1.0;
 	if (!gl_FrontFacing)
+	{
 		k = -k;
+	}
 
 	gl_FragColor = stencilColor(k);
 }

+ 3 - 1
examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc

@@ -11,14 +11,16 @@ vec4 stencilColor(float _k)
 			  , float(abs(_k + 1.0) < 0.0001)/255.0
 			  , float(abs(_k - 2.0) < 0.0001)/255.0
 			  , float(abs(_k + 2.0) < 0.0001)/255.0
-			  ); 
+			  );
 }
 
 void main()
 {
 	float k = 2.0;
 	if (!gl_FrontFacing)
+	{
 		k = -k;
+	}
 
 	gl_FragColor = stencilColor(k);
 }

+ 14 - 12
examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc

@@ -1,24 +1,26 @@
 /*
-* Copyright 2013-2014 Dario Manesku. All rights reserved.
-* License: http://www.opensource.org/licenses/BSD-2-Clause
-*/
+ * Copyright 2013-2014 Dario Manesku. All rights reserved.
+ * License: http://www.opensource.org/licenses/BSD-2-Clause
+ */
 
 #include "../common/common.sh"
 
 vec4 stencilColor(float _k)
 {
-   return vec4(float(abs(_k - 1.0) < 0.0001)/255.0
-			 , float(abs(_k + 1.0) < 0.0001)/255.0
-			 , float(abs(_k - 2.0) < 0.0001)/255.0
-			 , float(abs(_k + 2.0) < 0.0001)/255.0
-			 ); 
+	return vec4(float(abs(_k - 1.0) < 0.0001)/255.0
+			  , float(abs(_k + 1.0) < 0.0001)/255.0
+			  , float(abs(_k - 2.0) < 0.0001)/255.0
+			  , float(abs(_k + 2.0) < 0.0001)/255.0
+			  );
 }
 
 void main()
 {
-   float k = -1.0;
-   if (gl_FrontFacing)
-	   k = -k;
+	float k = -1.0;
+	if (gl_FrontFacing)
+	{
+		k = -k;
+	}
 
-   gl_FragColor = stencilColor(k);
+	gl_FragColor = stencilColor(k);
 }

+ 2 - 0
examples/14-shadowvolumes/fs_shadowvolume_svside.sc

@@ -11,7 +11,9 @@ void main()
 {
 	float k = v_k;
 	if (!gl_FrontFacing)
+	{
 		k = -k;
+	}
 
 	gl_FragColor.xyzw =
 		vec4( float(abs(k - 1.0) < 0.0001)/255.0

+ 2 - 2
examples/14-shadowvolumes/fs_shadowvolume_texture.sc

@@ -6,9 +6,9 @@ $input v_texcoord0
  */
 
 #include "../common/common.sh"
-SAMPLER2D(u_texColor, 0);
+SAMPLER2D(s_texColor, 0);
 
 void main()
 {
-	gl_FragColor = texture2D(u_texColor, v_texcoord0);
+	gl_FragColor = texture2D(s_texColor, v_texcoord0);
 }

+ 4 - 4
examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc

@@ -14,8 +14,8 @@ uniform vec4 u_specular_shininess;
 uniform vec4 u_fog;
 uniform vec4 u_lightPosRadius;
 uniform vec4 u_lightRgbInnerR;
-SAMPLER2D(u_texColor, 0);
-SAMPLER2D(u_texStencil, 7);
+SAMPLER2D(s_texColor,   0);
+SAMPLER2D(s_texStencil, 1);
 
 #define u_ambientPass   u_params.x
 #define u_lightningPass u_params.y
@@ -68,7 +68,7 @@ void main()
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 
 	vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf;
-	vec4 texcolor = texture2D(u_texStencil, ndc);
+	vec4 texcolor = texture2D(s_texStencil, ndc);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	s *= u_useStencilTex;
 
@@ -77,7 +77,7 @@ void main()
 	float fogFactor = 1.0/exp2(u_fogDensity*u_fogDensity*z*z*LOG2);
 	fogFactor = clamp(fogFactor, 0.0, 1.0);
 
-	vec3 color = toLinear(texture2D(u_texColor, v_texcoord0)).xyz;
+	vec3 color = toLinear(texture2D(s_texColor, v_texcoord0)).xyz;
 
 	vec3 ambient = toGamma(ambientColor * color);
 	vec3 diffuse = toGamma(lightColor * color);

+ 8 - 8
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -116,8 +116,8 @@ static float s_texelHalf = 0.0f;
 
 static uint32_t s_viewMask = 0;
 
-static bgfx::UniformHandle u_texColor;
-static bgfx::UniformHandle u_texStencil;
+static bgfx::UniformHandle s_texColor;
+static bgfx::UniformHandle s_texStencil;
 static bgfx::FrameBufferHandle s_stencilFb;
 
 void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
@@ -1175,9 +1175,9 @@ struct Model
 			// Set textures
 			if (bgfx::invalidHandle != m_texture.idx)
 			{
-				bgfx::setTexture(0, u_texColor, m_texture);
+				bgfx::setTexture(0, s_texColor, m_texture);
 			}
-			bgfx::setTexture(7, u_texStencil, s_stencilFb);
+			bgfx::setTexture(1, s_texStencil, s_stencilFb);
 
 			// Apply render state
 			::setRenderState(_renderState);
@@ -1897,8 +1897,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 	};
 	s_stencilFb  = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true);
 
-	u_texColor   = bgfx::createUniform("u_texColor",   bgfx::UniformType::Int1);
-	u_texStencil = bgfx::createUniform("u_texStencil", bgfx::UniformType::Int1);
+	s_texColor   = bgfx::createUniform("s_texColor",   bgfx::UniformType::Int1);
+	s_texStencil = bgfx::createUniform("s_texStencil", bgfx::UniformType::Int1);
 
 	bgfx::ProgramHandle programTextureLightning = loadProgram("vs_shadowvolume_texture_lightning", "fs_shadowvolume_texture_lightning");
 	bgfx::ProgramHandle programColorLightning   = loadProgram("vs_shadowvolume_color_lightning",   "fs_shadowvolume_color_lightning"  );
@@ -2843,8 +2843,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 
 	s_uniforms.destroy();
 
-	bgfx::destroyUniform(u_texColor);
-	bgfx::destroyUniform(u_texStencil);
+	bgfx::destroyUniform(s_texColor);
+	bgfx::destroyUniform(s_texStencil);
 	bgfx::destroyFrameBuffer(s_stencilFb);
 
 	bgfx::destroyTexture(figureTex);

BIN
examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin


BIN
examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin


BIN
examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin


BIN
examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin


BIN
examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin


BIN
examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin


BIN
examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin


BIN
examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin


BIN
examples/runtime/shaders/gles/fs_shadowvolume_texture.bin


BIN
examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin


BIN
examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin


BIN
examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin


BIN
examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin


BIN
examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin