diff --git a/samples/golf/src/golf/MenuState.cpp b/samples/golf/src/golf/MenuState.cpp index 1497c6fb6..2becadcb6 100644 --- a/samples/golf/src/golf/MenuState.cpp +++ b/samples/golf/src/golf/MenuState.cpp @@ -1626,7 +1626,7 @@ void MenuState::loadAssets() m_resources.shaders.loadFromString(ShaderID::Ball, CelVertexShader, CelFragmentShader, "#define VERTEX_COLOURED\n#define BALL_COLOUR\n"/* + wobble*/); //this breaks rendering thumbs m_resources.shaders.loadFromString(ShaderID::CelTextured, CelVertexShader, CelFragmentShader, "#define RX_SHADOWS\n#define TEXTURED\n" + wobble); m_resources.shaders.loadFromString(ShaderID::CelTexturedMasked, CelVertexShader, CelFragmentShader, "#define RX_SHADOWS\n#define TEXTURED\n#define MASK_MAP\n" + wobble); - m_resources.shaders.loadFromString(ShaderID::Course, CelVertexShader, CelFragmentShader, "#define TEXTURED\n#define RX_SHADOWS\n" + wobble); + m_resources.shaders.loadFromString(ShaderID::Course, CelVertexShader, CelFragmentShader, "#define MENU_PROJ\n#define TEXTURED\n#define RX_SHADOWS\n" + wobble); m_resources.shaders.loadFromString(ShaderID::CelTexturedSkinned, CelVertexShader, CelFragmentShader, "#define SUBRECT\n#define TEXTURED\n#define SKINNED\n#define MASK_MAP\n"); //m_resources.shaders.loadFromString(ShaderID::CelTexturedSkinnedMasked, CelVertexShader, CelFragmentShader, "#define SUBRECT\n#define TEXTURED\n#define SKINNED\n#define MASK_MAP\n"); m_resources.shaders.loadFromString(ShaderID::Hair, CelVertexShader, CelFragmentShader, "#define USER_COLOUR\n"); @@ -1660,11 +1660,16 @@ void MenuState::loadAssets() m_resources.materials.get(m_materialIDs[MaterialID::CelTexturedMasked]).setProperty("u_reflectMap", cro::CubemapID(m_reflectionMap)); + auto proj = glm::ortho(-20.f, 20.f, -14.f, 0.f, 0.1f, 10.f); + auto view = glm::translate(glm::mat4(1.f), glm::vec3(0.f, 2.f, 0.f)); + view *= glm::toMat4(glm::rotate(cro::Transform::QUAT_IDENTITY, -cro::Util::Const::PI / 2.f, cro::Transform::X_AXIS)); + proj *= view; + shader = &m_resources.shaders.get(ShaderID::Course); m_scaleBuffer.addShader(*shader); m_resolutionBuffer.addShader(*shader); m_materialIDs[MaterialID::Ground] = m_resources.materials.add(*shader); - + m_resources.materials.get(m_materialIDs[MaterialID::Ground]).setProperty("u_menuViewProjectionMatrix", proj); cro::Image defaultMask; defaultMask.create(2, 2, cro::Colour::Black); @@ -2426,11 +2431,11 @@ void MenuState::createScene() MenuState::PropFileData MenuState::getPropPath() const { PropFileData ret; - /*ret.timeOfDay = TimeOfDay::Night; - ret.propFilePath = "somer.bgd"; + ret.timeOfDay = TimeOfDay::Night; + ret.propFilePath = "midori.bgd"; m_sharedData.menuSky = Skies[ret.timeOfDay]; - return ret;*/ + return ret; const auto mon = cro::SysTime::now().months(); const auto day = cro::SysTime::now().days(); @@ -2658,6 +2663,12 @@ void MenuState::createRopes(std::int32_t timeOfDay, const std::vector md.createModel(entity); entity.getComponent().setMaterial(0, lightMaterial); entity.getComponent().setMaterialProperty(0, "u_ballColour", LightColours[cro::Util::Random::value(0u, LightColours.size() - 1)]); + + if (timeOfDay != TimeOfDay::Night) + { + entity.addComponent(); + entity.getComponent().setShadowMaterial(0, m_resources.materials.get(shadowMatID)); + } } } createRopeMesh(polePos[i], rope); diff --git a/samples/golf/src/golf/shaders/CelShader.inl b/samples/golf/src/golf/shaders/CelShader.inl index ab3cffd50..65fb29cdf 100644 --- a/samples/golf/src/golf/shaders/CelShader.inl +++ b/samples/golf/src/golf/shaders/CelShader.inl @@ -88,6 +88,12 @@ inline const std::string CelVertexShader = R"( VARYING_OUT vec4 v_targetProjection; #endif +#if defined (MENU_PROJ) +//TODO make this a constant +uniform mat4 u_menuViewProjectionMatrix; +VARYING_OUT vec4 v_menuProjection; +#endif + //dirX, strength, dirZ, elapsedTime #include WIND_BUFFER @@ -242,6 +248,9 @@ inline const std::string CelVertexShader = R"( #if defined(MULTI_TARGET) v_targetProjection = u_targetViewProjectionMatrix * u_worldMatrix * a_position; #endif +#if defined (MENU_PROJ) + v_menuProjection = u_menuViewProjectionMatrix * u_worldMatrix * a_position; +#endif #if defined(TERRAIN_CLIP) gl_ClipDistance[1] = dot(worldPosition, vec4(vec3(0.0, 1.0, 0.0), WaterLevel - 0.001)); #endif @@ -339,7 +348,10 @@ inline const std::string CelFragmentShader = R"( #if defined(MULTI_TARGET) VARYING_IN vec4 v_targetProjection; #endif - +#if defined(MENU_PROJ) + VARYING_IN vec4 v_menuProjection; +#endif + #define USE_MRT #include OUTPUT_LOCATION @@ -704,6 +716,16 @@ inline const std::string CelFragmentShader = R"( NORM_OUT.a = 1.0 - (0.9 * targetAmount); FRAG_OUT.rgb = mix(FRAG_OUT.rgb, targetColour + FRAG_OUT.rgb, targetAmount); +#endif +#if defined(MENU_PROJ) + vec2 projUV = v_menuProjection.xy/v_menuProjection.w; + projUV = projUV * 0.5 + 0.5; +FRAG_OUT.r *= step(0.001, projUV.x); +FRAG_OUT.r *= 1.0 - step(0.999, projUV.x); + +FRAG_OUT.r *= step(0.001, projUV.y); +//FRAG_OUT.r *= 1.0 - step(0.999, projUV.y); + #endif //FRAG_OUT += vec4(1.0, 0.0, 0.0, 1.0); })"; \ No newline at end of file