Jump to content

  • Log In with Google      Sign In   
  • Create Account

alkisbkn

Member Since 21 Feb 2008
Offline Last Active Oct 22 2014 10:26 AM

Topics I've Started

PBR (blurry reflections)

09 September 2014 - 10:15 AM

Hello,

 

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.

 

Thanks!


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:

http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf

 

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!


Normal of sine

09 August 2012 - 08:15 PM

Hello,

I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)

Is there a computationally cheap way to find the normal (this is for an iOS game).

Thanks a bunch!

PARTNERS