wraitii Posted July 3, 2012 Report Share Posted July 3, 2012 Played around with the shaders... Setting a_normal as the output color. It flickers. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 3, 2012 Author Report Share Posted July 3, 2012 This is completely based on a hunch, so don't count that it'll work.Can you please try going into renderer/InstancingModelRenderer.cpp and after the line:CModelDefPtr mdldef = model->GetModelDef();add:glDepthFunc(GL_LEQUAL);& recompile. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 3, 2012 Report Share Posted July 3, 2012 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? Quote Link to comment Share on other sites More sharing options...
myconid Posted July 3, 2012 Author Report Share Posted July 3, 2012 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. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 3, 2012 Report Share Posted July 3, 2012 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. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 3, 2012 Author Report Share Posted July 3, 2012 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). Quote Link to comment Share on other sites More sharing options...
MrEmjeR Posted July 3, 2012 Report Share Posted July 3, 2012 hey myconid, can i give a try on a tilt-shift shader? Quote Link to comment Share on other sites More sharing options...
myconid Posted July 3, 2012 Author Report Share Posted July 3, 2012 hey myconid, can i give a try on a tilt-shift shader?Sure! If you want a way to try it in-game, you'll need to apply the old "bumpy4" patch, as screen-space effects still aren't in the new git. Quote Link to comment Share on other sites More sharing options...
Mythos_Ruler Posted July 4, 2012 Report Share Posted July 4, 2012 Tilt shift would be excellent for a possible "Campaign map" style single player game. See: Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 (edited) 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 July 4, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
myconid Posted July 4, 2012 Author Report Share Posted July 4, 2012 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 functionvoid 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. Quote Link to comment Share on other sites More sharing options...
zoot Posted July 4, 2012 Report Share Posted July 4, 2012 (edited) 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 July 5, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 (edited) @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 July 4, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
myconid Posted July 4, 2012 Author Report Share Posted July 4, 2012 (edited) 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 functionCShaderProgram::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 July 4, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 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. Quote Link to comment Share on other sites More sharing options...
myconid Posted July 4, 2012 Author Report Share Posted July 4, 2012 (edited) 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 July 4, 2012 by myconid Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 (edited) 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 July 4, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
myconid Posted July 4, 2012 Author Report Share Posted July 4, 2012 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); Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 (edited) The problem actually came from me completely messing up my transposition... I fixed it and it appears to work. I'll just have to check if it's the right direction. Edited July 4, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 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... Quote Link to comment Share on other sites More sharing options...
myconid Posted July 4, 2012 Author Report Share Posted July 4, 2012 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. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 4, 2012 Report Share Posted July 4, 2012 I'll try to do the water shader for ARB first, and I'll then try to push that. Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted July 4, 2012 Report Share Posted July 4, 2012 Excellent, I was hoping we could get this working for non-GLSL hardware For those unaware of the difference, I found this page last night: http://www.opengl.org/wiki/Selecting_a_Shading_Language which gives an overview of the different choices for shaders, pros and cons. Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 5, 2012 Report Share Posted July 5, 2012 (edited) 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 July 5, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
wraitii Posted July 5, 2012 Report Share Posted July 5, 2012 (edited) 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 July 5, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.