working texture?
This commit is contained in:
parent
c89a3a9ab5
commit
d69354ea09
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
//"log"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -15,7 +16,8 @@ func Col2Uint(r, g, b byte) uint {
|
|||||||
|
|
||||||
func Color2Uint(col color.Color) uint {
|
func Color2Uint(col color.Color) uint {
|
||||||
r, g, b, _ := col.RGBA()
|
r, g, b, _ := col.RGBA()
|
||||||
return uint((r << 16) | (g << 8) | b)
|
//log.Print(r, g, b)
|
||||||
|
return uint(((r & 0xff00) << 8) | (g & 0xff00) | ((b & 0xff00) >> 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert uint to rgb (in that order)
|
// Convert uint to rgb (in that order)
|
||||||
|
@ -111,7 +111,7 @@ func main() {
|
|||||||
n = n.Normalize()
|
n = n.Normalize()
|
||||||
intensity := n.MultSimp(&light)
|
intensity := n.MultSimp(&light)
|
||||||
if intensity > 0 {
|
if intensity > 0 {
|
||||||
Triangle3t(&fb, texture, intensity, byte(255*intensity), byte(255*intensity)), sc[0], sc[1], sc[2])
|
Triangle3t(&fb, texture, intensity, sc[0], sc[1], sc[2])
|
||||||
//Triangle3(&fb, uint(rand.Int()), sc[0], sc[1], sc[2])
|
//Triangle3(&fb, uint(rand.Int()), sc[0], sc[1], sc[2])
|
||||||
//Triangle1(&fb, uint(rand.Int()), sc[0].ToVec2i(), sc[1].ToVec2i(), sc[2].ToVec2i())
|
//Triangle1(&fb, uint(rand.Int()), sc[0].ToVec2i(), sc[1].ToVec2i(), sc[2].ToVec2i())
|
||||||
//Triangle2(&fb, 0xFFFFFF, sc[0], sc[1], sc[2])
|
//Triangle2(&fb, 0xFFFFFF, sc[0], sc[1], sc[2])
|
||||||
|
@ -326,7 +326,7 @@ func Triangle3t(fb *Framebuffer, texture image.Image, intensity float32, v0v Ver
|
|||||||
//log.Print(pz)
|
//log.Print(pz)
|
||||||
fb.ZBuffer[x+y*fb.Width] = pz
|
fb.ZBuffer[x+y*fb.Width] = pz
|
||||||
txo := int(float32(tw) * (w0a*v0v.Tex.X + w1a*v1v.Tex.X + w2a*v2v.Tex.X))
|
txo := int(float32(tw) * (w0a*v0v.Tex.X + w1a*v1v.Tex.X + w2a*v2v.Tex.X))
|
||||||
tyo := int(float32(th) * (w0a*v0v.Tex.Y + w1a*v1v.Tex.Y + w2a*v2v.Tex.Y))
|
tyo := int(float32(th) * (1 - (w0a*v0v.Tex.Y + w1a*v1v.Tex.Y + w2a*v2v.Tex.Y)))
|
||||||
col := texture.At(tx+txo, ty+tyo)
|
col := texture.At(tx+txo, ty+tyo)
|
||||||
//c := texture.At()
|
//c := texture.At()
|
||||||
fb.Set(x, y, Color2Uint(col)) //uint(texture.Bounds().Dx())
|
fb.Set(x, y, Color2Uint(col)) //uint(texture.Bounds().Dx())
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
if [ $# -ne 1 ]; then
|
if [ $# -ne 1 ]; then
|
||||||
echo "You must pass the basename for the .prof and .ppm"
|
echo "You must pass the basename for the .prof and .ppm"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user