Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Sep 2012
Offline Last Active Yesterday, 08:50 PM

Topics I've Started

Yo dawg, I herd u liek gd.net

09 April 2016 - 03:41 PM

So we put gd.net in ur gd.net PM editor so you can gd.net while you're gd.net'ing


Attached File  yo-dawg.jpg   79.93KB   6 downloads


I have no idea how this happened. I accessed the PM screen, then some other section, then hit "back" on the broswer a few times and soon enough I had gd.net loaded inside the text editor \o/


PD: I posted this topic from inside the text editor  :D


EDIT: It seems the text editor is an iframe, and somehow the site got set as source of the iframe (My guess: Relative fetch element magic of jQuery).

Managing game object IDs

21 February 2016 - 02:54 PM

Hi! I wanted to hear your opinions on how to manage game objects IDs, at runtime and in save files or game data. Have in mind I'm talking about a persistent world, RPG, think of any Elder Scrolls game (Oblivion, Skyrim, etc), also single player, so no additional restrictions for network stuff.


Currently my tiny project has only runtime entity ids only for the things currently loaded, which means I create an entity, which has an ID, and use that to fetch its components when I need them. After the program is closed, everything is lost.


Eventually I'll have to move this into some form of persistence, I'd need a way to store entity instances and their IDs, for normal base game data, and do the same for storing player's save files.


Afaik Elder Scrolls games have a couple of "levels" for this data:

  • First is the main game data. This stores the base game data for all things (NPCs, places, quests, etc). All objects have their own ID.
  • Second the "plugin" data. This stores official addons, mods, and that kind of thing. These also have their own IDs.
  • Third is the player data. These are the game files, I'm assuming it kinda works like the other two, storing the IDs of things the player modified from the base game (say, player killed an NPC, solved a quest, looted a dungeon, etc, that stuff will be stored there,), and also the things the player "spawned". Say that you spawn a demon companion, that NPC is new, or say that you crafted a sword, etc.


I'm not quite imagining how to handle such things. For example, if we're going to make a new unique ID for a crafted sword, we need to know all used IDs in the game, even for stuff that isn't loaded so not to step over an existing item. I'm guessing the ID list is either present in memory all the time, managed through an embedded database or memory mapped file maybe.


Thats fine because we know the IDs occupied by the base game and the ones the player modified. But what if the user makes a mod that adds a new item? Or if I release an official addon that adds a new town or something?


Now I'd need to patch up all the IDs of the addon, and/or patch up the IDs of the player's save game and all their references. Moreover, now the load order of the game data matters. If I load up an addon or another before/after they were before in a previous game run, their IDs will be different (ie, run 1: addon a gets loaded before addon b, so addon a IDs are smaller, run2: addon b gets loaded after addon a, addon b IDs are smaller now), and thats a whole different kind of ID patching D:


Any opinions/experiences about this?

Shadowmap not getting projected correctly

07 December 2015 - 02:54 PM

Hi, so this is the issue:


Scene picture


Attached File  scene.png   695.67KB   6 downloads


Shadowmap picture


Attached File  shadowmap.png   50.28KB   6 downloads



As you can see in the scene pic, the shadowmap isn't getting projected correctly. The directional light is straight down on the Y axis. The sphere shadow should appear right next to the rightmost cube, and the cube shadows should appear below them.


Shadowmap size is 1024x1024, screen size is 1280x720. I'm thinking it has something to do with that but I'm not terribly sure how to rescale the tex coords.


Its a deferred setup, view space position gets computed from the depth buffer.


This is my entire directional light fragment shader:


// Input parameters.
in vec2 passTexCoord;

// Output parameters.
layout ( location = RT_0 ) out vec3 outLightAcc;

// G Buffer texture samplers.
SAMPLING(gbAlbedo, SMP_RT, 2D, 0);
SAMPLING(gbNormal, SMP_RT, 2D, 1);
SAMPLING(gbMisc, SMP_RT, 2D, 2);
SAMPLING(gbDepth, SMP_RT, 2D, 3);
SAMPLING(gbShadowmap, SMP_RT, 2D, 4);


void main ( void )
	// Fetch shininess value.
	float shininess = texture(gbMisc, passTexCoord).x;
	// Fetch albedo texel.
	vec4 txAlbedo = texture(gbAlbedo, passTexCoord).xyzw;
	// Fetch specular intensity.
	float specIntensity = txAlbedo.w;
	// Fetch g buffer normal and decode it.
	vec3 normal = decodeNormal(texture(gbNormal, passTexCoord).xy);
        // Fetch depth and compute view space position.
	vec3 viewPos = computeViewPos(frustum, viewRays, passTexCoord, texture(gbDepth, passTexCoord).x);

	// Compute position in light space.
	vec4 tmpLightSpacePos = dirLight.invViewShadowProj * vec4(viewPos, 1.0);
	vec3 lightSpacePos = tmpLightSpacePos.xyz / tmpLightSpacePos.w;
	vec2 shadowmapCoords = lightSpacePos.xy * 0.5 + 0.5;
	float lightSpaceDepth = lightSpacePos.z * 0.5 + 0.5;

	float shadowDepth = texture2D(gbShadowmap, shadowmapCoords).x;
	float inShadow =  max(0.2, float(lightSpaceDepth < shadowDepth));
	// View space light direction.
	vec3 lightDir = normalize(dirLight.viewDir.xyz);
	// Light color
	vec3 lightColor = dirLight.color.xyz;

	// Cos angle incidence of light.
	float cosAngle = dot( normal, lightDir );
	// Influence factor to lerp for hemispheric ambient.
	float influence = dot( normal, vec3(0, 1.0, 0) ) * 0.5 + 0.5;
	// Diffuse light term.
	vec3 diffuse = max(0.0, cosAngle ) * lightColor;
	// Specular term.
	vec3 specular = computeSpecular(viewPos, lightDir, normal, specIntensity, shininess) * lightColor;
	// Hemisperic ambient term.
	vec3 ambient = mix( dirLight.groundColor.xyz, dirLight.skyColor.xyz, influence ) * lightColor;

	outLightAcc = (txAlbedo.xyz * diffuse + specular) * inShadow + ambient;


The code for computing the "invViewShadowProj" matrix is the following:


// Computing the shadowmap generation matrix:

private final void computeShadowViewProj ( final DirectionalLight dl )
	final Mat4f tmp = dl.shadowViewProj;
	final Vec3f dir = new Vec3f( dl.worldDirection ).negate();
	// Fixed bounding box for now.
	float size = 50;
	// Left, right, bottom, top, znear, zfar.
	tmp.setOrtho( -size, size, -size, size, -size, size);
	// Target, "up" vector. Up cant be (0,1,0) because target would be parallel.
	tmp.lookAlong( dir, new Vec3f( 0, 0, 1 ) );

// Compute view space position to light space position matrix

private final void computeInvViewShadowProj ( final DirectionalLight dl )
	final Mat4f view = cameras.getUnsafe( cameraEntities.getUnsafe( 0 ) ).viewTransform;
	final Mat4f invView = view.invert( new Mat4f() );
	// shadowViewProj is left, invView is right, invViewShadowProj is destination matrix.
	dl.shadowViewProj.mul( invView, dl.invViewShadowProj );


Any help is appreciated :)

nVidia's OpenGL Core debugger for Linux

12 August 2015 - 05:39 PM

nVidia released a OpenGL debugger for Linux, 4.3 core profiles and above.




...as long as you get a Gameworks dev account that is.

Tinted bloom?

07 August 2015 - 12:01 PM

Hi! Please look at these pictures (they're from Planetside 2)





As you may notice, the glow of the sun and the bloom of the surfaces has this tint that looks to depend on the direction. I'm not terribly sure whats going on.


I added (for teh lulz) a chromatic aberration shader on the bloom pass:

Attached File  bloom.jpg   78.61KB   5 downloads


But it doesn't quite looks the same. Besides, from the Planetside 2 pics you can see the tinting doesn't always follow the same direction (sometimes its reddish to blueish from right to left, sometimes from top to bottom, and so on).