Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Feb 2008
Offline Last Active Sep 25 2015 06:18 AM

Topics I've Started

Insane comment

11 March 2015 - 07:45 AM

So I was browsing through the code trying to fix some camera issues that we have in the game.

This is what I encounter at some point, made me laugh a lot:

//TODO: PUT Back IN !!!!! NAUGHTY   (I am naughtier)
return 0;//(int)Mathf.Floor (t * 100);

PBR (blurry reflections)

09 September 2014 - 10:15 AM



so I am writing a PBR shader to experiment with the latest techniques, and I find the metalness, roughness and how they relate the the blurry reflections a bit confusing. I understand that the rougher the surface, the more blurry the cubemap will be. For my tests, I have a cubemap generated using CubemapGen, which I sample like this to get the blurred texel:

half current = roughness * 6;
half f0 = floor(current);
half f1 = ceil(current);
half f = saturate(current - f0) / (f1-f0);
half3 reflectDir = reflect(V, N_WS);
half4 reflection1 = texCUBElod (_IndirectLightTex, float4(reflectDir, f0));
half4 reflection2 = texCUBElod (_IndirectLightTex, float4(reflectDir, f1));
half4 reflection = lerp(reflection1, reflection2, f);

Where does metalness come in though? As I understand from the articles that I've been reading, the more metallic a surface, the more reflection it has (and less albedo). Is it as simple as this?

half3 totalReflection = metalness * reflection;

As a clarification, my roughness comes from the alpha channel of the main texture, and the metalness comes from the vertex color.



Projected Grid Ocean undersampling

26 June 2014 - 09:59 AM

So I've been implementing a projected grid ocean for our latest game and I ran into a what it seems, undersampling issue when I sample my displacement heightmaps. It seems that I can't tile the heightmaps a lot over the water surface - if I do so, the surface wobbles a lot. This leaves me with relatively big lumps of water of low amplitude. The heightmaps are 512x512 (I can't go much higher than that, the implementation is for iOS devices).


How do games like Assasin's creed and others fix this aliasing problem? I couldn't see it happening in their implementation and they have massive waves.


Here is my texture sampling code for the heightmap, if someone feels like helping smile.png

float dist = 0;
float3 ray = 0;
// calculate the water world space vertex position from the screen space quad
float3 waterWpos = reconstruct(v.vertex, dist, ray);
float fade = exp(-dist * _LodExponent);
float lod = _MaxLod * (1-fade);

// if _GridSize becomes too small, very obvious sampling artifacts occur
float4 tc = float4(waterWpos/_GridSize, 0, lod);
float4 texel = tex2Dlod (_HeightsTex, tc);
waterWpos = texel.r*_WaveHeight;

I have tried sampling the heightmap using a radial grid, however I have the same problem.

Any input is appreciated!

Best comment ever

27 May 2014 - 10:50 AM

Okay, although this is not a code snippet, it can trigger your imagination about what we've been going through with this guy's code smile.png

This is the comment that I came across (obviously after another programmer fixed his mental code design and bugs)


// TODO BILLYPotentially improve programming skills

Material Layering

18 December 2013 - 10:42 AM

So, as a graphics programmer directly working on mobile games, I haven't really played with the recent trend that I see everywhere regarding material layers, an example is Unreal Engine 4, and more specifically the following article:



I understand the need for this and it's awesome! What I haven't grasped yet is, is each layer a separate pass? Can someone explain this to me please?


Many thanks!