Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Vincent

#1
ok i added the .d3ddef file in the shader folder and edited the glsl and hlsl:

hlsl:
Spoiler
Code: ags
// Pixel shader input structure
struct PS_INPUT
{
    float2 Texture : TEXCOORD0;
};

// Pixel shader output structure
struct PS_OUTPUT
{
    float4 Color : COLOR0;
};

// Configuration uniforms
const float USE_XBR : register(c4);
const float USE_CRT_SCANLINES : register(c5);
const float USE_SUBPIXEL_AA : register(c6);
const float2 iOutputDim : register(c7); 

// Engine-provided uniforms
sampler2D iTexture : register(s0);
const float2 iTextureDim : register(c2);
const float iAlpha : register(c3);

// XBR (eXperimental Batch Rendering) edge detection
float4 getXBRColor(float2 uv)
{
    float2 texel = 1.0 / iTextureDim;
    
    // Sample 3x3 grid
    float4 c11 = tex2D(iTexture, uv); // Center
    float4 c00 = tex2D(iTexture, uv + texel * float2(-1, -1));
    float4 c20 = tex2D(iTexture, uv + texel * float2(1, -1));
    float4 c02 = tex2D(iTexture, uv + texel * float2(-1, 1));
    float4 c22 = tex2D(iTexture, uv + texel * float2(1, 1));
    
    // Calculate edge weights
    float d_edge = (dot(abs(c00 - c22), 1) + dot(abs(c20 - c02), 1)) * 0.25;
    float h_edge = (c20.r + c20.g + c20.b - c00.r - c00.g - c00.b) * 0.5;
    float v_edge = (c02.r + c02.g + c02.b - c00.r - c00.g - c00.b) * 0.5;
    
    // Blend based on edges
    float blend_factor = smoothstep(0.0, 0.5, d_edge);
    float4 result = c11;
    
    if (abs(h_edge) > abs(v_edge))
    {
        result = lerp(result, (c20 + c00) * 0.5, blend_factor);
    }
    else
    {
        result = lerp(result, (c02 + c00) * 0.5, blend_factor);
    }
    
    return result;
}

// CRT scanline effect (now resolution-aware)
float3 applyScanlines(float2 uv, float3 color)
{
    // Base scanline density on output resolution
    float scanlineDensity = iOutputDim.y / 600.0; // 600 = reference resolution
    float scanline = sin(uv.y * scanlineDensity * 3.14159 * 2.0);
    return color * (0.9 + 0.1 * scanline * scanline);
}

// Subpixel anti-aliasing (resolution-aware)
float3 applySubpixelAA(float2 uv, float3 color)
{
    // Use output dimensions for AA scaling
    float2 texel = 1.0 / iOutputDim;
    float2 subCoord = frac(uv * iOutputDim);
    
    float4 c = tex2D(iTexture, uv);
    float4 r = tex2D(iTexture, uv + float2(texel.x, 0));
    float4 l = tex2D(iTexture, uv - float2(texel.x, 0));
    float4 u = tex2D(iTexture, uv + float2(0, texel.y));
    float4 d = tex2D(iTexture, uv - float2(0, texel.y));
    
    // Weighted blend based on subpixel position
    float3 result = color;
    result = lerp(result, 0.5 * (c.rgb + r.rgb), smoothstep(0.3, 0.7, subCoord.x));
    result = lerp(result, 0.5 * (c.rgb + l.rgb), smoothstep(0.7, 0.3, subCoord.x));
    result = lerp(result, 0.5 * (c.rgb + u.rgb), smoothstep(0.3, 0.7, subCoord.y));
    result = lerp(result, 0.5 * (c.rgb + d.rgb), smoothstep(0.7, 0.3, subCoord.y));
    
    return result;
}

PS_OUTPUT main(in PS_INPUT In)
{
    float2 uv = In.Texture;
    float4 color = tex2D(iTexture, uv);
    
    // Advanced upscaling techniques
    if (USE_XBR > 0.5)
    {
        color = getXBRColor(uv);
    }
    
    if (USE_SUBPIXEL_AA > 0.5)
    {
        color.rgb = applySubpixelAA(uv, color.rgb);
    }
    
    if (USE_CRT_SCANLINES > 0.5)
    {
        color.rgb = applyScanlines(uv, color.rgb);
    }
    
    // Output with alpha
    PS_OUTPUT Out;
    Out.Color = float4(color.rgb, color.a * iAlpha);
    return Out;
}
[close]

glsl:
Spoiler
Code: ags
// Configuration uniforms (controlled from AGS)
uniform float USE_XBR;
uniform float USE_CRT_SCANLINES;
uniform float USE_SUBPIXEL_AA;

uniform vec2 iOutputDim;

// Standard engine-provided uniforms
uniform float iTime;
uniform int iGameFrame;
uniform sampler2D iTexture;
uniform vec2 iTextureDim;
uniform float iAlpha;

varying vec2 vTexCoord;

// XBR (eXperimental Batch Rendering) edge detection
vec4 getXBRColor(vec2 uv)
{
    vec2 texel = 1.0 / iTextureDim;
    
    // Sample 3x3 grid
    vec4 c11 = texture2D(iTexture, uv); // Center
    vec4 c00 = texture2D(iTexture, uv + texel * vec2(-1, -1));
    vec4 c20 = texture2D(iTexture, uv + texel * vec2(1, -1));
    vec4 c02 = texture2D(iTexture, uv + texel * vec2(-1, 1));
    vec4 c22 = texture2D(iTexture, uv + texel * vec2(1, 1));
    
    // Calculate edge weights
    float d_edge = (dot(abs(c00 - c22), vec4(1)) + dot(abs(c20 - c02), vec4(1))) * 0.25;
    float h_edge = (c20.r + c20.g + c20.b - c00.r - c00.g - c00.b) * 0.5;
    float v_edge = (c02.r + c02.g + c02.b - c00.r - c00.g - c00.b) * 0.5;
    
    // Blend based on edges
    float blend_factor = smoothstep(0.0, 0.5, d_edge);
    vec4 result = c11;
    
    if (abs(h_edge) > abs(v_edge))
    {
        result = mix(result, (c20 + c00) * 0.5, blend_factor);
    }
    else
    {
        result = mix(result, (c02 + c00) * 0.5, blend_factor);
    }
    
    return result;
}

// CRT scanline effect
vec3 applyScanlines(vec2 uv, vec3 color)
{
    float scanline = sin(uv.y * iTextureDim.y * 3.14159 * 2.0);
    return color * (0.9 + 0.1 * scanline * scanline);
}

// Subpixel anti-aliasing
vec3 applySubpixelAA(vec2 uv, vec3 color)
{
    vec2 texel = 1.0 / iTextureDim;
    vec2 subCoord = fract(uv * iTextureDim);
    
    vec4 c = texture2D(iTexture, uv);
    vec4 r = texture2D(iTexture, uv + vec2(texel.x, 0));
    vec4 l = texture2D(iTexture, uv - vec2(texel.x, 0));
    vec4 u = texture2D(iTexture, uv + vec2(0, texel.y));
    vec4 d = texture2D(iTexture, uv - vec2(0, texel.y));
    
    // Weighted blend based on subpixel position
    vec3 result = color;
    result = mix(result, 0.5 * (c.rgb + r.rgb), smoothstep(0.3, 0.7, subCoord.x));
    result = mix(result, 0.5 * (c.rgb + l.rgb), smoothstep(0.7, 0.3, subCoord.x));
    result = mix(result, 0.5 * (c.rgb + u.rgb), smoothstep(0.3, 0.7, subCoord.y));
    result = mix(result, 0.5 * (c.rgb + d.rgb), smoothstep(0.7, 0.3, subCoord.y));
    
    return result;
}

void main()
{
    vec2 uv = vTexCoord;
    vec4 color = texture2D(iTexture, uv);
    
    // Calculate scaling based on output dimensions
    vec2 pixelSize = 1.0/iOutputDim;
    
    // Advanced upscaling techniques
    if (USE_XBR > 0.5) {
        color = getXBRColor(uv);
    }
    
    if (USE_SUBPIXEL_AA > 0.5) {
        color.rgb = applySubpixelAA(uv, color.rgb);
    }
    
    if (USE_CRT_SCANLINES > 0.5) {
        // Make scanlines scale with output resolution
        float scanlineDensity = iOutputDim.y / 600.0; // Base on 600p
        color.rgb = applyScanlines(uv*scanlineDensity, color.rgb);
    }
    
    gl_FragColor = vec4(color.rgb, color.a * iAlpha);
}
[close]

d3ddef:
Spoiler
Code: ags
[compiler]
target = ps_2_b


[constants]
iGameFrame = 1
iTextureDim = 2
iAlpha = 3
USE_XBR = 4
USE_CRT_SCANLINES = 5
USE_SUBPIXEL_AA = 6
iOutputDim = 7  ; 
[close]

room script:
Spoiler
Code: ags
function SetPixelSettings(float useXBR, float useScanlines, float useSubpixelAA)
{
    pixelInstance.SetConstantF("USE_XBR", 1.);
    pixelInstance.SetConstantF("USE_CRT_SCANLINES", 1.);
    pixelInstance.SetConstantF("USE_SUBPIXEL_AA", 0.);
}

function initialize_shaders()
{
  PixelShader = ShaderProgram.CreateFromFile("$DATA$/shaders/PixelShader.glsl");
  pixelInstance = PixelShader.CreateInstance();
  SetPixelSettings(1., 1., 1.);
}

function room_RepExec()
{
  if (pixelactive) Room.BackgroundShader = pixelInstance;
  else Room.BackgroundShader = null;
}
[close]

it was just a quick test tho but its working all good now indeed, thanks. I might come out with a proper demo soon or later. But in the meantime I hope you took the demo I shared.
#2
Is the link broken? Cause I shared the whole project with all the shaders.
By the way this is one of the shader I was trying to set their costants, this is still without editing though: but other parameters were not changing either

Spoiler
Code: ags
// Pixel shader input structure
struct PS_INPUT
{
    float2 Texture : TEXCOORD0;
};

// Pixel shader output structure
struct PS_OUTPUT
{
    float4 Color : COLOR0;
};

// Configuration (set these to 1 to enable, 0 to disable)
#define USE_XBR 1          // Advanced edge detection (recommended)
#define USE_CRT_SCANLINES 1 // CRT-style scanlines
#define USE_SUBPIXEL_AA 0  // Subpixel anti-aliasing
#define SCALE_FACTOR 4.0   // Must match your render target upscale

// Global variables
sampler2D iTexture;
const float2 iTextureDim : register(c2);
const float iAlpha : register(c3);

// XBR (eXperimental Batch Rendering) edge detection
float4 getXBRColor(float2 uv)
{
    float2 texel = 1.0 / iTextureDim;
    
    // Sample 3x3 grid
    float4 c11 = tex2D(iTexture, uv); // Center
    float4 c00 = tex2D(iTexture, uv + texel * float2(-1, -1));
    float4 c20 = tex2D(iTexture, uv + texel * float2(1, -1));
    float4 c02 = tex2D(iTexture, uv + texel * float2(-1, 1));
    float4 c22 = tex2D(iTexture, uv + texel * float2(1, 1));
    
    // Calculate edge weights
    float d_edge = (dot(abs(c00 - c22), 1) + dot(abs(c20 - c02), 1)) * 0.25;
    float h_edge = (c20.r + c20.g + c20.b - c00.r - c00.g - c00.b) * 0.5;
    float v_edge = (c02.r + c02.g + c02.b - c00.r - c00.g - c00.b) * 0.5;
    
    // Blend based on edges
    float blend_factor = smoothstep(0.0, 0.5, d_edge);
    float4 result = c11;
    
    if (abs(h_edge) > abs(v_edge))
    {
        result = lerp(result, (c20 + c00) * 0.5, blend_factor);
    }
    else
    {
        result = lerp(result, (c02 + c00) * 0.5, blend_factor);
    }
    
    return result;
}

// CRT scanline effect
float3 applyScanlines(float2 uv, float3 color)
{
    float scanline = sin(uv.y * iTextureDim.y * 3.14159 * 2.0);
    return color * (0.9 + 0.1 * scanline * scanline);
}

// Subpixel anti-aliasing
float3 applySubpixelAA(float2 uv, float3 color)
{
    float2 texel = 1.0 / iTextureDim;
    float2 subCoord = frac(uv * iTextureDim);
    
    float4 c = tex2D(iTexture, uv);
    float4 r = tex2D(iTexture, uv + float2(texel.x, 0));
    float4 l = tex2D(iTexture, uv - float2(texel.x, 0));
    float4 u = tex2D(iTexture, uv + float2(0, texel.y));
    float4 d = tex2D(iTexture, uv - float2(0, texel.y));
    
    // Weighted blend based on subpixel position
    float3 result = color;
    result = lerp(result, 0.5 * (c.rgb + r.rgb), smoothstep(0.3, 0.7, subCoord.x));
    result = lerp(result, 0.5 * (c.rgb + l.rgb), smoothstep(0.7, 0.3, subCoord.x));
    result = lerp(result, 0.5 * (c.rgb + u.rgb), smoothstep(0.3, 0.7, subCoord.y));
    result = lerp(result, 0.5 * (c.rgb + d.rgb), smoothstep(0.7, 0.3, subCoord.y));
    
    return result;
}

PS_OUTPUT main(in PS_INPUT In)
{
    float2 uv = In.Texture;
    float4 color = tex2D(iTexture, uv);
    
    // Advanced upscaling techniques
#if USE_XBR
    color = getXBRColor(uv);
#endif
    
#if USE_SUBPIXEL_AA
        color.rgb = applySubpixelAA(uv, color.rgb);
#endif
    
#if USE_CRT_SCANLINES
    color.rgb = applyScanlines(uv, color.rgb);
#endif
    
    // Output with alpha
    PS_OUTPUT Out;
    Out.Color = float4(color.rgb, color.a * iAlpha);
    return Out;
}
[close]
#3
Quote from: Crimson Wizard on Tue 27/05/2025 15:32:57For the reference, shader scripts do not have to be packed inside the game of course, they may also be placed just in the game's folder (or subfolder) and loaded from there at runtime. This makes them more visible (better serving demonstration purpose).

Right i only had to add shaders in the package custom data in the general setting. I did these shaders following some tutorials, tho they need some editing to suit the SetConstantF so they can be changed via script. I've been trying converting the defines into shader constants and even if i dont get any errors it doesn't seems anything changes, I did a quick upload but I might can do a better one in the future with the full demostration: https://www.fileconvoy.com/dfl.php?id=gb4565f24b363a49010005925505cf67d38eb685b35

I tried to had a function like this but it didnt work:
Code: ags
function update_pixel_shader(float alpha, float scanlineIntensity, float useXBR, float useScanlines, float useSubpixelAA, float scaleFactor)
{
    pixelInstance.SetConstantF2("iTextureDim", textureWidth, textureHeight); // c2 
    pixelInstance.SetConstantF("iAlpha", alpha);                     // c3
    pixelInstance.SetConstantF("iScanlineIntensity", scanlineIntensity); // c4
    pixelInstance.SetConstantF("USE_XBR", useXBR);                   // c5
    pixelInstance.SetConstantF("USE_CRT_SCANLINES", useScanlines);   // c6
    pixelInstance.SetConstantF("USE_SUBPIXEL_AA", useSubpixelAA);    // c7
    pixelInstance.SetConstantF("SCALE_FACTOR", scaleFactor);         // c8
}

// room_Load():
update_pixel_shader(
    0.8,   // alpha
    0.2,   // scanlineIntensity
    1.0,   // useXBR (enabled)
    1.0,   // useScanlines (enabled)
    0.0,   // useSubpixelAA (disabled)
    4.0    // scaleFactor
);
#4
I wrote the shaders only in hlsl in visual studio and the graphic driver is directx9 in both editor and at runtime. My forgetfulness because it was enough to make them prebuilt to make it work fine. I might also convert them to glsl just in case.

Quote from: Crimson Wizard on Tue 27/05/2025 10:31:49I tried this, and it works correctly when I switch Screen.Shader to another shader instance. Please post the code that you are using.

My bad, it was just a trivial mistake in the code, it's indeed working all good. I'm pretty much excited with the shaders features :) you guys are doing a beautiful work.
#5
Quote from: Crimson Wizard on Wed 21/05/2025 04:27:24Hey, I wanted to play with this and had some ideas, but currently the only texture a shader instance can have access to, is the one it is attached to.

Ehy CW this is looking so amazing! Lately I tried experimenting with some shaders along with some tutorials and i might be facing an issue. If I attach a shader (eg. to Screen.Shader) then I can't assign another shader to it? I am passing the shader to null before assign it a new one but it doesn't seems to be working, i might be doing something wrong. Here i tried experimenting assigning different shaders to Screen, Camera, Room etc. and its all working good also with SetTexture (I use it for the CRT shader): https://imgur.com/S8CfpZN Also for some reason if i run the game from the exe i don't see any shaders at all but its working fine in the editor.
#6
Thanks a lot you are very kind. :) I think AGS is like a Swiss Army knife: it looks unassuming until someone uses it to build a spaceship. Seriously though, your enthusiasm means a lot :) I have got higly inspired by this video which looks way better: https://www.youtube.com/watch?v=XjjB3R3Iac4
#7
Ciao Lorenzo come stai?  :) 

Thanks so much as usual for the detailed feedback—I really appreciate you taking the time to analyze everything so thoroughly!

Movement & AI: Glad the movement feels smooth! The enemies currently use hitscan attacks, but I love the idea of introducing projectile-based enemies or varied alertness levels to mix up combat. Maybe a 'veteran' enemy type that reacts faster could add tension.

Textures & Doors: Totally agree about the walls and doors. I'll experiment with distinct textures (maybe subtle color-coding or symbols for locked doors) to help with navigation. Doom's approach is a great reference indeed!  :-D

Fisheye Effect: Haha, yes! The raycasting gives it that slight curvature—it's unintentionally retro, but I'm leaning into it now for style.

Gameplay Vision: You nailed it—I'm aiming for tense, tactical moments where every bullet counts. The radar is meant to keep things fair while preserving that 'Alien'-style dread.

Your ideas are gold! If you're up for it, I'd love to bounce more tweaks off you guys as I refine things. Thanks again for the hype and insights—it's fuel for the dev process!

(And next time, I'll let the enemies shoot me in the demo... for science.)  :-D
#8
Over the past few weekends, I've been working on this project from scratch in my spare time. It's still very much a work in progress, but I'm excited about how it's coming together. The biggest challenges so far have been:

  • Optimizing the raycasting to run smoothly in AGS
  • Creating convincing 3D movement within a grid-based system
  • Balancing the enemy AI to be challenging but fair

Still failing to create a proper dynamic lights source. But in the meantime I'd love to hear what you guys think! Any feature suggestions or technical advices are welcome!

#9
Quote from: eri0o on Tue 03/12/2024 12:34:21@Vincent hey, I noticed the web game wasn't updated in the game page. Did something else happen wrong?

@eri0o
My workmate reiterated that he still can't upload the file on itch (we both tested the game with your app, he tried to make a zip file of the whole folder but he still couldn't upload it for some reason) so we decided to give up. Still today I still don't understand why he can't upload it but it doesn't matter as long as the exe file is working. Thanks anyway for your interest, I really appreciated it 💖and thanks also for making sure I could try the game with your app which works great. I decided to keep it anyway because it is very useful for future projects. 👍
#10
@eri0o Thank you very much - btw this isn't our first time uploading a web version of our games on itch and indeed we never had any troubles. This time I have a feeling that my friend tried to upload the rar file i shared with him so i believe that is the problem, still thank you very much!  :)
#11
@eri0o Thanks a lot as usual you are always very kind. Sorry for the trouble regarding this: "The game can only work if it's served by a server, if you are simply trying to double click the html to run in the browser it won't work." Is actually what I was trying to do by my side since i dont own the account on itch so i wasn't sure how to test it properly. Btw I tried it with your MinimalWebServer.zip and its working all good indeed. Now I will share those info with my friend and hopefully we should upload a web version to itch page - im still not sure why he had trouble on uploading the web version but I'll let you know in case, still thanks a lot for your time.
#12
Quote from: eri0o on Fri 29/11/2024 19:26:52Afaik it should be working. The AGS.js file is the same for all builds, AGS has always a runtime and the game files - mainly the .ags file. Is your game available somewhere?

I've uploaded the whole web folder if that help
Spoiler

Here's the game but my friend say that he can't upload the web version for some reason
https://digital-mosaic-games.itch.io/dust-n-rust
#13
Hi I just finished to compile a mini game with AGS-4.00.00.06-Alpha11. The .exe file is working all good but when I try to open it on broswer it gives me this kind of error. Is there any bug related with this version and the web compiling?




Here's the file of ags.js
Spoiler
#14
Quote from: Crimson Wizard on Wed 27/11/2024 15:50:38Please, also mention AGS 4 in the topic titles, because this version may be different from AGS 3 in a number of ways, and not many people have a knowledge of it yet.

Thanks all done!  :)
#15
@Crimson Wizard Thank you very much  :)
#16
Hello Agser I am using AGS-4.00.00.06-Alpha11 and I was trying to use the functions Remove/Restore WalkableArea but it gives me undefined token. Altough the manual doesn't say this is an obsolate command and I was wondering to know how to do that?
#17
Critics' Lounge / Re: Platformer
Thu 15/08/2024 20:54:56
@lorenzo Thanks, you are always so kind!! ❤️ And I am really glad to hear all your input which it's all this thread about. Definitely I have to work out more about the combat system and add a flashing for both character and enemies when they get hit, its indeed not much clear as it is right now. Also adding a sound when you collect items is a good idea. Regarding the design of the stairs, I wanted to have some sort of cutscene which the camera move up to show the stairs to the player (also liked the idea to let the stairs go down once you used the item) so I think I might go ahead and add some sort of cables or something that goes up to let the player want to actually look up. Btw I really appreciated all your thoughs they are really welcome to me, thanks a lot!!  :)

ps: I've seen you did such an amazing game with CaptainD, congrats!!! :-D  Sorry I am late but your graphics always looks so stunning, please keep it up!! ❤️
#18
Critics' Lounge / Re: Platformer
Sat 10/08/2024 21:33:51
@AndreasBlack Thank you so much I appreciate your kind words. 😊 Art of Dying is definitely the proper way if you want to learn about making a platform game in general, it helped me a lot to understand the basic.

@eri0o thank you I appreciate you like it😊Yeah the flying thing was meant to be some sort of partner, the camera zoom is such a great idea, i'd love to implement something like this. Also regarding the tween tint I was doing something like this lately, when you stand next to him, you'll get tint in red like he's scanning you. But it can be done also when you get hit of course. Thanks, I really appreciate all the input😊
#19
Critics' Lounge / Platformer
Sat 10/08/2024 10:18:22
I have been working on this in my latest spare time, what you guys think?
#20
Okay thanks a lot for the info. I'll try to make something myself while still using your module because is an huge help. Also I hope one day you will write the ActionSequencer as well.


:EDIT: @Crimson Wizard I managed to make it work (with your module) by using a couple of functions like KeyListener.KeySequenceLength and KeyListener.EvtKeyAutoRepeated they really came in handy.
SMF spam blocked by CleanTalk