Parallax Shader Problem

Hello
I’ve played arround withe the Parallax Shader a little and noticed a strange Happening.

Both Parts of this Screenshot made from the same View.

The upper Part shows the Parallax Shader from the GLSL Demos on a single Plane. Please notice UV-Layout nearby. The UVs ara larger then the Face, and the Parallax-FX is totally wrong here.

The lower Part shows the same View, but now the Plane ist subdividet a few times, and the UVs are smaller now. And here, the Parallax-FX is OK.

This makes it necessary, to subdivide the Meshes and blow up the Polycount needless. Not?
I tried to fix, but i’m just starting with GLSL coding.

Maybe someone can help.
Thx, Doc

Attachments


Actually I like the look of the rocks in the top picture. The one on the bottom would have the bricks not touching, but somehow still stacked?

They would have to be glued to the wall in the back to look like that?

Here is a *.blend to show what i mean. The lower Part is perspectival correct, the upper not, because the Mesh is not subdividet. I can’t figure out why. I thought, this Shader works per Pixel. ???

Hi Doc, maybe its a “quadrant issue” please take a look:

I couldn’t down load you file to check your settings but GLSL works based on the local co-ordinate system unless you tell it to work globally… so if you haven’t made sure your blender material is using UV’s,you might have it set on global,orco or something else? then if you subdivide the mesh it will change the co-ordinates/scale of the image being mapped… ie your stone blocks will change.

So my question is… are you using blender materials with the correct UV settings? do you have TEX face checked? this could also be causing a problem?

Hi,
I’ve checked the Download, and it work for me. Did You insert the PassCode beside the Download Button?

The UVsSettings are correct in the Materials, and TexFace has no Effect. (Except the Dummy-Teture is used now.)

But the Normal-Bug in the Video can be involved, maybe. I’ve noticed, that the upper/left Corner of the Plane is always correct. Even the Plane is not subdividet, and no matter where the UV-Layout is placed.

Whst is this Normal-Bug exactly?

I have faced this quadrant light diference (http://www.youtube.com/watch?v=PtczGOO5Oyg) during the use of this python script :

import GameLogic as g
objlist = g.getCurrentScene().getObjectList()
g.setLogicTicRate(60.0)

-------------------------------------

ShaderObjects = [ objlist[‘OBNameOfobjecHere’] ]
MaterialIndexList = [0,1]
GlobalAmbient = [0.39,0.35,0.32,1]
AmbF = 0.5

-------------------------------------

VertexShader = “”"
uniform mat4 mvi;
vec4 Tangent;

varying vec4 vcol;

varying vec3 lvec,vvec;

vec3 TBN(in vec3 by)
{
vec3 tangent = (Tangent.xyz);
vec3 binormal = cross(gl_Normal, Tangent.xyz)*Tangent.w;
vec3 normal = gl_Normal;

vec3 tvec;
tvec.x = dot(tangent, by);
tvec.y = dot(binormal, by);
tvec.z = dot(normal, by);
return tvec;
}

void main() {
gl_Position = ftransform();

// texcoord now (vec4())
Tangent = gl_MultiTexCoord1;

vec4 light0 = (mvi*gl_LightSource[0].position)-gl_Vertex;

vec4 view = mvi[3]-gl_Vertex;

lvec = TBN(light0.xyz);
vvec = TBN(view.xyz);

gl_TexCoord[0] = gl_MultiTexCoord0;

vcol =gl_Color;
}
“”"

FragmentShader = “”"
varying vec4 vcol;
varying vec3 lvec,vvec,hvec;

uniform sampler2D color;
uniform sampler2D bump;

void main() {
vec4 diffuse_color = vcol*gl_LightSource[0].diffuse;
vec4 specular_color = gl_FrontMaterial.specular;
vec4 colormap = texture2D(color, gl_TexCoord[0].st);

vec3 lv = normalize(lvec);
vec3 vv = normalize(vvec);
vec3 nv = normalize(2.0*texture2D(bump, gl_TexCoord[0].st).xyz-1.0);

float diff = max(dot(lv, nv), 0.0);
float spec = pow(max(dot(reflect(-vv, nv), lv),0.0), gl_FrontMaterial.shininess);

vec4 diff_pass = colormap*(diffdiffuse_color);
vec4 spec_pass = spec
specular_color;
gl_FragColor = vec4(0.1,0.1,0.1,1.0)+diff_pass+spec_pass;
}
“”"

def MainLoop ():

for each object

for obj in ShaderObjects:

mesh_index = 0
mesh = obj.getMesh(mesh_index)

while mesh != None:

for mat in mesh.materials:

regular TexFace materials do NOT have this function

if not hasattr(mat, “getMaterialIndex”):
return

mat_index = mat.getMaterialIndex()

find an index

found = 0
for i in range(len(MaterialIndexList)):
if mat_index == MaterialIndexList[i]:
found=1
break
if not found: continue

shader = mat.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(VertexShader, FragmentShader,1)

shader.setAttrib(g.SHD_TANGENT)

shader.setUniformDef(‘mvi’, g.MODELVIEWMATRIX_INVERSE)
shader.setSampler(‘color’, 0)
shader.setSampler(‘bump’, 1)

mesh_index += 1
mesh = obj.getMesh(mesh_index)

I guess it is related to new UV maping tools (unwrap) and GLSL integration.

Here is an alternative Download Link.

Hi Thorgal
I’ve played around with the Shader a While. There is no much Difference to the Shader, used in the File.
It uses the Normal Map for Tangent Values in the Vertex Shader.
Tangent = gl_MultiTexCoord1;
Sounds good, but i’ve expandet it to an Parallax Version with the same Problem. :frowning:

But to the Parallax Shader:
If removing the TBN Function from the Vertex Shader Values, it works!
lvec = (light0.xyz);
vvec = (view.xyz);

But only if the Vertex have no local Z Values. You can rotate the Objekt. It will still work fine, but rotating the Face (in Edit Mode), it will fail.

I can’t get any Shaders i’ve found in the Web working. Can it be, that the gl_Normal Function itself is bugy?

EDIT …
Finally i got it. Haha! Oh Men! I thought it was a coding Problem! No, it seems gl_Normal does not work with Quads! So it schould be better to don’t use them!
CTRL+T did the Trick! :smiley:

Ok, Ashes on my Head, my Mistake! But anyway, thanks for helping. :slight_smile:

Awesome! As usually. Congratulations master! Tris… sure! Let me see if it solves my problem… (I am at an internet cafe right now).

Btw i miss your old “Blue Brothers” avatar. But this other one looks very cute. :cool:

Hug.
Ortiz
EDIT: Sadly, “Ctrl T” was not enough to correct this problem: (http://www.youtube.com/watch?v=PtczGOO5Oyg) :frowning:
But… this is a very small issue. BGE Rocks! :stuck_out_tongue: