[Solved] White TerrainGrid:Geforce 9400m/osx 10.5.8+Gf. 320m/osx 10.6.7

Terraingrid renders white with these two cards and os’s, normal terrain renders ok.

I guess it has to do with the shaders in which terraingrid uses and something unsupported by osx or the graphics card.

Here is a table of supported feautures on the cards mentioned: http://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1060.html

I’ld like to investigate this, but if someone has a quick answer, then I won’t waste time on it (although I could need a crash course in shaders).

well @normen had the same issues with this, and uses a mac too as far as I know.



I created a new material that uses height information instead of alphamaps to pick textures, and somehow it seems to be broken on mac as far as I can see. Unfortunately I do not have any macs, but will take a look at the docs you linked to. Try to find out something.

I found the cause and a workaround/fix.



Texture2D region4ColorMap and Vector3 region4 are not set on the material in the example provided.



Simply setting region4ColorMap to same as region3ColorMap should solve the issue if you want only 3 regions, othervise the shader needs redesigning, but it seems unneccery.



Not setting a variable I guess causes the shaders to behave differently depending on os and opengl implementation.



// Terrain m_region 4.

m_regionMin = m_region4.x;

m_regionMax = m_region4.y;

m_regionRange = m_regionMax - m_regionMin;

m_regionWeight = (m_regionRange - abs(height - m_regionMax)) / m_regionRange;

m_regionWeight = max(0.0, m_regionWeight);

terrainColor += m_regionWeight * texture2D(m_region4ColorMap, p.xz * m_region4.z);

2 Likes
pspeed said:
The above will fail on some platforms and all Macs. Change the 0's to 0.0.....

My first post was premature. I've tried altering 0 to 0.0, since 0 gets interpreted as an integer, and 0.0 float, it wasn't the reason, it gets fixed as soon as the shader starts running, it should anyways be altered though, so thanx :)
The fix is in my previous now altered post.

I wasn’t sure if it would or wouldn’t fix the issue… but it is definitely an issue. I’ve had shaders fail on some platforms for no other reason than I left a single 0 somewhere instead of 0.0. Always on Macs. Sometimes on other platforms.

Good to know, I started with shaders yesterday so any tips are good to bring along.

If I have fixes for things later, how would I go about commiting them by svn?

makeshift said:
[java][/java]
vec4 terrainColor = vec4(0, 0, 0, 1.0);


The above will fail on some platforms and all Macs. Change the 0's to 0.0.

Yes, it sounds silly. Yes, writing shaders is sometimes an exercise in the absurd.

bah… I was overlooking this :frowning: I committed the change. The only part why this material exists is really the ability to texture steep slopes, which cannot be represented in alphamaps.

I can confirm it works now, community ftw :wink: