Skip to content

Commit

Permalink
First iteration of the Android port.
Browse files Browse the repository at this point in the history
  • Loading branch information
pboechat committed Nov 12, 2023
1 parent e54db69 commit bcc9700
Show file tree
Hide file tree
Showing 142 changed files with 6,721 additions and 4,810 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.20)

project(FastCG)

Expand Down
15 changes: 11 additions & 4 deletions FastCG/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.20)

if(FASTCG_GRAPHICS_SYSTEM STREQUAL "Vulkan")
find_package(Vulkan REQUIRED)
Expand Down Expand Up @@ -40,12 +40,19 @@ set(SHADERS ${FORWARD_SHADERS} ${DEFERRED_SHADERS} ${GENERAL_SHADERS})
if(FASTCG_PLATFORM STREQUAL "Linux")
set(PLATFORM_INCLUDE_DIRS ${messagebox_x11_INCLUDE_DIRS} ${X11_INCLUDE} ${X11_Xrender_INCLUDE_PATH})
set(PLATFORM_LIBRARIES ${messagebox_x11_LIBRARIES} ${X11_LIBRARIES} ${X11_Xrender_LIB})
elseif(FASTCG_PLATFORM STREQUAL "Android")
set(PLATFORM_INCLUDE_DIRS ${android_native_app_glue_INCLUDE_DIRS})
set(PLATFORM_LIBRARIES android log android_native_app_glue)
endif()

if(FASTCG_GRAPHICS_SYSTEM STREQUAL "OpenGL")
set(GRAPHICS_SYSTEM_INCLUDE_DIRS ${glew_INCLUDE_DIRS})
set(GRAPHICS_SYSTEM_LIBRARIES ${glew_LIBRARIES})
set(GRAPHICS_SYSTEM_DEFINES -DGLEW_STATIC)
if(FASTCG_PLATFORM STREQUAL "Android")
set(GRAPHICS_SYSTEM_LIBRARIES EGL GLESv3)
else()
set(GRAPHICS_SYSTEM_INCLUDE_DIRS ${glew_INCLUDE_DIRS})
set(GRAPHICS_SYSTEM_LIBRARIES ${glew_LIBRARIES})
set(GRAPHICS_SYSTEM_DEFINES -DGLEW_STATIC)
endif()
elseif(FASTCG_GRAPHICS_SYSTEM STREQUAL "Vulkan")
set(GRAPHICS_SYSTEM_INCLUDE_DIRS ${Vulkan_INCLUDE_DIRS} ${VulkanMemoryAllocator_INCLUDE_DIRS})
set(GRAPHICS_SYSTEM_LIBRARIES ${Vulkan_LIBRARIES} ${VulkanMemoryAllocator_LIBRARIES} spirv-cross-core)
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/ImGui.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"

layout(BINDING_0_1) uniform sampler2D uColorMap;
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/ImGui.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "ImGui.glsl"

Expand Down
4 changes: 2 additions & 2 deletions FastCG/assets/shaders/Lighting.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ vec4 Phong(vec4 diffuse, vec4 specular, float shininess, vec3 lightDirection, ve
vec4 diffuseContribution = uLight0DiffuseColor * uLight0Intensity * diffuse * diffuseAttenuation;

vec3 reflectionDirection = normalize(reflect(-lightDirection, normal));
float specularAttenuation = max(pow(max(dot(reflectionDirection, viewerDirection), 0.0), shininess), 0);
float specularAttenuation = max(pow(max(dot(reflectionDirection, viewerDirection), 0.0), shininess), 0.0);
vec4 specularContribution = uLight0SpecularColor * uLight0Intensity * specular * specularAttenuation;

return DistanceAttenuation(worldPosition) * (uAmbientColor + diffuseContribution + specularContribution) * GetShadow(uPCSSData, uShadowMap, worldPosition) * GetAmbientOcclusion(uAmbientOcclusionMap, screenCoords);
Expand All @@ -71,7 +71,7 @@ vec4 BlinnPhong(vec4 diffuse, vec4 specular, float shininess, vec3 lightDirectio
vec4 diffuseContribution = uLight0DiffuseColor * uLight0Intensity * diffuse * diffuseAttenuation;

vec3 halfwayVector = normalize(lightDirection + viewerDirection);
float specularAttenuation = max(pow(max(dot(halfwayVector, normal), 0.0), shininess), 0);
float specularAttenuation = max(pow(max(dot(halfwayVector, normal), 0.0), shininess), 0.0);
vec4 specularContribution = uLight0SpecularColor * uLight0Intensity * specular * specularAttenuation;

return DistanceAttenuation(worldPosition) * (uAmbientColor + diffuseContribution + specularContribution) * GetShadow(uPCSSData, uShadowMap, worldPosition) * GetAmbientOcclusion(uAmbientOcclusionMap, screenCoords);
Expand Down
6 changes: 3 additions & 3 deletions FastCG/assets/shaders/Noise.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef FASTCG_NOISE_GLSL
#define FASTCG_NOISE_GLSL

const vec2 poissonDisk[16] = {
const vec2 poissonDisk[16] = vec2[](
vec2( -0.94201624, -0.39906216 ),
vec2( 0.94558609, -0.76890725 ),
vec2( -0.094184101, -0.92938870 ),
Expand All @@ -18,11 +18,11 @@ const vec2 poissonDisk[16] = {
vec2( -0.81409955, 0.91437590 ),
vec2( 0.19984126, 0.78641367 ),
vec2( 0.14383161, -0.14100790 )
};
);

vec2 PoissonDiskSample(float d)
{
return poissonDisk[int(d * 16)];
return poissonDisk[int(d * 16.0)];
}

#endif
2 changes: 1 addition & 1 deletion FastCG/assets/shaders/Shadow.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vec3 GetShadowMapCoordinates(ShadowMapData shadowMapData, vec3 worldPosition)
{
vec4 clipPos = shadowMapData.viewProjection * vec4(worldPosition, 1);
vec3 ndc = clipPos.xyz / clipPos.w;
#if VULKAN
#ifdef VULKAN
return vec3(ndc.x * 0.5 + 0.5,
ndc.y * -0.5 + 0.5, // flip y
ndc.z); // z already in [0, 1]
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/BumpedDiffuse.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Material.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/BumpedDiffuse.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/BumpedSpecular.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Material.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/BumpedSpecular.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/Diffuse.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Material.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/Diffuse.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/DirectionalLightPass.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
10 changes: 2 additions & 8 deletions FastCG/assets/shaders/deferred/DirectionalLightPass.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"

layout(location = 0) in vec3 iPosition;
Expand All @@ -15,8 +9,8 @@ layout(location = 0) out vec2 vUV;
void main()
{
vUV = iUV;
#if VULKAN
vUV.y = 1 - vUV.y;
#ifdef VULKAN
vUV.y = 1.0 - vUV.y;
#endif
gl_Position = vec4(iPosition, 1);
}
4 changes: 2 additions & 2 deletions FastCG/assets/shaders/deferred/FastCG.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vec3 GetViewPositionFromScreenPositionAndDepth(mat4 inverseProjection, vec2 scre
{
vec3 ndc;
ndc.x = 2.0 * (screenPos.x / screenSize.x) - 1.0;
#if VULKAN
#ifdef VULKAN
ndc.y = 2.0 * ((screenSize.y - screenPos.y) / screenSize.y) - 1.0;
// FIXME:
ndc.z = depth; // [0, 1]
Expand All @@ -32,7 +32,7 @@ vec3 GetViewPositionFromScreenPositionAndDepth(mat4 inverseProjection, vec2 scre

bool HasBump(vec4 tangent, vec4 extraData)
{
return extraData.x != 0 && extraData.y != 0 && extraData.z != 0;
return extraData.x != 0.0 && extraData.y != 0.0 && extraData.z != 0.0;
}

#endif
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/PointLightPass.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/PointLightPass.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/SolidColor.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Material.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/SolidColor.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/Specular.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Material.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/Specular.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
2 changes: 0 additions & 2 deletions FastCG/assets/shaders/deferred/StencilPass.frag
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#version 430 core

void main()
{
}
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/deferred/StencilPass.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Instance.glsl"

Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/forward/BumpedDiffuse.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/forward/BumpedDiffuse.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Instance.glsl"
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/forward/BumpedSpecular.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
8 changes: 1 addition & 7 deletions FastCG/assets/shaders/forward/BumpedSpecular.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Instance.glsl"
Expand All @@ -29,7 +23,7 @@ void main()

vec4 worldPosition = GetInstanceData().model * vec4(iPosition, 1);
vec3 viewPosition = vec3(uView * worldPosition);
vLightDirection = tangentSpaceMatrix * normalize(uLight0ViewPosition.xyz - (step(0, GetLightType()) * viewPosition));
vLightDirection = tangentSpaceMatrix * normalize(uLight0ViewPosition.xyz - (step(0.0, GetLightType()) * viewPosition));
vViewerDirection = tangentSpaceMatrix * normalize(-viewPosition);
vPosition = worldPosition.xyz;
vUV = iUV;
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/forward/Diffuse.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
8 changes: 1 addition & 7 deletions FastCG/assets/shaders/forward/Diffuse.vert
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand All @@ -22,7 +16,7 @@ void main()
{
vec4 worldPosition = GetInstanceData().model * vec4(iPosition, 1);
vec3 viewPosition = vec3(uView * worldPosition);
vLightDirection = normalize(uLight0ViewPosition.xyz - (step(0, GetLightType()) * viewPosition));
vLightDirection = normalize(uLight0ViewPosition.xyz - (step(0.0, GetLightType()) * viewPosition));
vPosition = worldPosition.xyz;
vNormal = normalize(mat3(GetInstanceData().modelViewInverseTranspose) * iNormal);
vUV = iUV;
Expand Down
6 changes: 0 additions & 6 deletions FastCG/assets/shaders/forward/SolidColor.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#version 430 core

#ifdef ENABLE_INCLUDE_EXTENSION_DIRECTIVE
#extension GL_GOOGLE_include_directive : enable
#endif

#include "FastCG.glsl"
#include "Scene.glsl"
#include "Lighting.glsl"
Expand Down
Loading

0 comments on commit bcc9700

Please sign in to comment.