Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8397663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:51:02+00:00 2026-06-09T20:51:02+00:00

I have been working on a 3D rendering project as a technical excersise to

  • 0

I have been working on a 3D rendering project as a technical excersise to see if I can replicate what a lot of the 3D frameworks do already: all the way from loading the model to plotting the triangles to a buffer ready to be drawn.

Here is a sample of what I have managed to produce
Render of program output

As you can see from the screenshot I have hit a snag plotting the textures on the surface. This Wikipedia link I have found explains about affine vs non-affine.
Some other links similar to this one about perspective correct texture mapping go into it in more detail.

I still do not understand how I can correct my UV coordinates when plotting a pixel.

How my engine currently works with a triangle:
Convert 3D vertex data into 2D screen data
call draw triangle passing depth between 0 & 1 and texture details
within draw triangle each vertical line is draw by interpolating along the 3 edges of the triangle

I have made the changes in the links but I get divide by zero errors. If I ignore them nothing is drawn.

The question

How can I correct the UV co-ordinate selected at each pixel. Currently at each pixel I know the depth between 0.0 and 1.0, the apparent UV.

Any help would be much appreciated. Thank you in advance.

Tom 🙂

UPDATE:

Solution, use Andreas Brinck’s answer. It works fine. Below is a screenshot of it now working.

working correct perspective texture mapping

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:51:04+00:00Added an answer on June 9, 2026 at 8:51 pm

    Instead of interpolating u and v over the triangle, interpolate u/z, v/z and 1/z (calculated at the vertices) and retrieve the perspective correct coordinates as (u/z) / (1/z) and (v/z) / (1/z).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a project in C# (.net4). Project pretty much allows
I have been working on a project on and off, but I haven't touched
I have been working on a huge ETL project with 150+ tables and during
I have been working in a project that have been working wothount problems till
I have been working on an app all day which has been working fine
For a school assignment me and a friend have been working on rendering a
I have been working on a perspective projection rendering demo using javascript, recently I
I have been working with a small team on a small project about fiction
I have a small open source OSX project I've been working on that I'd
Have been working on this question for a couple hours and have come close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.