本文整理汇总了C++中ofShader::setUniformTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ ofShader::setUniformTexture方法的具体用法?C++ ofShader::setUniformTexture怎么用?C++ ofShader::setUniformTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofShader
的用法示例。
在下文中一共展示了ofShader::setUniformTexture方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(){
wc.begin();
if(!switchVideo){
wc.setUniformTexture("colorMap", img.getTexture(), 1);
wc.setUniformTexture("heightMap",gray.getTexture(), 2);
}
else{
wc.setUniformTexture("colorMap", player.getTexture(), 1);
fboDepth.begin();
player.draw(0,0);
fboDepth.end();
wc.setUniformTexture("heightMap",fboDepth.getDepthTexture(),2);
}
wc.setUniform1f("time", ofGetElapsedTimef()*time);
wc.setUniform1f("gradientStep", stepGradient);
wc.setUniform1f("advectStep", advectStep);
wc.setUniform1f("flipHeightMap",flipHeightMap);
wc.setUniform4f("advectMatrix",advectMatrix->w,advectMatrix->x,advectMatrix->y,advectMatrix->z);
fbo.draw(0,0);
wc.end();
img.draw(0,0,img.getWidth()/4,img.getHeight()/4);
player.draw(img.getWidth()/4,0,img.getWidth()/4,img.getHeight()/4);
gui.draw();
}
示例2: begin
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::begin(ofShader& shader){
if(playingVO){
return;
}
if(!getPlayer().isLoaded() ){
return;
}
if(!getTextureReference().isAllocated()){
return;
}
getPlayer().bind();
shader.setUniformTexture("rgbdTexture", getTextureReference(), 1);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
shader.setUniform3f("skinSampleColor",skinSampleColor.r,skinSampleColor.g,skinSampleColor.b);
shader.setUniform3f("skinWeights", skinWeights.x,skinWeights.y,skinWeights.z);
shader.setUniform2f("skinThreshold", skinThreshold.min, skinThreshold.max);
shader.setUniform3f("headPosition",headPosition.x,-headPosition.y,headPosition.z);
shader.setUniform1f("flowPosition", flowPosition);
}
示例3: draw
void draw() {
ofBackgroundGradient(64, 0);
if(reflect || sreflect)
env.draw(0,0,env.getWidth()/8,env.getHeight()/8);
if(sreflect)
env1.draw(env.getWidth()/8,0,env1.getWidth()/8,env1.getHeight()/8);
ofEnableDepthTest();
cam.begin();
shader.begin();
if(sreflect){
// shader.setUniform3f("CameraPos",cam.getGlobalPosition().x, cam.getGlobalPosition().y, cam.getGlobalPosition().z);
// shader.setUniformMatrix4f("ModelWorld4x4",cam.getGlobalTransformMatrix());
shader.setUniform3f("CameraPos",cam.getPosition().x, cam.getPosition().y, cam.getPosition().z);
shader.setUniformMatrix4f("ModelWorld4x4",cam.getModelViewMatrix());//getLocalTransformMatrix());
shader.setUniformTexture("frontMap", env,1);
shader.setUniformTexture("backMap", env1,2);
}
if(reflect){
shader.setUniformTexture("colorMap",env1,1);
shader.setUniformTexture("envMap", env,2);
}else if(sreflect==false){
shader.setUniformTexture("texture", img, 1);
shader.setUniform1f("time", ofGetElapsedTimef());
}
if(cube)
ofDrawBox(200);
else {
ofTranslate(0,-150,0);
ofRotateX(-90);
ofRotateY(-90);
ofRotateZ(45);
model.drawFaces();
}
shader.end();
cam.end();
ofDisableDepthTest();
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
示例4: setUniforms
void GpuParticles::setUniforms(ofShader& shader)
{
for (unsigned i = 0; i < fbos[currentReadFbo].getNumTextures(); ++i)
{
ostringstream oss;
oss << UNIFORM_PREFIX << ofToString(i);
shader.setUniformTexture(oss.str().c_str(), fbos[currentReadFbo].getTextureReference(i), i + textureLocation);
}
}
示例5: draw
//--------------------------------------------------------------
void testApp::draw(){
ofEnableLighting();
light.enable();
if(rotating) t++;
fbo.begin();
glColor4f(1, 1, 1, 1);
ofClear(0, 0, 0, 0);
glPushMatrix();
glScalef(2, 2, 2);
glTranslatef(ofGetWidth()/2, ofGetHeight()/2, 0);
glRotatef(t, 0, 1, 1);
/*glBegin(GL_QUADS);
glVertex2f(-100, -100);
glVertex2f(100, -100);
glVertex2f(100, 100);
glVertex2f(-100, 100);
glEnd();*/
ofBox(0, 0, 0, 100);
glPopMatrix();
fbo.end();
ofDisableLighting();
if(shading) {
fxaa.begin();
fxaa.setUniformTexture("bgl_RenderedTexture", fbo.getTextureReference(0), 0);
fxaa.setUniform1f("bgl_RenderedTextureWidth", fbo.getWidth());
fxaa.setUniform1f("bgl_RenderedTextureHeight", fbo.getHeight());
} else {
fbo.getTextureReference(0).bind();
}
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(fbo.getWidth(), 0);
glVertex2f(ofGetWidth(), 0);
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex2f(ofGetWidth(), ofGetHeight());
glTexCoord2f(0, fbo.getHeight());
glVertex2f(0, ofGetHeight());
glEnd();
if(shading) {
fxaa.end();
} else {
fbo.getTextureReference(0).unbind();
}
}
示例6: draw
void Model::draw(ofShader& shader) {
// Scale and translate the model into position.
ofRotateY(rotateY);
ofScale(uniformScale, uniformScale, uniformScale);
ofTranslate(0, translateY, 0);
// Set shader inputs and draw meshes.
shader.setUniformTexture("diffuseTex", diffuse, 1);
shader.setUniformTexture("specularTex", specular, 2);
if (useNormalMapping) {
shader.setUniformTexture("ambientTex", ambient, 3);
shader.setUniformTexture("normalTex", normal, 4);
}
for (unsigned int i = 0; i < meshes.size(); ++i) {
if (useNormalMapping) {
shader.setAttribute4fv("tangent", tangents[i].data(), 4);
}
meshes[i].drawFaces();
}
}
示例7: setupProjectionUniforms
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::setupProjectionUniforms(ofShader& shader){
if(!getPlayer().isLoaded()){
ofLogWarning() << " CloudsRGBDVideoPlayer::setupProjectionUniforms -- player is not ready";
return;
}
shader.setUniformTexture("rgbdTexture", getPlayer().getTextureReference(), 0);
shader.setUniform2f("textureSize", getPlayer().getWidth(), getPlayer().getHeight());
shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
shader.setUniform2f("dP", distortionP.x, distortionP.y);
ofMatrix4x4 adjustmentMatrix;
adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);
shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
shader.setUniform1i("useFaces", useFaces ? 1 : 0);
shader.setUniform1f("flowPosition", flowPosition);
shader.setUniform1f("farClip", farClip);
shader.setUniform1f("nearClip", nearClip);
shader.setUniform1f("edgeClip", edgeClip);
shader.setUniform1f("minDepth", minDepth);
shader.setUniform1f("maxDepth", maxDepth);
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:VisualSystemsLibrary,代码行数:45,代码来源:CloudsRGBDVideoPlayer.cpp
示例8: updateMaterial
void ofMaterial::updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
shader.setUniform4fv("mat_ambient", &data.ambient.r);
shader.setUniform4fv("mat_diffuse", &data.diffuse.r);
shader.setUniform4fv("mat_specular", &data.specular.r);
shader.setUniform4fv("mat_emissive", &data.emissive.r);
shader.setUniform4fv("global_ambient", &ofGetGlobalAmbientColor().r);
shader.setUniform1f("mat_shininess",data.shininess);
for(auto & uniform: uniforms1f){
shader.setUniform1f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2f) {
shader.setUniform2f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3f) {
shader.setUniform3f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms4f) {
shader.setUniform4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms1i) {
shader.setUniform1i(uniform.first, uniform.second);
}
for (auto & uniform : uniforms2i) {
shader.setUniform2i(uniform.first, uniform.second.x, uniform.second.y);
}
for (auto & uniform : uniforms3i) {
shader.setUniform3i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z);
}
for (auto & uniform : uniforms4i) {
shader.setUniform4i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z, uniform.second.w);
}
for (auto & uniform : uniforms4m) {
shader.setUniformMatrix4f(uniform.first, uniform.second);
}
for (auto & uniform : uniforms3m) {
shader.setUniformMatrix3f(uniform.first, uniform.second);
}
for (auto & uniform : uniformstex) {
shader.setUniformTexture(uniform.first,
uniform.second.textureTarget,
uniform.second.textureID,
uniform.second.textureLocation);
}
}
示例9: draw
void draw() {
ofBackground(25);
fbo.begin();
ofClear(0,0,0,0);
ofEnableDepthTest();
camera.begin();
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
if(dvel) draw_velocity();
if(dden){
draw_density();
}
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glPopMatrix();
if( drawAxis ){ ofDrawAxis(15); }
camera.end();
ofDisableDepthTest();
fbo.end();
shader.begin();
shader.setUniformTexture("tex",fbo.getTextureReference(),0);
shader.setUniform2f("resolution",dw,dh);
shader.setUniform1f("timer",ofGetElapsedTimef());
fbo.draw(0,0);
shader.end();
gui.draw();
}
示例10: update
void update() {
#ifdef INSTALL
if(cam.update()) {
ofPixels& pixels = cam.getColorPixels();
#else
cam.update();
if(cam.isFrameNew()) {
ofPixels& pixels = cam.getPixelsRef();
#endif
// next two could be replaced with one line
ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0);
ofxCv:flip(rotated, rotated, 1);
Mat rotatedMat = toCv(rotated);
if(tracker.update(rotatedMat)) {
ofVec2f position = tracker.getPosition();
vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount);
FaceTrackerData curData;
curData.load(tracker);
if(!neighbors.empty()) {
nearestData = *faceCompare.nearest(curData, neighbors);
if(nearestData.label != lastLabel) {
similar.loadImage(nearestData.getImageFilename());
#ifdef INSTALL
whitePoint = getWhitePoint(similar);
#else
whitePoint.set(1, 1, 1);
#endif
}
lastLabel = nearestData.label;
}
if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) {
saveFace(curData, rotated);
currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData));
}
}
presence.update(tracker.getFound());
if(presence.wasTriggered()) {
presenceFade.stop();
}
if(presence.wasUntriggered()) {
for(int i = 0; i < currentData.size(); i++) {
data.add(currentData[i].first, currentData[i].second);
}
currentData.clear();
presenceFade.start();
}
}
}
void draw() {
ofBackground(255);
CGDisplayHideCursor(NULL);
ofSetColor(255);
if(similar.isAllocated()) {
shader.begin();
shader.setUniformTexture("tex", similar, 0);
shader.setUniform3fv("whitePoint", (float*) &whitePoint);
similar.draw(0, 0);
shader.end();
}
ofPushStyle();
if(presenceFade.getActive()) {
ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128));
ofFill();
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32));
data.drawBins();
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64));
data.drawData();
}
ofSetColor(255, 64);
ofNoFill();
if(!tracker.getFound()) {
ofCircle(tracker.getPosition(), 10);
}
tracker.draw();
ofPopStyle();
#ifndef INSTALL
drawFramerate();
#endif
}
示例11: update
//--------------------------------------------------------------
void SnapshotRamses::update(ofShader& shader)
{
shader.setUniformTexture("uTransform", m_bufferTexture, 0);
}