AGS 3.4.1 - RC 3 (new release candidate)

Started by Crimson Wizard, Sun 09/04/2017 22:02:10

Previous topic - Next topic

Dave Gilbert

Hah. Awesome. Getting closer at least!

Seriously. Thank you for this. Sorry this is such a tricky problem!

Crimson Wizard


AGD2

Another thing I noticed is that pressing the Tilde (~) key to bring up the console results in a blank white console with no text in it. This happens for all three graphics drivers (D3D. OpenGL, and software).

Also, in addition to ogg vorbis speech audio files not playing, .ogv theora movie files aren't playing either when I run the compiled game from my Compiled/Windows directory. Strangely enough theora movies do play if I hit F5 to test the game from the editor. But ogg vorbis speech files don't play on either occassion.

Crimson Wizard

#83
The problem with tinting is that there is no precise formula of what AGS is using in the code.
Software renderer uses Allegro blenders for tinting, but part of their implementation is written in ASM, which I do not know too well.
Direct3D uses shaders, but we only have them in compiled form (machine code). Perhaps if Chris Jones added original shader program text, but I am not seeing it anywhere in repositories.
I only know for certain that they work with HSV color instead of RGB. But for everything else I have to make guesses.

This is my current result so far:

Top is Direct3D, bottom is OpenGL.

At first I was changing only Hue part, and thought I got it right, you may see that in Roger's head and arms. But his white/grey body requires Saturation shift too (I guess), but most direct approach did not work well yet. It looks like there is a color "overflow" somewhere, but can't find mistake atm.

For the reference, this is my shader program:

Code: cpp

#version 130
out vec4 gl_FragColor;
uniform sampler2D textID;
uniform vec3 tintHSV;       // this is HSV of a tint color (converted from RGB)
uniform vec3 tintAmnTrsLum; // this is tint's Amount, custom Translucence and tint's Luminocity (last two are not used yet)

// Two functions which convert between HSV and RGB, I copied them from some tutorial
vec3 rgb2hsv(vec3 c)
{
	vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
	vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
	vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
	float d = q.x - min(q.w, q.y);
	float e = 1.0e-10;
	return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
	vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
	vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
	return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

// Main process
void main()
{
	vec2 coords = gl_TexCoord[0].xy;
	vec4 src_col = texture2D(textID, coords); // this is the original sprite color
	vec3 src_hsv = rgb2hsv(src_col.xyz); // we convert original sprite color to HSV

	// Here we change Hue, and I **think** that this part is correct;
        // although maybe not very optimized with the if/else
	if (abs(tintHSV.x - src_hsv.x) > 0.5)
		src_hsv.x = fract(src_hsv.x + (tintHSV.x + 1.0 - src_hsv.x) * tintAmnTrsLum.x);
	else
		src_hsv.x = abs(fract(src_hsv.x + (tintHSV.x - src_hsv.x) * tintAmnTrsLum.x));
        // Here I tried to change Saturation same way, but it did not work well yet
	src_hsv.y = src_hsv.y + (tintHSV.y - src_hsv.y) * tintAmnTrsLum.x;

        // Final color is a combination of the transformed color and original Alpha (because we must keep same sprite's shape)
	vec3 new_col = hsv2rgb(vec3(src_hsv.x, src_hsv.y, src_hsv.z));
	gl_FragColor = vec4(new_col, src_col.w);
}

Scorpiorus


Crimson Wizard

#85
Quote from: Scorpiorus on Thu 22/06/2017 19:30:25
I've just found two shader source files in the repository that seem related to tinting.
Or is there any additional source code that's missing?

https://github.com/adventuregamestudio/ags/blob/master/Engine/resource/tintshader.fx
https://github.com/adventuregamestudio/ags/blob/master/Engine/resource/tintshaderLegacy.fx

Oh crud, that's it. I mistook them for "fxo", which is compiled format.
I'll take a look, thank you!

Argh, if I'd just notice them in time that would save me couple of days...

Crimson Wizard

#86
Ok, thanks goodness, this seem be working now:





EDIT: Build download:
http://www.mediafire.com/file/ovoayko4qfe7p2m/acwin-3.4.1--opengl--tinting.zip

I will make a proper new release after fixing few more bugs.

Scorpiorus

Awesome!
And great work with implementing and polishing the OpenGL graphics renderer!
I sense it may well become a primary renderer, seeing as people are starting to have issues with using the 9th version of Direct3D API on the recent versions of MS Windows, somewhat similar to how it was with DirectDraw in the past.

Dave Gilbert

Just tested tinting and it works perfectly in OpenGL!

Tinted dark!


Tinted purple!


Tinted yellow!


Many thanks. :)

Dave Gilbert

So I just got some new music and the issue I reported before has definitely resurfaced. Newly imported music will NOT play unless I select "rebuilt all files" first. This definitely didn't happen before.

Crimson Wizard

#90
Build with OpenGL supporting both tinting and light levels: http://www.mediafire.com/file/0cseqkeom9jtsva/acwin-3.4.1--opengl--tinting2.zip

That was scary to find out that those were not implemented, but OpenGL covers most of drawing now. There is still one function that does not work in OpenGL, which is supposed to clear black screen. I think that may be an issue only when ShakeScreen is used.

Now I will be addressing other bugs reported above.

Dave Gilbert

Hm. I use shakescreen quite often in Unavowed, and I haven't seen any problems.

Thanks again for your hard work!

Crimson Wizard

#92
Quote from: Dave Gilbert on Sun 25/06/2017 00:04:06
Hm. I use shakescreen quite often in Unavowed, and I haven't seen any problems.

I think someone reported this in yours bugs thread couple of days ago, that there are black lines remaining on screen after shaking, or something like that.

Anyway, I think you need to have black borders to see a difference (run fullscreen without stretching game to max somehow, for example).

EDIT: Hmm, actually, disregard that. OpenGL does viewport clipping, so nothing from the game could be drawn over black borders.

Crimson Wizard

#93
Quote from: AGD2 on Thu 22/06/2017 14:55:47
Also, in addition to ogg vorbis speech audio files not playing, .ogv theora movie files aren't playing either when I run the compiled game from my Compiled/Windows directory. Strangely enough theora movies do play if I hit F5 to test the game from the editor.

This is the same problem as we had with FLIC videos after upgrade of Allegro library. It cannot read the video file if it is embedded in EXE. Temporary workaround is to place the file near game's exe.


EDIT: this build should have OGV fixed, hopefully -
http://www.mediafire.com/file/h6pfs813w7sc57t/acwin-3.4.1--theora-fixed.zip

AGD2

Yes, I can confirm that the latest acwin.exe fixes the issue with Theora videos not playing. Thanks!

Crimson Wizard

#95
Does it make sense to save windowed/fullscreen mode to config if it was changed in game? I have certain doubts of whether that will be convenient. One case is if there is an in-game menu where you can change it, but another is when user toggles it using key combination. Currently there is no way to distinguish these.

Why do people toggle mode at all?

monkey0506

I may toggle a game to a window from fullscreen if I want quick/easy access to my music player, Facebook, or something else which is distracting me from my distractions. I may wish to switch back to fullscreen for a more immersive experience though.

Personally, I don't think it should be persisted across save games, if that's what you're asking, but it does make sense to save that setting to the configuration file.

Crimson Wizard

Quote from: monkey0506 on Tue 27/06/2017 13:47:11
Personally, I don't think it should be persisted across save games, if that's what you're asking, but it does make sense to save that setting to the configuration file.

No, I mean configuration of course!

monkey0506

I figured that's what you meant, but just clarifying. :)

Crimson Wizard

#99
AGS 3.4.1 Beta 6
http://www.adventuregamestudio.co.uk/releases/betas/AGS-3.4.1-Beta6/AGS-3.4.1-beta-6.zip
(also updated first post)

Changes since Beta 5:

Editor:
- The speech.vox file is now not recompiled if game is quick-run (using F5). Engine is supposed to find newer files in the Speech folder.

Script:
- Fixed few cases of possible compiler crashing when there is an unfinished statement in the end of the script (by Gurok).

Script API:
- Added setter for System.Windowed property, letting to change it at runtime, switching between windowed and fullscreen modes.
- Added System.RenderAtScreenResolution property to change sprite rendering mode at runtime.

Engine:
- Made Tint and LightLevel work with OpenGL. NOTE: you need OpenGL 3.0 or higher support for these to work (you probably have it if your system's last update is not older than year 2008).
- Fixed OpenGL had one extra row and column of black pixels displayed if "RenderAtScreenResolution" is disabled. (this was a recurring problem, that hopefully fixed for good)
- Engine now tries to get voice files from the Speech folder first, and speech.vox later, when quick-run from the Editor.
- Engine saves last Windowed and RenderAtScreenResolution mode states to user config file.
- Fixed voice-over cannot be found if it is MP3 or OGG type.
- Fixed audio clip could not be found in some cases if its bundled in audio.vox and game is quick-run from the Editor.
- Fixed Theora OGV videos not playing if compiled into game EXE.
- Fixed plugin API's function BlitSpriteTranslucent for software driver (by Scorpiorus).
- Fixed in-game mouse cursor was restricted to the left-top corner of the screen during execution of game_start() script function.


Known issues still:

- In Direct3D mode, if RenderAtScreenResolution is OFF, the game misses one rightmost column and bottom row of pixels (since it is still stretched to proper rectangle, this might also cause minor image distortion). I know approximately where this bug is coming from, but could not yet find a correct way to fix it.

SMF spam blocked by CleanTalk