Sunday, November 22, 2009

PyStream Texture Support

PyStream now supports textures. There are a lot of simple issues like texture mapping that have been lost in the shuffle until now, and I am going back to fix.



def shadeVertex(self, context, pos, normal, texCoord):
    trans     = self.worldToCamera*self.objectToWorld
    newpos    = trans*pos
    newnormal = trans*vec4(normal, 0.0)

    context.position = self.projection*newpos

    return newpos.xyz, newnormal.xyz, texCoord

def shadeFragment(self, context, pos, normal, texCoord):
    surface = self.material.surface(pos, normal.normalize())

    # Texture
    surface.diffuseColor *= self.sampler.texture(texCoord).xyz
    
    # Accumulate lighting
    self.ambient.accumulate(surface, self.worldToCamera)
    self.light.accumulate(surface, self.worldToCamera)
                
    mainColor = surface.litColor()

    mainColor = rgb2srgb(tonemap(mainColor))
    
    mainColor = vec4(mainColor, 1.0)
    context.colors = (mainColor,)

1 comment:

  1. Harrah's Cherokee Casino & Hotel - Mapyro
    The 아산 출장안마 Harrah's Cherokee Casino & Hotel is a casino in Cherokee, North Carolina and is open daily 24 hours. The 문경 출장샵 casino has 의정부 출장마사지 a restaurant 목포 출장샵 on site. Rating: 4.2 · ‎12 reviews 당진 출장마사지

    ReplyDelete