Update random vegetation for project Rembrandt. Unfortunately due to a possible bug in the techniques code, the previous tree transparency handling has been disabled for the moment.
This commit is contained in:
parent
fba49c56a3
commit
b09e37fefd
3 changed files with 94 additions and 4 deletions
|
@ -37,6 +37,44 @@
|
|||
</fogtype>
|
||||
<!-- END fog include -->
|
||||
</parameters>
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/rembrandt</property>
|
||||
<property>/sim/rendering/random-vegetation</property>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass n="0">
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
<ambient type="vec4d">1.0 1.0 1.0 1.0</ambient>
|
||||
<diffuse type="vec4d">1.0 1.0 1.0 1.0</diffuse>
|
||||
<color-mode>off</color-mode>
|
||||
</material>
|
||||
<alpha-test>
|
||||
<comparison>gequal</comparison>
|
||||
<reference type="float">0.1</reference>
|
||||
</alpha-test>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>2d</type>
|
||||
<image>
|
||||
<use>texture[0]/image</use>
|
||||
</image>
|
||||
<wrap-s>clamp</wrap-s>
|
||||
<wrap-t>clamp</wrap-t>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/deferred-tree.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/deferred-tree.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
|
@ -123,6 +161,8 @@
|
|||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
|
||||
<!--
|
||||
<pass n="1">
|
||||
<lighting>true</lighting>
|
||||
<material>
|
||||
|
@ -132,7 +172,6 @@
|
|||
</material>
|
||||
<render-bin>
|
||||
<bin-number>2</bin-number>
|
||||
<!-- RANDOM_OBJECTS_BIN -->
|
||||
<bin-name>RenderBin</bin-name>
|
||||
</render-bin>
|
||||
<alpha-test>
|
||||
|
@ -166,7 +205,6 @@
|
|||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
<!-- BEGIN fog include -->
|
||||
<uniform>
|
||||
<name>visibility</name>
|
||||
<type>float</type>
|
||||
|
@ -209,7 +247,7 @@
|
|||
<use>fogtype</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
-->
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
22
Shaders/deferred-tree.frag
Normal file
22
Shaders/deferred-tree.frag
Normal file
|
@ -0,0 +1,22 @@
|
|||
#extension GL_EXT_gpu_shader4 : enable
|
||||
//
|
||||
// attachment 0: normal.x | normal.x | normal.y | normal.y
|
||||
// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id
|
||||
// attachment 2: specular.l | shininess | emission.l | unused
|
||||
//
|
||||
uniform int materialID;
|
||||
uniform sampler2D texture;
|
||||
void main() {
|
||||
vec4 texel = texture2D(texture, gl_TexCoord[0].st);
|
||||
if (texel.a < 0.1)
|
||||
discard;
|
||||
float specular = 0.0;
|
||||
float shininess = 0.1;
|
||||
float emission = 0.0;
|
||||
|
||||
// Normal is straight towards the viewer.
|
||||
vec3 normal2 = (0.0, 0.0, 0.0);
|
||||
gl_FragData[0] = vec4( 0.5, 0.5, 0.0, 1.0 );
|
||||
gl_FragData[1] = vec4( gl_Color.rgb * texel.rgb, float( materialID ) / 255.0 );
|
||||
gl_FragData[2] = vec4( specular, shininess / 255.0, emission, 1.0 );
|
||||
}
|
30
Shaders/deferred-tree.vert
Normal file
30
Shaders/deferred-tree.vert
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Tree instance scheme:
|
||||
// vertex - local position of quad vertex.
|
||||
// normal - x y scaling, z number of varieties
|
||||
// fog coord - rotation
|
||||
// color - xyz of tree quad origin, replicated 4 times.
|
||||
#version 120
|
||||
|
||||
void main() {
|
||||
|
||||
// Texture coordinates
|
||||
float numVarieties = gl_Normal.z;
|
||||
float texFract = floor(fract(gl_MultiTexCoord0.x) * numVarieties) / numVarieties;
|
||||
texFract += floor(gl_MultiTexCoord0.x) / numVarieties;
|
||||
gl_TexCoord[0] = vec4(texFract, gl_MultiTexCoord0.y, 0.0, 0.0);
|
||||
|
||||
// Position and scaling
|
||||
vec3 position = gl_Vertex.xyz * gl_Normal.xxy;
|
||||
float sr = sin(gl_FogCoord);
|
||||
float cr = cos(gl_FogCoord);
|
||||
|
||||
// Rotation of the generic quad to specific one for the tree.
|
||||
position.xy = vec2(dot(position.xy, vec2(cr, sr)), dot(position.xy, vec2(-sr, cr)));
|
||||
position = position + gl_Color.xyz;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
|
||||
|
||||
// Color - white.
|
||||
gl_FrontColor = vec4(1.0, 1.0, 1.0,1.0);
|
||||
gl_BackColor = vec4(1.0, 1.0, 1.0,1.0);
|
||||
}
|
||||
|
Loading…
Reference in a new issue