Jump to content
  • Advertisement

L0rdDiabl0

Member
  • Content Count

    53
  • Joined

  • Last visited

Community Reputation

122 Neutral

About L0rdDiabl0

  • Rank
    Member
  1. L0rdDiabl0

    Problem in vertex/fragment programs

    Nobody can help me? at least tell me if this is the correct way of input, I suspect the problem has something to do with the input glEnableVertexAttribArrayARB(1); glVertexAttribPointerARB(1, 3, GL_FLOAT, GL_FALSE, sizeof(Cube_Vertices), &cube.vertices[0].Normal); glEnableVertexAttribArrayARB(2); glVertexAttribPointerARB(2, 3, GL_FLOAT, GL_FALSE, sizeof(Cube_Vertices), &cube.vertices[0].Tangent); Thanks
  2. L0rdDiabl0

    Need a little help.

    You mean, you want help building your Camera Class?
  3. L0rdDiabl0

    Problem in vertex/fragment programs

    I did what _DarkWIng_ suggested, and I found out that the problem is with (Normal, Tangent) everything seems alright before transforming Light Vector to the Tangent Space, but TBN Matrix calculations are definitely right as they produce correct results using VBO and RC, so the only thing that might cause the error is the input of them in the vertex program, I’m doing this for the input glEnableVertexAttribArrayARB(1); glVertexAttribPointerARB(1, 3, GL_FLOAT, GL_FALSE, sizeof(Cube_Vertices), &cube.vertices[0].Normal); glEnableVertexAttribArrayARB(2); glVertexAttribPointerARB(2, 3, GL_FLOAT, GL_FALSE, sizeof(Cube_Vertices), &cube.vertices[0].Tangent); Is there something wrong with this? And here’s the updated vp/fp for diffuse light only, the result is flashing triangles and cube. Vertex program !!ARBvp1.0 #Per-vertex inputs ATTRIB Position = vertex.position; ATTRIB Color = vertex.color; ATTRIB Normal = vertex.attrib[1]; ATTRIB Tangent = vertex.attrib[2]; ATTRIB DecalTex = vertex.texcoord[0]; ATTRIB NormalTex = vertex.texcoord[1]; #Constant Parameters PARAM mvp[4] = {state.matrix.mvp}; PARAM mvinv[4] = {state.matrix.modelview.invtrans}; PARAM EyeLightPos = program.local[5]; TEMP LightPos, Binormal, LightVector; #Per-vertex outputs OUTPUT oPosition = result.position; OUTPUT oColor = result.color; OUTPUT oDecalTex = result.texcoord[0]; OUTPUT oNormalTex = result.texcoord[1]; OUTPUT TS_LightVector = result.texcoord[2]; #Transform the Vertex to Clip Space DP4 oPosition.x, mvp[0], Position; DP4 oPosition.y, mvp[1], Position; DP4 oPosition.z, mvp[2], Position; DP4 oPosition.w, mvp[3], Position; #Transform Light Position from Eye Space to Object Space (Using Inverse Model-View Matrix) DP3 LightPos.x, mvinv[0], EyeLightPos; DP3 LightPos.y, mvinv[1], EyeLightPos; DP3 LightPos.z, mvinv[2], EyeLightPos; #Calculate Binormal XPD Binormal, Normal, Tangent; #Create Light Vector ADD LightVector, LightPos, -Position; #Transform Light Vector to Tangent Space DP3 TS_LightVector.x, LightVector, Tangent; DP3 TS_LightVector.y, LightVector, Binormal; DP3 TS_LightVector.z, LightVector, Normal; MOV oColor, Color; MOV oDecalTex , DecalTex; MOV oNormalTex , NormalTex; END fragment program !!ARBfp1.0 #Fragment inputs ATTRIB Color = fragment.color.primary; # Diffuse interpolated color ATTRIB DecalTex = fragment.texcoord[0]; ATTRIB NormalTex = fragment.texcoord[1]; ATTRIB LightVector = fragment.texcoord[2]; TEMP texelColor, texelNormal, nLightVector, NdotL; #Fragment outputs OUTPUT outColor = result.color; #Texture Fetch TEX texelColor, DecalTex, texture[0], 2D; TEX texelNormal, NormalTex, texture[1], 2D; #Normalize Light Vector DP3 nLightVector.w, LightVector, LightVector; RSQ nLightVector.w, nLightVector.w; MUL nLightVector.xyz, nLightVector.w, LightVector; DP3 NdotL, texelNormal, nLightVector; #Modulate texel color with vertex color MUL outColor, texelColor, NdotL; END
  4. L0rdDiabl0

    Problem in vertex/fragment programs

    Thanks for the advice _DarkWIng_ I'll do that, and I'll report back when i find the source of the problem
  5. I’m trying to replace the fixed function pipeline in my demo with vp/fp , and after several weeks of tinkering with it, it started to work but it seems that something is not right and I can’t put my hand on it, The problem is with the lighting(diffuse, specualr), it looks wrong as if only one vertex is affected by lighting, and the lighting acts funny when moving the camera, and i'm putting the lightsource in the center of the cube. here's a screenshot http://www.myfilestash.com/userfiles/L0rdDiabl0/Normal.JPG so i thought some of the expert guys can spot where the problem is. Thanks in advance. here's the vertex program: !!ARBvp1.0 #Per-vertex inputs ATTRIB Position = vertex.position; ATTRIB Color = vertex.color; ATTRIB Normal = vertex.attrib[1]; ATTRIB Tangent = vertex.attrib[2]; ATTRIB DecalTex = vertex.texcoord[0]; ATTRIB NormalTex = vertex.texcoord[1]; #Constant Parameters PARAM mvp[4] = {state.matrix.mvp}; PARAM mvinv[4] = {state.matrix.modelview.invtrans}; PARAM EyeLightPos = state.light[0].position; PARAM EyeCameraPos = program.local[5]; TEMP LightPos, CameraPos, LightVector, ViewVector, HalfVector, Binormal, TS_LightVector, TS_HalfVector, mag; #Per-vertex outputs OUTPUT oPosition = result.position; OUTPUT oColor = result.color; OUTPUT oDecalTex = result.texcoord[0]; OUTPUT oNormalTex = result.texcoord[1]; OUTPUT LV_TexCoord = result.texcoord[2]; OUTPUT HV_TexCoord = result.texcoord[3]; #Transform the Vertex to Clip Space DP4 oPosition.x, mvp[0], Position; DP4 oPosition.y, mvp[1], Position; DP4 oPosition.z, mvp[2], Position; DP4 oPosition.w, mvp[3], Position; #Transform Light Position from Eye Space to Object Space (Using Inverse Model-View Matrix) DP4 LightPos.x, mvinv[0], EyeLightPos; DP4 LightPos.y, mvinv[1], EyeLightPos; DP4 LightPos.z, mvinv[2], EyeLightPos; #Transform Camera Position from Eye Space to Object Space (Using Inverse Model-View Matrix) DP4 CameraPos.x, mvinv[0], EyeCameraPos; DP4 CameraPos.y, mvinv[1], EyeCameraPos; DP4 CameraPos.z, mvinv[2], EyeCameraPos; #Create Light Vector ADD LightVector, -Position, LightPos; #Create View Vector ADD ViewVector, -Position, CameraPos; #Create Half Vector ADD HalfVector, LightVector, ViewVector; #Normalize Light Vector DP3 mag.w, LightVector, LightVector; RSQ mag.w, mag.w; MUL LightVector.xyz, mag.w, LightVector; #Normalize Half Vector DP3 mag.w, HalfVector, HalfVector; RSQ mag.w, mag.w; MUL HalfVector.xyz, mag.w, HalfVector; #Calculate Binormal XPD Binormal, Normal, Tangent; #Transform Light Vector to Tangent Space DP3 TS_LightVector.x, LightVector, Tangent; DP3 TS_LightVector.y, LightVector, Binormal; DP3 TS_LightVector.z, LightVector, Normal; #Transform View Vector to Tangent Space DP3 TS_HalfVector.x, HalfVector, Tangent; DP3 TS_HalfVector.y, HalfVector, Binormal; DP3 TS_HalfVector.z, HalfVector, Normal; MOV oColor, Color; MOV oDecalTex , DecalTex; MOV oNormalTex, NormalTex; MOV LV_TexCoord , TS_LightVector; MOV HV_TexCoord , TS_HalfVector; END and here's the fragment program: !!ARBfp1.0 #Fragment inputs ATTRIB DecalTexCoord = fragment.texcoord[0]; ATTRIB NormalTexCoord = fragment.texcoord[1]; ATTRIB LVTexCoord = fragment.texcoord[2]; ATTRIB HVTexCoord = fragment.texcoord[3]; #Fragment outputs OUTPUT outColor = result.color; TEMP texelColor, texelNormal, NdotL, NdotH, NormalizedLight, NormalizedHalf, Color; #Texture Fetch TEX texelColor, DecalTexCoord, texture[0], 2D; TEX texelNormal, NormalTexCoord, texture[1], 2D; #Normalize Light Vector, no need for it if LV is normalized with the cube map DP3 NormalizedLight.w, LVTexCoord, LVTexCoord; RSQ NormalizedLight.w, NormalizedLight.w; MUL NormalizedLight.xyz, NormalizedLight.w, LVTexCoord; #Normalize Half Vector, no need for it if HV is normalized with the cube map DP3 NormalizedHalf.w, HVTexCoord, HVTexCoord; RSQ NormalizedHalf.w, NormalizedHalf.w; MUL NormalizedHalf.xyz, NormalizedHalf.w, HVTexCoord; #This Computes N.L DP3 NdotL, texelNormal, NormalizedLight; #This Computes N.H DP3 NdotH, texelNormal, NormalizedHalf; MUL Color, NdotL, NdotH; #Modulate texel color with vertex color MUL outColor, texelColor, Color; END
  6. Yes, it's called nvemulate and you can find it here: http://developer.nvidia.com/object/nvemulate.html
  7. L0rdDiabl0

    winAlice & co.

    I found the program itself its very good, but i can't find its Source code, can you provide me with some link if possible?
  8. L0rdDiabl0

    Vertex/Fragment Program Debugger?

    Thanks for the Suggestions guys, guess i'll have to do it by hand
  9. L0rdDiabl0

    How do I do this DDRAW operation in OpenGL?

    vichollis: Can you send it to my E-mail too?
  10. L0rdDiabl0

    Vertex/Fragment Program Debugger?

    Sorry but i'm not using CG just plain ARB vp/fp extensions. Thanks for your help anyway.
  11. L0rdDiabl0

    Vertex/Fragment Program Debugger?

    Thanks for the response guys Lutz : How can i print the compiler(shader) output? it would be better than nothing. I found such program, its called shadesmith http://graphics.stanford.edu/projects/shadesmith/ but its so buggy like it crashes all the time and work only on ARB_FRAGMENT_PROGRAM and NV_FRAGMENT_PROGRAM. btw. Thanks vincoof for the great program (Cel-Shading) its the best Tutorial on Vertex/Fragment Programs
  12. Anybody know of a good debugger that can work with Vertex/Fragment Programs? Its really hard to find where the Error is in those programs without debugging and going through it step by step.
  13. L0rdDiabl0

    My Uni Project

    I would very much appreciate this kind of tool, but i think it should be quick and easy to use, and above all easy to understand File Format
  14. L0rdDiabl0

    Cool new stuff to do with openGL

    If i were you I would do real Displacement Mapping (using Vertex Textures), since so few demos or games have done that (only one game as i recall Pacific Fighters)
  15. L0rdDiabl0

    D3D - OpenGL #1 (SwapChains)

    I'm curious, why would you change from DX9.0 to OpenGL?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!