Duplicated iOS shaders so they can be optimized for OSX.
Implemented OSX preamble and automatic selection of OSX shader versions. Updated FBX import process so that it does not KRBundle the final output, but rather keeps each kind of asset bundled together in groups at the top level.
This commit is contained in:
@@ -306,6 +306,37 @@
|
||||
E414F9AB1694DA37000B3D58 /* KRUnknown.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRUnknown.h; path = Classes/KRUnknown.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
E416AA9816713749000F6786 /* KRAnimationCurveManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAnimationCurveManager.h; path = Classes/KRAnimationCurveManager.h; sourceTree = "<group>"; };
|
||||
E416AA9B1671375C000F6786 /* KRAnimationCurveManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRAnimationCurveManager.cpp; path = Classes/KRAnimationCurveManager.cpp; sourceTree = "<group>"; };
|
||||
E41AE1DD16B124CA00980428 /* font.tga */ = {isa = PBXFileReference; lastKnownFileType = file; name = font.tga; path = Shaders/font.tga; sourceTree = "<group>"; };
|
||||
E41AE1E116B1265500980428 /* sky_box_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = sky_box_osx.fsh; path = Shaders/sky_box_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1E216B1265500980428 /* debug_font_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = debug_font_osx.fsh; path = Shaders/debug_font_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1E316B1265500980428 /* debug_font_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = debug_font_osx.vsh; path = Shaders/debug_font_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1E416B1265500980428 /* dust_particle_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = dust_particle_osx.fsh; path = Shaders/dust_particle_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1E516B1265500980428 /* dust_particle_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = dust_particle_osx.vsh; path = Shaders/dust_particle_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1E616B1265500980428 /* flare_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare_osx.fsh; path = Shaders/flare_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1E716B1265500980428 /* flare_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare_osx.vsh; path = Shaders/flare_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1E816B1265500980428 /* light_directional_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_directional_osx.fsh; path = Shaders/light_directional_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1E916B1265500980428 /* light_directional_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_directional_osx.vsh; path = Shaders/light_directional_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1EA16B1265500980428 /* light_point_inside_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_point_inside_osx.fsh; path = Shaders/light_point_inside_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1EB16B1265500980428 /* light_point_inside_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_point_inside_osx.vsh; path = Shaders/light_point_inside_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1EC16B1265500980428 /* light_point_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_point_osx.fsh; path = Shaders/light_point_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1ED16B1265500980428 /* light_point_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = light_point_osx.vsh; path = Shaders/light_point_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1EE16B1265500980428 /* ObjectShader_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = ObjectShader_osx.fsh; path = Shaders/ObjectShader_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1EF16B1265500980428 /* ObjectShader_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = ObjectShader_osx.vsh; path = Shaders/ObjectShader_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F016B1265500980428 /* occlusion_test_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = occlusion_test_osx.fsh; path = Shaders/occlusion_test_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1F116B1265500980428 /* occlusion_test_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = occlusion_test_osx.vsh; path = Shaders/occlusion_test_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F216B1265500980428 /* PostShader_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = PostShader_osx.fsh; path = Shaders/PostShader_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1F316B1265500980428 /* PostShader_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = PostShader_osx.vsh; path = Shaders/PostShader_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F416B1265500980428 /* ShadowShader_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = ShadowShader_osx.fsh; path = Shaders/ShadowShader_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1F516B1265500980428 /* ShadowShader_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = ShadowShader_osx.vsh; path = Shaders/ShadowShader_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F616B1265500980428 /* simple_blit_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = simple_blit_osx.fsh; path = Shaders/simple_blit_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1F716B1265500980428 /* simple_blit_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = simple_blit_osx.vsh; path = Shaders/simple_blit_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F816B1265500980428 /* sky_box_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = sky_box_osx.vsh; path = Shaders/sky_box_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1F916B1265500980428 /* visualize_overlay_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = visualize_overlay_osx.fsh; path = Shaders/visualize_overlay_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1FA16B1265500980428 /* visualize_overlay_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = visualize_overlay_osx.vsh; path = Shaders/visualize_overlay_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1FB16B1265500980428 /* volumetric_fog_downsampled_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_downsampled_osx.fsh; path = Shaders/volumetric_fog_downsampled_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1FC16B1265500980428 /* volumetric_fog_downsampled_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_downsampled_osx.vsh; path = Shaders/volumetric_fog_downsampled_osx.vsh; sourceTree = "<group>"; };
|
||||
E41AE1FD16B1265500980428 /* volumetric_fog_osx.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_osx.fsh; path = Shaders/volumetric_fog_osx.fsh; sourceTree = "<group>"; };
|
||||
E41AE1FE16B1265500980428 /* volumetric_fog_osx.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = volumetric_fog_osx.vsh; path = Shaders/volumetric_fog_osx.vsh; sourceTree = "<group>"; };
|
||||
E41B841D16260C5600C7A771 /* sky_box.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = sky_box.fsh; path = Shaders/sky_box.fsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
||||
E41B842016260C6500C7A771 /* sky_box.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = sky_box.vsh; path = Shaders/sky_box.vsh; sourceTree = "<group>"; };
|
||||
E428C2F11669610500A16EDF /* KRAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRAnimationManager.h; path = Classes/KRAnimationManager.h; sourceTree = "<group>"; };
|
||||
@@ -530,6 +561,80 @@
|
||||
name = AnimationCurve;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E41AE1DF16B125EC00980428 /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E45772F113C9A13C0037BEEA /* ShadowShader.vsh */,
|
||||
E45772F213C9A13C0037BEEA /* ShadowShader.fsh */,
|
||||
E45772F513C9A13C0037BEEA /* ObjectShader.vsh */,
|
||||
E45772F413C9A13C0037BEEA /* ObjectShader.fsh */,
|
||||
E45772F313C9A13C0037BEEA /* PostShader.fsh */,
|
||||
E45772F613C9A13C0037BEEA /* PostShader.vsh */,
|
||||
E4D133B91538F7480070068C /* light_directional.fsh */,
|
||||
E4D133BB1538F7560070068C /* light_directional.vsh */,
|
||||
E4A9DEBD154120C4009DF363 /* light_point.fsh */,
|
||||
E4A9DEC0154120E8009DF363 /* light_point.vsh */,
|
||||
E4769DEC158A78B6004B83AC /* flare.fsh */,
|
||||
E4769DEF158A78C6004B83AC /* flare.vsh */,
|
||||
E48278AE15F03010001C9431 /* visualize_overlay.vsh */,
|
||||
E430D08015F8882F0010558D /* occlusion_test.fsh */,
|
||||
E430D08815F88AD10010558D /* occlusion_test.vsh */,
|
||||
E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */,
|
||||
E4CE184C15FF124600F80870 /* light_point_inside.fsh */,
|
||||
E4CE184E15FF125700F80870 /* light_point_inside.vsh */,
|
||||
E41B841D16260C5600C7A771 /* sky_box.fsh */,
|
||||
E41B842016260C6500C7A771 /* sky_box.vsh */,
|
||||
E45AC02F1641D66300DC3C3B /* simple_blit.vsh */,
|
||||
E45AC0331641D67300DC3C3B /* simple_blit.fsh */,
|
||||
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */,
|
||||
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */,
|
||||
E45AC0461643451200DC3C3B /* dust_particle.fsh */,
|
||||
E45AC0491643452000DC3C3B /* dust_particle.vsh */,
|
||||
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */,
|
||||
E443C615164B5BFB00FC4FD8 /* volumetric_fog.vsh */,
|
||||
E431C1B6164DB79A00BE1575 /* volumetric_fog_downsampled.vsh */,
|
||||
E431C1B7164DB7B200BE1575 /* volumetric_fog_downsampled.fsh */,
|
||||
);
|
||||
name = ios;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E41AE1E016B1261B00980428 /* osx */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E41AE1E116B1265500980428 /* sky_box_osx.fsh */,
|
||||
E41AE1E216B1265500980428 /* debug_font_osx.fsh */,
|
||||
E41AE1E316B1265500980428 /* debug_font_osx.vsh */,
|
||||
E41AE1E416B1265500980428 /* dust_particle_osx.fsh */,
|
||||
E41AE1E516B1265500980428 /* dust_particle_osx.vsh */,
|
||||
E41AE1E616B1265500980428 /* flare_osx.fsh */,
|
||||
E41AE1E716B1265500980428 /* flare_osx.vsh */,
|
||||
E41AE1E816B1265500980428 /* light_directional_osx.fsh */,
|
||||
E41AE1E916B1265500980428 /* light_directional_osx.vsh */,
|
||||
E41AE1EA16B1265500980428 /* light_point_inside_osx.fsh */,
|
||||
E41AE1EB16B1265500980428 /* light_point_inside_osx.vsh */,
|
||||
E41AE1EC16B1265500980428 /* light_point_osx.fsh */,
|
||||
E41AE1ED16B1265500980428 /* light_point_osx.vsh */,
|
||||
E41AE1EE16B1265500980428 /* ObjectShader_osx.fsh */,
|
||||
E41AE1EF16B1265500980428 /* ObjectShader_osx.vsh */,
|
||||
E41AE1F016B1265500980428 /* occlusion_test_osx.fsh */,
|
||||
E41AE1F116B1265500980428 /* occlusion_test_osx.vsh */,
|
||||
E41AE1F216B1265500980428 /* PostShader_osx.fsh */,
|
||||
E41AE1F316B1265500980428 /* PostShader_osx.vsh */,
|
||||
E41AE1F416B1265500980428 /* ShadowShader_osx.fsh */,
|
||||
E41AE1F516B1265500980428 /* ShadowShader_osx.vsh */,
|
||||
E41AE1F616B1265500980428 /* simple_blit_osx.fsh */,
|
||||
E41AE1F716B1265500980428 /* simple_blit_osx.vsh */,
|
||||
E41AE1F816B1265500980428 /* sky_box_osx.vsh */,
|
||||
E41AE1F916B1265500980428 /* visualize_overlay_osx.fsh */,
|
||||
E41AE1FA16B1265500980428 /* visualize_overlay_osx.vsh */,
|
||||
E41AE1FB16B1265500980428 /* volumetric_fog_downsampled_osx.fsh */,
|
||||
E41AE1FC16B1265500980428 /* volumetric_fog_downsampled_osx.vsh */,
|
||||
E41AE1FD16B1265500980428 /* volumetric_fog_osx.fsh */,
|
||||
E41AE1FE16B1265500980428 /* volumetric_fog_osx.vsh */,
|
||||
);
|
||||
name = osx;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E428C2EF166960ED00A16EDF /* Animation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -567,36 +672,8 @@
|
||||
E45772E313C99F160037BEEA /* Shaders */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E45772F113C9A13C0037BEEA /* ShadowShader.vsh */,
|
||||
E45772F213C9A13C0037BEEA /* ShadowShader.fsh */,
|
||||
E45772F513C9A13C0037BEEA /* ObjectShader.vsh */,
|
||||
E45772F413C9A13C0037BEEA /* ObjectShader.fsh */,
|
||||
E45772F313C9A13C0037BEEA /* PostShader.fsh */,
|
||||
E45772F613C9A13C0037BEEA /* PostShader.vsh */,
|
||||
E4D133B91538F7480070068C /* light_directional.fsh */,
|
||||
E4D133BB1538F7560070068C /* light_directional.vsh */,
|
||||
E4A9DEBD154120C4009DF363 /* light_point.fsh */,
|
||||
E4A9DEC0154120E8009DF363 /* light_point.vsh */,
|
||||
E4769DEC158A78B6004B83AC /* flare.fsh */,
|
||||
E4769DEF158A78C6004B83AC /* flare.vsh */,
|
||||
E48278AE15F03010001C9431 /* visualize_overlay.vsh */,
|
||||
E430D08015F8882F0010558D /* occlusion_test.fsh */,
|
||||
E430D08815F88AD10010558D /* occlusion_test.vsh */,
|
||||
E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */,
|
||||
E4CE184C15FF124600F80870 /* light_point_inside.fsh */,
|
||||
E4CE184E15FF125700F80870 /* light_point_inside.vsh */,
|
||||
E41B841D16260C5600C7A771 /* sky_box.fsh */,
|
||||
E41B842016260C6500C7A771 /* sky_box.vsh */,
|
||||
E45AC02F1641D66300DC3C3B /* simple_blit.vsh */,
|
||||
E45AC0331641D67300DC3C3B /* simple_blit.fsh */,
|
||||
E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */,
|
||||
E45AC0411641DE6D00DC3C3B /* debug_font.fsh */,
|
||||
E45AC0461643451200DC3C3B /* dust_particle.fsh */,
|
||||
E45AC0491643452000DC3C3B /* dust_particle.vsh */,
|
||||
E443C612164B5BE500FC4FD8 /* volumetric_fog.fsh */,
|
||||
E443C615164B5BFB00FC4FD8 /* volumetric_fog.vsh */,
|
||||
E431C1B6164DB79A00BE1575 /* volumetric_fog_downsampled.vsh */,
|
||||
E431C1B7164DB7B200BE1575 /* volumetric_fog_downsampled.fsh */,
|
||||
E41AE1E016B1261B00980428 /* osx */,
|
||||
E41AE1DF16B125EC00980428 /* ios */,
|
||||
);
|
||||
name = Shaders;
|
||||
sourceTree = "<group>";
|
||||
@@ -929,6 +1006,7 @@
|
||||
E4CE184615FEED6800F80870 /* Standard Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E41AE1DD16B124CA00980428 /* font.tga */,
|
||||
E4CE184815FEEDA200F80870 /* font.pvr */,
|
||||
E45772E313C99F160037BEEA /* Shaders */,
|
||||
);
|
||||
@@ -1328,6 +1406,7 @@
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = /usr/local/include;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -1343,6 +1422,7 @@
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = /usr/local/include;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -1353,7 +1433,7 @@
|
||||
E491016C13C99B9E0098455B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
DSTROOT = /tmp/KREngine.dst;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -1376,7 +1456,7 @@
|
||||
E491016D13C99B9E0098455B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
DSTROOT = /tmp/KREngine.dst;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@@ -1399,7 +1479,7 @@
|
||||
E4BBBB8F1512A40300F43B5B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
@@ -1424,6 +1504,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"/Applications/Autodesk/FBX SDK/2013.3/include\"",
|
||||
/usr/local/include,
|
||||
);
|
||||
INFOPLIST_FILE = "krengine_osx/krengine_osx-Info.plist";
|
||||
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
||||
@@ -1444,7 +1525,7 @@
|
||||
E4BBBB901512A40300F43B5B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
@@ -1465,6 +1546,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"/Applications/Autodesk/FBX SDK/2013.3/include\"",
|
||||
/usr/local/include,
|
||||
);
|
||||
INFOPLIST_FILE = "krengine_osx/krengine_osx-Info.plist";
|
||||
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
||||
|
||||
@@ -201,7 +201,7 @@ void KRAudioSample::PopulateBuffer(KRAudioSample *sound, int index, void *data)
|
||||
{
|
||||
int maxFramesPerBuffer = KRENGINE_AUDIO_MAX_BUFFER_SIZE / sound->m_bytesPerFrame;
|
||||
int startFrame = index * maxFramesPerBuffer;
|
||||
UInt32 frameCount = KRMIN(sound->m_totalFrames - startFrame, maxFramesPerBuffer);
|
||||
UInt32 frameCount = (UInt32)KRMIN(sound->m_totalFrames - startFrame, maxFramesPerBuffer);
|
||||
|
||||
|
||||
AudioBufferList outputBufferInfo;
|
||||
@@ -221,7 +221,7 @@ KRAudioBuffer *KRAudioSample::getBuffer(int index)
|
||||
|
||||
int maxFramesPerBuffer = KRENGINE_AUDIO_MAX_BUFFER_SIZE / m_bytesPerFrame;
|
||||
int startFrame = index * maxFramesPerBuffer;
|
||||
UInt32 frameCount = KRMIN(m_totalFrames - startFrame, maxFramesPerBuffer);
|
||||
UInt32 frameCount = (UInt32)KRMIN(m_totalFrames - startFrame, maxFramesPerBuffer);
|
||||
|
||||
KRAudioBuffer *buffer = new KRAudioBuffer(getContext().getAudioManager(), this, index, m_dataFormat, frameCount, m_frameRate, m_bytesPerFrame, PopulateBuffer);
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ float const D2R = PI * 2 / 360;
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
|
||||
|
||||
using std::vector;
|
||||
|
||||
@@ -44,6 +44,29 @@ KRMaterialManager::~KRMaterialManager() {
|
||||
}
|
||||
|
||||
|
||||
void KRMaterialManager::configure(bool blend_enable, GLenum blend_src, GLenum blend_dest, bool depth_test_enable, GLenum depth_func, bool depth_write_enable) {
|
||||
if(blend_enable) {
|
||||
GLDEBUG(glEnable(GL_BLEND));
|
||||
GLDEBUG(glBlendFunc(blend_src, blend_dest));
|
||||
} else {
|
||||
GLDEBUG(glDisable(GL_BLEND));
|
||||
}
|
||||
|
||||
if(depth_test_enable) {
|
||||
GLDEBUG(glEnable(GL_DEPTH_TEST));
|
||||
GLDEBUG(glDepthFunc(depth_func));
|
||||
} else {
|
||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||
}
|
||||
|
||||
if(depth_write_enable) {
|
||||
GLDEBUG(glDepthMask(GL_TRUE));
|
||||
} else {
|
||||
GLDEBUG(glDepthMask(GL_FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KRMaterial *KRMaterialManager::getMaterial(const char *szName) {
|
||||
std::string lowerName = szName;
|
||||
std::transform(lowerName.begin(), lowerName.end(),
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
bool load(const char *szName, KRDataBlock *data);
|
||||
KRMaterial *getMaterial(const char *szName);
|
||||
|
||||
|
||||
void configure(bool blend_enable, GLenum blend_src, GLenum blend_dest, bool depth_test_enable, GLenum depth_func, bool depth_write_enable);
|
||||
|
||||
private:
|
||||
map<std::string, KRMaterial *> m_materials;
|
||||
|
||||
@@ -169,36 +169,43 @@ std::vector<KRResource *> KRResource::LoadFbx(KRContext &context, const std::str
|
||||
context.getTextureManager()->compress(); // TODO, HACK, FINDME - This should be configurable and exposed through the World Builder GUI
|
||||
|
||||
std::string base_name = KRResource::GetFileBase(path);
|
||||
KRBundle *main_bundle = new KRBundle(context, base_name);
|
||||
KRBundle texture_bundle(context, base_name + "_textures");
|
||||
KRBundle animation_bundle(context, base_name + "_animations");
|
||||
KRBundle material_bundle(context, base_name + "_materials");
|
||||
KRBundle meshes_bundle(context, base_name + "_meshes");
|
||||
std::vector<KRResource *> output_resources;
|
||||
|
||||
// KRBundle *main_bundle = new KRBundle(context, base_name);
|
||||
KRBundle *texture_bundle = new KRBundle(context, base_name + "_textures");
|
||||
KRBundle *animation_bundle = new KRBundle(context, base_name + "_animations");
|
||||
KRBundle *material_bundle = new KRBundle(context, base_name + "_materials");
|
||||
KRBundle *meshes_bundle = new KRBundle(context, base_name + "_meshes");
|
||||
|
||||
for(std::vector<KRResource *>::iterator resource_itr=resources.begin(); resource_itr != resources.end(); resource_itr++) {
|
||||
KRResource *resource = *resource_itr;
|
||||
if(dynamic_cast<KRTexture *>(resource) != NULL) {
|
||||
texture_bundle.append(*resource);
|
||||
texture_bundle->append(*resource);
|
||||
} else if(dynamic_cast<KRAnimation *>(resource) != NULL) {
|
||||
animation_bundle.append(*resource);
|
||||
animation_bundle->append(*resource);
|
||||
} else if(dynamic_cast<KRAnimationCurve *>(resource) != NULL) {
|
||||
animation_bundle.append(*resource);
|
||||
animation_bundle->append(*resource);
|
||||
} else if(dynamic_cast<KRMaterial *>(resource) != NULL) {
|
||||
material_bundle.append(*resource);
|
||||
material_bundle->append(*resource);
|
||||
} else if(dynamic_cast<KRMesh *>(resource) != NULL) {
|
||||
meshes_bundle.append(*resource);
|
||||
meshes_bundle->append(*resource);
|
||||
} else {
|
||||
main_bundle->append(*resource);
|
||||
output_resources.push_back(resource);
|
||||
// main_bundle->append(*resource);
|
||||
}
|
||||
}
|
||||
|
||||
main_bundle->append(texture_bundle);
|
||||
main_bundle->append(animation_bundle);
|
||||
main_bundle->append(material_bundle);
|
||||
main_bundle->append(meshes_bundle);
|
||||
output_resources.push_back(texture_bundle);
|
||||
output_resources.push_back(animation_bundle);
|
||||
output_resources.push_back(material_bundle);
|
||||
output_resources.push_back(meshes_bundle);
|
||||
|
||||
// main_bundle->append(texture_bundle);
|
||||
// main_bundle->append(animation_bundle);
|
||||
// main_bundle->append(material_bundle);
|
||||
// main_bundle->append(meshes_bundle);
|
||||
// output_resources.push_back(main_bundle);
|
||||
|
||||
std::vector<KRResource *> output_resources;
|
||||
output_resources.push_back(main_bundle);
|
||||
return output_resources;
|
||||
}
|
||||
|
||||
@@ -764,19 +771,19 @@ void LoadMaterial(KRContext &context, std::vector<KRResource *> &resources, FbxS
|
||||
KRMaterial *new_material = new KRMaterial(context, pMaterial->GetName());
|
||||
|
||||
std::string name = pMaterial->GetName();
|
||||
if(boost:starts_with(name, "ab_reflect_")) {
|
||||
if(boost::starts_with(name, "ab_reflect_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||
int underscore_pos = name.find('_', 11);
|
||||
size_t underscore_pos = name.find('_', 11);
|
||||
new_material->setReflectionCube(name.substr(11, underscore_pos - 11));
|
||||
} else if(boost::starts_with(name, "reflect_")) {
|
||||
int underscore_pos = name.find('_', 8);
|
||||
size_t underscore_pos = name.find('_', 8);
|
||||
new_material->setReflectionCube(name.substr(8, underscore_pos - 8));
|
||||
} else if(boost::starts_with(name, "at_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_TEST);
|
||||
} else if(boost::starts_with(name, "ab_")) {
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||
} else if(boost::starts_with(name, "ab2_")) {
|
||||
new_material->setAlphaMode(KRMAterial::KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||
new_material->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||
}
|
||||
|
||||
FbxPropertyT<FbxDouble3> lKFbxDouble3;
|
||||
|
||||
@@ -50,6 +50,13 @@ KRShaderManager::~KRShaderManager() {
|
||||
|
||||
KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRLight *> &lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass) {
|
||||
|
||||
std::string platform_shader_name = shader_name;
|
||||
#if TARGET_OS_MAC
|
||||
platform_shader_name = shader_name + "_osx";
|
||||
#else
|
||||
platform_shader_name = shader_name;
|
||||
#endif
|
||||
|
||||
int iShadowQuality = 0; // FINDME - HACK - Placeholder code, need to iterate through lights and dynamically build shader
|
||||
|
||||
|
||||
@@ -76,7 +83,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
||||
}
|
||||
|
||||
char szKey[256];
|
||||
sprintf(szKey, "%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f", light_directional_count, light_point_count, light_spot_count, bone_count, pCamera->settings.fog_type, pCamera->settings.bEnablePerPixel,bAlphaTest, bAlphaBlend, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, pCamera->settings.bDebugPSSM, iShadowQuality, pCamera->settings.bEnableAmbient, pCamera->settings.bEnableDiffuse, pCamera->settings.bEnableSpecular, bLightMap, bDiffuseMapScale, bSpecMapScale, bReflectionMapScale, bNormalMapScale, bDiffuseMapOffset, bSpecMapOffset, bReflectionMapOffset, bNormalMapOffset,pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0, renderPass, shader_name.c_str(),pCamera->settings.dof_quality,pCamera->settings.bEnableFlash,pCamera->settings.bEnableVignette,pCamera->settings.dof_depth,pCamera->settings.dof_falloff,pCamera->settings.flash_depth,pCamera->settings.flash_falloff,pCamera->settings.flash_intensity,pCamera->settings.vignette_radius,pCamera->settings.vignette_falloff);
|
||||
sprintf(szKey, "%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f", light_directional_count, light_point_count, light_spot_count, bone_count, pCamera->settings.fog_type, pCamera->settings.bEnablePerPixel,bAlphaTest, bAlphaBlend, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, pCamera->settings.bDebugPSSM, iShadowQuality, pCamera->settings.bEnableAmbient, pCamera->settings.bEnableDiffuse, pCamera->settings.bEnableSpecular, bLightMap, bDiffuseMapScale, bSpecMapScale, bReflectionMapScale, bNormalMapScale, bDiffuseMapOffset, bSpecMapOffset, bReflectionMapOffset, bNormalMapOffset,pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0, renderPass, platform_shader_name.c_str(),pCamera->settings.dof_quality,pCamera->settings.bEnableFlash,pCamera->settings.bEnableVignette,pCamera->settings.dof_depth,pCamera->settings.dof_falloff,pCamera->settings.flash_depth,pCamera->settings.flash_falloff,pCamera->settings.flash_intensity,pCamera->settings.vignette_radius,pCamera->settings.vignette_falloff);
|
||||
|
||||
KRShader *pShader = m_shaders[szKey];
|
||||
|
||||
@@ -91,6 +98,14 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
||||
|
||||
stringstream stream;
|
||||
stream.precision(std::numeric_limits<long double>::digits10);
|
||||
|
||||
#if TARGET_OS_MAC
|
||||
stream << "\n#version 120";
|
||||
stream << "\n#define lowp";
|
||||
stream << "\n#define mediump";
|
||||
stream << "\n#define highp";
|
||||
#endif
|
||||
|
||||
stream << "\n#define LIGHT_DIRECTIONAL_COUNT " << light_directional_count;
|
||||
stream << "\n#define LIGHT_POINT_COUNT " << light_point_count;
|
||||
stream << "\n#define LIGHT_SPOT_COUNT " << light_spot_count;
|
||||
@@ -162,7 +177,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
||||
stream << "\n";
|
||||
std::string options = stream.str();
|
||||
|
||||
pShader = new KRShader(getContext(), szKey, options, m_vertShaderSource[shader_name], m_fragShaderSource[shader_name]);
|
||||
pShader = new KRShader(getContext(), szKey, options, m_vertShaderSource[platform_shader_name], m_fragShaderSource[platform_shader_name]);
|
||||
|
||||
m_shaders[szKey] = pShader;
|
||||
}
|
||||
|
||||
380
KREngine/KREngine/Shaders/ObjectShader_osx.fsh
Normal file
380
KREngine/KREngine/Shaders/ObjectShader_osx.fsh
Normal file
@@ -0,0 +1,380 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#extension GL_EXT_shadow_samplers : require
|
||||
|
||||
#if FOG_TYPE > 0
|
||||
// FOG_TYPE 1 - Linear
|
||||
// FOG_TYPE 2 - Exponential
|
||||
// FOG_TYPE 3 - Exponential squared
|
||||
uniform lowp vec3 fog_color;
|
||||
uniform mediump float fog_near;
|
||||
#if FOG_TYPE == 1
|
||||
uniform mediump float fog_far;
|
||||
uniform mediump float fog_scale;
|
||||
#endif
|
||||
|
||||
#if FOG_TYPE > 1
|
||||
uniform mediump float fog_density;
|
||||
#endif
|
||||
|
||||
#if FOG_TYPE == 2
|
||||
uniform mediump float fog_density_premultiplied_exponential;
|
||||
#endif
|
||||
#if FOG_TYPE == 3
|
||||
uniform mediump float fog_density_premultiplied_squared;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
|
||||
uniform mediump float material_shininess;
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
uniform sampler2D normalTexture;
|
||||
#else
|
||||
varying mediump vec3 normal;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1 || HAS_NORMAL_MAP == 1 || HAS_SPEC_MAP == 1 || HAS_REFLECTION_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
#endif
|
||||
#if HAS_NORMAL_MAP_OFFSET == 1 || HAS_NORMAL_MAP_SCALE == 1
|
||||
varying highp vec2 normal_uv;
|
||||
#else
|
||||
#define normal_uv texCoord
|
||||
#endif
|
||||
#else
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if GBUFFER_PASS == 3
|
||||
uniform sampler2D gbuffer_frame;
|
||||
uniform sampler2D gbuffer_depth;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
varying highp mat3 tangent_to_view_matrix;
|
||||
#else
|
||||
uniform highp mat4 model_view_inverse_transpose_matrix;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1 && ALPHA_TEST == 1
|
||||
uniform sampler2D diffuseTexture;
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
varying highp vec2 diffuse_uv;
|
||||
#else
|
||||
#define diffuse_uv texCoord
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
uniform lowp vec3 material_ambient, material_diffuse, material_specular;
|
||||
uniform lowp float material_alpha;
|
||||
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
uniform sampler2D diffuseTexture;
|
||||
#endif
|
||||
|
||||
#if HAS_SPEC_MAP == 1
|
||||
uniform sampler2D specularTexture;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_MAP == 1
|
||||
uniform sampler2D reflectionTexture;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||
uniform lowp vec3 material_reflection;
|
||||
uniform samplerCube reflectionCubeTexture;
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
varying highp mat3 tangent_to_world_matrix;
|
||||
varying mediump vec3 eyeVec;
|
||||
uniform highp mat4 model_matrix;
|
||||
#else
|
||||
varying mediump vec3 reflectionVec;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if SHADOW_QUALITY >= 1
|
||||
#ifdef GL_EXT_shadow_samplers
|
||||
uniform sampler2DShadow shadowTexture1;
|
||||
#else
|
||||
uniform sampler2D shadowTexture1;
|
||||
#endif
|
||||
varying highp vec4 shadowMapCoord1;
|
||||
#endif
|
||||
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
uniform sampler2D lightmapTexture;
|
||||
varying mediump vec2 lightmap_uv;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2
|
||||
uniform sampler2D shadowTexture2;
|
||||
varying highp vec4 shadowMapCoord2;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 3
|
||||
uniform sampler2D shadowTexture3;
|
||||
varying highp vec4 shadowMapCoord3;
|
||||
#endif
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec3 lightVec;
|
||||
varying mediump vec3 halfVec;
|
||||
#else
|
||||
varying mediump float lamberFactor;
|
||||
varying mediump float specularFactor;
|
||||
#endif
|
||||
|
||||
#if (HAS_SPEC_MAP_OFFSET == 1|| HAS_SPEC_MAP_SCALE == 1) && ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec2 spec_uv;
|
||||
#else
|
||||
#define spec_uv texCoord
|
||||
#endif
|
||||
|
||||
#if (HAS_REFLECTION_MAP_OFFSET == 1|| HAS_REFLECTION_MAP_SCALE == 1) && ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec2 reflection_uv;
|
||||
#else
|
||||
#define reflection_uv texCoord
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
varying highp vec2 diffuse_uv;
|
||||
#else
|
||||
#define diffuse_uv texCoord
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1 || GBUFFER_PASS == 3
|
||||
uniform mediump vec4 viewport;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if ALPHA_TEST == 1 && HAS_DIFFUSE_MAP == 1
|
||||
mediump vec4 diffuseMaterial = texture2D(diffuseTexture, diffuse_uv);
|
||||
if(diffuseMaterial.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1 && ALPHA_TEST == 1
|
||||
if(texture2D(diffuseTexture, diffuse_uv).a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 2 || GBUFFER_PASS == 3
|
||||
mediump vec2 gbuffer_uv = vec2(gl_FragCoord.xy / viewport.zw); // FINDME, TODO - Dependent Texture Read adding latency, due to calculation of texture UV within fragment -- move to vertex shader?
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 3
|
||||
lowp vec4 gbuffer_sample = texture2D(gbuffer_frame, gbuffer_uv);
|
||||
mediump vec3 gbuffer_lamber_factor = gbuffer_sample.rgb * 5.0;
|
||||
lowp float gbuffer_specular_factor = gbuffer_sample.a;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
mediump vec3 normal = normalize(2.0 * texture2D(normalTexture,normal_uv).rgb - 1.0);
|
||||
mediump vec3 view_space_normal = tangent_to_view_matrix * normal;
|
||||
#else
|
||||
mediump vec3 view_space_normal = vec3(model_view_inverse_transpose_matrix * vec4(normal, 1.0));
|
||||
#endif
|
||||
gl_FragColor = vec4(view_space_normal * 0.5 + 0.5, material_shininess / 100.0);
|
||||
#else
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
#if ALPHA_TEST == 1
|
||||
diffuseMaterial.a = 1.0;
|
||||
#else
|
||||
mediump vec4 diffuseMaterial = texture2D(diffuseTexture, diffuse_uv);
|
||||
#endif
|
||||
|
||||
#else
|
||||
mediump vec4 diffuseMaterial = vec4(1.0);
|
||||
#endif
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
mediump vec3 normal = normalize(2.0 * texture2D(normalTexture,normal_uv).rgb - 1.0);
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 3
|
||||
mediump vec3 lamberFactor = gbuffer_lamber_factor;
|
||||
#else
|
||||
mediump float lamberFactor = max(0.0,dot(lightVec, normal));
|
||||
#endif
|
||||
mediump float specularFactor = 0.0;
|
||||
if(material_shininess > 0.0) {
|
||||
#if GBUFFER_PASS == 3
|
||||
specularFactor = gbuffer_specular_factor;
|
||||
#else
|
||||
specularFactor = max(0.0,pow(dot(halfVec,normal), material_shininess));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GL_EXT_shadow_samplers
|
||||
#if SHADOW_QUALITY == 1
|
||||
lowp float shadow = shadow2DProjEXT(shadowTexture1, shadowMapCoord1);
|
||||
lamberFactor *= shadow;
|
||||
specularFactor *= shadow;
|
||||
#endif
|
||||
#else
|
||||
|
||||
#if SHADOW_QUALITY == 1
|
||||
|
||||
highp float shadowMapDepth = 1.0;
|
||||
highp float vertexShadowDepth = 1.0;
|
||||
highp vec2 shadowMapPos = (shadowMapCoord1 / shadowMapCoord1.w).st;
|
||||
|
||||
if(shadowMapCoord1.x >= -1.0 && shadowMapCoord1.x <= 1.0 && shadowMapCoord1.y >= -1.0 && shadowMapCoord1.y <= 1.0 && shadowMapCoord1.z >= 0.0 && shadowMapCoord1.z <= 1.0) {
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.75, 0.5, 1.0) + vec4(0.0, 0.0, 0.5, 0.0);
|
||||
#endif
|
||||
shadowMapDepth = texture2D(shadowTexture1, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord1 / shadowMapCoord1.w).z;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2
|
||||
|
||||
highp float shadowMapDepth = 1.0;
|
||||
highp float vertexShadowDepth = 1.0;
|
||||
|
||||
if(shadowMapCoord1.x >= -1.0 && shadowMapCoord1.x <= 1.0 && shadowMapCoord1.y >= -1.0 && shadowMapCoord1.y <= 1.0 && shadowMapCoord1.z >= 0.0 && shadowMapCoord1.z <= 1.0) {
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.75, 0.5, 1.0) + vec4(0.0, 0.0, 0.5, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord1 / shadowMapCoord1.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture1, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord1 / shadowMapCoord1.w).z;
|
||||
} else if(shadowMapCoord2.s >= -1.0 && shadowMapCoord2.s <= 1.0 && shadowMapCoord2.t >= -1.0 && shadowMapCoord2.t <= 1.0 && shadowMapCoord2.z >= 0.0 && shadowMapCoord2.z <= 1.0) {
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.50, 0.75, 1.0) + vec4(0.0, 0.5, 0.0, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord2 / shadowMapCoord2.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture2, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord2 / shadowMapCoord2.w).z;
|
||||
}
|
||||
#if SHADOW_QUALITY >= 3
|
||||
else if(shadowMapCoord3.s >= -1.0 && shadowMapCoord3.s <= 1.0 && shadowMapCoord3.t >= -1.0 && shadowMapCoord3.t <= 1.0 && shadowMapCoord3.z >= 0.0 && shadowMapCoord3.z <= 1.0) {
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.50, 0.75, 0.75, 1.0) + vec4(0.5, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord3 / shadowMapCoord3.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture3, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord3 / shadowMapCoord3.w).z;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 1
|
||||
if(vertexShadowDepth >= shadowMapDepth && shadowMapDepth < 1.0) {
|
||||
#if GBUFFER_PASS == 3
|
||||
lamberFactor = vec3(0.0);
|
||||
#else
|
||||
lamberFactor = 0.0;
|
||||
#endif
|
||||
specularFactor = 0.0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLE_AMBIENT == 1
|
||||
// -------------------- Add ambient light and alpha component --------------------
|
||||
gl_FragColor = vec4(vec3(diffuseMaterial) * material_ambient, 0.0);
|
||||
#else
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
#if ENABLE_DIFFUSE == 1
|
||||
// -------------------- Add diffuse light --------------------
|
||||
gl_FragColor += diffuseMaterial * vec4(material_diffuse, 1.0) * vec4(vec3(lamberFactor), 1.0);
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||
// -------------------- Add reflected light --------------------
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// Calculate reflection vector as I - 2.0 * dot(N, I) * N
|
||||
mediump vec3 incidenceVec = -normalize(eyeVec);
|
||||
highp vec3 world_space_normal = tangent_to_world_matrix * normal;
|
||||
mediump vec3 reflectionVec = mat3(model_matrix) * (incidenceVec - 2.0 * dot(world_space_normal, incidenceVec) * world_space_normal);
|
||||
#endif
|
||||
#if HAS_REFLECTION_MAP == 1
|
||||
gl_FragColor += vec4(material_reflection, 0.0) * texture2D(reflectionTexture, reflection_uv) * textureCube(reflectionCubeTexture, reflectionVec);
|
||||
#else
|
||||
gl_FragColor += vec4(material_reflection, 0.0) * textureCube(reflectionCubeTexture, reflectionVec);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// -------------------- Add specular light --------------------
|
||||
#if ENABLE_SPECULAR == 1
|
||||
#if HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1
|
||||
gl_FragColor += vec4(material_specular * vec3(texture2D(specularTexture, spec_uv)) * specularFactor, 0.0);
|
||||
#else
|
||||
gl_FragColor += vec4(material_specular * specularFactor, 0.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 1
|
||||
gl_FragColor.a = gl_FragColor.a * material_alpha;
|
||||
#endif
|
||||
|
||||
// -------------------- Multiply light map --------------------
|
||||
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
mediump vec3 lightMapColor = vec3(texture2D(lightmapTexture, lightmap_uv));
|
||||
gl_FragColor = vec4(gl_FragColor.r * lightMapColor.r, gl_FragColor.g * lightMapColor.g, gl_FragColor.b * lightMapColor.b, gl_FragColor.a);
|
||||
#endif
|
||||
|
||||
// -------------------- Apply Fog --------------------
|
||||
#if FOG_TYPE == 1
|
||||
// Linear fog
|
||||
gl_FragColor.rgb = mix(fog_color.rgb, gl_FragColor.rgb, clamp((fog_far - gl_FragCoord.z / gl_FragCoord.w) * fog_scale, 0.0, 1.0));
|
||||
#endif
|
||||
|
||||
#if FOG_TYPE == 2
|
||||
// Exponential fog
|
||||
mediump float fog_z = gl_FragCoord.z / gl_FragCoord.w - fog_near;
|
||||
gl_FragColor.rgb = mix(fog_color.rgb, gl_FragColor.rgb, clamp(exp2(fog_density_premultiplied_exponential * fog_z), 0.0, 1.0));
|
||||
#endif
|
||||
|
||||
#if FOG_TYPE == 3
|
||||
// Exponential squared fog
|
||||
mediump float fog_z = max(gl_FragCoord.z / gl_FragCoord.w - fog_near, 0.0);
|
||||
gl_FragColor.rgb = mix(fog_color.rgb, gl_FragColor.rgb, clamp(exp2(fog_density_premultiplied_squared * fog_z * fog_z), 0.0, 1.0));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
332
KREngine/KREngine/Shaders/ObjectShader_osx.vsh
Normal file
332
KREngine/KREngine/Shaders/ObjectShader_osx.vsh
Normal file
@@ -0,0 +1,332 @@
|
||||
//
|
||||
// Shader.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute highp vec3 vertex_position, vertex_normal, vertex_tangent;
|
||||
attribute mediump vec2 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
#if BONE_COUNT > 0
|
||||
attribute highp vec4 bone_weights;
|
||||
attribute mediump vec4 bone_indexes;
|
||||
uniform highp mat4 bone_transforms[BONE_COUNT];
|
||||
#else
|
||||
#define vertex_position_skinned vertex_position
|
||||
#define vertex_normal_skinned vertex_normal
|
||||
#define vertex_tangent_skinned vertex_tangent
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1 || GBUFFER_PASS == 1
|
||||
#if HAS_DIFFUSE_MAP == 1 || HAS_NORMAL_MAP == 1 || HAS_SPEC_MAP == 1 || HAS_REFLECTION_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
#endif
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
#if HAS_NORMAL_MAP_SCALE == 1
|
||||
uniform highp vec2 normalTexture_Scale;
|
||||
#endif
|
||||
|
||||
#if HAS_NORMAL_MAP_OFFSET == 1
|
||||
uniform highp vec2 normalTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_NORMAL_MAP_OFFSET == 1 || HAS_NORMAL_MAP_SCALE == 1
|
||||
varying highp vec2 normal_uv;
|
||||
#endif
|
||||
#else
|
||||
varying mediump vec3 normal;
|
||||
#endif
|
||||
#else
|
||||
uniform mediump float material_shininess;
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
uniform highp mat4 model_view_inverse_transpose_matrix;
|
||||
varying highp mat3 tangent_to_view_matrix;
|
||||
#endif
|
||||
#else
|
||||
|
||||
uniform highp vec3 light_direction_model_space; // Must be normalized before entering shader
|
||||
uniform highp vec3 camera_position_model_space;
|
||||
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
attribute mediump vec2 vertex_lightmap_uv;
|
||||
varying mediump vec2 lightmap_uv;
|
||||
#endif
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec3 lightVec;
|
||||
varying mediump vec3 halfVec;
|
||||
|
||||
#if HAS_SPEC_MAP_OFFSET == 1 || HAS_SPEC_MAP_SCALE == 1
|
||||
varying highp vec2 spec_uv;
|
||||
#endif
|
||||
|
||||
#if HAS_SPEC_MAP_SCALE == 1
|
||||
uniform highp vec2 specularTexture_Scale;
|
||||
#endif
|
||||
|
||||
#if HAS_SPEC_MAP_OFFSET == 1
|
||||
uniform highp vec2 specularTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_MAP_OFFSET == 1 || HAS_REFLECTION_MAP_SCALE == 1
|
||||
varying highp vec2 reflection_uv;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_MAP_SCALE == 1
|
||||
uniform highp vec2 reflection_Scale;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_MAP_OFFSET == 1
|
||||
uniform highp vec2 reflection_Offset;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 1
|
||||
uniform highp mat4 shadow_mvp1;
|
||||
varying highp vec4 shadowMapCoord1;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2
|
||||
uniform highp mat4 shadow_mvp2;
|
||||
varying highp vec4 shadowMapCoord2;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 3
|
||||
uniform highp mat4 shadow_mvp3;
|
||||
varying highp vec4 shadowMapCoord3;
|
||||
#endif
|
||||
|
||||
#else
|
||||
varying mediump float lamberFactor;
|
||||
varying mediump float specularFactor;
|
||||
#endif
|
||||
|
||||
|
||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
uniform highp mat4 model_inverse_transpose_matrix;
|
||||
varying mediump vec3 eyeVec;
|
||||
varying highp mat3 tangent_to_world_matrix;
|
||||
#else
|
||||
uniform highp mat4 model_matrix;
|
||||
varying mediump vec3 reflectionVec;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_SCALE == 1
|
||||
uniform highp vec2 diffuseTexture_Scale;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1
|
||||
uniform highp vec2 diffuseTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
varying highp vec2 diffuse_uv;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
#if BONE_COUNT > 0
|
||||
mediump vec4 scaled_bone_indexes = bone_indexes;
|
||||
mediump vec4 scaled_bone_weights = bone_weights;
|
||||
|
||||
// scaled_bone_indexes = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
// scaled_bone_weights = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
highp vec3 vertex_position_skinned =
|
||||
((bone_transforms[ int(scaled_bone_indexes.x) ] * vec4(vertex_position, 1.0)).xyz * scaled_bone_weights.x) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.y) ] * vec4(vertex_position, 1.0)).xyz * scaled_bone_weights.y) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.z) ] * vec4(vertex_position, 1.0)).xyz * scaled_bone_weights.z) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.w) ] * vec4(vertex_position, 1.0)).xyz * scaled_bone_weights.w);
|
||||
|
||||
highp vec3 vertex_normal_skinned = normalize(
|
||||
((bone_transforms[ int(scaled_bone_indexes.x) ] * vec4(vertex_normal, 1.0)).xyz * scaled_bone_weights.x) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.y) ] * vec4(vertex_normal, 1.0)).xyz * scaled_bone_weights.y) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.z) ] * vec4(vertex_normal, 1.0)).xyz * scaled_bone_weights.z) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.w) ] * vec4(vertex_normal, 1.0)).xyz * scaled_bone_weights.w));
|
||||
|
||||
highp vec3 vertex_tangent_skinned = normalize(
|
||||
((bone_transforms[ int(scaled_bone_indexes.x) ] * vec4(vertex_tangent, 1.0)).xyz * scaled_bone_weights.x) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.y) ] * vec4(vertex_tangent, 1.0)).xyz * scaled_bone_weights.y) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.z) ] * vec4(vertex_tangent, 1.0)).xyz * scaled_bone_weights.z) +
|
||||
((bone_transforms[ int(scaled_bone_indexes.w) ] * vec4(vertex_tangent, 1.0)).xyz * scaled_bone_weights.w));
|
||||
#endif
|
||||
|
||||
|
||||
// Transform position
|
||||
gl_Position = mvp_matrix * vec4(vertex_position_skinned,1.0);
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1 || (HAS_NORMAL_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1) || (HAS_REFLECTION_MAP == 1 && ENABLE_PER_PIXEL == 1)
|
||||
// Pass UV co-ordinates
|
||||
texCoord = vertex_uv.st;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// Scaled and translated normal map UV's
|
||||
#if (HAS_NORMAL_MAP_OFFSET == 1 || HAS_NORMAL_MAP_SCALE == 1) && ENABLE_PER_PIXEL == 1
|
||||
normal_uv = texCoord;
|
||||
|
||||
#if HAS_NORMAL_MAP_OFFSET == 1
|
||||
normal_uv += normalTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_NORMAL_MAP_SCALE == 1
|
||||
normal_uv *= normalTexture_Scale;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS != 1 || ALPHA_TEST == 1
|
||||
// Scaled and translated diffuse map UV's
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
diffuse_uv = texCoord;
|
||||
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1
|
||||
diffuse_uv += diffuseTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_SCALE == 1
|
||||
diffuse_uv *= diffuseTexture_Scale;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
mediump vec3 a_bitangent = cross(vertex_normal_skinned, vertex_tangent_skinned);
|
||||
tangent_to_view_matrix[0] = vec3(model_view_inverse_transpose_matrix * vec4(vertex_tangent_skinned, 1.0));
|
||||
tangent_to_view_matrix[1] = vec3(model_view_inverse_transpose_matrix * vec4(a_bitangent, 1.0));
|
||||
tangent_to_view_matrix[2] = vec3(model_view_inverse_transpose_matrix * vec4(vertex_normal_skinned, 1.0));
|
||||
#else
|
||||
normal = vertex_normal_skinned;
|
||||
#endif
|
||||
#else
|
||||
|
||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
||||
#else
|
||||
// Calculate reflection vector as I - 2.0 * dot(N, I) * N
|
||||
mediump vec3 eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
||||
mediump vec3 incidenceVec = -eyeVec;
|
||||
reflectionVec = mat3(model_matrix) * (incidenceVec - 2.0 * dot(vertex_normal_skinned, incidenceVec) * vertex_normal_skinned);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
// Pass shadow UV co-ordinates
|
||||
lightmap_uv = vertex_lightmap_uv.st;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
// Scaled and translated specular map UV's
|
||||
#if HAS_SPEC_MAP_OFFSET == 1 || HAS_SPEC_MAP_SCALE == 1
|
||||
spec_uv = texCoord;
|
||||
#if HAS_SPEC_MAP_OFFSET == 1
|
||||
spec_uv += specularTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_SPEC_MAP_SCALE == 1
|
||||
spec_uv *= specularTexture_Scale;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Scaled and translated reflection map UV's
|
||||
#if HAS_REFLECTION_MAP_OFFSET == 1 || HAS_REFLECTION_MAP_SCALE == 1
|
||||
reflection_uv = texCoord;
|
||||
#if HAS_REFLECTION_MAP_OFFSET == 1
|
||||
reflection_uv += reflectionTexture_Offset;
|
||||
#endif
|
||||
|
||||
#if HAS_REFLECTION_MAP_SCALE == 1
|
||||
reflection_uv *= reflectionTexture_Scale;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if SHADOW_QUALITY >= 1
|
||||
shadowMapCoord1 = shadow_mvp1 * vec4(vertex_position_skinned,1.0);
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2
|
||||
shadowMapCoord2 = shadow_mvp2 * vec4(vertex_position_skinned,1.0);
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 3
|
||||
shadowMapCoord3 = shadow_mvp3 * vec4(vertex_position_skinned,1.0);
|
||||
#endif
|
||||
|
||||
// ----------- Directional Light (Sun) -----------
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// ----- Calculate per-pixel lighting in tangent space, for normal mapping ------
|
||||
mediump vec3 a_bitangent = cross(vertex_normal_skinned, vertex_tangent_skinned);
|
||||
#if HAS_REFLECTION_CUBE_MAP == 0
|
||||
// The cube map reflections also require an eyeVec as a varying attribute when normal mapping, so only re-calculate here when needed
|
||||
mediump vec3 eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
||||
#else
|
||||
tangent_to_world_matrix[0] = vec3(model_inverse_transpose_matrix * vec4(vertex_tangent_skinned, 1.0));
|
||||
tangent_to_world_matrix[1] = vec3(model_inverse_transpose_matrix * vec4(a_bitangent, 1.0));
|
||||
tangent_to_world_matrix[2] = vec3(model_inverse_transpose_matrix * vec4(vertex_normal_skinned, 1.0));
|
||||
#endif
|
||||
|
||||
lightVec = normalize(vec3(dot(light_direction_model_space, vertex_tangent_skinned), dot(light_direction_model_space, a_bitangent), dot(light_direction_model_space, vertex_normal_skinned)));
|
||||
halfVec = normalize(vec3(dot(eyeVec, vertex_tangent_skinned), dot(eyeVec, a_bitangent), dot(eyeVec, vertex_normal_skinned)));
|
||||
halfVec = normalize(halfVec + lightVec); // Normalizing anyways, no need to divide by 2
|
||||
#else
|
||||
// ------ Calculate per-pixel lighting without normal mapping ------
|
||||
normal = vertex_normal_skinned;
|
||||
lightVec = light_direction_model_space;
|
||||
halfVec = normalize((normalize(camera_position_model_space - vertex_position_skinned) + lightVec)); // Normalizing anyways, no need to divide by 2
|
||||
#endif
|
||||
#else
|
||||
|
||||
// ------ Calculate per-vertex lighting ------
|
||||
mediump vec3 halfVec = normalize((normalize(camera_position_model_space - vertex_position_skinned) + light_direction_model_space)); // Normalizing anyways, no need to divide by 2
|
||||
lamberFactor = max(0.0,dot(light_direction_model_space, vertex_normal_skinned));
|
||||
specularFactor = max(0.0,pow(dot(halfVec,vertex_normal_skinned), material_shininess));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
192
KREngine/KREngine/Shaders/PostShader_osx.fsh
Normal file
192
KREngine/KREngine/Shaders/PostShader_osx.fsh
Normal file
@@ -0,0 +1,192 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#version 120
|
||||
#define lowp
|
||||
#define mediump
|
||||
#define highp
|
||||
|
||||
#define ENABLE_VIDEO_BG 0
|
||||
#define PIXEL_SHIFT_1 0.001
|
||||
#define PIXEL_SHIFT_2 0.002
|
||||
#define PIXEL_SHIFT_3 0.003
|
||||
#define PIXEL_SHIFT_4 0.004
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
precision lowp float;
|
||||
|
||||
#if ENABLE_VIDEO_BG == 0
|
||||
uniform lowp sampler2D videoFrame;
|
||||
#endif
|
||||
|
||||
uniform lowp sampler2D renderFrame;
|
||||
uniform lowp sampler2D depthFrame;
|
||||
|
||||
#if VOLUMETRIC_ENVIRONMENT_DOWNSAMPLED == 1
|
||||
uniform lowp sampler2D volumetricEnvironmentFrame;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
lowp vec4 renderColor = texture2D(renderFrame, textureCoordinate);
|
||||
#if DOF_QUALITY > 0 || ENABLE_FLASH == 1
|
||||
mediump float depth = texture2D(depthFrame, textureCoordinate).r;
|
||||
#endif
|
||||
mediump vec4 pixelColor = renderColor;
|
||||
|
||||
|
||||
#if DOF_QUALITY == 2
|
||||
|
||||
// Render high quality circle of confusion
|
||||
// __XXX__
|
||||
// _XXXXX_
|
||||
// _XXXXX_
|
||||
// _XXXXX_
|
||||
// __XXX__
|
||||
mediump float cf1 = PIXEL_SHIFT_1;
|
||||
mediump float cf2 = PIXEL_SHIFT_2;
|
||||
|
||||
mediump float bx1 = textureCoordinate.s + cf1;
|
||||
mediump float bx2 = textureCoordinate.s + cf2;
|
||||
mediump float bxm1 = textureCoordinate.s - cf1;
|
||||
mediump float bxm2 = textureCoordinate.s - cf2;
|
||||
|
||||
mediump float by1 = textureCoordinate.t + cf1;
|
||||
mediump float by2 = textureCoordinate.t + cf2;
|
||||
mediump float bym1 = textureCoordinate.t - cf1;
|
||||
mediump float bym2 = textureCoordinate.t - cf2;
|
||||
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1, textureCoordinate.t));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm1, textureCoordinate.t));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx2, textureCoordinate.t));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm2, textureCoordinate.t));
|
||||
|
||||
pixelColor += texture2D(renderFrame, vec2(textureCoordinate.s, by1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1, by1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm1, by1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx2, by1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm2, by1));
|
||||
|
||||
pixelColor += texture2D(renderFrame, vec2(textureCoordinate.s, by2));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1, by2));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm1, by2));
|
||||
|
||||
pixelColor += texture2D(renderFrame, vec2(textureCoordinate.s,bym1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1,bym1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm1,bym1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx2,bym1));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm2,bym1));
|
||||
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1, bym2));
|
||||
pixelColor += texture2D(renderFrame, vec2(bx1, bym2));
|
||||
pixelColor += texture2D(renderFrame, vec2(bxm1, bym2));
|
||||
pixelColor /= 21.0;
|
||||
|
||||
#endif
|
||||
// DOF_QUALITY == 2
|
||||
|
||||
#if DOF_QUALITY == 1
|
||||
|
||||
// Render low quality circle of confusion
|
||||
// ___X___
|
||||
// __XXX__
|
||||
// _XXXXX_
|
||||
// __XXX__
|
||||
// ___X___
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(0, -PIXEL_SHIFT_2));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(-PIXEL_SHIFT_1, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(0, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(+PIXEL_SHIFT_1, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(-PIXEL_SHIFT_2, 0));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(-PIXEL_SHIFT_1, 0));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(+PIXEL_SHIFT_1, 0));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(+PIXEL_SHIFT_2, 0));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(-PIXEL_SHIFT_1, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(0, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(+PIXEL_SHIFT_1, -PIXEL_SHIFT_1));
|
||||
pixelColor += texture2D(renderFrame, textureCoordinate + vec2(0, -PIXEL_SHIFT_2));
|
||||
pixelColor /= 13.0;
|
||||
|
||||
#endif
|
||||
// DOF_QUALITY == 1
|
||||
|
||||
#if DOF_QUALITY > 0
|
||||
mediump float focusDepth = texture2D(depthFrame, vec2(0.5, 0.5)).r;
|
||||
mediump float blurAmount = clamp((depth - DOF_DEPTH - focusDepth) / DOF_FALLOFF, 0.0, 1.0);
|
||||
pixelColor = pixelColor * blurAmount + renderColor * (1.0 - blurAmount);
|
||||
#endif
|
||||
|
||||
// ---- DEPTH_OF_FIELD END ----
|
||||
|
||||
|
||||
|
||||
|
||||
// ---- NIGHT_TIME START ----
|
||||
#if ENABLE_FLASH == 1
|
||||
// Un-comment to enable night time / flash effect
|
||||
pixelColor *= vec4(vec3(1.0 - clamp((depth - FLASH_DEPTH) / FLASH_FALLOFF, 0.0, 1.0)) * FLASH_INTENSITY, 1.0);
|
||||
//pixelColor *= vec4(vec3(clamp(1.0 / (depth - FLASH_DEPTH) * FLASH_FALLOFF, 0.0, 1.0) * FLASH_INTENSITY), 1.0);
|
||||
|
||||
#endif
|
||||
// ---- NIGHT_TIME END ----
|
||||
|
||||
// ---- VIDEO_BG START ----
|
||||
|
||||
/*
|
||||
// Overlay video background
|
||||
if(depth == 1.0) {
|
||||
//FILTER COLOR BY CALCULATING PER PIXEL DOT PRODUCT
|
||||
pixelColor = vec4(dot(vec3(texture2D(videoFrame, textureCoordinate)), vec3(.222, .707, .071)));
|
||||
}
|
||||
*/
|
||||
|
||||
// ---- VIDEO_BG END ----
|
||||
|
||||
#if VOLUMETRIC_ENVIRONMENT_DOWNSAMPLED == 1
|
||||
pixelColor += texture2D(volumetricEnvironmentFrame, textureCoordinate);
|
||||
#endif
|
||||
|
||||
|
||||
// ---- VIGNETTE START ----
|
||||
|
||||
// Render vignette effect
|
||||
|
||||
#if ENABLE_VIGNETTE
|
||||
pixelColor *= vec4(vec3(clamp(1.0 - (distance(textureCoordinate, vec2(0.5, 0.5)) - VIGNETTE_RADIUS) / VIGNETTE_FALLOFF, 0.0, 1.0)), 1.0);
|
||||
#endif
|
||||
// ---- VIGNETTE END ----
|
||||
|
||||
gl_FragColor = pixelColor;
|
||||
|
||||
|
||||
//PASSTHROUGH STATEMENT
|
||||
// gl_FragColor = texture2D(depthFrame, textureCoordinate);
|
||||
|
||||
//gl_FragColor = vec4(vec3(blurAmount), 1.0);
|
||||
|
||||
}
|
||||
37
KREngine/KREngine/Shaders/PostShader_osx.vsh
Normal file
37
KREngine/KREngine/Shaders/PostShader_osx.vsh
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
attribute lowp vec4 vertex_uv;
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vertex_position;
|
||||
textureCoordinate = vertex_uv.xy;
|
||||
}
|
||||
33
KREngine/KREngine/Shaders/ShadowShader_osx.fsh
Normal file
33
KREngine/KREngine/Shaders/ShadowShader_osx.fsh
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
//varying mediump vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
47
KREngine/KREngine/Shaders/ShadowShader_osx.vsh
Normal file
47
KREngine/KREngine/Shaders/ShadowShader_osx.vsh
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#define SHADOW_BIAS 0.01
|
||||
|
||||
|
||||
attribute highp vec4 vertex_position;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
// Transform position
|
||||
/*
|
||||
position = shadow_mvp1 * vec4(vertex_position,1.0);
|
||||
*/
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
gl_Position.z += SHADOW_BIAS;
|
||||
/*
|
||||
// Pass UV co-ordinates
|
||||
texCoord = vertex_uv.st;
|
||||
*/
|
||||
|
||||
}
|
||||
35
KREngine/KREngine/Shaders/debug_font_osx.fsh
Normal file
35
KREngine/KREngine/Shaders/debug_font_osx.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
|
||||
uniform sampler2D diffuseTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(diffuseTexture, textureCoordinate);
|
||||
}
|
||||
38
KREngine/KREngine/Shaders/debug_font_osx.vsh
Normal file
38
KREngine/KREngine/Shaders/debug_font_osx.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
attribute lowp vec4 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
textureCoordinate = vertex_uv.xy;
|
||||
}
|
||||
43
KREngine/KREngine/Shaders/dust_particle_osx.fsh
Normal file
43
KREngine/KREngine/Shaders/dust_particle_osx.fsh
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// dust_particle.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#extension GL_EXT_shadow_samplers : require
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
uniform sampler2DShadow shadowTexture1;
|
||||
uniform mediump vec3 light_color;
|
||||
varying lowp float intensity_modulate;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1) * max(1.0 - texCoord.x*texCoord.x-texCoord.y*texCoord.y, 0.0) * intensity_modulate;
|
||||
}
|
||||
57
KREngine/KREngine/Shaders/dust_particle_osx.vsh
Normal file
57
KREngine/KREngine/Shaders/dust_particle_osx.vsh
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// dust_particle.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute mediump vec2 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
uniform mediump vec4 viewport;
|
||||
uniform mediump float flare_size;
|
||||
attribute vec4 vertex_position;
|
||||
uniform highp vec3 particle_origin;
|
||||
|
||||
uniform highp mat4 shadow_mvp1;
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform highp float time_absolute;
|
||||
varying lowp float intensity_modulate;
|
||||
|
||||
void main() {
|
||||
highp vec4 offset_center = vertex_position + vec4(particle_origin, 0.0);
|
||||
offset_center.xyz += vec3(sin((time_absolute + vertex_position.x * 100.0) * 0.05), sin((time_absolute + vertex_position.y * 100.0) * 0.07), sin((time_absolute + vertex_position.z * 100.0) * 0.03)) * 0.05;
|
||||
offset_center = vec4(mod(offset_center.x + 1.0, 2.0) - 1.0, mod(offset_center.y + 1.0, 2.0) - 1.0, mod(offset_center.z + 1.0, 2.0) - 1.0, 1.0);
|
||||
highp vec4 particle_center = mvp_matrix * offset_center;
|
||||
texCoord = vertex_uv * 3.46410161513775; // 3.46410161513775 = 2 * sqrt(3); 1 / (2 * sqrt(3)) is the radius of a circle encompased by a equilateral triangle with a side length of 1.
|
||||
gl_Position = particle_center + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||
|
||||
shadowMapCoord1 = shadow_mvp1 * offset_center;
|
||||
|
||||
intensity_modulate = sin(time_absolute + mod(vertex_position.x * 100.0, 6.28318530717959)) * 0.5 + 0.5;
|
||||
}
|
||||
37
KREngine/KREngine/Shaders/flare_osx.fsh
Normal file
37
KREngine/KREngine/Shaders/flare_osx.fsh
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// flare.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform sampler2D diffuseTexture;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
||||
}
|
||||
42
KREngine/KREngine/Shaders/flare_osx.vsh
Normal file
42
KREngine/KREngine/Shaders/flare_osx.vsh
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// flare.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute mediump vec2 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
uniform mediump vec4 viewport;
|
||||
uniform mediump float flare_size;
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
texCoord = vertex_uv;
|
||||
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||
}
|
||||
BIN
KREngine/KREngine/Shaders/font.tga
Normal file
BIN
KREngine/KREngine/Shaders/font.tga
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 192 KiB |
60
KREngine/KREngine/Shaders/light_directional_osx.fsh
Normal file
60
KREngine/KREngine/Shaders/light_directional_osx.fsh
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
|
||||
uniform sampler2D gbuffer_frame;
|
||||
uniform sampler2D gbuffer_depth;
|
||||
|
||||
uniform mediump vec3 light_direction_view_space; // Must be normalized and converted to view space before entering shader
|
||||
uniform lowp vec3 light_color;
|
||||
uniform highp float light_intensity;
|
||||
uniform mediump vec4 viewport;
|
||||
|
||||
void main()
|
||||
{
|
||||
lowp vec2 gbuffer_uv = vec2(gl_FragCoord.xy / viewport.zw); // FINDME, TODO - Dependent Texture Read adding latency, due to calculation of texture UV within fragment -- move to vertex shader?
|
||||
lowp vec4 gbuffer_sample = texture2D(gbuffer_frame, gbuffer_uv);
|
||||
|
||||
mediump vec3 gbuffer_normal = normalize(2.0 * gbuffer_sample.rgb - 1.0);
|
||||
mediump float gbuffer_specular_exponent = gbuffer_sample.a * 100.0;
|
||||
|
||||
mediump vec3 view_space_vertex_position = vec3(
|
||||
((2.0 * gl_FragCoord.xy) - (2.0 * viewport.xy)) / (viewport.zw) - 1.0,
|
||||
(2.0 * -texture2D(gbuffer_depth, gbuffer_uv).r - gl_DepthRange.near - gl_DepthRange.far) / (gl_DepthRange.far - gl_DepthRange.near)
|
||||
);
|
||||
|
||||
//mediump float lamberFactor = max(0.0,dot(light_direction_view_space, gbuffer_normal)) * 0.2;
|
||||
mediump float lamberFactor = dot(light_direction_view_space, gbuffer_normal) * 0.2;
|
||||
|
||||
mediump float specularFactor = 0.0;
|
||||
|
||||
mediump vec3 halfVec = normalize((normalize(- view_space_vertex_position) + light_direction_view_space)); // Normalizing anyways, no need to divide by 2
|
||||
specularFactor = pow(dot(halfVec,gbuffer_normal), gbuffer_specular_exponent);
|
||||
|
||||
|
||||
gl_FragColor = vec4(light_color * lamberFactor, specularFactor) * light_intensity;
|
||||
}
|
||||
33
KREngine/KREngine/Shaders/light_directional_osx.vsh
Normal file
33
KREngine/KREngine/Shaders/light_directional_osx.vsh
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vertex_position;
|
||||
}
|
||||
73
KREngine/KREngine/Shaders/light_point_inside_osx.fsh
Normal file
73
KREngine/KREngine/Shaders/light_point_inside_osx.fsh
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
|
||||
uniform sampler2D gbuffer_frame;
|
||||
uniform sampler2D gbuffer_depth;
|
||||
|
||||
uniform lowp vec3 light_color;
|
||||
uniform highp float light_intensity;
|
||||
uniform highp float light_decay_start;
|
||||
uniform highp float light_cutoff;
|
||||
uniform mediump vec4 viewport;
|
||||
|
||||
uniform highp mat4 inv_projection_matrix;
|
||||
|
||||
uniform highp vec3 view_space_model_origin;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
lowp vec2 gbuffer_uv = vec2(gl_FragCoord.xy / viewport.zw); // FINDME, TODO - Dependent Texture Read adding latency, due to calculation of texture UV within fragment -- move to vertex shader?
|
||||
lowp vec4 gbuffer_sample = texture2D(gbuffer_frame, gbuffer_uv);
|
||||
|
||||
mediump vec3 gbuffer_normal = normalize(2.0 * gbuffer_sample.rgb - 1.0);
|
||||
mediump float gbuffer_specular_exponent = gbuffer_sample.a * 100.0;
|
||||
|
||||
mediump vec4 clip_space_vertex_position = vec4(
|
||||
gl_FragCoord.xy / viewport.zw * 2.0 - 1.0,
|
||||
texture2D(gbuffer_depth, gbuffer_uv).r * 2.0 - 1.0,
|
||||
1.0
|
||||
);
|
||||
|
||||
|
||||
mediump vec4 view_space_vertex_position = inv_projection_matrix * clip_space_vertex_position;
|
||||
view_space_vertex_position.xyz /= view_space_vertex_position.w;
|
||||
|
||||
mediump float light_distance = max(0.0, distance(view_space_model_origin.xyz, view_space_vertex_position.xyz) - light_decay_start);
|
||||
mediump float light_attenuation = (light_intensity / ((light_distance + 1.0) * (light_distance + 1.0)) - light_cutoff) / (1.0 - light_cutoff);
|
||||
mediump vec3 light_vec = normalize(view_space_model_origin.xyz - view_space_vertex_position.xyz);
|
||||
mediump float lamberFactor = dot(light_vec, gbuffer_normal) * 0.2;
|
||||
|
||||
mediump float specularFactor = 0.0;
|
||||
//if(gbuffer_specular_exponent > 0.0) {
|
||||
mediump vec3 halfVec = normalize((normalize(- view_space_vertex_position.xyz) + light_vec));
|
||||
specularFactor = pow(dot(halfVec,gbuffer_normal), gbuffer_specular_exponent);
|
||||
//}
|
||||
|
||||
gl_FragColor = vec4(light_color * lamberFactor, specularFactor) * light_attenuation;
|
||||
}
|
||||
33
KREngine/KREngine/Shaders/light_point_inside_osx.vsh
Normal file
33
KREngine/KREngine/Shaders/light_point_inside_osx.vsh
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vertex_position;
|
||||
}
|
||||
73
KREngine/KREngine/Shaders/light_point_osx.fsh
Normal file
73
KREngine/KREngine/Shaders/light_point_osx.fsh
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
|
||||
uniform sampler2D gbuffer_frame;
|
||||
uniform sampler2D gbuffer_depth;
|
||||
|
||||
uniform lowp vec3 light_color;
|
||||
uniform highp float light_intensity;
|
||||
uniform highp float light_decay_start;
|
||||
uniform highp float light_cutoff;
|
||||
uniform mediump vec4 viewport;
|
||||
|
||||
uniform highp mat4 inv_projection_matrix;
|
||||
|
||||
uniform highp vec3 view_space_model_origin; // For point lights, this is the position of the light
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
lowp vec2 gbuffer_uv = vec2(gl_FragCoord.xy / viewport.zw); // FINDME, TODO - Dependent Texture Read adding latency, due to calculation of texture UV within fragment -- move to vertex shader?
|
||||
lowp vec4 gbuffer_sample = texture2D(gbuffer_frame, gbuffer_uv);
|
||||
|
||||
mediump vec3 gbuffer_normal = normalize(2.0 * gbuffer_sample.rgb - 1.0);
|
||||
mediump float gbuffer_specular_exponent = gbuffer_sample.a * 100.0;
|
||||
|
||||
mediump vec4 clip_space_vertex_position = vec4(
|
||||
gl_FragCoord.xy / viewport.zw * 2.0 - 1.0,
|
||||
texture2D(gbuffer_depth, gbuffer_uv).r * 2.0 - 1.0,
|
||||
1.0
|
||||
);
|
||||
|
||||
|
||||
mediump vec4 view_space_vertex_position = inv_projection_matrix * clip_space_vertex_position;
|
||||
view_space_vertex_position.xyz /= view_space_vertex_position.w;
|
||||
|
||||
mediump float light_distance = max(0.0, distance(view_space_model_origin.xyz, view_space_vertex_position.xyz) - light_decay_start);
|
||||
mediump float light_attenuation = (light_intensity / ((light_distance + 1.0) * (light_distance + 1.0)) - light_cutoff) / (1.0 - light_cutoff);
|
||||
mediump vec3 light_vec = normalize(view_space_model_origin.xyz - view_space_vertex_position.xyz);
|
||||
mediump float lamberFactor = dot(light_vec, gbuffer_normal) * 0.2;
|
||||
|
||||
mediump float specularFactor = 0.0;
|
||||
//if(gbuffer_specular_exponent > 0.0) {
|
||||
mediump vec3 halfVec = normalize((normalize(- view_space_vertex_position.xyz) + light_vec));
|
||||
specularFactor = pow(dot(halfVec,gbuffer_normal), gbuffer_specular_exponent);
|
||||
//}
|
||||
|
||||
gl_FragColor = vec4(light_color * lamberFactor, specularFactor) * light_attenuation;
|
||||
}
|
||||
35
KREngine/KREngine/Shaders/light_point_osx.vsh
Normal file
35
KREngine/KREngine/Shaders/light_point_osx.vsh
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
gl_Position.z = max(gl_Position.z / gl_Position.w, 0.00) * gl_Position.w;
|
||||
}
|
||||
35
KREngine/KREngine/Shaders/occlusion_test_osx.fsh
Normal file
35
KREngine/KREngine/Shaders/occlusion_test_osx.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// flare.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
void main() {
|
||||
//gl_FragColor = vec4(0.00, 0.00, 0.00, 0.00);
|
||||
gl_FragColor = vec4(0.00, 0.00, 0.00, 0.00);
|
||||
}
|
||||
34
KREngine/KREngine/Shaders/occlusion_test_osx.vsh
Normal file
34
KREngine/KREngine/Shaders/occlusion_test_osx.vsh
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
}
|
||||
35
KREngine/KREngine/Shaders/simple_blit_osx.fsh
Normal file
35
KREngine/KREngine/Shaders/simple_blit_osx.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
|
||||
uniform sampler2D diffuseTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(diffuseTexture, textureCoordinate);
|
||||
}
|
||||
38
KREngine/KREngine/Shaders/simple_blit_osx.vsh
Normal file
38
KREngine/KREngine/Shaders/simple_blit_osx.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 textureCoordinate;
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
attribute lowp vec4 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
textureCoordinate = vertex_uv.xy;
|
||||
}
|
||||
38
KREngine/KREngine/Shaders/sky_box_osx.fsh
Normal file
38
KREngine/KREngine/Shaders/sky_box_osx.fsh
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// sky_box.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
uniform samplerCube diffuseTexture;
|
||||
|
||||
varying mediump vec3 texCoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = textureCube(diffuseTexture, normalize(texCoord));
|
||||
}
|
||||
49
KREngine/KREngine/Shaders/sky_box_osx.vsh
Normal file
49
KREngine/KREngine/Shaders/sky_box_osx.vsh
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// sky_box.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
//attribute lowp vec4 vertex_uv;
|
||||
//
|
||||
//varying mediump vec2 textureCoordinate;
|
||||
|
||||
varying mediump vec3 texCoord;
|
||||
uniform highp mat4 inv_mvp_matrix_no_translate; // Inverse of the model-view-projection matrix, without view translation component
|
||||
uniform mediump vec4 viewport;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(vertex_position.xy, 1.0, 1.0);
|
||||
|
||||
vec4 t = inv_mvp_matrix_no_translate * vec4(vertex_position.xy, 1.0, 1.0);
|
||||
t /= t.w;
|
||||
texCoord = vec3(t);
|
||||
}
|
||||
35
KREngine/KREngine/Shaders/visualize_overlay_osx.fsh
Normal file
35
KREngine/KREngine/Shaders/visualize_overlay_osx.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// visualize_overlay.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(0.0, 0.05, 0.05, 0.0);
|
||||
}
|
||||
|
||||
38
KREngine/KREngine/Shaders/visualize_overlay_osx.vsh
Normal file
38
KREngine/KREngine/Shaders/visualize_overlay_osx.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// visualize_overlay.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute vec4 vertex_position;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
}
|
||||
41
KREngine/KREngine/Shaders/volumetric_fog_downsampled_osx.fsh
Normal file
41
KREngine/KREngine/Shaders/volumetric_fog_downsampled_osx.fsh
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#extension GL_EXT_shadow_samplers : require
|
||||
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
uniform sampler2DShadow shadowTexture1;
|
||||
uniform lowp sampler2D depthFrame;
|
||||
uniform mediump vec4 viewport;
|
||||
uniform mediump vec3 light_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(gl_FragCoord.z > texture2D(depthFrame, vec2(gl_FragCoord.xy / viewport.zw)).r) discard;
|
||||
|
||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1);
|
||||
}
|
||||
50
KREngine/KREngine/Shaders/volumetric_fog_downsampled_osx.vsh
Normal file
50
KREngine/KREngine/Shaders/volumetric_fog_downsampled_osx.vsh
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute highp vec4 vertex_position;
|
||||
uniform highp mat4 inv_mvp_matrix;
|
||||
|
||||
uniform highp vec2 slice_depth_scale; // First component is the depth for the nearest plane, in view space. Second component is the distance between planes, in view space
|
||||
|
||||
uniform highp mat4 shadow_mvp1;
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
|
||||
uniform highp mat4 projection_matrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec4 d = projection_matrix * vec4(0.0, 0.0, slice_depth_scale.x + vertex_position.z * slice_depth_scale.y, 1.0);
|
||||
d /= d.w;
|
||||
gl_Position = vec4(vertex_position.x, vertex_position.y, d.z, 1.0);
|
||||
|
||||
|
||||
shadowMapCoord1 = inv_mvp_matrix * gl_Position;
|
||||
shadowMapCoord1 /= shadowMapCoord1.w;
|
||||
shadowMapCoord1.w = 1.0;
|
||||
shadowMapCoord1 = shadow_mvp1 * shadowMapCoord1;
|
||||
|
||||
}
|
||||
37
KREngine/KREngine/Shaders/volumetric_fog_osx.fsh
Normal file
37
KREngine/KREngine/Shaders/volumetric_fog_osx.fsh
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#extension GL_EXT_shadow_samplers : require
|
||||
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
uniform sampler2DShadow shadowTexture1;
|
||||
uniform mediump vec3 light_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(light_color, 1.0) * shadow2DProjEXT(shadowTexture1, shadowMapCoord1);
|
||||
}
|
||||
51
KREngine/KREngine/Shaders/volumetric_fog_osx.vsh
Normal file
51
KREngine/KREngine/Shaders/volumetric_fog_osx.vsh
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute highp vec4 vertex_position;
|
||||
uniform highp mat4 inv_mvp_matrix;
|
||||
|
||||
uniform highp vec2 slice_depth_scale; // First component is the depth for the nearest plane, in view space. Second component is the distance between planes, in view space
|
||||
|
||||
uniform highp mat4 shadow_mvp1;
|
||||
varying mediump vec4 shadowMapCoord1;
|
||||
|
||||
uniform highp mat4 projection_matrix;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
highp vec4 d = projection_matrix * vec4(0.0, 0.0, slice_depth_scale.x + vertex_position.z * slice_depth_scale.y, 1.0);
|
||||
d /= d.w;
|
||||
gl_Position = vec4(vertex_position.x, vertex_position.y, d.z, 1.0);
|
||||
|
||||
|
||||
shadowMapCoord1 = inv_mvp_matrix * gl_Position;
|
||||
shadowMapCoord1 /= shadowMapCoord1.w;
|
||||
shadowMapCoord1.w = 1.0;
|
||||
shadowMapCoord1 = shadow_mvp1 * shadowMapCoord1;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user