mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Cleanup.
This commit is contained in:
parent
72454acc8e
commit
ddf0959d35
5 changed files with 12 additions and 12 deletions
|
@ -148,8 +148,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
|
||||
|
||||
// Create texture sampler uniforms.
|
||||
bgfx::UniformHandle u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Int1);
|
||||
bgfx::UniformHandle u_texNormal = bgfx::createUniform("u_texNormal", bgfx::UniformType::Int1);
|
||||
bgfx::UniformHandle s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
|
||||
bgfx::UniformHandle s_texNormal = bgfx::createUniform("s_texNormal", bgfx::UniformType::Int1);
|
||||
|
||||
uint16_t numLights = 4;
|
||||
bgfx::UniformHandle u_lightPosRadius = bgfx::createUniform("u_lightPosRadius", bgfx::UniformType::Vec4, numLights);
|
||||
|
@ -280,8 +280,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::setIndexBuffer(ibh);
|
||||
|
||||
// Bind textures.
|
||||
bgfx::setTexture(0, u_texColor, textureColor);
|
||||
bgfx::setTexture(1, u_texNormal, textureNormal);
|
||||
bgfx::setTexture(0, s_texColor, textureColor);
|
||||
bgfx::setTexture(1, s_texNormal, textureNormal);
|
||||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
|
@ -320,8 +320,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::setIndexBuffer(ibh);
|
||||
|
||||
// Bind textures.
|
||||
bgfx::setTexture(0, u_texColor, textureColor);
|
||||
bgfx::setTexture(1, u_texNormal, textureNormal);
|
||||
bgfx::setTexture(0, s_texColor, textureColor);
|
||||
bgfx::setTexture(1, s_texNormal, textureNormal);
|
||||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
|
@ -349,8 +349,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
bgfx::destroyProgram(program);
|
||||
bgfx::destroyTexture(textureColor);
|
||||
bgfx::destroyTexture(textureNormal);
|
||||
bgfx::destroyUniform(u_texColor);
|
||||
bgfx::destroyUniform(u_texNormal);
|
||||
bgfx::destroyUniform(s_texColor);
|
||||
bgfx::destroyUniform(s_texNormal);
|
||||
bgfx::destroyUniform(u_lightPosRadius);
|
||||
bgfx::destroyUniform(u_lightRgbInnerR);
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ $input v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0 // in...
|
|||
|
||||
#include "../common/common.sh"
|
||||
|
||||
SAMPLER2D(u_texColor, 0);
|
||||
SAMPLER2D(u_texNormal, 1);
|
||||
SAMPLER2D(s_texColor, 0);
|
||||
SAMPLER2D(s_texNormal, 1);
|
||||
uniform vec4 u_lightPosRadius[4];
|
||||
uniform vec4 u_lightRgbInnerR[4];
|
||||
|
||||
|
@ -61,7 +61,7 @@ void main()
|
|||
);
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = texture2D(u_texNormal, v_texcoord0).xy * 2.0 - 1.0;
|
||||
normal.xy = texture2D(s_texNormal, v_texcoord0).xy * 2.0 - 1.0;
|
||||
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy) );
|
||||
vec3 view = -normalize(v_view);
|
||||
|
||||
|
@ -71,7 +71,7 @@ void main()
|
|||
lightColor += calcLight(2, tbn, v_wpos, normal, view);
|
||||
lightColor += calcLight(3, tbn, v_wpos, normal, view);
|
||||
|
||||
vec4 color = toLinear(texture2D(u_texColor, v_texcoord0) );
|
||||
vec4 color = toLinear(texture2D(s_texColor, v_texcoord0) );
|
||||
|
||||
gl_FragColor.xyz = max(vec3_splat(0.05), lightColor.xyz)*color.xyz;
|
||||
gl_FragColor.w = 1.0;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue