• Welcome to Dark Bit Factory & Gravity.
 

little 3d cube with bumpmapping.

Started by ninogenio, May 18, 2013

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hellfire

#20
Quote from: ninogenio on May 27, 2013
an exe of your code that just does interpolated lightdir as rgb?
You can do that yourself, just change the last line in "data/spherefragments-frag.glsl" to:
gl_FragColor = vec4(nLightDir*0.5+0.5, 1.0);
Ooops, I copied the normalmap-stuff from a different project and didn't even change the filename ;)

Since the interpolated light direction is in normalmap space, the resulting rgbs are probably hard to figure out.
So if you want to display other values, you can easily pass them to the rasterizer the following way:

At the top of the vertex shader (-vert.glsl) add another "varying" variable (those get interpolated and passed to the fragment shader):
varying vec4 test;
And fill it with something interesting in the main:
test= normalize( (gl_ModelViewMatrix * gl_Vertex) - lightPosition );
(that's the light direction in world space)

At the top of the fragment shader (-frag.glsl) add the same varying variable:
varying vec4 test;
And write it into the color output:
gl_FragColor = test*0.5+0.5;
Challenge Trophies Won:

ninogenio

#21
ahh i never noticed the 2 shader files in there top stuff, i thought they had been build into the exe.

checking the interpolated color, im extreamly close too what you have there :).
thanks too everything you've posted over the last two normal mapping threads. me and everyone else now has a complete 101 on bumpmapping!! ill post the software version as soon as ive added the specular,

cheers mate!
Challenge Trophies Won:

ninogenio

#22
well after a few hours of head scratching tonight and playing around.
i think i finally have the diffuse component correct  :). there is probably still a few things not quite right but its close.

does opengl perspective correct the direction interpolation. im wondering if im possibly losing a bit of precision because im just affine mapping them atm.
Challenge Trophies Won:

hellfire

Looks nice and seems correct to me.
All vertex attributes are interpolated perspectively correct by the GPU.
In the times of Voodoo1 rgba was interpolated linearly across the polygon, don't know when exactly they scrapped that.
At this scale I doubt it makes much of a difference for the interpolated vectors, though.
Challenge Trophies Won:

ninogenio

#24
thanks hellfire,

you were right it wasnt really interpolation issues, my surface normals were not aligning properly with the faces of the cube so as it rotated the started pointing in the wrong directions, when i added specular it really showed this up bad.

ive fixed that and added specular highlights i think it looks pretty cool now  :).

also got rid of lots of the commented out code inside. and incorporated the specular and diffuse into the triangle routine for a bit of a speed bump. some of the dark areas get specular atm but thats just down too dist att i think its quite a trivial thing.

again thanks 10000% mate!!
Challenge Trophies Won: