adding texture on shader

This commit is contained in:
Clément Le Bihan
2021-06-16 11:13:02 +02:00
parent e135d89add
commit b6aa3f184a
3 changed files with 17 additions and 3 deletions
+7 -1
View File
@@ -4,14 +4,20 @@ precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec3 fragPosition;
varying vec2 fragTexCoord;
uniform sampler2D texture0;
uniform float alpha;
void main() {
// Texel color fetching from texture sampler
// NOTE: Implement here your fragment shader code
vec4 tmp = texture2D(texture0, fragTexCoord);
gl_FragColor = vec4(fragPosition, alpha);
tmp.a = alpha;
gl_FragColor = tmp;
//gl_FragColor = vec4(fragColor.r, fragColor.g, fragColor.b, alpha);
}
+4
View File
@@ -96,12 +96,16 @@ uniform float radius;
// Output vertex attributes (to fragment shader)
varying vec3 fragPosition;
varying vec2 fragTexCoord;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main() {
// Send vertex attributes to fragment shader
fragPosition = vertexPosition + vertexPosition * vec3(cnoise(vec3(vertexNormal + vec3(frame))) * 0.5);
fragColor = vertexColor;
fragTexCoord = vertexTexCoord;
// Calculate final vertex position
gl_Position = mvp * vec4(fragPosition , radius);
//gl_Position = vec4(vertexNormal, 1.0);
@@ -58,7 +58,7 @@ namespace BBM
if (duration_cast<std::chrono::milliseconds>(ctx.clock).count() <= 10)
return;
ctx.clock = 0ns;
ctx.explosionRadius -= 1;
ctx.explosionRadius -= 0.6;
if (ctx.explosionRadius < BombExplosionShaderComponent::maxRadius) {
ctx.explosionRadius = BombExplosionShaderComponent::maxRadius;
ctx.alpha -= 0.1;
@@ -73,7 +73,11 @@ namespace BBM
.addComponent<TimerComponent>(500ms, [](WAL::Entity &explosion, WAL::Wal &wal) {
explosion.scheduleDeletion();
})
.addComponent<Drawable3DComponent, RAY3D::Model>(GenMeshSphere(0.5, 16, 16));
.addComponent<Drawable3DComponent, RAY3D::Model>(GenMeshSphere(0.5, 16, 16),
std::make_pair(
MAP_DIFFUSE,
"assets/bombs/explosion/blast.png"
));
/*.addComponent<Drawable3DComponent, RAY3D::Model>("assets/bombs/explosion/explosion.glb", false,
std::make_pair(
MAP_DIFFUSE,