Carnage3D - [yet another] GTA1 remake project

Talk about any other games here
User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

jericho wrote:
10 Sep 2020, 09:25
JernejL wrote:
10 Sep 2020, 07:35
does box2d have any kind of support for top down vehicles? can it get velocity at point on body and apply force on a point?
Yep, disabling gravity force along Y axis gives "top down" mode.
What I am implemented at this point is: each vehicle is single rigid body with dimensions in meters (1 map unit equals 4 meters). Mass of the body I take directly from style data, I assume that value in kilograms. Applying forces, impulses and torque on it gives some driving-like mechanics.

Seems like a good start, i assume you already went thru these:

http://www.iforce2d.net/b2dtut/top-down-car/
http://domasx2.github.io/gamejs-box2d-car-example/
https://github.com/signalsin/Racer

One thing needing to be done is that you model each wheel on the car, so maybe next step is to figure out where tyres should be placed relative to center of body. also, does box2d support off-center mass for body?

So.. figure out how Drive Wheel Offset, Steeringwheel Offset place tyre in car, probably similar to doors (they just specify offset from center of body? )

User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote:
10 Sep 2020, 10:31
One thing needing to be done is that you model each wheel on the car, so maybe next step is to figure out where tyres should be placed relative to center of body. also, does box2d support off-center mass for body?
The first thing which i've tried is was adding "true" wheels as separate rigid bodies attached to chassis via joints. It was okay more or less, though I doubted whether it was really necessary, seems there was no wheels simulation in gta1. So I decided to get rid of wheels and make it more simple.

Didn't try to set custom center of mass yet, but it seems Box2d supports this.

User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

You might get better behaviors with separate tyres, things like j-turns and handbrake turns might perform poorly or impossible without simulating tyres separatedly as they are product of each tyre functioning on the body in different way.

You just need to catch similar feeling to gta1 for it to be good and fun, and then have some method to choose your physics simulation engine values approximately from gta values.

I think with today's technology it's hard to reproduce rather poor mid-90s physics math, that thing ran in fixed-math, especially the ridiculous and glitchy collision detection & response :)

User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Added live demo: https://codenamecpp.github.io/carnage3d ... _wasm.html
It works on webassembly now

ItaliaPizzaman
Ped
Ped
Posts: 3
Joined: 06 Apr 2016, 19:23
GH nick: ItaliaPizzaman

Re: Carnage3D - [yet another] GTA1 remake project

Post by ItaliaPizzaman »

WOW!

I have been waiting for so long for someone to create GTA in its original style and crack the code...

What are the possibilities of a stable remake here?

Kudos! :o 8-)

User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

Nice work with webassembly, that does open up a lot more options since it can run on web, it also loads really really fast!

May i suggest an graphics option to use bilinear filtering?

User avatar
Sektor
Boss
Boss
Posts: 1390
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Carnage3D - [yet another] GTA1 remake project

Post by Sektor »

The loading speed really is impressive and the game runs at a nice 60 FPS. Great work, it has a lot of potential.

User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote:
07 Oct 2020, 07:54
May i suggest an graphics option to use bilinear filtering?
Sure I will add filtering, but it is'nt trivial as one might expect since all graphics is stored in paletted format (single channel unsigned byte) and color gets generated in shaders - so it's not enough just to generate mipmaps and enable GL_LINEAR_MIP_LINEAR or something like that.
Sektor wrote:
07 Oct 2020, 09:35
The loading speed really is impressive and the game runs at a nice 60 FPS. Great work, it has a lot of potential.
Thanks! It bundled with demo version data, it rather small.

User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

jericho wrote:
07 Oct 2020, 13:20
JernejL wrote:
07 Oct 2020, 07:54
May i suggest an graphics option to use bilinear filtering?
Sure I will add filtering, but it is'nt trivial as one might expect since all graphics is stored in paletted format (single channel unsigned byte) and color gets generated in shaders - so it's not enough just to generate mipmaps and enable GL_LINEAR_MIP_LINEAR or something like that.

You must still be using texture2d / texture function in the end to get index - you can use something like this (example is bicubic filtering) - but you'd need to adapt your shader to add palette lookup (i'm guessing you have that in another texture where you store palette clut and just replace those bits ):

Code: Select all

// from http://www.java-gaming.org/index.php?topic=35123.0
vec4 cubic(float v){
    vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;
    vec4 s = n * n * n;
    float x = s.x;
    float y = s.y - 4.0 * s.x;
    float z = s.z - 4.0 * s.y + 6.0 * s.x;
    float w = 6.0 - x - y - z;
    return vec4(x, y, z, w) * (1.0/6.0);
}

vec4 textureBicubic(sampler2D sampler, vec2 texCoords){
	
	if (!uBicubic) {
		
		return texture(sampler, texCoords);
		
	}
	
   vec2 texSize = textureSize(sampler, 0);
   vec2 invTexSize = 1.0 / texSize;

   texCoords = texCoords * texSize - 0.5;


    vec2 fxy = fract(texCoords);
    texCoords -= fxy;

    vec4 xcubic = cubic(fxy.x);
    vec4 ycubic = cubic(fxy.y);

    vec4 c = texCoords.xxyy + vec2 (-0.5, +1.5).xyxy;

    vec4 s = vec4(xcubic.xz + xcubic.yw, ycubic.xz + ycubic.yw);
    vec4 offset = c + vec4 (xcubic.yw, ycubic.yw) / s;

    offset *= invTexSize.xxyy;

    vec4 sample0 = texture(sampler, offset.xz);
    vec4 sample1 = texture(sampler, offset.yz);
    vec4 sample2 = texture(sampler, offset.xw);
    vec4 sample3 = texture(sampler, offset.yw);

    float sx = s.x / (s.x + s.y);
    float sy = s.z / (s.z + s.w);

    return mix(
       mix(sample3, sample2, sx), mix(sample1, sample0, sx)
    , sy);
}

User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote:
07 Oct 2020, 14:22

You must still be using texture2d / texture function in the end to get index - you can use something like this (example is bicubic filtering) - but you'd need to adapt your shader to add palette lookup (i'm guessing you have that in another texture where you store palette clut and just replace those bits ):
Thanks for sharing code.

Yes, i'm using two textures for sprites - one with pal indices data and second with cluts data.
For city mesh it little bit more complex, as there is 2 additional textures involved for do dynamic things like lids animations and remapping... It might took some time to implement.

User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

You don't need to actually use map shadow palettes, you can just apply brightness correction depending on wall side and ground shadow index, it would probably look cleaner in code, too.

User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote:
07 Oct 2020, 17:26
You don't need to actually use map shadow palettes, you can just apply brightness correction depending on wall side and ground shadow index, it would probably look cleaner in code, too.
Sounds good, I didn't thought about that. Nice trick, thanks! :)

User avatar
JernejL
Hitman
Hitman
Posts: 126
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

Gtacars and my g24 editor will automaticly make those shadow palettes for tiles but only game uses them, no editors ever used then (j25 or m1)

Post Reply