Skip to content

example-08-update: Scan through the LODs of the textures with shader. #3312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/08-update/fs_update.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ $input v_texcoord0
#include "../common/common.sh"

SAMPLERCUBE(s_texCube, 0);
uniform vec4 u_time;

void main()
{
gl_FragColor = textureCube(s_texCube, v_texcoord0);
float lod = (1.0 - cos(u_time.x)) * 4.0; // 0 to 8
gl_FragColor = textureCubeLod(s_texCube, v_texcoord0, lod);
}
5 changes: 4 additions & 1 deletion examples/08-update/fs_update_cmp.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ $input v_texcoord0

SAMPLER2D(s_texColor, 0);

uniform vec4 u_time;

void main()
{
gl_FragColor = texture2D(s_texColor, v_texcoord0.xy*0.5+0.5);
float lod = (1.0 - cos(u_time.x)) * 4.0; // 0 to 8
gl_FragColor = texture2DLod(s_texColor, v_texcoord0.xy*0.5+0.5, lod);
}
8 changes: 4 additions & 4 deletions examples/08-update/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ class ExampleUpdate : public entry::AppI
if (bgfx::isValid(m_textureCube[ii]))
{
float mtx[16];
bx::mtxSRT(mtx, 0.65f, 0.65f, 0.65f, time, time*0.37f, 0.0f, -2.5f +ii*1.8f, 0.0f, 0.0f);
bx::mtxSRT(mtx, 0.65f, 0.65f, 0.65f, time, time*0.37f, 0.0f, -2.5f +ii*1.8f, 0.3f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);
Expand All @@ -788,7 +788,7 @@ class ExampleUpdate : public entry::AppI

const float aspectRatio = float(m_height)/float(m_width);
const float margin = 0.7f;
const float sizeX = 0.5f * numColumns * 2.3f + margin;
const float sizeX = 0.5f * (numColumns + 2) * 2.3f + margin;
const float sizeY = sizeX * aspectRatio;

const bgfx::Caps* caps = bgfx::getCaps();
Expand All @@ -798,7 +798,7 @@ class ExampleUpdate : public entry::AppI
bx::mtxMul(worldToScreen, proj, projToScreen);

float mtx[16];
bx::mtxTranslate(mtx, -sizeX + margin + 1.0f, 1.9f, 0.0f);
bx::mtxTranslate(mtx, -sizeX + margin + 1.0f, 0.0f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);
Expand Down Expand Up @@ -851,7 +851,7 @@ class ExampleUpdate : public entry::AppI

for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii)
{
bx::mtxTranslate(mtx, xpos + (ii%numColumns) * 2.3f, sizeY - margin - 2.8f + (ii/numColumns) * 2.3f, 0.0f);
bx::mtxTranslate(mtx, xpos + (1+ii%numColumns) * 2.3f, sizeY - margin - 2.8f + (ii/numColumns) * 2.3f, 0.0f);

// Set model matrix for rendering.
bgfx::setTransform(mtx);
Expand Down
Loading