Jump to content

Post-processing effects test (SSAO/HDR/Bloom)


Recommended Posts

Doesn't seem to change anything.

You seem to give the GLSL shaders a "a_tangent" matrix/vector used in normal mapping... Any idea how I can get the ARB shaders to use it?

I haven't looked at the ARB shaders much, but I suspect you'd need to modify shaders/arb/model_common.xml and tell it to expect an extra stream.

Link to comment
Share on other sites

Looks like it's a bit of a mess... And IIRC you calculate tangents on the fly, which may require GLSL in the first place.

Dunno, I haven't looked at the ARB code. Maybe you could try using Nvidia's CG compiler to do the conversion automatically. I haven't tested it, though in theory it should be able to convert everything except the parallax mapping.

The tangents are calculated on the CPU and then passed in to the shaders. I believe both the GLSL and ARB are invoked using the same code on the CPU side, and if Nvidia's compiler really works, it should know how to find them (as long as you set up the xml config).

Link to comment
Share on other sites

The tangents are calculated on the CPU and then passed in to the shaders. I believe both the GLSL and ARB are invoked using the same code on the CPU side, and if Nvidia's compiler really works, it should know how to find them (as long as you set up the xml config).

Actually, it looks like you're using glVertexAttribPointerARB() to pass the tangents to the shader, and as it happens, I do not believe this function does anything to the ARB shader... I'll take a look at the code and see if I can use an alternative for the ARB shaders.It's not as complicated as I initially thought.

Edit: Nope, complicated indeed. I've understood how to pass a new uniform, but the tangents are stored in a weird pointer thingy that uses the GLSL only "VertexAttribPointer" function... It probably can be replaced by some variation of "glVertexAttrib4fv" but I have no idea which exactly.

Edited by wraitii
Link to comment
Share on other sites

Actually, it looks like you're using glVertexAttribPointerARB() to pass the tangents to the shader, and as it happens, I do not believe this function does anything to the ARB shader... I'll take a look at the code and see if I can use an alternative for the ARB shaders.It's not as complicated as I initially thought.

You've probably figured this out by now, but you might want to try passing the data as texcoords instead.

I.e. you could override this function


void CShaderProgram::VertexAttribPointer(const char* UNUSED(id), GLint UNUSED(size), GLenum UNUSED(type),
GLboolean UNUSED(normalized), GLsizei UNUSED(stride), void* UNUSED(pointer))

in CShaderProgramARB and try to hack it so it passes its arguments with glTexCoordPointer.

Link to comment
Share on other sites

I'll try to see if I can port your glsl shaders to arb, which seems to work.

If you manage to convert all the modelmapping shaders to ARB, that should increase the chance of getting them into A11 considerably (because it would remove the need for an unwieldy GLSL compatibility database).

If you feel like pushing any of your work to Github, I'd be happy to help test/debug.

Edited by zoot
Link to comment
Share on other sites

@Myconid: Yeah, that was part of the plan I had... Only I'm not completely understanding the "pointer" argument, and I'm not sure I can pass that as a texture coord. I'll ook into it, I can perhaps pass it as a secondary color.

@Zoot: I'll see that when I get it working. I wonder if converting the water shader to ARB would fix #966/#1380.

Edited by wraitii
Link to comment
Share on other sites

It's the address of the first tangent of the first vertex in memory and it's passed in from the renderer. You don't need to change that in any way, it's the same as with glVertexAttribPointerARB.

Looking at the code now, you probably want to call this function


CShaderProgram::TexCoordPointer(GLenum texture, GLint size, GLenum type, GLsizei stride, void* pointer)

from CShaderProgramARB::VertexAttribPointer. The size, type, stride and pointer are passed unchanged. You'll need to figure out how to get a value for the "texture" parameter, though.

Edited by myconid
Link to comment
Share on other sites

Allright, it looks like I've managed to do it by passing to to ColorPointer (apparently unused by instancingModelRenderer or ModelRenderer). I'll see if I can do something with that.

Well, if you are going to hardcode it like that, you might as well use this:


void CShaderProgramARB::VertexAttribPointer(const char* id, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, void* pointer)
{
TexCoordPointer(GL_TEXTURE1, size, type, stride, pointer);
}

because you can't trust the colour interpolation to always be very accurate.

Edited by myconid
Link to comment
Share on other sites

I'll trust you on that one.

Making some progress, but I wonder if there's something wrong with my normals, it doesn't react like i'd have expected it too... SHowing the normals after transformations, I get this. It sure isn't completely wrong, but it feels sort of weird (the marble in front for example… Why is it split in two?) Do you think this is correct?

Also: you transpose the matrix (for the normal calculation). I'm not sure why... Apparently, it changes the behaviour of the vector*matrix multiplication done later. But as none of these two functions exist in ARB, you must do it yourself, and I'm not sure it's needed...

Edited by wraitii
Link to comment
Share on other sites

I'll trust you on that one.

Making some progress, but I wonder if there's something wrong with my normals, it doesn't react like i'd have expected it too... SHowing the normals after transformations, I get this. It sure isn't completely wrong, but it feels sort of weird (the marble in front for example… Why is it split in two?) Do you think this is correct?

That looks wrong. The normals should always face in the direction of the surface, so that should probably be all green.

Also: you transpose the matrix (for the normal calculation). I'm not sure why... Apparently, it changes the behaviour of the vector*matrix multiplication done later. But as none of these two functions exist in ARB, you must do it yourself, and I'm not sure it's needed...

There used to be an optimisation somewhere in there, though it got taken out and you're left with bits and pieces. Because of this, you can remove the transpose, if you change the following matrix multiplication to have the matrix on the left. ie:


mat3 tbn = mat3(v_tangent.xyz, v_bitangent * -sign, v_normal);
...
normal = normalize(tbn * ntex);

Link to comment
Share on other sites

Allright. So I've gotten normal mapping to work with specular and diffuse lighting, but parallax mapping requires loops/conditionals, which ARB doesn't allow as is. I also failed to use the secondary set of UVs for AO.

I don't think using the '08 NVIDIA extension would do any good...

Link to comment
Share on other sites

Allright. So I've gotten normal mapping to work with specular and diffuse lighting, but parallax mapping requires loops/conditionals, which ARB doesn't allow as is. I also failed to use the secondary set of UVs for AO.

I don't think using the '08 NVIDIA extension would do any good...

Nice work. :)

A low-quality parallax could be done with manual loop unrolling (basically by duplicating the code for each loop).

If you push your work to github I'll test it, if you want.

Link to comment
Share on other sites

Yeah, from the looks of it I might be able to do a simple parallax, but I'd really doubt that given the very basic capabilities of ARB. I might be able to port the water shader, again, perhaps fixing that one bug I mentioned.

I'll look into the GLSL problem, however. There's hardly a reason for it to crash that way.

Edit: also, I must do the terrain specular/diffuse mapping, and perhaps give a look at trilinear texturing.

Edited by wraitii
Link to comment
Share on other sites

Okay, so I've ported the water shader to ARB. It's been surprisingly straightforward, this time. The code and everything else works nicely, however, I'm not too sure how to push that to github/wherever... I'm not used to those things. Any tutorials/guidelines?

While the water patch is extremely neat (the 3 shader files, and 4 lines modified in terrainRenderer.cpp), the other patch might be more messy (as I tried stuff, I may have modified tons of little things here and there in a few files).

I'll check if it fixes the water bug on my MacBook Air when it's finished copying.

BTW, I might give a shot at slightly improving the shader... The waviness factor is used in very weird ways.

Edited by wraitii
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...