Skip to content

Commit

Permalink
improved normal map in biplanar mapping shader
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Aug 30, 2024
1 parent 6c6feb3 commit 96332a7
Show file tree
Hide file tree
Showing 40 changed files with 95 additions and 7 deletions.
5 changes: 5 additions & 0 deletions data/scenes-maps/biplanar-monkey.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scenes/biplanar-monkey/biplanar.pack

scenes/biplanar-monkey/biplanar.object
0 0 0
0
13 changes: 13 additions & 0 deletions data/scenes-maps/biplanar-shapes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
scenes/biplanar-shapes/biplanar.pack

scenes/biplanar-shapes/biplanar.object
0 0 0
0

scenes/biplanar-shapes/biplanar.object
0 10 0
45

scenes/biplanar-shapes/biplanar.object
0 -10 0
120
5 changes: 0 additions & 5 deletions data/scenes-maps/biplanar.txt

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void main()
mat.emissive = spec.z;
mat.opacity = 1;
mat.fade = 0;
normal = biplanarSampleNormal(texMaterialNormalArray, bip, normal, arrayIndex);
normal = biplanarSampleNormal(texMaterialNormalArray, bip, arrayIndex);
mat3 nm = mat3(uniMeshes[varInstanceId].normalMat);
normal = normalize(nm * normal);
outColor = lighting(mat);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
23 changes: 23 additions & 0 deletions data/scenes/biplanar-shapes/biplanar.assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[]
scheme = shader
biplanar.glsl

[]
scheme = object
biplanar.object

[]
scheme = pack
biplanar.pack

[]
scheme = texture
convert = heightToNormal
normal = true
heightmap.png

[]
scheme = model
material = shapes.cpm
uvs = false
shapes.glb
35 changes: 35 additions & 0 deletions data/scenes/biplanar-shapes/biplanar.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

$include /cage/shader/shaderConventions.h

$include /cage/shader/engine/vertex.glsl

void main()
{
updateVertex();
}

$include /cage/shader/engine/fragment.glsl

$include /cage/shader/functions/simplex.glsl
$include /cage/shader/functions/biplanar.glsl

void main()
{
#ifndef DepthOnly
Material mat;
normal = normalize(varNormal);
mat.albedo = vec3(0, 0.2, 0.7);
mat.roughness = 0.4;
mat.metalness = 0;
mat.emissive = 0;
mat.opacity = 1;
mat.fade = 0;
Biplanar bip = biplanarPrepare(varPosition * 2, normal, 50);
vec3 bent = biplanarSampleNormal(texMaterialNormal2d, bip);
//normal = mix(normal, bent, sin(uniViewport.time.z * 3000) * 0.5 + 0.5);
normal = bent;
mat3 nm = mat3(uniMeshes[varInstanceId].normalMat);
normal = normalize(nm * normal);
outColor = lighting(mat);
#endif // DepthOnly
}
2 changes: 2 additions & 0 deletions data/scenes/biplanar-shapes/biplanar.object
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[]
shapes.glb
4 changes: 4 additions & 0 deletions data/scenes/biplanar-shapes/biplanar.pack
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[]
biplanar.object
biplanar.glsl
shapes.glb
Binary file added data/scenes/biplanar-shapes/heightmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions data/scenes/biplanar-shapes/shapes.cpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[base]
albedo = 0, 0.2, 0.8
roughness = 0.3

[textures]
normal = heightmap.png

[render]
shader = biplanar.glsl

[flags]
Binary file added data/scenes/biplanar-shapes/shapes.glb
Binary file not shown.

0 comments on commit 96332a7

Please sign in to comment.