Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin'
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed May 20, 2024
2 parents f7622d8 + 33930f5 commit 8bfd3f3
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,108 @@ supported tests:
## Documentation
The full documentation will be available very soon, however, for now you can have a look at the [Wiki](https://github.com/ravi688/VulkanRenderer/wiki).

## Shader Description Language Example
```GLSL
#sl version 2022 // shader language version
#sb version 2022 // shader binary version, i.e. in which binary encoding to compile to
Shader
{
[NoParse] // mandatory for legacy reasons
Properties
{
vertex fragment [MATERIAL_SET, MATERIAL_PROPERTIES_BINDING] uniform Parameters
{
vec4 color;
} parameters;
// for sampling a 2D texture, you may add the following line
// fragment [MATERIAL_SET, TEXTURE_BINDING0] uniform Sampler2D myTexture;
}
[NoParse] // mandatory for legacy reasons
Layout // this where we can define vertex buffer layouts
{
per_vertex [POSITION_BINDING, POSITION_LOCATION] vec3 position;
per_vertex [NORMAL_BINDING, NORMAL_LOCATION] vec3 normal;
}
RenderPass
{
SubPass
{
[NoParse] // mandatory for legacy reasons
GraphicsPipeline
{
colorBlend
{
// the pipeline for this subpass requires a color attachment, so mention it here
attachment { }
}
// the pipeline for this subpass requires interaction with depth buffers, so mention it here too
depthStencil
{
depthWriteEnable = true,
depthTestEnable = true
}
}
[NoParse] // mandatory for legacy reasons
GLSL // this is where actual GLSL shader will be written in
{
// vertex shader
#stage vertex
#version 450
#include <v3d.h>
layout(set = CAMERA_SET, binding = CAMERA_PROPERTIES_BINDING) uniform CameraInfo cameraInfo;
layout(set = OBJECT_SET, binding = TRANSFORM_BINDING) uniform ObjectInfo objectInfo;
layout(location = POSITION_LOCATION) in vec3 position;
layout(location = NORMAL_LOCATION) in vec3 normal;
layout(location = 0) out vec3 _normal;
void main()
{
vec4 clipPos = cameraInfo.projection * cameraInfo.view * objectInfo.transform * vec4(position, 1);
clipPos.y = -clipPos.y;
gl_Position = clipPos;
_normal = normalize((objectInfo.normal * vec4(normal, 0)).xyz);
}
// fragment shader
#stage fragment
#version 450
#include <v3d.h>
layout(set = GLOBAL_SET, binding = LIGHT_BINDING) uniform DirectionalLight lightInfo;
layout(set = MATERIAL_SET, binding = MATERIAL_PROPERTIES_BINDING) uniform Parameters
{
vec4 color;
} parameters;
layout(location = 0) in vec3 _normal;
layout(location = 0) out vec4 color;
void main()
{
float dp = 0.5 * dot(-_normal, lightInfo.direction) + 0.5;
color = parameters.color * dp * vec4(lightInfo.color, 1);
}
}
}
}
}
```

## Screenshots and video clips

#### Point Lights
Expand Down

0 comments on commit 8bfd3f3

Please sign in to comment.