bkaradzic 12 anni fa
parent
commit
6752a421a2

+ 1 - 1
examples/06-bump/fs_bump.sc

@@ -48,7 +48,7 @@ vec3 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view)
 	vec3 lightDir = mul(_tbn, normalize(lp) );
 	vec3 lightDir = mul(_tbn, normalize(lp) );
 	vec2 bln = blinn(lightDir, _normal, _view);
 	vec2 bln = blinn(lightDir, _normal, _view);
 	vec4 lc = lit(bln.x, bln.y, 1.0);
 	vec4 lc = lit(bln.x, bln.y, 1.0);
-	vec3 rgb = u_lightRgbInnerR[_idx].xyz*max(0.0, saturate(lc.y) ) * attn;
+	vec3 rgb = u_lightRgbInnerR[_idx].xyz * saturate(lc.y) * attn;
 	return rgb;
 	return rgb;
 }
 }
 
 

+ 6 - 3
examples/12-lod/fs_tree.sc

@@ -23,16 +23,19 @@ void main()
 {
 {
 	vec2 viewport = (u_viewRect.zw - u_viewRect.xy) * vec2(1.0/8.0, 1.0/4.0);
 	vec2 viewport = (u_viewRect.zw - u_viewRect.xy) * vec2(1.0/8.0, 1.0/4.0);
 	vec2 stippleUV = viewport*(v_pos.xy*0.5 + 0.5);
 	vec2 stippleUV = viewport*(v_pos.xy*0.5 + 0.5);
-	if ((u_stipple.x - texture2D(u_texStipple,stippleUV).r)*u_stipple.y > u_stipple.z)
+	vec4 color = texture2D(u_texColor, v_texcoord0);
+	if ((u_stipple.x - texture2D(u_texStipple,stippleUV).r)*u_stipple.y > u_stipple.z || color.w < 0.5)
+	{
 		discard;
 		discard;
+	}
 
 
 	vec3 lightDir = vec3(0.0, 0.0, -1.0);
 	vec3 lightDir = vec3(0.0, 0.0, -1.0);
 	vec3 normal = normalize(v_normal);
 	vec3 normal = normalize(v_normal);
 	vec3 view = normalize(v_view);
 	vec3 view = normalize(v_view);
 	vec2 bln = blinn(lightDir, normal, view);
 	vec2 bln = blinn(lightDir, normal, view);
-	float l = max(0.0, saturate(bln.y) );
+	float l = saturate(bln.y);
 
 
-	vec4 color = toLinear(abs(texture2D(u_texColor, v_texcoord0))*l); 
+	color.xyz = toLinear(color.xyz)*l;
 	gl_FragColor = toGamma(color);
 	gl_FragColor = toGamma(color);
 }
 }
 
 

+ 4 - 4
examples/12-lod/lod.cpp

@@ -481,12 +481,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 
 
 		bgfx::setTexture(0, u_texColor, textureBark);
 		bgfx::setTexture(0, u_texColor, textureBark);
 		bgfx::setTexture(1, u_texStipple, textureStipple);
 		bgfx::setTexture(1, u_texStipple, textureStipple);
-		bgfx::setUniform(u_stipple, stipple, 1);
+		bgfx::setUniform(u_stipple, stipple);
 		mesh_trunk[mainLOD].submit(program, mtx, false);
 		mesh_trunk[mainLOD].submit(program, mtx, false);
 
 
 		bgfx::setTexture(0, u_texColor, textureLeafs);
 		bgfx::setTexture(0, u_texColor, textureLeafs);
 		bgfx::setTexture(1, u_texStipple, textureStipple);
 		bgfx::setTexture(1, u_texStipple, textureStipple);
-		bgfx::setUniform(u_stipple, stipple, 1);
+		bgfx::setUniform(u_stipple, stipple);
 		mesh_top[mainLOD].submit(program, mtx, true);
 		mesh_top[mainLOD].submit(program, mtx, true);
 
 
 		if (transitions 
 		if (transitions 
@@ -494,12 +494,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 		{
 		{
 			bgfx::setTexture(0, u_texColor, textureBark);
 			bgfx::setTexture(0, u_texColor, textureBark);
 			bgfx::setTexture(1, u_texStipple, textureStipple);
 			bgfx::setTexture(1, u_texStipple, textureStipple);
-			bgfx::setUniform(u_stipple, stippleInv, 1);
+			bgfx::setUniform(u_stipple, stippleInv);
 			mesh_trunk[targetLOD].submit(program, mtx, false);
 			mesh_trunk[targetLOD].submit(program, mtx, false);
 
 
 			bgfx::setTexture(0, u_texColor, textureLeafs);
 			bgfx::setTexture(0, u_texColor, textureLeafs);
 			bgfx::setTexture(1, u_texStipple, textureStipple);
 			bgfx::setTexture(1, u_texStipple, textureStipple);
-			bgfx::setUniform(u_stipple, stippleInv, 1);
+			bgfx::setUniform(u_stipple, stippleInv);
 			mesh_top[targetLOD].submit(program, mtx, true);
 			mesh_top[targetLOD].submit(program, mtx, true);
 		}
 		}
 	
 	

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


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


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


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


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


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