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 6378111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:57:43+00:00 2026-05-25T01:57:43+00:00

When you create a brush in a 3D map editor such as Valve’s Hammer

  • 0

When you create a brush in a 3D map editor such as Valve’s Hammer Editor, textures of the object are by default repeated and aligned to the world coordinates.

How can i implement this functionality using OpenGL?

Can glTexGen be used to achieve this?

Or do i have to use texture matrix somehow?

If i create 3×3 box, then it’s easy:
Set GL_TEXTURE_WRAP_T to GL_REPEAT
Set texturecoords to 3,3 at the edges.

But if the object is not an axis aligned convexhull it gets, uh, a bit complicated.

Basically i want to create functionality of face edit sheet from Valve Hammer:

Valve Hammer Face Edit tool

  • 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-05-25T01:57:44+00:00Added an answer on May 25, 2026 at 1:57 am

    Technically you can use texture coordinate generation for this. But I recommend using a vertex shader that generates the texture coordinates from the transformed vertex coordinates. Be a bit more specific (I don’t know Hammer very well).


    After seeing the video I understand your confusion. I think you should know, that Hammer/Source probably don’t have the drawing API generate texture coordinates, but produce them internally.

    So what you can see there are textures that are projected on either the X, Y or Z plane, depending in which major direction the face is pointing to. It then uses the local vertex coordinates as texture coordinates.

    You can implement this in the code loading a model to a Vertex Buffer Object (more efficient, since the computation is done only once), or in a GLSL vertex shader. I’ll give you the pseudocode:

    cross(v1, v2):
        return { x = v1.y * v2.z - v1.z * v2.y,
                 y = v2.x * v1.z - v2.z * v1.x, // <- "swapped" order!
                 z = v1.x * v2.y - v1.y * v2.x }
    
    normal(face): 
        return cross(face.position[1] - face.position[0], face.position[2] - face.position[0])
    
    foreach face in geometry:
        n = normal(face) // you'd normally precompute the normals and store them
        if abs(n.x) > max(abs(n.y), abs(n.z)): // X major axis, project to YZ plane
            foreach (i, pos) in enumerate(face.position):
                 face.texcoord[i] = { s = pos.y, t = pos.z }
    
        if abs(n.y) > max(abs(n.x), abs(n.z)): // Y major axis, project to XZ plane
            foreach (i, pos) in enumerate(face.position):
                 face.texcoord[i] = { s = pos.x, t = pos.z }
    
        if abs(n.z) > max(abs(n.y), abs(n.x)): // Z major axis, project to XY plane
            foreach (i, pos) in enumerate(face.position):
                 face.texcoord[i] = { s = pos.x, t = pos.y }
    

    To make this work with glTexGen texture coordinate generation, you’d have to split your models into parts of each major axis. What glTexGen does is just the mapping step face.texcoord[i] = { s = pos.<>, t = pos.<> }. In a vertex shader you can do the branching directly.

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

Sidebar

Related Questions

I was trying to create a brush that draws a geometry. Everything worked fine
I'm looking to create a progress bar that doesn't use the WPF default style,
I want to create a custom brush in WPF that will be applied to
I want to create a list of BrushInfo which has properties of a brush
When I do this I get: Cannot create default converter to perform 'one-way' conversions
I need to do this in order to create a dynamic background brush for
I'm working with WP7, and i'd like to create a custom brush (as a
I am looking for ideas to create a WPF Brush with a brushed steel
create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int
Create a flat text file in c++ around 50 - 100 MB with the

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.