FlipY texture flag, display world texture atlas

This commit is contained in:
2022-02-16 00:29:34 +08:00
parent 326253a73b
commit 565e0390f3
6 changed files with 86 additions and 17 deletions

View File

@ -2,6 +2,7 @@ package render
import (
"errors"
"math"
"math/rand"
"time"
"unsafe"
@ -132,6 +133,7 @@ func (r *WorldRenderer) Init(w *world.World) (err error) {
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_ANISOTROPY, maxaf)
r.gbuffer.shader.SetUniformTexture("tex", r.texture)
r.water.shader.SetUniformTexture("tex", r.texture)
igwrap.SetTextureFlag(r.texture.Handle(), igwrap.TextureFlag_RGBA, igwrap.TextureFlag_FlipY)
r.depthmap.shader.SetUniformMat4("model", mgl32.Ident4())
r.gbuffer.shader.SetUniformMat4("model", mgl32.Ident4())
@ -295,10 +297,11 @@ func (r *WorldRenderer) ResizeDisplay(newSize itype.Vec2i) {
}
var (
sun = [3]float32{0.2, 0.4, 0.3}
alpha = float32(0.55)
gamma = float32(2.2)
exposure = float32(1)
sun = [3]float32{0.2, 0.4, 0.3}
alpha = float32(0.55)
gamma = float32(2.2)
exposure = float32(1)
atlasScale = float32(1)
)
func (r *WorldRenderer) Render(world *world.World, view *View) {
@ -445,7 +448,7 @@ func (r *WorldRenderer) Render(world *world.World, view *View) {
// Show G-buffers?
if io.ShowDebugInfo {
imgui.SetNextWindowPosV(imgui.Vec2{X: float32(r.lastDisplaySize[0]), Y: 0}, imgui.ConditionAlways, imgui.Vec2{X: 1, Y: 0})
if igwrap.Begin("Renderer Textures/Outputs", nil, imgui.WindowFlagsAlwaysAutoResize|imgui.WindowFlagsNoBackground|imgui.WindowFlagsNoNavFocus|imgui.WindowFlagsNoDecoration|imgui.WindowFlagsNoInputs|imgui.WindowFlagsNoSavedSettings|imgui.WindowFlagsNoFocusOnAppearing) {
if igwrap.Begin("Renderer Textures/Outputs", nil, igwrap.WindowFlagsOverlay) {
imgui.PushStyleVarVec2(imgui.StyleVarItemSpacing, imgui.Vec2{})
imageSize := r.lastDisplaySize.ToFloat32().Multiply(0.25)
@ -460,5 +463,28 @@ func (r *WorldRenderer) Render(world *world.World, view *View) {
imgui.PopStyleVar()
imgui.End()
}
if igwrap.Begin("F3", nil, 0) {
imgui.PushStyleColor(imgui.StyleColorButton, imgui.Vec4{0, 0, 0, 0.5})
imgui.PushStyleColor(imgui.StyleColorButtonHovered, imgui.Vec4{0, 0, 0, 0.6})
imgui.PushStyleColor(imgui.StyleColorButtonActive, imgui.Vec4{0, 0, 0, 0.8})
igwrap.TextBlank()
isize := asset.WorldTextureAtlas.ImageSize
igwrap.TextBackground("Texture Atlas Size: (%dx%d)", isize[0], isize[1])
imgui.SameLine()
igwrap.TextBackground("[Hover]")
if imgui.IsItemHoveredV(imgui.HoveredFlagsAllowWhenDisabled) {
_, wheely := imgui.CurrentIO().MouseWheel()
if math.Abs(float64(wheely)) > 1e-3 {
atlasScale = util.Maxf(1, atlasScale+wheely)
}
imgui.BeginTooltip()
igwrap.Image(r.texture.Handle(), isize.ToFloat32().Multiply(atlasScale), itype.Rectf{0, 0, 1, 1})
imgui.EndTooltip()
}
imgui.PopStyleColorV(3)
imgui.End()
}
}
}