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

Removed flipV from 14-shadowvolumes example.

Dario Manesku пре 11 година
родитељ
комит
7ec6e06fee
23 измењених фајлова са 10 додато и 33 уклоњено
  1. 2 3
      examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc
  2. 1 1
      examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc
  3. 2 3
      examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc
  4. 1 11
      examples/14-shadowvolumes/shadowvolumes.cpp
  5. 0 1
      examples/14-shadowvolumes/varying.def.sc
  6. 2 7
      examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc
  7. 2 7
      examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc
  8. BIN
      examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin
  9. BIN
      examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin
  10. BIN
      examples/runtime/shaders/dx11/vs_shadowvolume_color_lightning.bin
  11. BIN
      examples/runtime/shaders/dx11/vs_shadowvolume_texture_lightning.bin
  12. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin
  13. BIN
      examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin
  14. BIN
      examples/runtime/shaders/dx9/vs_shadowvolume_color_lightning.bin
  15. BIN
      examples/runtime/shaders/dx9/vs_shadowvolume_texture_lightning.bin
  16. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin
  17. BIN
      examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin
  18. BIN
      examples/runtime/shaders/gles/vs_shadowvolume_color_lightning.bin
  19. BIN
      examples/runtime/shaders/gles/vs_shadowvolume_texture_lightning.bin
  20. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin
  21. BIN
      examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin
  22. BIN
      examples/runtime/shaders/glsl/vs_shadowvolume_color_lightning.bin
  23. BIN
      examples/runtime/shaders/glsl/vs_shadowvolume_texture_lightning.bin

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

@@ -1,4 +1,4 @@
-$input v_normal, v_view, v_pos
+$input v_normal, v_view
 
 
 /*
 /*
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
@@ -67,8 +67,7 @@ void main()
 	vec3 viewDir = -normalize(v_view);
 	vec3 viewDir = -normalize(v_view);
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 
 
-	vec2 ndc = ((v_pos.xy / v_pos.w) + 1.0) / 2.0;
-	ndc += u_viewTexel.xy * u_texelHalf;
+	vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf;
 	vec4 texcolor = texture2D(u_texStencil, ndc);
 	vec4 texcolor = texture2D(u_texStencil, ndc);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	s *= u_useStencilTex;
 	s *= u_useStencilTex;

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

@@ -19,4 +19,4 @@ void main()
 	}
 	}
 
 
 	gl_FragColor = toGamma(tcolor + u_color);
 	gl_FragColor = toGamma(tcolor + u_color);
-}                           
+}

+ 2 - 3
examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc

@@ -1,4 +1,4 @@
-$input v_normal, v_view, v_texcoord0, v_pos
+$input v_normal, v_view, v_texcoord0
 
 
 /*
 /*
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
@@ -68,8 +68,7 @@ void main()
 	vec3 viewDir = -normalize(v_view);
 	vec3 viewDir = -normalize(v_view);
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 	vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass;
 
 
-	vec2 ndc = ((v_pos.xy / v_pos.w) + 1.0) / 2.0;
-	ndc += u_viewTexel.xy * u_texelHalf;
+	vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf;
 	vec4 texcolor = texture2D(u_texStencil, ndc);
 	vec4 texcolor = texture2D(u_texStencil, ndc);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w);
 	s *= u_useStencilTex;
 	s *= u_useStencilTex;

+ 1 - 11
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -109,7 +109,6 @@ static const uint16_t s_planeIndices[] =
 };
 };
 
 
 static const char* s_shaderPath = NULL;
 static const char* s_shaderPath = NULL;
-static bool s_flipV = false;
 static float s_texelHalf = 0.0f;
 static float s_texelHalf = 0.0f;
 
 
 static uint32_t s_viewMask = 0;
 static uint32_t s_viewMask = 0;
@@ -269,8 +268,6 @@ struct Uniforms
 
 
 		m_time = 0.0f;
 		m_time = 0.0f;
 
 
-		m_flipV = float(s_flipV) * 2.0f - 1.0f;
-
 		m_lightPosRadius[0] = 0.0f;
 		m_lightPosRadius[0] = 0.0f;
 		m_lightPosRadius[1] = 0.0f;
 		m_lightPosRadius[1] = 0.0f;
 		m_lightPosRadius[2] = 0.0f;
 		m_lightPosRadius[2] = 0.0f;
@@ -294,7 +291,6 @@ struct Uniforms
 		u_fog                           = bgfx::createUniform("u_fog",                           bgfx::UniformType::Uniform4fv);
 		u_fog                           = bgfx::createUniform("u_fog",                           bgfx::UniformType::Uniform4fv);
 		u_color                         = bgfx::createUniform("u_color",                         bgfx::UniformType::Uniform4fv);
 		u_color                         = bgfx::createUniform("u_color",                         bgfx::UniformType::Uniform4fv);
 		u_time                          = bgfx::createUniform("u_time",                          bgfx::UniformType::Uniform1f );
 		u_time                          = bgfx::createUniform("u_time",                          bgfx::UniformType::Uniform1f );
-		u_flipV                         = bgfx::createUniform("u_flipV",                         bgfx::UniformType::Uniform1f );
 		u_lightPosRadius                = bgfx::createUniform("u_lightPosRadius",                bgfx::UniformType::Uniform4fv);
 		u_lightPosRadius                = bgfx::createUniform("u_lightPosRadius",                bgfx::UniformType::Uniform4fv);
 		u_lightRgbInnerR                = bgfx::createUniform("u_lightRgbInnerR",                bgfx::UniformType::Uniform4fv);
 		u_lightRgbInnerR                = bgfx::createUniform("u_lightRgbInnerR",                bgfx::UniformType::Uniform4fv);
 		u_virtualLightPos_extrusionDist = bgfx::createUniform("u_virtualLightPos_extrusionDist", bgfx::UniformType::Uniform4fv);
 		u_virtualLightPos_extrusionDist = bgfx::createUniform("u_virtualLightPos_extrusionDist", bgfx::UniformType::Uniform4fv);
@@ -307,7 +303,6 @@ struct Uniforms
 		bgfx::setUniform(u_diffuse,            &m_diffuse);
 		bgfx::setUniform(u_diffuse,            &m_diffuse);
 		bgfx::setUniform(u_specular_shininess, &m_specular_shininess);
 		bgfx::setUniform(u_specular_shininess, &m_specular_shininess);
 		bgfx::setUniform(u_fog,                &m_fog);
 		bgfx::setUniform(u_fog,                &m_fog);
-		bgfx::setUniform(u_flipV,              &m_flipV);
 	}
 	}
 
 
 	//call this once per frame
 	//call this once per frame
@@ -337,7 +332,6 @@ struct Uniforms
 		bgfx::destroyUniform(u_fog);
 		bgfx::destroyUniform(u_fog);
 		bgfx::destroyUniform(u_color);
 		bgfx::destroyUniform(u_color);
 		bgfx::destroyUniform(u_time);
 		bgfx::destroyUniform(u_time);
-		bgfx::destroyUniform(u_flipV);
 		bgfx::destroyUniform(u_lightPosRadius);
 		bgfx::destroyUniform(u_lightPosRadius);
 		bgfx::destroyUniform(u_lightRgbInnerR);
 		bgfx::destroyUniform(u_lightRgbInnerR);
 		bgfx::destroyUniform(u_virtualLightPos_extrusionDist);
 		bgfx::destroyUniform(u_virtualLightPos_extrusionDist);
@@ -367,7 +361,6 @@ struct Uniforms
 	float m_fog[4];
 	float m_fog[4];
 	float m_color[4];
 	float m_color[4];
 	float m_time;
 	float m_time;
-	float m_flipV;
 	float m_lightPosRadius[4];
 	float m_lightPosRadius[4];
 	float m_lightRgbInnerR[4];
 	float m_lightRgbInnerR[4];
 	float m_virtualLightPos_extrusionDist[4];
 	float m_virtualLightPos_extrusionDist[4];
@@ -392,7 +385,6 @@ struct Uniforms
 	bgfx::UniformHandle u_fog;
 	bgfx::UniformHandle u_fog;
 	bgfx::UniformHandle u_color;
 	bgfx::UniformHandle u_color;
 	bgfx::UniformHandle u_time;
 	bgfx::UniformHandle u_time;
-	bgfx::UniformHandle u_flipV;
 	bgfx::UniformHandle u_lightPosRadius;
 	bgfx::UniformHandle u_lightPosRadius;
 	bgfx::UniformHandle u_lightRgbInnerR;
 	bgfx::UniformHandle u_lightRgbInnerR;
 	bgfx::UniformHandle u_virtualLightPos_extrusionDist;
 	bgfx::UniformHandle u_virtualLightPos_extrusionDist;
@@ -1910,7 +1902,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 	uint32_t debug = BGFX_DEBUG_TEXT;
 	uint32_t debug = BGFX_DEBUG_TEXT;
 	uint32_t reset = BGFX_RESET_VSYNC;
 	uint32_t reset = BGFX_RESET_VSYNC;
 
 
-	bgfx::init();
+	bgfx::init(bgfx::RendererType::OpenGL);
 	bgfx::reset(viewState.m_width, viewState.m_height, reset);
 	bgfx::reset(viewState.m_width, viewState.m_height, reset);
 
 
 	// Enable debug text.
 	// Enable debug text.
@@ -1932,12 +1924,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 
 
 	case bgfx::RendererType::OpenGL:
 	case bgfx::RendererType::OpenGL:
 		s_shaderPath = "shaders/glsl/";
 		s_shaderPath = "shaders/glsl/";
-		s_flipV = true;
 		break;
 		break;
 
 
 	case bgfx::RendererType::OpenGLES:
 	case bgfx::RendererType::OpenGLES:
 		s_shaderPath = "shaders/gles/";
 		s_shaderPath = "shaders/gles/";
-		s_flipV = true;
 		break;
 		break;
 	}
 	}
 
 

+ 0 - 1
examples/14-shadowvolumes/varying.def.sc

@@ -1,5 +1,4 @@
 vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
 vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec4 v_pos       : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 1.0);
 vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
 vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
 vec3 v_view      : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
 vec3 v_view      : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
 vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
 vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);

+ 2 - 7
examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc

@@ -1,14 +1,12 @@
 $input a_position, a_color0, a_normal, a_texcoord0
 $input a_position, a_color0, a_normal, a_texcoord0
-$output  v_normal, v_view, v_pos
+$output  v_normal, v_view
 
 
 /*
 /*
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
  */
 
 
-#include "../common/common.sh" 
-
-uniform float u_flipV;
+#include "../common/common.sh"
 
 
 void main()
 void main()
 {
 {
@@ -17,7 +15,4 @@ void main()
 	vec4 normal = a_normal * 2.0f - 1.0f;
 	vec4 normal = a_normal * 2.0f - 1.0f;
 	v_normal = mul(u_modelView, vec4(normal.xyz, 0.0)).xyz;
 	v_normal = mul(u_modelView, vec4(normal.xyz, 0.0)).xyz;
 	v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz;
 	v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz;
-
-	v_pos = gl_Position;
-	v_pos.y *= u_flipV;
 }
 }

+ 2 - 7
examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc

@@ -1,14 +1,12 @@
 $input a_position, a_normal, a_texcoord0
 $input a_position, a_normal, a_texcoord0
-$output  v_normal, v_view, v_texcoord0, v_pos
+$output  v_normal, v_view, v_texcoord0
 
 
 /*
 /*
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * Copyright 2013-2014 Dario Manesku. All rights reserved.
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  * License: http://www.opensource.org/licenses/BSD-2-Clause
  */
  */
 
 
-#include "../common/common.sh" 
-
-uniform float u_flipV;
+#include "../common/common.sh"
 
 
 void main()
 void main()
 {
 {
@@ -19,7 +17,4 @@ void main()
 	v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz;
 	v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz;
 
 
 	v_texcoord0 = a_texcoord0;
 	v_texcoord0 = a_texcoord0;
-
-	v_pos = gl_Position;
-	v_pos.y *= u_flipV;
 }
 }

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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