mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-10-13 00:08:26 +08:00
CUDA 13.2 samples update (#432)
- Added Python samples for CUDA Python 1.0 release - Renamed top-level `Samples` directory to `cpp` to accommodate Python samples.
This commit is contained in:
30
cpp/4_CUDA_Libraries/oceanFFT/data/ocean.frag
Normal file
30
cpp/4_CUDA_Libraries/oceanFFT/data/ocean.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
// GLSL fragment shader
|
||||
varying vec3 eyeSpacePos;
|
||||
varying vec3 worldSpaceNormal;
|
||||
varying vec3 eyeSpaceNormal;
|
||||
|
||||
uniform vec4 deepColor;
|
||||
uniform vec4 shallowColor;
|
||||
uniform vec4 skyColor;
|
||||
uniform vec3 lightDir;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 eyeVector = normalize(eyeSpacePos);
|
||||
vec3 eyeSpaceNormalVector = normalize(eyeSpaceNormal);
|
||||
vec3 worldSpaceNormalVector = normalize(worldSpaceNormal);
|
||||
|
||||
float facing = max(0.0, dot(eyeSpaceNormalVector, -eyeVector));
|
||||
float fresnel = pow(1.0 - facing, 5.0); // Fresnel approximation
|
||||
float diffuse = max(0.0, dot(worldSpaceNormalVector, lightDir));
|
||||
|
||||
// vec4 waterColor = mix(shallowColor, deepColor, facing);
|
||||
vec4 waterColor = deepColor;
|
||||
|
||||
// gl_FragColor = gl_Color;
|
||||
// gl_FragColor = vec4(fresnel);
|
||||
// gl_FragColor = vec4(diffuse);
|
||||
// gl_FragColor = waterColor;
|
||||
// gl_FragColor = waterColor*diffuse;
|
||||
gl_FragColor = waterColor*diffuse + skyColor*fresnel;
|
||||
}
|
||||
24
cpp/4_CUDA_Libraries/oceanFFT/data/ocean.vert
Normal file
24
cpp/4_CUDA_Libraries/oceanFFT/data/ocean.vert
Normal file
@@ -0,0 +1,24 @@
|
||||
// GLSL vertex shader
|
||||
varying vec3 eyeSpacePos;
|
||||
varying vec3 worldSpaceNormal;
|
||||
varying vec3 eyeSpaceNormal;
|
||||
uniform float heightScale; // = 0.5;
|
||||
uniform float chopiness; // = 1.0;
|
||||
uniform vec2 size; // = vec2(256.0, 256.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
float height = gl_MultiTexCoord0.x;
|
||||
vec2 slope = gl_MultiTexCoord1.xy;
|
||||
|
||||
// calculate surface normal from slope for shading
|
||||
vec3 normal = normalize(cross( vec3(0.0, slope.y*heightScale, 2.0 / size.x), vec3(2.0 / size.y, slope.x*heightScale, 0.0)));
|
||||
worldSpaceNormal = normal;
|
||||
|
||||
// calculate position and transform to homogeneous clip space
|
||||
vec4 pos = vec4(gl_Vertex.x, height * heightScale, gl_Vertex.z, 1.0);
|
||||
gl_Position = gl_ModelViewProjectionMatrix * pos;
|
||||
|
||||
eyeSpacePos = (gl_ModelViewMatrix * pos).xyz;
|
||||
eyeSpaceNormal = (gl_NormalMatrix * normal).xyz;
|
||||
}
|
||||
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/ref_slopeShading.bin
Normal file
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/ref_slopeShading.bin
Normal file
Binary file not shown.
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/ref_spatialDomain.bin
Normal file
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/ref_spatialDomain.bin
Normal file
Binary file not shown.
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/reference.ppm
Normal file
BIN
cpp/4_CUDA_Libraries/oceanFFT/data/reference.ppm
Normal file
Binary file not shown.
Reference in New Issue
Block a user