Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#76 #79 Continues work on celestial graphics #80

Merged
merged 7 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions BUILD_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you encounter problems with unofficial operating systems and would like to
contribute a fix, feel free to raise a PR.

## The lazy way
Head over to the [releases page](https://github.com/feynmansbongos/Cosmosis/releases)
Head over to the [releases page](https://github.com/frostoven/Cosmosis/releases)
and download a pre-built copy. Done.

## By way of developer madness
Expand All @@ -21,7 +21,7 @@ _Note: this project currently only has a dev webpack config. Feel free to raise
a PR with a prod webpack config._

Once you've cloned the project
(`git clone https://github.com/feynmansbongos/Cosmosis.git`)
(`git clone https://github.com/frostoven/Cosmosis.git`)
you'll want to make sure all dependencies are installed:
```bash
npm install
Expand Down Expand Up @@ -70,7 +70,7 @@ as small as possible (git gets slow with large binary files, and GitHub has
horribly low file size limits).

To get the production assets, head over to the
[releases section](https://github.com/feynmansbongos/Cosmosis/releases) and
[releases section](https://github.com/frostoven/Cosmosis/releases) and
download the 'Stand-Alone Production Assets.zip' package. You will see a folder
named 'prodHqAssets'. Copy that into the same directory as this build document
and restart the game. The game will automatically load the better assets.
Expand All @@ -95,12 +95,12 @@ npm installed. See 'Development' above for more details.
##### Building the application
* Create a directory to work in, for example `C:\COSMOSIS_BUILDS` and open it.
* Open a bash terminal, and navigate to the builds directory you created above.
* Do a git clone of the repo, example `git clone https://github.com/feynmansbongos/Cosmosis.git`
* Do a git clone of the repo, example `git clone https://github.com/frostoven/Cosmosis.git`
* Download the Windows SDK version of NW.js matching the version written in
[package.json](package.json). At the time of writing, this is
[NW.js version 0.55.0](https://nwjs.io/blog/v0.55.0/).
* Extract the zip contents ([7-Zip](https://www.7-zip.org/download.html) recommended as Windows ZIP can corrupt files).
* Download the latest `Stand-Alone Production Assets` zip from the [releases page](https://github.com/feynmansbongos/Cosmosis/releases),
* Download the latest `Stand-Alone Production Assets` zip from the [releases page](https://github.com/frostoven/Cosmosis/releases),
and extract it into a directory named `Stand-Alone.Production.Assets`. `Stand-Alone.Production.Assets` should contain `prodHqAssets`.
* Your builds directory should now have these files / directories:
* `Cosmosis`
Expand All @@ -127,5 +127,5 @@ Once all the above is complete, please run tests to ensure correct functioning:
* Still in the dev console, run: `powerOnSelfTest()`. This runs unit tests
(i.e. looks for obvious bugs and problems). You should have no errors.
* If all is good, zip up FILL_ME_IN, rename the zip to `Cosmosis-win-x64.zip`.
* Upload to the [releases](https://github.com/feynmansbongos/Cosmosis/releases)
* Upload to the [releases](https://github.com/frostoven/Cosmosis/releases)
page.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Copyright infringement
**If your work has been unlawfully used in this project, please
[raise an issue](https://github.com/feynmansbongos/Cosmosis/issues/new/choose)
[raise an issue](https://github.com/frostoven/Cosmosis/issues/new/choose)
and we'll remove it ASAP.** This project is maintained for free during
contributors' spare time, so it may take us a few days to notice the complaint.
However, rest assured copyright infringement is taken very seriously and your issue
Expand Down Expand Up @@ -110,7 +110,7 @@ described above.



Please [raise an issue](https://github.com/feynmansbongos/Cosmosis/issues/new/choose)
Please [raise an issue](https://github.com/frostoven/Cosmosis/issues/new/choose)
before starting work. This game's art style has a very specific direction. Even
if you create art much better than what's already in the project, it might
simply be rejected on the basis that it does not match existing style. Once
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div align="center">
<b>Downloads</b>
<br>
<a href="https://github.com/feynmansbongos/Cosmosis/releases/latest">
<a href="https://github.com/frostoven/Cosmosis/releases/latest">
<img src="https://img.shields.io/static/v1?label=Latest%20stable&message=v0.72.0&color=blue&style=for-the-badge">
</a>
<a href="https://github.com/feynmansbongos/Cosmosis/releases">
<a href="https://github.com/frostoven/Cosmosis/releases">
<img src="https://img.shields.io/static/v1?label=Dev%20builds&message=all%20versions&color=red&style=for-the-badge">
</a>
<br><br>
Expand Down Expand Up @@ -62,7 +62,7 @@ The latest beta can currently do the following:
nothing else. Note that it currently generates a static skybox based on real
star data when the game boots; to actually fly amongst nearby stars, see the
next point.
* Fly around [real Earth-visible stars](https://github.com/feynmansbongos/BSC5P-JSON-XYZ)
* Fly around [real Earth-visible stars](https://github.com/frostoven/BSC5P-JSON-XYZ)
as a ghost. You can activate this mode by pressing Backspace and going to
`debug tools` -> `Star free-flight`. Use `+` and `-` to change flight speed.
* You can fly around your spaceship by pressing `F8`. If the spaceship has
Expand All @@ -79,7 +79,7 @@ source to change ships needs to change, and soon.
Windows may force the application to use integrated graphics, which will
massively decrease performance. The game does not yet allow changing graphics
cards, though
[an issue is currently open](https://github.com/feynmansbongos/Cosmosis/issues/61)
[an issue is currently open](https://github.com/frostoven/Cosmosis/issues/61)
to add this feature.

For now, you may force Windows to use discrete graphics by setting power
Expand Down
40 changes: 40 additions & 0 deletions app/earlyLoad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Used for functions that need to run very early (such as boot-debugging
* tools).
*/

import userProfile from './userProfile';

// Automatically show dev tools window if user has enabled it.
userProfile.cacheChangeEvent.getOnce(({ userOptions }) => {
if (userOptions.debug.autoOpenDevTools) {
nw.Window.get().showDevTools();
}
});

// Automatically reload the application if code changes occur.
if (process.env && process.env.NODE_ENV !== 'production') {
// This flag allows us to disable HMR when we don't want reloads during
// debugging.
window.hmrEnabled = true;

function reload(event, filename) {
if (filename) {
if (!window.hmrEnabled) {
return console.log('HMR: Ignoring external changes.');
}
// console.log(`${filename} file Changed`);
setTimeout(() => {
// Webpack sometimes modifies files multiple times in a short span,
// causing a broken reload. Wait a bit for it to finish.
// Currently a bug in nw.js. TODO: remove once they fix it.
// nw.Window.get().reload();
chrome.tabs.reload();
}, 250);
}
}

const fs = require('fs');
fs.watch('./build/game.js', reload);
fs.watch('./build/offscreenSkybox.js', reload);
}
81 changes: 81 additions & 0 deletions app/effectsManager/EffectsContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { GodRaysEffect, SelectiveBloomEffect } from 'postprocessing';
import EffectsManager from './EffectsManager';
import ChangeTracker from '../emitters/ChangeTracker';

export default class EffectsContext {
constructor({ scene, camera, meta } = { scene: null, meta: null }) {
this.scene = scene;
this.camera = camera;
this.rebuildTriggers = new ChangeTracker();
this.selectiveBloom = null;
if (meta) {
this.meta = meta;
}

// This is a key:value pair, with mesh UUIDs as keys.
this.godRaySelections = {};
}

addRebuildTrigger(callback) {
console.log('[addRebuildTrigger]', {callback})
this.rebuildTriggers.getEveryChange(callback);
}

getAllEffects() {
return [
...Object.values(this.godRaySelections),
];
}

setSelectiveBloom({ mesh, scene, options={} }) {
const camera = this.camera;
this.selectiveBloom = new SelectiveBloomEffect(
scene,
camera,
// {
// ...options,
// // ...EffectsManager.defaultBloomOptions,
// }
);
}

removeSelectiveBloom({ mesh, options }) {
console.log('TBA');
}

/**
* Removes selective bloom from all meshes.
*/
clearAllSelectiveBloom() {
console.log('TBA');
}

setOutline({ mesh, scene, options }) {
console.log('TBA');
}

removeOutline({ mesh, options }) {
console.log('TBA');
}

setGodRays({ mesh, options }) {
const effect = new GodRaysEffect(this.camera, mesh, {
...EffectsManager.defaultGodRaysOptions,
...options,
})

// Something to consider: we might want to make this should be 4 when very
// close, and 1 when far. Probably don't want to go as low as 0 because it
// seems to foam at the mouth when the mouse moves. It's very distracting.
// Reason we need a high number when close is because it solves an ugly
// pixelation problem.
effect.blurPass.kernelSize = 4;

this.godRaySelections[mesh.uuid] = effect;
this.rebuildTriggers.setValue(this);
}

removeGodRays({ mesh, options }) {
console.log('TBA');
}
}
116 changes: 116 additions & 0 deletions app/effectsManager/EffectsManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import {
BloomEffect,
EffectComposer,
EffectPass,
RenderPass,
BlendFunction,
KernelSize,
} from 'postprocessing';

export default class EffectsManager {

static defaultFullscreenBloomOptions = {
blendFunction: BlendFunction.SCREEN,
height: 480,
kernelSize: KernelSize.MEDIUM,
luminanceSmoothing: 0.1,
// 1 means off, 0 means full. 0.3-0.4 are good overall values.
luminanceThreshold: 1,
};

static defaultGodRaysOptions = {
clampMax: 1.0,
decay: 0.92,
density: 0.96,
exposure: 0.54,
height: 240,
kernelSize: KernelSize.SMALL,
samples: 60,
weight: 0.3,
};

constructor({ renderer, camera, effectsContexts }) {
this.renderer = renderer;
this.camera = camera;
this._contexts = effectsContexts;
this._composer = null;

for (let i = 0, len = effectsContexts.length; i < len; i++) {
/** @link EffectsContext */
const context = effectsContexts[i];
context.addRebuildTrigger(() => {this.rebuildComposer()});
}

this.setFullscreenBloom();

this.rebuildComposer();
}

get composer() {
return this._composer;
}

set composer(undef) {
throw 'EffectsManager.composer is read-only.';
}

rebuildComposer() {
const renderer = this.renderer;
const camera = this.camera;
const effectComposer = new EffectComposer(renderer);

const postEffects = [];

// Add all scenes. These need to be first in the render order, or else
// things things get erased and never render.
const contexts = this._contexts;
for (let i = 0, len = contexts.length; i < len; i++) {
/** @link EffectsContext */
const ctx = contexts[i];
console.log('xxx> [rebuildComposer] processing', ctx.meta);
const pass = new RenderPass(ctx.scene, camera);
// This insures that clear=true on the first scene only. Without this,
// only the last scene gets rendered.
pass.clear = i === 0;
effectComposer.addPass(pass);

// Save postprocessing effects for later.
postEffects.push(ctx.getAllEffects());
}

// Add fullscreen effects.
const combinedEffects = [];
this.fullscreenBloom && combinedEffects.push(this.fullscreenBloom);

// Add all postprocessing effects.
for (let i = 0, len = postEffects.length; i < len; i++) {
const effects = postEffects[i];
for (let j = 0, len = effects.length; j < len; j++) {
const effect = effects[j];
combinedEffects.push(effect);
}
}

const effectPass = new EffectPass(
camera,
...combinedEffects,
);
effectPass.clear = false;
effectComposer.addPass(effectPass);

this._composer = effectComposer;
}

setFullscreenBloom({ options={} } = { options: {} }) {
this.fullscreenBloom = new BloomEffect(
{
...EffectsManager.defaultFullscreenBloomOptions,
...options,
}
);
}

removeFullscreenBloom({ options={} }) {
console.log('TBA');
}
}
Loading