Skip to content

Commit

Permalink
Merge pull request #2098 from Eiton/3d-stage
Browse files Browse the repository at this point in the history
fix:embed file name typo
  • Loading branch information
K4thos authored Nov 4, 2024
2 parents 6d532dd + 2e4146d commit 702ad91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions src/render_gl.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ type Renderer struct {
// Shader and index data for 3D model rendering
shadowMapShader *ShaderProgram
modelShader *ShaderProgram
panoramaToCubemapShader *ShaderProgram
panoramaToCubeMapShader *ShaderProgram
cubemapFilteringShader *ShaderProgram
stageVertexBuffer uint32
stageIndexBuffer uint32
Expand Down Expand Up @@ -361,8 +361,8 @@ var identVertShader string
//go:embed shaders/ident.frag.glsl
var identFragShader string

//go:embed shaders/panoramaToCubemap.frag.glsl
var panoramaToCubemapFragShader string
//go:embed shaders/panoramaToCubeMap.frag.glsl
var panoramaToCubeMapFragShader string

//go:embed shaders/cubemapFiltering.frag.glsl
var cubemapFilteringFragShader string
Expand Down Expand Up @@ -420,10 +420,10 @@ func (r *Renderer) Init() {
r.shadowMapShader.RegisterUniforms("model", "lightMatrices[0]", "lightMatrices[1]", "lightMatrices[2]", "lightMatrices[3]", "lightMatrices[4]", "lightMatrices[5]", "lightType", "lightPos", "farPlane", "numJoints", "morphTargetWeight", "morphTargetOffset", "numTargets", "numVertices", "enableAlpha", "alphaThreshold", "baseColorFactor", "useTexture")
r.shadowMapShader.RegisterTextures("morphTargetValues", "jointMatrices", "tex")

r.panoramaToCubemapShader = newShaderProgram(identVertShader, panoramaToCubemapFragShader, "", "Panorama To Cubemap Shader")
r.panoramaToCubemapShader.RegisterAttributes("VertCoord")
r.panoramaToCubemapShader.RegisterUniforms("currentFace")
r.panoramaToCubemapShader.RegisterTextures("panorama")
r.panoramaToCubeMapShader = newShaderProgram(identVertShader, panoramaToCubeMapFragShader, "", "Panorama To Cubemap Shader")
r.panoramaToCubeMapShader.RegisterAttributes("VertCoord")
r.panoramaToCubeMapShader.RegisterUniforms("currentFace")
r.panoramaToCubeMapShader.RegisterTextures("panorama")

r.cubemapFilteringShader = newShaderProgram(identVertShader, cubemapFilteringFragShader, "", "Cubemap Filtering Shader")
r.cubemapFilteringShader.RegisterAttributes("VertCoord")
Expand Down Expand Up @@ -1137,22 +1137,22 @@ func (r *Renderer) RenderElements(mode PrimitiveMode, count, offset int) {
func (r *Renderer) RenderCubeMap(envTexture *Texture, cubeTexture *Texture, textureSize int32) {
gl.BindFramebuffer(gl.FRAMEBUFFER, r.fbo_env)
gl.Viewport(0, 0, textureSize, textureSize)
gl.UseProgram(r.panoramaToCubemapShader.program)
loc := r.panoramaToCubemapShader.a["VertCoord"]
gl.UseProgram(r.panoramaToCubeMapShader.program)
loc := r.panoramaToCubeMapShader.a["VertCoord"]
gl.EnableVertexAttribArray(uint32(loc))
gl.VertexAttribPointerWithOffset(uint32(loc), 2, gl.FLOAT, false, 0, 0)
data := f32.Bytes(binary.LittleEndian, -1, -1, 1, -1, -1, 1, 1, 1)
gl.BindBuffer(gl.ARRAY_BUFFER, r.vertexBuffer)
gl.BufferData(gl.ARRAY_BUFFER, len(data), unsafe.Pointer(&data[0]), gl.STATIC_DRAW)
loc, unit := r.panoramaToCubemapShader.u["panorama"], r.panoramaToCubemapShader.t["panorama"]
loc, unit := r.panoramaToCubeMapShader.u["panorama"], r.panoramaToCubeMapShader.t["panorama"]
gl.ActiveTexture((uint32(gl.TEXTURE0 + unit)))
gl.BindTexture(gl.TEXTURE_2D, envTexture.handle)
gl.Uniform1i(loc, int32(unit))
for i := 0; i < 6; i++ {
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, uint32(gl.TEXTURE_CUBE_MAP_POSITIVE_X+i), cubeTexture.handle, 0)

gl.Clear(gl.COLOR_BUFFER_BIT)
loc := r.panoramaToCubemapShader.u["currentFace"]
loc := r.panoramaToCubeMapShader.u["currentFace"]
gl.Uniform1i(loc, int32(i))

gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
Expand Down
22 changes: 11 additions & 11 deletions src/render_gl_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ type Renderer struct {
// Shader and index data for 3D model rendering
shadowMapShader *ShaderProgram
modelShader *ShaderProgram
panoramaToCubemapShader *ShaderProgram
panoramaToCubeMapShader *ShaderProgram
cubemapFilteringShader *ShaderProgram
stageVertexBuffer uint32
stageIndexBuffer uint32
Expand Down Expand Up @@ -357,8 +357,8 @@ var identVertShader string
//go:embed shaders/ident.frag.glsl
var identFragShader string

//go:embed shaders/panoramaToCubemap.frag.glsl
var panoramaToCubemapFragShader string
//go:embed shaders/panoramaToCubeMap.frag.glsl
var panoramaToCubeMapFragShader string

//go:embed shaders/cubemapFiltering.frag.glsl
var cubemapFilteringFragShader string
Expand Down Expand Up @@ -419,10 +419,10 @@ func (r *Renderer) Init() {
r.shadowMapShader.RegisterUniforms("model", "lightMatrices[0]", "lightMatrices[1]", "lightMatrices[2]", "lightMatrices[3]", "lightMatrices[4]", "lightMatrices[5]", "lightType", "lightPos", "farPlane", "numJoints", "morphTargetWeight", "morphTargetOffset", "numTargets", "numVertices", "enableAlpha", "alphaThreshold", "baseColorFactor", "useTexture")
r.shadowMapShader.RegisterTextures("morphTargetValues", "jointMatrices", "tex")

r.panoramaToCubemapShader = newShaderProgram(identVertShader, panoramaToCubemapFragShader, "", "Panorama To Cubemap Shader")
r.panoramaToCubemapShader.RegisterAttributes("VertCoord")
r.panoramaToCubemapShader.RegisterUniforms("currentFace")
r.panoramaToCubemapShader.RegisterTextures("panorama")
r.panoramaToCubeMapShader = newShaderProgram(identVertShader, panoramaToCubeMapFragShader, "", "Panorama To Cubemap Shader")
r.panoramaToCubeMapShader.RegisterAttributes("VertCoord")
r.panoramaToCubeMapShader.RegisterUniforms("currentFace")
r.panoramaToCubeMapShader.RegisterTextures("panorama")

r.cubemapFilteringShader = newShaderProgram(identVertShader, cubemapFilteringFragShader, "", "Cubemap Filtering Shader")
r.cubemapFilteringShader.RegisterAttributes("VertCoord")
Expand Down Expand Up @@ -1144,22 +1144,22 @@ func (r *Renderer) RenderElements(mode PrimitiveMode, count, offset int) {
func (r *Renderer) RenderCubeMap(envTexture *Texture, cubeTexture *Texture, textureSize int32) {
gl.BindFramebuffer(gl.FRAMEBUFFER, r.fbo_env)
gl.Viewport(0, 0, textureSize, textureSize)
gl.UseProgram(r.panoramaToCubemapShader.program)
loc := r.panoramaToCubemapShader.a["VertCoord"]
gl.UseProgram(r.panoramaToCubeMapShader.program)
loc := r.panoramaToCubeMapShader.a["VertCoord"]
gl.EnableVertexAttribArray(uint32(loc))
gl.VertexAttribPointerWithOffset(uint32(loc), 2, gl.FLOAT, false, 0, 0)
data := f32.Bytes(binary.LittleEndian, -1, -1, 1, -1, -1, 1, 1, 1)
gl.BindBuffer(gl.ARRAY_BUFFER, r.vertexBuffer)
gl.BufferData(gl.ARRAY_BUFFER, len(data), unsafe.Pointer(&data[0]), gl.STATIC_DRAW)
loc, unit := r.panoramaToCubemapShader.u["panorama"], r.panoramaToCubemapShader.t["panorama"]
loc, unit := r.panoramaToCubeMapShader.u["panorama"], r.panoramaToCubeMapShader.t["panorama"]
gl.ActiveTexture((uint32(gl.TEXTURE0 + unit)))
gl.BindTexture(gl.TEXTURE_2D, envTexture.handle)
gl.Uniform1i(loc, int32(unit))
for i := 0; i < 6; i++ {
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, uint32(gl.TEXTURE_CUBE_MAP_POSITIVE_X+i), cubeTexture.handle, 0)

gl.Clear(gl.COLOR_BUFFER_BIT)
loc := r.panoramaToCubemapShader.u["currentFace"]
loc := r.panoramaToCubeMapShader.u["currentFace"]
gl.Uniform1i(loc, int32(i))

gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
Expand Down

0 comments on commit 702ad91

Please sign in to comment.