mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Move ambient color to lightubo
This commit is contained in:
20
main.go
20
main.go
@ -242,6 +242,7 @@ type LightsUboData struct {
|
|||||||
DirLight DirLightUboData
|
DirLight DirLightUboData
|
||||||
PointLights [POINT_LIGHT_COUNT]PointLightUboData
|
PointLights [POINT_LIGHT_COUNT]PointLightUboData
|
||||||
SpotLights [SPOT_LIGHT_COUNT]SpotLightUboData
|
SpotLights [SPOT_LIGHT_COUNT]SpotLightUboData
|
||||||
|
AmbientColor gglm.Vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -333,8 +334,6 @@ var (
|
|||||||
dpiScaling float32
|
dpiScaling float32
|
||||||
|
|
||||||
// Light settings
|
// Light settings
|
||||||
ambientColor = gglm.NewVec3(20.0/255, 20.0/255, 20.0/255)
|
|
||||||
|
|
||||||
dirLightDir = gglm.NewVec3(0, -0.5, -0.8)
|
dirLightDir = gglm.NewVec3(0, -0.5, -0.8)
|
||||||
// Lights
|
// Lights
|
||||||
dirLight = DirLight{
|
dirLight = DirLight{
|
||||||
@ -614,7 +613,6 @@ func (g *Game) Init() {
|
|||||||
whiteMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
whiteMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
||||||
whiteMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
whiteMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
||||||
whiteMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
whiteMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
||||||
whiteMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
whiteMat.SetUnifFloat32("material.shininess", whiteMat.Shininess)
|
whiteMat.SetUnifFloat32("material.shininess", whiteMat.Shininess)
|
||||||
whiteMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
whiteMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
||||||
whiteMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
whiteMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
||||||
@ -629,7 +627,6 @@ func (g *Game) Init() {
|
|||||||
containerMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
containerMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
||||||
containerMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
containerMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
||||||
containerMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
containerMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
||||||
containerMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
containerMat.SetUnifFloat32("material.shininess", containerMat.Shininess)
|
containerMat.SetUnifFloat32("material.shininess", containerMat.Shininess)
|
||||||
containerMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
containerMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
||||||
containerMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
containerMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
||||||
@ -644,7 +641,6 @@ func (g *Game) Init() {
|
|||||||
groundMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
groundMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
||||||
groundMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
groundMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
||||||
groundMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
groundMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
||||||
groundMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
groundMat.SetUnifFloat32("material.shininess", groundMat.Shininess)
|
groundMat.SetUnifFloat32("material.shininess", groundMat.Shininess)
|
||||||
groundMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
groundMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
||||||
groundMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
groundMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
||||||
@ -658,7 +654,6 @@ func (g *Game) Init() {
|
|||||||
palleteMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
palleteMat.SetUnifInt32("material.specular", int32(materials.TextureSlot_Specular))
|
||||||
palleteMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
palleteMat.SetUnifInt32("material.normal", int32(materials.TextureSlot_Normal))
|
||||||
palleteMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
palleteMat.SetUnifInt32("material.emission", int32(materials.TextureSlot_Emission))
|
||||||
palleteMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
palleteMat.SetUnifFloat32("material.shininess", palleteMat.Shininess)
|
palleteMat.SetUnifFloat32("material.shininess", palleteMat.Shininess)
|
||||||
palleteMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
palleteMat.SetUnifInt32("dirLightShadowMap", int32(materials.TextureSlot_ShadowMap1))
|
||||||
palleteMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
palleteMat.SetUnifInt32("pointLightCubeShadowMaps", int32(materials.TextureSlot_Cubemap_Array))
|
||||||
@ -699,8 +694,6 @@ func (g *Game) Init() {
|
|||||||
|
|
||||||
// Fbos and lights
|
// Fbos and lights
|
||||||
g.initFbos()
|
g.initFbos()
|
||||||
g.applyLightUpdates()
|
|
||||||
|
|
||||||
// Ubos
|
// Ubos
|
||||||
g.initUbos()
|
g.initUbos()
|
||||||
|
|
||||||
@ -708,6 +701,7 @@ func (g *Game) Init() {
|
|||||||
cam.Update()
|
cam.Update()
|
||||||
updateAllProjViewMats(cam.ProjMat, cam.ViewMat)
|
updateAllProjViewMats(cam.ProjMat, cam.ViewMat)
|
||||||
|
|
||||||
|
lightsUboData.AmbientColor = gglm.NewVec3(20.0/255, 20.0/255, 20.0/255)
|
||||||
g.applyLightUpdates()
|
g.applyLightUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,6 +756,9 @@ func (g *Game) initUbos() {
|
|||||||
{Id: 20, Type: buffers.DataTypeFloat32}, // 04 176
|
{Id: 20, Type: buffers.DataTypeFloat32}, // 04 176
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Ambient
|
||||||
|
{Id: 21, Type: buffers.DataTypeVec3}, // 12 192
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -957,11 +954,8 @@ func (g *Game) showDebugWindow() {
|
|||||||
// Ambient light
|
// Ambient light
|
||||||
imgui.Text("Ambient Light")
|
imgui.Text("Ambient Light")
|
||||||
|
|
||||||
if imgui.ColorEdit3("Ambient Color", &ambientColor.Data) {
|
if imgui.ColorEdit3("Ambient Color", &lightsUboData.AmbientColor.Data) {
|
||||||
whiteMat.SetUnifVec3("ambientColor", &ambientColor)
|
updateLights = true
|
||||||
containerMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
groundMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
palleteMat.SetUnifVec3("ambientColor", &ambientColor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imgui.Spacing()
|
imgui.Spacing()
|
||||||
|
|||||||
@ -52,6 +52,7 @@ layout (std140) uniform Lights {
|
|||||||
DirLight dirLight;
|
DirLight dirLight;
|
||||||
PointLight pointLights[NUM_POINT_LIGHTS];
|
PointLight pointLights[NUM_POINT_LIGHTS];
|
||||||
SpotLight spotLights[NUM_SPOT_LIGHTS];
|
SpotLight spotLights[NUM_SPOT_LIGHTS];
|
||||||
|
vec3 ambientColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -197,10 +198,9 @@ layout (std140) uniform Lights {
|
|||||||
DirLight dirLight;
|
DirLight dirLight;
|
||||||
PointLight pointLights[NUM_POINT_LIGHTS];
|
PointLight pointLights[NUM_POINT_LIGHTS];
|
||||||
SpotLight spotLights[NUM_SPOT_LIGHTS];
|
SpotLight spotLights[NUM_SPOT_LIGHTS];
|
||||||
|
vec3 ambientColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
uniform vec3 ambientColor = vec3(0.2, 0.2, 0.2);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Outputs
|
// Outputs
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user