ich möchte gern an den Schnittflächen zum Terrain Schaum rendern. Dazu habe ich folgendes gedacht. Ich habe ja meine Tiefentextur aus dem DFS pass. Im Wassershader müsste ich aus dieser Tiefemap, welche ja Screenspace ist, die 3D-Position zurückrechnen und die Entfernung zum aktuellen Pixel berechnen.
Wie bekomme ich aber die passenden Texturkoordinaten für die Tiefenmap? Mein Gefühl würde mir sagen:
Das geht zwar um depth-of-field, aber weiter unten ist ein Beispiel, wie man aus dem Wert im Depthbuffer und der Screencoord die Weltkoordinate zurückrechnen kann. NOT TESTED YET!
ich habe mal versucht den HLSL Shader aus dem Link in GLSL zu übersetzten, doch irgendwie steigt der mittendrin aus und zeigt mir nur die HeightMap vom Wasser an.. hier mal mein Code:
Code:
#version 120
uniform sampler2D heightMap;
uniform sampler2D backBufferMap;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform sampler2D foamMap;
uniform sampler2D reflectionMap;
uniform mat4 proM;
// We need this matrix to restore position in world space
uniform mat4 matViewInverse;
uniform vec3 cameraPos;
float waterLevel = 0.0;
// How fast will colours fade out. You can also think about this
// values as how clear water is. Therefore use smaller values (eg. 0.05f)
// to have crystal clear water and bigger to achieve "muddy" water.
float fadeSpeed = 0.15;
// Timer
float timer = 1.0;
// Normals scaling factor
float normalScale = 1.0;
// R0 is a constant related to the index of refraction (IOR).
// It should be computed on the CPU and passed to the shader.
float R0 = 0.5;
// Maximum waves amplitude
float maxAmplitude = 1.0;
// Direction of the light
vec3 lightDir = vec3(0.0, 1.0, 0.0);
// Colour of the sun
vec3 sunColor = vec3(1.0, 1.0, 1.0);
// The smaller this value is, the more soft the transition between
// shore and water. If you want hard edges use very big value.
// Default is 1.0f.
float shoreHardness = 1.0;
// This value modifies current fresnel term. If you want to weaken
// reflections use bigger value. If you want to empasize them use
// value smaller then 0. Default is 0.0f.
float refractionStrength = 0.0;
//float refractionStrength = -0.3f;
// Modifies 4 sampled normals. Increase first values to have more
// smaller "waves" or last to have more bigger "waves"
vec4 normalModifier = vec4(1.0, 2.0, 4.0, 8.0);
// Strength of displacement along normal.
float displace = 1.7;
// Describes at what depth foam starts to fade out and
// at what it is completely invisible. The fird value is at
// what height foam for waves appear (+ waterLevel).
Mitglieder in diesem Forum: 0 Mitglieder und 14 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.