c++ - Texture Mapping without OpenGL -
so i'm supposed texture map specific model i've loaded scene (with framebuffer , planar pinhole camera), i'm not allowed utilize opengl , have no thought how otherwise (we utilize gldrawpixels other functionality, that's function can use).
is here able plenty give me run-through on how texture map without opengl functionality?
i'm supposed utilize these slides: https://www.cs.purdue.edu/cgvlab/courses/334/fall_2014/lectures/tmapping.pdf
but create little sense me.
what i've gathered far following:
you iterate on model, , assign each triangle "texture coordinates" (which i'm not sure are), , utilize "model space interpolation" (again, don't understand is) apply texture right perspective.
i have programme doing following:
tl;dr: 1. model space interpolation/how do it? 2. explicitly texture coordinates? 3. how, on high level (in layman's terms) texture map model without using opengl.
ok, let's start making sure we're both on same page how color interpolation works. lines 125 through 143 set 3 vectors redabc
, greenabc
, blueabc
used interpolate colors across triangle. work 1 color component @ time, , each of 3 vectors helps interpolate 1 color component.
by convention, s,t coordinates in source texture space. provided in mesh data, specify position within texture of particular vertex of triangle. crucial thing understand s,t coordinates need interpolated across triangle colors.
so, want set 2 more abc
vectors: sabc
, tabc
, duplicating logic used set redabc
, instead of using color components of each vertex, utilize s,t coordinates of each vertex. each pixel, instead of computing ssired
etc. unsigned int
values, compute ssis
, ssit
floats, should in range 0.0f
through 1.0f
assuming source s,t values behaved.
now have interpolated s,t coordinate, multiply ssis
texel width of texture, , ssit
texel height, , utilize coordinates fetch texel. set on screen.
c++ visual-c++ textures texture-mapping interpolation
No comments:
Post a Comment