Water is in ECS; water material is created in code

This commit is contained in:
2025-09-03 05:31:13 +03:00
parent 847aab6ed0
commit aca04ff621
8 changed files with 324 additions and 168 deletions

14
water/depth.frag Normal file
View File

@@ -0,0 +1,14 @@
OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
#include <OgreUnifiedShader.h>
OGRE_UNIFORMS(
uniform vec3 cameraPosition;
)
MAIN_PARAMETERS
IN(vec4 position, POSITION)
IN(vec3 positionWS, TEXCOORD0)
MAIN_DECLARATION
{
vec4 depth = vec4(length(positionWS - cameraPosition), 0.0, 0.0, 1.0);
gl_FragColor = depth;
}

20
water/depth.vert Normal file
View File

@@ -0,0 +1,20 @@
OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
#include <OgreUnifiedShader.h>
OGRE_UNIFORMS(
uniform mat4 world;
uniform mat4 worldViewProj;
)
MAIN_PARAMETERS
IN(vec4 vertex, POSITION);
OUT(vec4 vposition, POSITION);
OUT(vec3 positionWS, TEXCOORD0);
MAIN_DECLARATION
{
vposition = mul(worldViewProj, vertex);
positionWS = mul(world, vertex).xyz;
gl_Position = vposition;
}

View File

@@ -1,25 +1,4 @@
/*
//----------------------------
// Distortion effects
//----------------------------
vertex_program Examples/FresnelRefractReflectVP glsl glsles glslang hlsl
{
source Example_FresnelVp.glsl
}
fragment_program Examples/FresnelRefractReflectFP glsl glsles glslang hlsl
{
source Example_FresnelFp.glsl
default_params
{
// assign samplers as required by GLSL
param_named noiseMap int 0
param_named reflectMap int 1
param_named refractMap int 2
}
}
*/
material Water/Above
{
technique
@@ -31,82 +10,18 @@ material Water/Above
diffuse 0.0 0.2 0.5 1.0
cull_hardware none
cull_software none
/*
vertex_program_ref Examples/FresnelRefractReflectVP
{
param_named_auto worldViewProjMatrix worldviewproj_matrix
param_named_auto textureProjMatrix texture_worldviewproj_matrix 0
param_named_auto eyePosition camera_position_object_space
param_named_auto timeVal time 0.05
param_named scroll float 1
param_named scale float 1
param_named noise float 1
// scroll and noisePos will need updating per frame
}
fragment_program_ref Examples/FresnelRefractReflectFP
{
param_named fresnelBias float -0.1
param_named fresnelScale float 1.8
param_named fresnelPower float 8
param_named tintColour float4 0 0.05 0.05 1
param_named noiseScale float 0.05
}
*/
vertex_program_ref Water/water_vp
{
}
fragment_program_ref Water/water_fp
{
}
/*
// Noise
texture_unit
{
// Perlin noise volume
texture waves2.png
// min / mag filtering, no mip
filtering linear linear none
tex_address_mode mirror
}
// Reflection
texture_unit
{
content_type compositor Fresnel reflection
tex_address_mode mirror
}
// Refraction
texture_unit
{
content_type compositor Fresnel refraction
tex_address_mode mirror
}
// Normal
texture_unit
{
texture waves2.png
sampler_ref RTSS/NormalMapSampler
// RT Shader system section.
rtshader_system
{
normal_map tangent_space
}
tex_address_mode mirror
}
*/
texture_unit
{
texture ReflectionRefractionTexture
tex_address_mode mirror
filtering linear linear linear
}
/*
texture_unit
{
texture RefractionTexture
tex_address_mode mirror
filtering linear linear linear
}
*/
}
}
rtshader_system
@@ -134,43 +49,12 @@ material Water/Below
fragment_program_ref Water/water_fp
{
}
/*
// Noise
texture_unit
{
// Perlin noise volume
texture waves2.png
// min / mag filtering, no mip
filtering linear linear none
tex_address_mode mirror
}
// Reflection
texture_unit
{
content_type compositor Fresnel reflection
tex_address_mode mirror
}
// Refraction
texture_unit
{
content_type compositor Fresnel refraction
tex_address_mode mirror
}
*/
texture_unit
{
texture ReflectionRefractionTexture
tex_address_mode mirror
filtering linear linear linear
}
/*
texture_unit
{
texture RefractionTexture
tex_address_mode mirror
filtering linear linear linear
}
*/
}
}
rtshader_system
@@ -179,28 +63,5 @@ material Water/Below
lighting_stage per_pixel
}
}
/*
material Water/Depth
{
technique
{
pass
{
cull_hardware none
alpha_rejection greater_equal 0.5
vertex_program_ref Water/depth_vp
{
param_named_auto world world_matrix
param_named_auto worldViewProj worldviewproj_matrix
}
fragment_program_ref Water/depth_fp
{
param_named_auto cameraPosition camera_position
}
}
}
}
*/

View File

@@ -24,32 +24,32 @@ fragment_program Water/water_fp glsl glsles glslang hlsl
{
param_named_auto renderTargetFlipping render_target_flipping
param_named_auto cameraPosition camera_position
param_named_auto ambient surface_ambient_colour
param_named_auto diffuse surface_diffuse_colour
// param_named_auto ambient surface_ambient_colour
// param_named_auto diffuse surface_diffuse_colour
param_named_auto viewportSize viewport_size
param_named_auto time time
// param_named NormalMap int 0
// param_named EnvironmentMap int 1
param_named deepColor float4 0 0.2 0.5 1.0
param_named shallowColor float4 0 0.8 1 1.0
param_named reflectionColor float4 0.95 1 1 1.0
param_named reflectionAmount float 0.5
param_named reflectionBlur float 0.0
param_named waterAmount float 0.5
// param_named fresnelPower float 5.0
// param_named fresnelPower float 8.0
param_named fresnelPower float 2.0
//// param_named_auto time time
//// param_named NormalMap int 0
//// param_named EnvironmentMap int 1
// param_named deepColor float4 0 0.2 0.5 1.0
// param_named shallowColor float4 0 0.8 1 1.0
// param_named reflectionColor float4 0.95 1 1 1.0
// param_named reflectionAmount float 0.5
// param_named reflectionBlur float 0.0
// param_named waterAmount float 0.5
//// param_named fresnelPower float 5.0
//// param_named fresnelPower float 8.0
// param_named fresnelPower float 2.0
//// param_named fresnelBias float 0.328
// param_named fresnelBias float 0.328
param_named fresnelBias float 0.328
// param_named fresnelScale float 1.8
// param_named fresnelScale float 1.8
param_named fresnelScale float 1.0
param_named hdrMultiplier float 0.471
param_named tintColour float4 0 0.05 0.05 1
param_named noiseScale float 0.03
// param_named noiseMap int 0
//// param_named fresnelScale float 1.8
//// param_named fresnelScale float 1.8
// param_named fresnelScale float 1.0
// param_named hdrMultiplier float 0.471
// param_named tintColour float4 0 0.05 0.05 1
// param_named noiseScale float 0.03
//// param_named noiseMap int 0
param_named reflectMap int 0
// param_named refractMap int 1
//// param_named refractMap int 1
}
}