Skip to content

Commit

Permalink
Windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed May 10, 2019
1 parent 80d334e commit 5f4ebcb
Show file tree
Hide file tree
Showing 13 changed files with 698 additions and 49 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ endif()
bintoc(CModelShaders.common.glsl.cpp Shaders/CModelShaders.common.glsl CMODELSHADERS_COMMON_GLSL)
bintoc(CModelShaders.vert.glsl.cpp Shaders/CModelShaders.vert.glsl CMODELSHADERS_VERT_GLSL)
bintoc(CModelShaders.frag.glsl.cpp Shaders/CModelShaders.frag.glsl CMODELSHADERS_FRAG_GLSL)
add_library(CModelShaders CModelShaders.common.glsl.cpp CModelShaders.vert.glsl.cpp CModelShaders.frag.glsl.cpp)
bintoc(CModelShaders.common.hlsl.cpp Shaders/CModelShaders.common.hlsl CMODELSHADERS_COMMON_HLSL)
bintoc(CModelShaders.vert.hlsl.cpp Shaders/CModelShaders.vert.hlsl CMODELSHADERS_VERT_HLSL)
bintoc(CModelShaders.frag.hlsl.cpp Shaders/CModelShaders.frag.hlsl CMODELSHADERS_FRAG_HLSL)
add_library(CModelShaders
CModelShaders.common.glsl.cpp CModelShaders.vert.glsl.cpp CModelShaders.frag.glsl.cpp
CModelShaders.common.hlsl.cpp CModelShaders.vert.hlsl.cpp CModelShaders.frag.hlsl.cpp)

if(NOT TARGET atdna)
# Import native atdna if cross-compiling
Expand All @@ -264,8 +269,9 @@ add_subdirectory(amuse)
add_subdirectory(specter)
add_subdirectory(assetnameparser)
include_directories(${ATHENA_INCLUDE_DIR} ${LOGVISOR_INCLUDE_DIR} ${HECL_INCLUDE_DIR}
${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/NESEmulator)
${BOO_INCLUDE_DIR} ${AMUSE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/NESEmulator
${ZLIB_INCLUDE_DIR})
add_definitions(-DURDE_ZIP_INPUT_STREAM=1) # Enable CZipInputStream now that zlib header is known
add_subdirectory(NESEmulator)
add_subdirectory(DataSpec)
add_subdirectory(kabufuda)
Expand Down
12 changes: 5 additions & 7 deletions Runtime/Graphics/Shaders/CModelShaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
{0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Greater, hecl::Backend::CullMode::Backface, true, true, false},
/* MorphBall shadow shading */
{3, BallFadeTextures, hecl::Backend::BlendFactor::SrcAlpha,
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false,
false, true, false, true},
{3, BallFadeTextures, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
hecl::Backend::ZTest::Equal, hecl::Backend::CullMode::Backface, false, false, true, false, true},
/* World shadow shading (modified lighting) */
{1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface, false, false, true},
Expand All @@ -135,9 +134,8 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
hecl::Backend::ZTest::GEqual, hecl::Backend::CullMode::Backface, true, false, true},
/* Disintegration */
{2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha,
hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false,
false, true, false, false, true},
{2, DisintegrateTextures, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha,
hecl::Backend::ZTest::LEqual, hecl::Backend::CullMode::Original, false, false, true, false, false, true},
/* Forced additive shading without culling or Z-write and greater depth test */
{0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One,
hecl::Backend::ZTest::Greater, hecl::Backend::CullMode::None, true, false, true},
Expand All @@ -149,7 +147,7 @@ static hecl::Backend::ExtensionSlot g_ExtensionSlots[] = {
{0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original,
hecl::Backend::ZTest::Original, hecl::Backend::CullMode::Backface}};

const char* ShaderMacros[] = {
static const char* ShaderMacros[] = {
"URDE_LIGHTING",
"URDE_LIGHTING",
"URDE_THERMAL_HOT",
Expand Down
12 changes: 8 additions & 4 deletions Runtime/IOStreams.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once

#include "GCNTypes.hpp"
#include <athena/IStreamReader.hpp>
#include <athena/IStreamWriter.hpp>
#include <athena/MemoryReader.hpp>
#include <athena/MemoryWriter.hpp>
#include "athena/IStreamReader.hpp"
#include "athena/IStreamWriter.hpp"
#include "athena/MemoryReader.hpp"
#include "athena/MemoryWriter.hpp"
#ifdef URDE_ZIP_INPUT_STREAM
#include <zlib.h>
#endif

namespace urde {
using CInputStream = athena::io::IStreamReader;
Expand Down Expand Up @@ -50,6 +52,7 @@ class CBitStreamWriter : public athena::io::MemoryWriter {
using CMemoryInStream = athena::io::MemoryReader;
using CMemoryOutStream = athena::io::MemoryWriter;

#ifdef URDE_ZIP_INPUT_STREAM
class CZipInputStream : public CInputStream {
std::unique_ptr<u8[]> x24_compBuf;
std::unique_ptr<CInputStream> x28_strm;
Expand All @@ -63,5 +66,6 @@ class CZipInputStream : public CInputStream {
atUint64 position() const { return 0; }
atUint64 length() const { return 0; }
};
#endif

} // namespace urde
1 change: 0 additions & 1 deletion Shaders/CModelShaders.common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
struct VertToFrag {
vec4 mvPos;
vec4 mvNorm;
vec4 color;
vec2 lightmapUv;
vec2 diffuseUv;
vec2 emissiveUv;
Expand Down
15 changes: 15 additions & 0 deletions Shaders/CModelShaders.common.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct VertToFrag {
float4 mvpPos : SV_Position;
float4 mvPos : POSITION;
float4 mvNorm : NORMAL;
float2 lightmapUv : UV0;
float2 diffuseUv : UV1;
float2 emissiveUv : UV2;
float2 specularUv : UV3;
float2 extendedSpecularUv : UV4;
float2 reflectionUv : UV5;
float2 alphaUv : UV6;
float2 extUvs[3] : EXTUV;
float2 dynReflectionUvs[2] : REFLECTUV;
float dynReflectionAlpha : REFLECTALPHA;
};
46 changes: 23 additions & 23 deletions Shaders/CModelShaders.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ UBINDING2 uniform LightingUniform {
Fog fog;
};
#else
const vec4 colorReg0 = vec4(1.0, 1.0, 1.0, 1.0);
const vec4 colorReg1 = vec4(1.0, 1.0, 1.0, 1.0);
const vec4 colorReg2 = vec4(1.0, 1.0, 1.0, 1.0);
const vec4 colorReg0 = vec4(1.0);
const vec4 colorReg1 = vec4(1.0);
const vec4 colorReg2 = vec4(1.0);
#endif

#if defined(URDE_LIGHTING)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
vec3 LightingFunc() {
vec4 ret = ambient;

for (int i = 0; i < URDE_MAX_LIGHTS; ++i) {
vec3 delta = mvPosIn - lights[i].pos.xyz;
vec3 delta = vtf.mvPos.xyz - lights[i].pos.xyz;
float dist = length(delta);
vec3 deltaNorm = delta / dist;
float angDot = max(dot(deltaNorm, lights[i].dir.xyz), 0.0);
Expand All @@ -134,16 +134,16 @@ vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
float angAtt = lights[i].angAtt[2] * angDot * angDot +
lights[i].angAtt[1] * angDot +
lights[i].angAtt[0];
ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);
ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, vtf.mvNorm.xyz), 0.0);
}

return clamp(ret.rgb, vec3(0.0), vec3(1.0));
}
#endif

#if defined(URDE_THERMAL_HOT)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
return vec3(1.0,1.0,1.0);
vec3 LightingFunc() {
return vec3(1.0);
}
UBINDING2 uniform ThermalUniform {
vec4 tmulColor;
Expand All @@ -152,23 +152,23 @@ UBINDING2 uniform ThermalUniform {
#endif

#if defined(URDE_THERMAL_COLD)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
return vec3(1.0,1.0,1.0);
vec3 LightingFunc() {
return vec3(1.0);
}
#endif

#if defined(URDE_SOLID)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
return vec3(1.0,1.0,1.0);
vec3 LightingFunc() {
return vec3(1.0);
}
UBINDING2 uniform SolidUniform {
vec4 solidColor;
};
#endif

#if defined(URDE_MB_SHADOW)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
return vec3(1.0,1.0,1.0);
vec3 LightingFunc() {
return vec3(1.0);
}
UBINDING2 uniform MBShadowUniform {
vec4 shadowUp;
Expand All @@ -177,13 +177,13 @@ UBINDING2 uniform MBShadowUniform {
#endif

#if defined(URDE_LIGHTING_SHADOW)
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
vec3 LightingFunc() {
vec2 shadowUV = vtf.extUvs[0];
shadowUV.y = 1.0 - shadowUV.y;

vec4 ret = ambient;

vec3 delta = mvPosIn - lights[0].pos.xyz;
vec3 delta = vtf.mvPos.xyz - lights[0].pos.xyz;
float dist = length(delta);
vec3 deltaNorm = delta / dist;
float angDot = max(dot(deltaNorm, lights[0].dir.xyz), 0.0);
Expand All @@ -193,11 +193,11 @@ vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
float angAtt = lights[0].angAtt[2] * angDot * angDot +
lights[0].angAtt[1] * angDot +
lights[0].angAtt[0];
ret += lights[0].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0) *
ret += lights[0].color * angAtt * att * max(dot(-deltaNorm, vtf.mvNorm.xyz), 0.0) *
texture(extTex0, shadowUV).r;

for (int i = 1; i < URDE_MAX_LIGHTS; ++i) {
vec3 delta = mvPosIn - lights[i].pos.xyz;
vec3 delta = vtf.mvPos.xyz - lights[i].pos.xyz;
float dist = length(delta);
vec3 deltaNorm = delta / dist;
float angDot = max(dot(deltaNorm, lights[i].dir.xyz), 0.0);
Expand All @@ -207,7 +207,7 @@ vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
float angAtt = lights[i].angAtt[2] * angDot * angDot +
lights[i].angAtt[1] * angDot +
lights[i].angAtt[0];
ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, mvNormIn), 0.0);
ret += lights[i].color * angAtt * att * max(dot(-deltaNorm, vtf.mvNorm.xyz), 0.0);
}

return clamp(ret.rgb, vec3(0.0), vec3(1.0));
Expand All @@ -219,8 +219,8 @@ UBINDING2 uniform DisintegrateUniform {
vec4 daddColor;
Fog fog;
};
vec3 LightingFunc(vec3 mvPosIn, vec3 mvNormIn) {
return vec3(1.0,1.0,1.0);
vec3 LightingFunc() {
return vec3(1.0);
}
#endif

Expand Down Expand Up @@ -309,12 +309,12 @@ vec3 ReflectionFunc() { return texture(reflectionTex, vtf.dynReflectionUvs[1]).r
vec3 ReflectionFunc() { return texture(reflectionTex, (texture(reflectionIndTex, vtf.dynReflectionUvs[0]).ab -
vec2(0.5, 0.5)) * vec2(0.5, 0.5) + vtf.dynReflectionUvs[1]).rgb * vtf.dynReflectionAlpha; }
#else
vec3 ReflectionFunc() { return vec3(0.0, 0.0, 0.0); }
vec3 ReflectionFunc() { return vec3(0.0); }
#endif

layout(location=0) out vec4 colorOut;
void main() {
vec3 lighting = LightingFunc(vtf.mvPos.xyz, vtf.mvNorm.xyz);
vec3 lighting = LightingFunc();
vec4 tmp;
#if defined(URDE_DIFFUSE_ONLY)
tmp.rgb = SampleTexture_diffuse();
Expand Down
Loading

0 comments on commit 5f4ebcb

Please sign in to comment.