simple water without shaders that uses original MW textures
parent
c1693a0c63
commit
b3a186e729
@ -1,13 +1,11 @@
|
||||
project(resources)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/caustic_0.png "${OpenMW_BINARY_DIR}/resources/water/caustic_0.png" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Example_Fresnel.cg "${OpenMW_BINARY_DIR}/resources/water/Example_Fresnel.cg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Example_FresnelPS.asm "${OpenMW_BINARY_DIR}/resources/water/Example_FresnelPS.asm" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/GlassFP.cg "${OpenMW_BINARY_DIR}/resources/water/GlassFP.cg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/GlassVP.cg "${OpenMW_BINARY_DIR}/resources/water/GlassVP.cg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/perlinvolume.dds "${OpenMW_BINARY_DIR}/resources/water/perlinvolume.dds" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Water02.jpg "${OpenMW_BINARY_DIR}/resources/water/Water02.jpg" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.compositor "${OpenMW_BINARY_DIR}/resources/water/water.compositor" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/waves2.dds "${OpenMW_BINARY_DIR}/resources/water/waves2.dds" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Examples-Water.material "${OpenMW_BINARY_DIR}/resources/water/Examples-Water.material" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.material "${OpenMW_BINARY_DIR}/resources/water/water.material" COPYONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/WaterNormal1.tga "${OpenMW_BINARY_DIR}/resources/water/WaterNormal1.tga" COPYONLY)
|
||||
|
@ -1,116 +0,0 @@
|
||||
// Vertex program for fresnel reflections / refractions
|
||||
void main_vp(
|
||||
float4 pos : POSITION,
|
||||
float4 normal : NORMAL,
|
||||
float2 tex : TEXCOORD0,
|
||||
|
||||
out float4 oPos : POSITION,
|
||||
out float3 noiseCoord : TEXCOORD0,
|
||||
out float4 projectionCoord : TEXCOORD1,
|
||||
out float3 oEyeDir : TEXCOORD2,
|
||||
out float3 oNormal : TEXCOORD3,
|
||||
|
||||
uniform float4x4 worldViewProjMatrix,
|
||||
uniform float3 eyePosition, // object space
|
||||
uniform float timeVal,
|
||||
uniform float scale, // the amount to scale the noise texture by
|
||||
uniform float scroll, // the amount by which to scroll the noise
|
||||
uniform float noise // the noise perturb as a factor of the time
|
||||
)
|
||||
{
|
||||
oPos = mul(worldViewProjMatrix, pos);
|
||||
// Projective texture coordinates, adjust for mapping
|
||||
float4x4 scalemat = float4x4(0.5, 0, 0, 0.5,
|
||||
0,-0.5, 0, 0.5,
|
||||
0, 0, 0.5, 0.5,
|
||||
0, 0, 0, 1);
|
||||
projectionCoord = mul(scalemat, oPos);
|
||||
// Noise map coords
|
||||
noiseCoord.xy = (tex + (timeVal * scroll)) * scale;
|
||||
noiseCoord.z = noise * timeVal;
|
||||
|
||||
oEyeDir = normalize(pos.xyz - eyePosition);
|
||||
oNormal = normal.rgb;
|
||||
|
||||
}
|
||||
|
||||
// Fragment program for distorting a texture using a 3D noise texture
|
||||
void main_fp(
|
||||
float3 noiseCoord : TEXCOORD0,
|
||||
float4 projectionCoord : TEXCOORD1,
|
||||
float3 eyeDir : TEXCOORD2,
|
||||
float3 normal : TEXCOORD3,
|
||||
|
||||
out float4 col : COLOR,
|
||||
|
||||
uniform float4 tintColour,
|
||||
uniform float noiseScale,
|
||||
uniform float fresnelBias,
|
||||
uniform float fresnelScale,
|
||||
uniform float fresnelPower,
|
||||
uniform sampler2D waterTex : register(s0),
|
||||
uniform sampler2D noiseMap : register(s1),
|
||||
uniform sampler2D reflectMap : register(s2),
|
||||
uniform sampler2D refractMap : register(s3)
|
||||
)
|
||||
{
|
||||
// Do the tex projection manually so we can distort _after_
|
||||
float2 final = projectionCoord.xy / projectionCoord.w;
|
||||
|
||||
// Noise
|
||||
float3 noiseNormal = (tex2D(noiseMap, (noiseCoord.xy / 5)).rgb - 0.5).rbg * noiseScale;
|
||||
final += noiseNormal.xz;
|
||||
|
||||
// Fresnel
|
||||
//normal = normalize(normal + noiseNormal.xz);
|
||||
float fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower);
|
||||
|
||||
// Reflection / refraction
|
||||
float4 reflectionColour = tex2D(reflectMap, final);
|
||||
float4 refractionColour = tex2D(refractMap, final) + tintColour;
|
||||
|
||||
// Final colour
|
||||
col = lerp(refractionColour, reflectionColour, fresnel) * tex2D(waterTex, noiseNormal) / 3 ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Old version to match ATI PS 1.3 implementation
|
||||
void main_vp_old(
|
||||
float4 pos : POSITION,
|
||||
float4 normal : NORMAL,
|
||||
float2 tex : TEXCOORD0,
|
||||
|
||||
out float4 oPos : POSITION,
|
||||
out float fresnel : COLOR,
|
||||
out float3 noiseCoord : TEXCOORD0,
|
||||
out float4 projectionCoord : TEXCOORD1,
|
||||
|
||||
uniform float4x4 worldViewProjMatrix,
|
||||
uniform float3 eyePosition, // object space
|
||||
uniform float fresnelBias,
|
||||
uniform float fresnelScale,
|
||||
uniform float fresnelPower,
|
||||
uniform float timeVal,
|
||||
uniform float scale, // the amount to scale the noise texture by
|
||||
uniform float scroll, // the amount by which to scroll the noise
|
||||
uniform float noise // the noise perturb as a factor of the time
|
||||
)
|
||||
{
|
||||
oPos = mul(worldViewProjMatrix, pos);
|
||||
// Projective texture coordinates, adjust for mapping
|
||||
float4x4 scalemat = float4x4(0.5, 0, 0, 0.5,
|
||||
0,-0.5, 0, 0.5,
|
||||
0, 0, 0.5, 0.5,
|
||||
0, 0, 0, 1);
|
||||
projectionCoord = mul(scalemat, oPos);
|
||||
// Noise map coords
|
||||
noiseCoord.xy = (tex + (timeVal * scroll)) * scale;
|
||||
noiseCoord.z = noise * timeVal;
|
||||
|
||||
// calc fresnel factor (reflection coefficient)
|
||||
float3 eyeDir = normalize(pos.xyz - eyePosition);
|
||||
fresnel = fresnelBias + fresnelScale * pow(1 + dot(eyeDir, normal), fresnelPower);
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
ps.1.4
|
||||
// conversion from Cg generated ARB_fragment_program to ps.1.4 by NFZ
|
||||
// command line args: -profile arbfp1 -entry main_fp
|
||||
// program main_fp
|
||||
// c0 : distortionRange
|
||||
// c1 : tintColour
|
||||
// testure 0 : noiseMap
|
||||
// texture 1 : reflectMap
|
||||
// texture 2 : refractMap
|
||||
// v0.x : fresnel
|
||||
// t0.xyz : noiseCoord
|
||||
// t1.xyw : projectionCoord
|
||||
|
||||
def c2, 2, 1, 0, 0
|
||||
|
||||
// Cg: distort.x = tex3D(noiseMap, noiseCoord).x;
|
||||
// arbfp1: TEX R0.x, fragment.texcoord[0], texture[0], 3D;
|
||||
// sample noise map using noiseCoord in TEX unit 0
|
||||
|
||||
texld r0, t0.xyz
|
||||
|
||||
// get projected texture coordinates from TEX coord 1
|
||||
// will be used in phase 2
|
||||
|
||||
texcrd r1.xy, t1_dw.xyw
|
||||
mov r1.z, c2.y
|
||||
|
||||
// Cg: distort.y = tex3D(noiseMap, noiseCoord + yoffset).x;
|
||||
// arbfp1: ADD R1.xyz, fragment.texcoord[0], c1;
|
||||
// arbfp1: TEX R1.x, R1, texture[0], 3D;
|
||||
// arbfp1: MOV R0.y, R1.x;
|
||||
|
||||
// Cg: distort = (distort * 2 - 1) * distortionRange;
|
||||
// arbfp1: MAD R0.xy, R0, c0.x, -c0.y;
|
||||
// arbfp1: MUL R0.xy, R0, u0.x;
|
||||
// (distort * 2 - 1) same as 2*(distort -.5) so use _bx2
|
||||
|
||||
|
||||
// Cg: final = projectionCoord.xy / projectionCoord.w;
|
||||
// Cg: final += distort;
|
||||
// arbfp1: RCP R0.w, fragment.texcoord[1].w;
|
||||
// arbfp1: MAD R0.xy, fragment.texcoord[1], R0.w, R0;
|
||||
// final = (distort * projectionCoord.w) + projectionCoord.xy
|
||||
// for ps.1.4 have to re-arrange things a bit to perturb projected texture coordinates
|
||||
|
||||
mad r0.xyz, r0_bx2, c0.x, r1
|
||||
|
||||
phase
|
||||
|
||||
// do dependant texture reads
|
||||
// Cg: reflectionColour = tex2D(reflectMap, final);
|
||||
// arbfp1: TEX R0, R0, texture[1], 2D;
|
||||
// sampe reflectMap using dependant read : texunit 1
|
||||
|
||||
texld r1, r0.xyz
|
||||
|
||||
// Cg: refractionColour = tex2D(refractMap, final) + tintColour;
|
||||
// arbfp1: TEX R1, R0, texture[2], 2D;
|
||||
// sample refractMap : texunit 2
|
||||
|
||||
texld r2, r0.xyz
|
||||
|
||||
// adding tintColour that is in global c1
|
||||
// arbfp1: ADD R1, R1, u1;
|
||||
|
||||
add r2, r2, c1
|
||||
|
||||
// Cg: col = lerp(refractionColour, reflectionColour, fresnel);
|
||||
// arbfp1: ADD R0, R0, -R1;
|
||||
// arbfp1: MAD result.color, fragment.color.primary.x, R0, R1;
|
||||
|
||||
lrp r0, v0.x, r1, r2
|
@ -1,149 +0,0 @@
|
||||
|
||||
vertex_program Water/GlassVP cg
|
||||
{
|
||||
source GlassVP.cg
|
||||
entry_point glass_vp
|
||||
profiles vs_1_1 arbvp1
|
||||
|
||||
default_params
|
||||
{
|
||||
param_named_auto worldViewProj worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fragment_program Water/GlassFP cg
|
||||
{
|
||||
source GlassFP.cg
|
||||
entry_point main_ps
|
||||
profiles ps_2_0 arbfp1
|
||||
}
|
||||
|
||||
material Water/Compositor
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_check off
|
||||
vertex_program_ref Water/GlassVP
|
||||
{
|
||||
param_named_auto timeVal time 0.25
|
||||
param_named scale float 0.1
|
||||
}
|
||||
|
||||
fragment_program_ref Water/GlassFP
|
||||
{
|
||||
param_named tintColour float4 0 0.35 0.35 1
|
||||
}
|
||||
|
||||
texture_unit RT
|
||||
{
|
||||
tex_coord_set 0
|
||||
tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture WaterNormal1.tga 2d
|
||||
tex_coord_set 1
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture caustic_0.png 2d
|
||||
tex_coord_set 2
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vertex_program Water/RefractReflectVP cg
|
||||
{
|
||||
source Example_Fresnel.cg
|
||||
entry_point main_vp
|
||||
profiles vs_1_1 arbvp1
|
||||
}
|
||||
vertex_program Water/RefractReflectVPold cg
|
||||
{
|
||||
source Example_Fresnel.cg
|
||||
entry_point main_vp_old
|
||||
profiles vs_1_1 arbvp1
|
||||
}
|
||||
|
||||
fragment_program Water/RefractReflectFP cg
|
||||
{
|
||||
source Example_Fresnel.cg
|
||||
entry_point main_fp
|
||||
// sorry, ps_1_1 and fp20 can't do this
|
||||
profiles ps_2_0 arbfp1
|
||||
}
|
||||
|
||||
fragment_program Water/RefractReflectPS asm
|
||||
{
|
||||
source Example_FresnelPS.asm
|
||||
// sorry, only for ps_1_4 :)
|
||||
syntax ps_1_4
|
||||
|
||||
}
|
||||
material Examples/Water0
|
||||
{
|
||||
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
//
|
||||
|
||||
depth_write off
|
||||
vertex_program_ref Water/RefractReflectVP
|
||||
{
|
||||
param_named_auto worldViewProjMatrix worldviewproj_matrix
|
||||
param_named_auto eyePosition camera_position_object_space
|
||||
param_named_auto timeVal time 0.15
|
||||
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 Water/RefractReflectFP
|
||||
{
|
||||
param_named fresnelBias float -0.1
|
||||
param_named fresnelScale float 0.8
|
||||
param_named fresnelPower float 20
|
||||
param_named tintColour float4 1 1 1 1
|
||||
param_named noiseScale float 0.05
|
||||
}
|
||||
// Water
|
||||
scene_blend alpha_blend
|
||||
texture_unit
|
||||
{
|
||||
|
||||
// Water texture
|
||||
texture Water02.jpg
|
||||
// min / mag filtering, no mip
|
||||
filtering linear linear none
|
||||
alpha_op_ex source1 src_manual src_current 0.9
|
||||
|
||||
}
|
||||
// Noise
|
||||
texture_unit
|
||||
{
|
||||
alpha_op_ex source1 src_manual src_current 0.9
|
||||
// Perlin noise volume
|
||||
texture waves2.dds
|
||||
// min / mag filtering, no mip
|
||||
filtering linear linear none
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 227 KiB |
@ -0,0 +1,62 @@
|
||||
vertex_program Water/GlassVP cg
|
||||
{
|
||||
source GlassVP.cg
|
||||
entry_point glass_vp
|
||||
profiles vs_1_1 arbvp1
|
||||
|
||||
default_params
|
||||
{
|
||||
param_named_auto worldViewProj worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fragment_program Water/GlassFP cg
|
||||
{
|
||||
source GlassFP.cg
|
||||
entry_point main_ps
|
||||
profiles ps_2_0 arbfp1
|
||||
}
|
||||
|
||||
material Water/Compositor
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_check off
|
||||
vertex_program_ref Water/GlassVP
|
||||
{
|
||||
param_named_auto timeVal time 0.25
|
||||
param_named scale float 0.1
|
||||
}
|
||||
|
||||
fragment_program_ref Water/GlassFP
|
||||
{
|
||||
param_named tintColour float4 0 0.35 0.35 1
|
||||
}
|
||||
|
||||
texture_unit RT
|
||||
{
|
||||
tex_coord_set 0
|
||||
tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture WaterNormal1.tga 2d
|
||||
tex_coord_set 1
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture caustic_0.png 2d
|
||||
tex_coord_set 2
|
||||
//tex_address_mode clamp
|
||||
filtering linear linear linear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue